feat(tip): support tiered coffee gifts

This commit is contained in:
2026-07-14 10:44:46 +08:00
parent 37ae152abb
commit 0fe74b5371
17 changed files with 307 additions and 41 deletions
@@ -11,6 +11,7 @@ import {
import type {
PendingPaymentReturnTo,
PendingPaymentSubscriptionType,
PendingPaymentTipCoffeeType,
} from "@/lib/payment/pending_payment_order";
import type {
PaymentContextState,
@@ -35,6 +36,7 @@ export interface UsePaymentLaunchFlowInput {
paymentDispatch: Dispatch<PaymentEvent>;
returnTo?: PendingPaymentReturnTo;
subscriptionType: PendingPaymentSubscriptionType;
tipCoffeeType?: PendingPaymentTipCoffeeType;
}
export interface PaymentLaunchFlow {
@@ -72,6 +74,7 @@ export function usePaymentLaunchFlow({
paymentDispatch,
returnTo,
subscriptionType,
tipCoffeeType,
}: UsePaymentLaunchFlowInput): PaymentLaunchFlow {
const launchedNonceRef = useRef(0);
const [hiddenStripeClientSecret, setHiddenStripeClientSecret] = useState<
@@ -112,6 +115,7 @@ export function usePaymentLaunchFlow({
orderId: payment.currentOrderId,
paymentUrl,
subscriptionType,
...(tipCoffeeType ? { tipCoffeeType } : {}),
...(returnTo ? { returnTo } : {}),
onFailed: (errorMessage) =>
paymentDispatch({ type: "PaymentLaunchFailed", errorMessage }),
@@ -136,6 +140,7 @@ export function usePaymentLaunchFlow({
paymentDispatch,
returnTo,
subscriptionType,
tipCoffeeType,
]);
const shouldShowStripeDialog =
@@ -176,6 +181,7 @@ export function usePaymentLaunchFlow({
orderId: payment.currentOrderId,
paymentUrl: ezpayPaymentUrl,
subscriptionType,
...(tipCoffeeType ? { tipCoffeeType } : {}),
...(returnTo ? { returnTo } : {}),
onFailed: (errorMessage) => {
setIsConfirmingEzpay(false);