feat(payment): share payment method selector
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user