feat: switch mini program recharge to virtual payment

This commit is contained in:
kdletters
2026-05-26 22:32:16 +08:00
parent b388b124da
commit f36b90ebdb
22 changed files with 959 additions and 137 deletions

View File

@@ -1,13 +1,19 @@
export const WECHAT_MINI_PROGRAM_PAYMENT_CHANNEL = 'wechat_mp';
export const WECHAT_MINI_PROGRAM_VIRTUAL_PAYMENT_CHANNEL = 'wechat_mp_virtual';
export const WECHAT_H5_PAYMENT_CHANNEL = 'wechat_h5';
export const WECHAT_NATIVE_PAYMENT_CHANNEL = 'wechat_native';
export const MOCK_PAYMENT_CHANNEL = 'mock';
export type ProfileRechargeWechatPaymentChannel =
| typeof WECHAT_MINI_PROGRAM_PAYMENT_CHANNEL
| typeof WECHAT_MINI_PROGRAM_VIRTUAL_PAYMENT_CHANNEL
| typeof WECHAT_H5_PAYMENT_CHANNEL
| typeof WECHAT_NATIVE_PAYMENT_CHANNEL;
export type ProfileRechargeProductPaymentMode = {
kind: 'points' | 'membership';
};
type PaymentPlatformNavigator = Pick<Navigator, 'userAgent' | 'maxTouchPoints'>;
export type PaymentPlatformContext = {
@@ -45,7 +51,7 @@ export function resolveProfileRechargePaymentChannel(
: null);
if (isWechatMiniProgramRuntime(location)) {
return WECHAT_MINI_PROGRAM_PAYMENT_CHANNEL;
return WECHAT_MINI_PROGRAM_VIRTUAL_PAYMENT_CHANNEL;
}
if (isMobileWebRuntime(navigatorLike, matchMedia)) {
@@ -55,6 +61,13 @@ export function resolveProfileRechargePaymentChannel(
return WECHAT_NATIVE_PAYMENT_CHANNEL;
}
export function resolveProfileRechargeProductPaymentChannel(
_product: ProfileRechargeProductPaymentMode,
context: PaymentPlatformContext = {},
): ProfileRechargeWechatPaymentChannel {
return resolveProfileRechargePaymentChannel(context);
}
export function isManualMockPaymentChannel(paymentChannel: string) {
return paymentChannel.trim() === MOCK_PAYMENT_CHANNEL;
}