feat(payment): implement coffee tip plans and update payment flow
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
@@ -10,14 +10,7 @@ export function findTipCoffeePlan(
|
||||
coffeeType: TipCoffeeType,
|
||||
): PaymentPlan | null {
|
||||
const option = getTipCoffeeOption(coffeeType);
|
||||
|
||||
return (
|
||||
plans.find((plan) => plan.planId === option.planId) ??
|
||||
(coffeeType === "small"
|
||||
? (plans.find((plan) => plan.planId === "tip_coffee") ?? null)
|
||||
: null) ??
|
||||
null
|
||||
);
|
||||
return plans.find((plan) => plan.planId === option.planId) ?? null;
|
||||
}
|
||||
|
||||
export function formatTipPrice(
|
||||
|
||||
@@ -80,6 +80,7 @@ export function TipScreen({
|
||||
initialPayChannelAppliedRef.current = true;
|
||||
paymentDispatch({
|
||||
type: "PaymentInit",
|
||||
catalog: "tip",
|
||||
payChannel: resolvedInitialPayChannel,
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user