fix(payment): 同时启用易支付和 Stripe 时显示 Stripe 按钮

VISIBLE_METHOD_ALIASES 漏了 stripe,导致 getVisibleMethods 把后端返回
的 stripe 过滤掉。点 Stripe 按钮时省略 method 查询参数,让落地页渲染
完整的 Payment Element。
This commit is contained in:
shaw
2026-04-25 09:46:27 +08:00
parent 7424c73b05
commit 8f28a834f8
3 changed files with 29 additions and 5 deletions
@@ -14,9 +14,10 @@ const VISIBLE_METHOD_ALIASES = {
alipay_direct: 'alipay',
wxpay: 'wxpay',
wxpay_direct: 'wxpay',
stripe: 'stripe',
} as const
export type VisiblePaymentMethod = 'alipay' | 'wxpay'
export type VisiblePaymentMethod = 'alipay' | 'wxpay' | 'stripe'
export type StripeVisibleMethod = 'alipay' | 'wechat_pay'
export type PaymentLaunchKind =
| 'qr_waiting'
@@ -144,7 +145,12 @@ export function decidePaymentLaunch(
}, context.now)
if (baseState.clientSecret) {
const stripeMethod: StripeVisibleMethod = visibleMethod === 'wxpay' ? 'wechat_pay' : 'alipay'
// visibleMethod === 'stripe' means the user clicked the dedicated Stripe button
// and should land on the full Payment Element to choose a sub-method themselves.
const isStripeButton = visibleMethod === 'stripe'
const stripeMethod: StripeVisibleMethod | undefined = isStripeButton
? undefined
: visibleMethod === 'wxpay' ? 'wechat_pay' : 'alipay'
const kind: PaymentLaunchKind = stripeMethod === 'alipay' && !context.isMobile
? 'stripe_popup'
: 'stripe_route'