stripe 1/2

This commit is contained in:
lovebird 2026-02-21 11:46:29 +01:00
parent 8731ea7cf9
commit c580407163
6 changed files with 492 additions and 480 deletions

View File

@ -28,5 +28,7 @@ export interface EcommerceBundleDependencies {
currency?: string;
/** Returns the current auth token for authenticated API calls. */
getAuthToken?: () => Promise<string | null>;
/** Locale for Stripe Elements (e.g. "en", "de"). */
locale?: string;
}
export declare const EcommerceBundle: React.FC<EcommerceBundleDependencies>;

View File

@ -38,5 +38,7 @@ export interface CheckoutFlowProps {
currency?: string;
/** Returns the current auth token for authenticated API calls. */
getAuthToken?: () => Promise<string | null>;
/** Locale for Stripe Elements (e.g. "en", "de", "fr"). */
locale?: string;
}
export declare function CheckoutFlow({ userId, userDisplayName, userEmail, onFetchAddresses, onSaveAddress, onPlaceOrder, onBackToCart, onOrderSuccess, toast, stripePublishableKey, apiBaseUrl, stripeReturnUrl, currency, getAuthToken, }: CheckoutFlowProps): import("react/jsx-runtime").JSX.Element;
export declare function CheckoutFlow({ userId, userDisplayName, userEmail, onFetchAddresses, onSaveAddress, onPlaceOrder, onBackToCart, onOrderSuccess, toast, stripePublishableKey, apiBaseUrl, stripeReturnUrl, currency, getAuthToken, locale, }: CheckoutFlowProps): import("react/jsx-runtime").JSX.Element;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -38,6 +38,8 @@ export interface EcommerceBundleDependencies {
currency?: string;
/** Returns the current auth token for authenticated API calls. */
getAuthToken?: () => Promise<string | null>;
/** Locale for Stripe Elements (e.g. "en", "de"). */
locale?: string;
}
export const EcommerceBundle: React.FC<EcommerceBundleDependencies> = (props) => {
@ -64,6 +66,7 @@ export const EcommerceBundle: React.FC<EcommerceBundleDependencies> = (props) =>
stripeReturnUrl={props.stripeReturnUrl}
currency={props.currency}
getAuthToken={props.getAuthToken}
locale={props.locale}
/>
);
}

View File

@ -42,6 +42,8 @@ export interface CheckoutFlowProps {
currency?: string;
/** Returns the current auth token for authenticated API calls. */
getAuthToken?: () => Promise<string | null>;
/** Locale for Stripe Elements (e.g. "en", "de", "fr"). */
locale?: string;
}
export function CheckoutFlow({
@ -59,6 +61,7 @@ export function CheckoutFlow({
stripeReturnUrl,
currency = "eur",
getAuthToken,
locale,
}: CheckoutFlowProps) {
const [savedAddresses, setSavedAddresses] = useState<SavedAddress[]>([]);
const [stripePromise, setStripePromise] = useState<Promise<StripeJS | null> | null>(null);
@ -80,8 +83,8 @@ export function CheckoutFlow({
// 2. Load Stripe.js once we have a publishable key
useEffect(() => {
if (!stripePublishableKey) return;
setStripePromise(loadStripe(stripePublishableKey));
}, [stripePublishableKey]);
setStripePromise(loadStripe(stripePublishableKey, { locale: (locale as any) || 'auto' }));
}, [stripePublishableKey, locale]);
// 3. Create a PaymentIntent when the flow mounts (so the form is ready)
useEffect(() => {