fix(subscription): restrict payment methods by country
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { PaymentPlan } from "@/data/dto/payment";
|
||||
import type { PayChannel, PaymentPlan } from "@/data/dto/payment";
|
||||
import { getDefaultPayChannelForCountryCode } from "@/lib/payment/default_pay_channel";
|
||||
export { getDefaultPayChannelForCountryCode } from "@/lib/payment/default_pay_channel";
|
||||
|
||||
import type { CoinsOfferPlanView } from "./components/subscription-coins-offer-section";
|
||||
@@ -12,6 +13,23 @@ export interface FirstRechargeOfferView {
|
||||
subtitle: string;
|
||||
}
|
||||
|
||||
export function canChooseSubscriptionPayChannel(
|
||||
countryCode: string | null | undefined,
|
||||
): boolean {
|
||||
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