feat(payment): expand Stripe methods and checkout handoff

This commit is contained in:
Codex
2026-07-28 16:27:03 +08:00
parent fcb2492118
commit aee35353a3
42 changed files with 1151 additions and 92 deletions
@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from "vitest";
import {
getPaymentUrl,
getStripeCustomerSessionClientSecret,
getStripeClientSecret,
isEzpayPayment,
launchEzpayRedirect,
@@ -43,6 +44,28 @@ describe("payment launch helpers", () => {
).toBeNull();
});
it("enables saved cards only with an explicit flag and a Customer Session secret", () => {
expect(
getStripeCustomerSessionClientSecret({
provider: "stripe",
customerSessionClientSecret: "cuss_123_secret_456",
savedPaymentMethodsEnabled: true,
}),
).toBe("cuss_123_secret_456");
expect(
getStripeCustomerSessionClientSecret({
customerSessionClientSecret: "cuss_123_secret_456",
savedPaymentMethodsEnabled: false,
}),
).toBeNull();
expect(
getStripeCustomerSessionClientSecret({
customerSessionClientSecret: "invalid-customer-session",
savedPaymentMethodsEnabled: true,
}),
).toBeNull();
});
it("resolves Ezpay URL and QR launch parameters without treating QR data as a URL", () => {
expect(
resolveEzpayLaunchTarget({