feat(payment): implement coffee tip plans and update payment flow

This commit is contained in:
2026-07-14 11:48:46 +08:00
parent f9c15bd91f
commit 3a4f24cb06
30 changed files with 632 additions and 56 deletions
@@ -29,24 +29,23 @@ function makePlan(input: Partial<PaymentPlanInput>): PaymentPlan {
}
describe("tip screen helpers", () => {
it("uses the legacy tip coffee plan only for small", () => {
it("matches the official small coffee plan", () => {
const plan = makePlan({
planId: "tip_coffee",
planId: "tip_coffee_usd_4_99",
});
expect(findTipCoffeePlan([makePlan({}), plan], "small")).toBe(plan);
expect(findTipCoffeePlan([plan], "medium")).toBeNull();
});
it("matches medium and large coffee plans independently", () => {
const medium = makePlan({
planId: "tip_coffee_medium",
orderType: "tip_coffee_medium",
planId: "tip_coffee_usd_9_99",
orderType: "tip",
amountCents: 999,
});
const large = makePlan({
planId: "tip_coffee_large",
orderType: "tip_coffee_large",
planId: "tip_coffee_usd_19_99",
orderType: "tip",
amountCents: 1999,
});
@@ -57,7 +56,7 @@ describe("tip screen helpers", () => {
it("does not infer a coffee tier from order type or amount", () => {
const ambiguousPlan = makePlan({
planId: "legacy_coffee",
orderType: "tip_coffee_medium",
orderType: "tip",
amountCents: 999,
});