feat(payment): support Indonesia QRIS checkout

This commit is contained in:
Codex
2026-07-22 18:57:22 +08:00
parent a0b2d44ec6
commit 1e25279e8f
19 changed files with 806 additions and 42 deletions
@@ -6,10 +6,15 @@ import { PaymentLaunchDialogs } from "../payment-launch-dialogs";
const hiddenLaunch = {
handleEzpayCancel: vi.fn(),
handleEzpayConfirm: vi.fn(),
handleQrisClose: vi.fn(),
handleStripeClose: vi.fn(),
handleStripeConfirmed: vi.fn(),
isConfirmingEzpay: false,
qrisErrorMessage: null,
qrisPayment: null,
qrisStatus: null,
shouldShowEzpayConfirmDialog: false,
shouldShowQrisDialog: false,
shouldShowStripeDialog: false,
stripeClientSecret: null,
};
@@ -43,10 +48,65 @@ describe("PaymentLaunchDialogs", () => {
);
expect(html).toContain('role="alertdialog"');
expect(html).toContain("Continue to GCash?");
expect(html).toContain("Continue to payment?");
expect(html).toContain("Your coffee order is ready.");
expect(html).toContain("Order No. order-123");
expect(html).toContain('data-analytics-key="tip.external_checkout"');
expect(html).toContain("Opening...");
});
it("renders an accessible QRIS dialog with display cents and order status", () => {
const html = renderToStaticMarkup(
<PaymentLaunchDialogs
currentOrderId="order-id-qris"
externalCheckoutAnalyticsKey="tip.external_checkout"
ezpayDescription="Scan QRIS to finish the payment."
launch={{
...hiddenLaunch,
qrisPayment: {
qrData: "00020101021226670016COM.NOBUBANK.WWW",
orderId: "order-id-qris",
amountCents: 5_000_000,
currency: "IDR",
},
qrisStatus: "pending",
shouldShowQrisDialog: true,
}}
/>,
);
expect(html).toContain('role="dialog"');
expect(html).toContain("Scan to pay with QRIS");
expect(html).toContain("QRIS payment QR code");
expect(html).toContain("Order No. order-id-qris");
expect(html).toContain("Rp");
expect(html).toContain("50.000");
expect(html).toContain("Waiting for payment");
});
it("shows QRIS failure state and handles empty QR data safely", () => {
const html = renderToStaticMarkup(
<PaymentLaunchDialogs
currentOrderId="order-id-qris"
externalCheckoutAnalyticsKey="payment.external_checkout"
ezpayDescription="Scan QRIS to finish the payment."
launch={{
...hiddenLaunch,
qrisErrorMessage: "Payment failed or was cancelled.",
qrisPayment: {
qrData: "",
orderId: "order-id-qris",
amountCents: 5_000_000,
currency: "IDR",
},
qrisStatus: "failed",
shouldShowQrisDialog: true,
}}
/>,
);
expect(html).toContain("QRIS data is unavailable");
expect(html).toContain("Payment failed or was cancelled.");
expect(html).toContain("Close");
});
});
@@ -62,6 +62,27 @@ describe("PaymentMethodSelector", () => {
);
});
it("labels Indonesia Ezpay as QRIS without the GCash logo", () => {
const html = renderToStaticMarkup(
<PaymentMethodSelector
config={{
canChoosePaymentMethod: true,
initialPayChannel: "ezpay",
showPaymentMethodSelector: true,
ezpayDisplayName: "QRIS",
}}
value="ezpay"
caption="QRIS by default in Indonesia"
analyticsKey="subscription.payment_method"
onChange={() => undefined}
/>,
);
expect(html).toContain('aria-label="QRIS"');
expect(html).toContain("QRIS by default in Indonesia");
expect(html).not.toContain("gcash-logo.svg");
});
it("renders compact controls without the caption", () => {
const html = renderToStaticMarkup(
<PaymentMethodSelector