feat(payment): share payment method selector

This commit is contained in:
2026-07-17 18:27:24 +08:00
parent 66445a9972
commit b22db6d147
13 changed files with 386 additions and 173 deletions
@@ -1,7 +1,4 @@
import type { PayChannel, PaymentPlan } from "@/data/schemas/payment";
import { getDefaultPayChannelForCountryCode } from "@/lib/payment/default_pay_channel";
import { AppEnvUtil } from "@/utils/app-env";
export { getDefaultPayChannelForCountryCode } from "@/lib/payment/default_pay_channel";
import type { PaymentPlan } from "@/data/schemas/payment";
import type { CoinsOfferPlanView } from "./components/subscription-coins-offer-section";
import type { VipOfferPlanView } from "./components/subscription-vip-offer-section";
@@ -15,24 +12,6 @@ export interface FirstRechargeOfferView {
renewalNotice: string | null;
}
export function canChooseSubscriptionPayChannel(
countryCode: string | null | undefined,
): boolean {
if (!AppEnvUtil.isProduction()) return true;
return countryCode?.trim().toUpperCase() === "PH";
}
export function resolveSubscriptionPayChannel(input: {
countryCode: string | null | undefined;
requestedPayChannel: PayChannel | null | undefined;
}): PayChannel {
if (!canChooseSubscriptionPayChannel(input.countryCode)) return "stripe";
return (
input.requestedPayChannel ??
getDefaultPayChannelForCountryCode(input.countryCode)
);
}
export function isVipPlan(plan: PaymentPlan): boolean {
return plan.vipDays !== null;
}