Consolidate Kreditkarte/PayPal into one "Online-Zahlung" checkout option
Both already route through the same Stripe PaymentIntent (automatic_payment_methods: enabled — Stripe's own recommended Payment Element pattern, letting Stripe itself decide which eligible method to show). Pre-selecting one of two identical-behind-the-scenes rows before the payment step was redundant friction, not a real choice. Collapses them into one option with a hint text explaining the actual instrument is picked on the next screen; Überweisung is unaffected. Also refines paymentMethodTitle from a neutral "Online-Zahlung" placeholder (snapshotted at order-creation time, before the customer has picked an instrument) to the real one Stripe reports, once payment confirms — carried through to both the stored order and the sessionStorage snapshot shown on /bestellbestaetigung. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -621,6 +621,38 @@ export async function getPaymentMethods(): Promise<PaymentMethod[]> {
|
||||
}));
|
||||
}
|
||||
|
||||
export type CheckoutPaymentOption = PaymentMethod & { hint?: string };
|
||||
|
||||
// Kreditkarte and PayPal both resolve to `provider: 'stripe'` today, and
|
||||
// both end up on the exact same Stripe PaymentIntent
|
||||
// (`automatic_payment_methods: { enabled: true }` — Stripe's own
|
||||
// recommended Payment Element pattern lets Stripe itself decide which
|
||||
// eligible method to show, rather than the older per-method
|
||||
// Checkout-Session split). Pre-selecting one of two identical-behind-the-
|
||||
// scenes rows before the payment step is therefore no longer a real
|
||||
// choice, just redundant friction — so this collapses every active
|
||||
// `stripe` row into one "Online-Zahlung" option (representative id =
|
||||
// the first such row's, since app/api/checkout/route.ts only branches on
|
||||
// `provider`, never on which specific stripe row was picked) with a hint
|
||||
// explaining that the actual instrument is chosen on the next screen.
|
||||
// `manual` rows (Überweisung) pass through unchanged — one real gateway
|
||||
// there, one option, nothing to collapse.
|
||||
export function groupPaymentMethodsForCheckout(methods: PaymentMethod[]): CheckoutPaymentOption[] {
|
||||
const manual = methods.filter((m) => m.provider !== "stripe");
|
||||
const stripeMethods = methods.filter((m) => m.provider === "stripe");
|
||||
if (stripeMethods.length === 0) return manual;
|
||||
|
||||
const combinedIcons = Array.from(new Set(stripeMethods.flatMap((m) => m.icons)));
|
||||
const online: CheckoutPaymentOption = {
|
||||
id: stripeMethods[0].id,
|
||||
title: "Online-Zahlung",
|
||||
icons: combinedIcons,
|
||||
provider: "stripe",
|
||||
hint: "Kreditkarte, PayPal & weitere Methoden — die genaue Zahlungsart wählst du im nächsten Schritt.",
|
||||
};
|
||||
return [...manual, online];
|
||||
}
|
||||
|
||||
export type WerkzeugeCard = {
|
||||
id: number;
|
||||
title: string;
|
||||
|
||||
Reference in New Issue
Block a user