feat(payment): implement first recharge offer functionality and UI updates
This commit is contained in:
@@ -31,6 +31,9 @@ describe("PaymentPlan", () => {
|
||||
originalAmountCents: 2499,
|
||||
dailyPriceCents: 66,
|
||||
currency: "JPY",
|
||||
isFirstRechargeOffer: false,
|
||||
firstRechargeDiscountPercent: null,
|
||||
promotionType: null,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,4 +76,42 @@ describe("PaymentPlansResponse", () => {
|
||||
expect(response.plans).toHaveLength(1);
|
||||
expect(response.plans[0]?.dolAmount).toBe(1000);
|
||||
});
|
||||
|
||||
it("parses first recharge offer metadata", () => {
|
||||
const response = PaymentPlansResponse.from({
|
||||
isFirstRecharge: true,
|
||||
firstRechargeOffer: {
|
||||
enabled: true,
|
||||
type: "first_recharge_half_price",
|
||||
discountPercent: 50,
|
||||
},
|
||||
plans: [
|
||||
{
|
||||
planId: "vip_monthly",
|
||||
planName: "VIP Monthly",
|
||||
orderType: "vip_monthly",
|
||||
vipDays: 30,
|
||||
dolAmount: null,
|
||||
creditBalance: 3000,
|
||||
amountCents: 995,
|
||||
originalAmountCents: 1990,
|
||||
dailyPriceCents: null,
|
||||
currency: "USD",
|
||||
isFirstRechargeOffer: true,
|
||||
firstRechargeDiscountPercent: 50,
|
||||
promotionType: "first_recharge_half_price",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(response.isFirstRecharge).toBe(true);
|
||||
expect(response.firstRechargeOffer?.discountPercent).toBe(50);
|
||||
expect(response.plans[0]).toMatchObject({
|
||||
amountCents: 995,
|
||||
originalAmountCents: 1990,
|
||||
isFirstRechargeOffer: true,
|
||||
firstRechargeDiscountPercent: 50,
|
||||
promotionType: "first_recharge_half_price",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user