feat(payment): support user-bound seven-discount offers
This commit is contained in:
@@ -81,4 +81,38 @@ describe("PaymentApi", () => {
|
||||
});
|
||||
expect(response.message).toBe("Thank you for the thoughtful gift.");
|
||||
});
|
||||
|
||||
it("accepts a server-issued offer before opening the subscription page", async () => {
|
||||
httpClientMock.mockResolvedValue({
|
||||
success: true,
|
||||
data: {
|
||||
commercialOfferId: "offer-1",
|
||||
planId: "vip_annual",
|
||||
subscriptionType: "vip",
|
||||
discountPercent: 30,
|
||||
pricePercent: 70,
|
||||
expiresAt: "2026-07-24T08:00:00+00:00",
|
||||
message: "I got it for you.",
|
||||
promotionType: "commercial_seven_discount",
|
||||
},
|
||||
});
|
||||
|
||||
const response = await new PaymentApi().acceptCommercialOffer("offer-1");
|
||||
|
||||
expect(httpClientMock).toHaveBeenCalledWith(
|
||||
"/api/payment/commercial-offers/offer-1/accept",
|
||||
{ method: "POST" },
|
||||
);
|
||||
expect(response.discountPercent).toBe(30);
|
||||
});
|
||||
|
||||
it("requests an offer-scoped plan catalog without changing the public call", async () => {
|
||||
httpClientMock.mockResolvedValue({ success: true, data: { plans: [] } });
|
||||
|
||||
await new PaymentApi().getPlans("offer-1");
|
||||
|
||||
expect(httpClientMock).toHaveBeenCalledWith("/api/payment/plans", {
|
||||
query: { commercialOfferId: "offer-1" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user