fix(subscription): restrict payment methods by country
This commit is contained in:
@@ -3,10 +3,12 @@ import { describe, expect, it } from "vitest";
|
||||
import { PaymentPlan } from "@/data/dto/payment";
|
||||
|
||||
import {
|
||||
canChooseSubscriptionPayChannel,
|
||||
findSelectedSubscriptionPlan,
|
||||
getDefaultPayChannelForCountryCode,
|
||||
getDefaultSubscriptionPlanId,
|
||||
getFirstRechargeOfferView,
|
||||
resolveSubscriptionPayChannel,
|
||||
toCoinsOfferPlanViews,
|
||||
toVipOfferPlanViews,
|
||||
} from "../subscription-screen.helpers";
|
||||
@@ -38,6 +40,34 @@ describe("subscription screen helpers", () => {
|
||||
expect(getDefaultPayChannelForCountryCode(null)).toBe("stripe");
|
||||
});
|
||||
|
||||
it("only allows payment method switching for Philippines users", () => {
|
||||
expect(canChooseSubscriptionPayChannel("PH")).toBe(true);
|
||||
expect(canChooseSubscriptionPayChannel("ph")).toBe(true);
|
||||
expect(canChooseSubscriptionPayChannel("HK")).toBe(false);
|
||||
expect(canChooseSubscriptionPayChannel(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("resolves subscription pay channel by country", () => {
|
||||
expect(
|
||||
resolveSubscriptionPayChannel({
|
||||
countryCode: "PH",
|
||||
requestedPayChannel: null,
|
||||
}),
|
||||
).toBe("ezpay");
|
||||
expect(
|
||||
resolveSubscriptionPayChannel({
|
||||
countryCode: "PH",
|
||||
requestedPayChannel: "stripe",
|
||||
}),
|
||||
).toBe("stripe");
|
||||
expect(
|
||||
resolveSubscriptionPayChannel({
|
||||
countryCode: "HK",
|
||||
requestedPayChannel: "ezpay",
|
||||
}),
|
||||
).toBe("stripe");
|
||||
});
|
||||
|
||||
it("maps at most three VIP plans and all coin plans", () => {
|
||||
const plans = [
|
||||
makePlan({ planId: "vip_monthly", planName: "Monthly" }),
|
||||
|
||||
Reference in New Issue
Block a user