fix(paytr): encode hyphens in tenantId as Z in merchantOid
PayTR rejects merchant_oid with non-alphanumeric chars. Real Appwrite tenant IDs are hex (a-z0-9) and safe, but demo-tenant-001 contains hyphens. Encode - as Z (never appears in Appwrite hex IDs) in the merchantOid; decode back in the callback.
This commit is contained in:
@@ -16,8 +16,9 @@ export async function POST(req: Request): Promise<Response> {
|
||||
}
|
||||
|
||||
if (status === "success") {
|
||||
// merchant_oid: {tenantId}T{timestamp}{random}P{plan}X{period}
|
||||
const tenantId = merchantOid.split("T")[0];
|
||||
// merchant_oid: {encodedTenantId}T{timestamp}{random}P{plan}X{period}
|
||||
// Hyphens were encoded as Z — decode back
|
||||
const tenantId = (merchantOid.split("T")[0] ?? "").replace(/Z/g, "-");
|
||||
const planPart = merchantOid.split("P")[1]; // "{plan}X{period}"
|
||||
const plan = (planPart?.split("X")[0] ?? "pro") as TenantPlan;
|
||||
const period = (planPart?.split("X")[1] ?? "monthly") as PlanPeriod;
|
||||
|
||||
Reference in New Issue
Block a user