From 890c95571221ed73f5210033c64302bb281ab255 Mon Sep 17 00:00:00 2001 From: chenhang Date: Mon, 22 Jun 2026 16:35:06 +0800 Subject: [PATCH] fix(payment): support ezpay cashier urls --- .../subscription-checkout-button.tsx | 6 ++- .../payment/create_payment_order_response.ts | 39 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/app/subscription/components/subscription-checkout-button.tsx b/src/app/subscription/components/subscription-checkout-button.tsx index 3b51b0fb..a0e58c40 100644 --- a/src/app/subscription/components/subscription-checkout-button.tsx +++ b/src/app/subscription/components/subscription-checkout-button.tsx @@ -134,13 +134,17 @@ export function SubscriptionCheckoutButton({ function getPaymentUrl(payParams: Record): string | null { const keys = [ - "url", + "cashierUrl", + "cashier_url", "checkoutUrl", "checkout_url", "paymentUrl", "payment_url", + "approvalUrl", + "approval_url", "redirectUrl", "redirect_url", + "url", ]; for (const key of keys) { diff --git a/src/data/schemas/payment/create_payment_order_response.ts b/src/data/schemas/payment/create_payment_order_response.ts index d134c632..4b5475ab 100644 --- a/src/data/schemas/payment/create_payment_order_response.ts +++ b/src/data/schemas/payment/create_payment_order_response.ts @@ -3,9 +3,48 @@ */ import { z } from "zod"; +const paymentUrlKeys = [ + "cashierUrl", + "cashier_url", + "checkoutUrl", + "checkout_url", + "paymentUrl", + "payment_url", + "approvalUrl", + "approval_url", + "redirectUrl", + "redirect_url", + "url", +] as const; + export const CreatePaymentOrderResponseSchema = z.object({ orderId: z.string(), payParams: z.record(z.string(), z.unknown()), + cashierUrl: z.string().optional(), + cashier_url: z.string().optional(), + checkoutUrl: z.string().optional(), + checkout_url: z.string().optional(), + paymentUrl: z.string().optional(), + payment_url: z.string().optional(), + approvalUrl: z.string().optional(), + approval_url: z.string().optional(), + redirectUrl: z.string().optional(), + redirect_url: z.string().optional(), + url: z.string().optional(), +}).transform((data) => { + const payParams = { ...data.payParams }; + + for (const key of paymentUrlKeys) { + const value = data[key]; + if (typeof value === "string" && value.length > 0 && !(key in payParams)) { + payParams[key] = value; + } + } + + return { + orderId: data.orderId, + payParams, + }; }); export type CreatePaymentOrderResponseInput = z.input<