import { PaymentRequestPaymentMethodEvent, StripeConstructor } from "@stripe/stripe-js"; //#region src/payment-methods/stripe-apple-pay-adapter.d.ts declare global { interface Window { Stripe?: StripeConstructor; ApplePaySession?: typeof ApplePaySession; } } interface ApplePayPaymentRequestConfig { country: string; currency: string; total: { label: string; amount: number; }; supportedNetworks?: string[]; merchantCapabilities?: string[]; } type ShowApplePaySheetResult = { success: true; paymentMethodId: string; paymentMethodEvent: PaymentRequestPaymentMethodEvent; billingDetails?: { email?: string; name?: string; address?: { city?: string | null; country?: string | null; line1?: string | null; line2?: string | null; postal_code?: string | null; state?: string | null; } | null; }; } | { success: false; cancelled: true; } | { success: false; error: string; }; type ConfirmResult = { success: true; } | { success: false; error: string; }; declare enum ApplePayMockScenario { None = "none", Success = "success", Cancelled = "cancelled", } /** * Stripe Apple Pay Adapter using Stripe's PaymentRequest API. * * This uses Stripe's PaymentRequest API instead of the native ApplePaySession API. * The key benefit is that Stripe handles merchant validation automatically, * which is required for Apple Pay to work correctly. * * IMPORTANT: To comply with browser security requirements, Apple Pay must be shown * synchronously from a user click. The flow is: * * 1. Call preparePaymentRequest() BEFORE user clicks (e.g., when page loads) * - This creates the PaymentRequest and calls canMakePayment() * 2. On user click, call showPreparedPaymentSheet() * - This calls show() on the pre-created PaymentRequest (no async!) * 3. Handle the paymentmethod event and call complete() */ declare class StripeApplePayAdapter { private stripe; private mockScenario; private preparedPaymentRequest; constructor(mockScenario?: ApplePayMockScenario); initialize(publishableKey: string): boolean; /** * Check if Apple Pay is available on this device/browser. * Uses Stripe's PaymentRequest.canMakePayment() which is more reliable * than checking ApplePaySession directly. */ static isAvailable(): boolean; /** * Check availability using Stripe's PaymentRequest API. * This is more accurate as it checks Stripe's configuration too. */ canMakePayment(): Promise<{ applePay: boolean; googlePay: boolean; } | null>; /** * Prepare a PaymentRequest for later use. Call this BEFORE the user clicks. * This creates the PaymentRequest and calls canMakePayment() to validate. * * @returns Promise with success status and whether Apple Pay is available */ preparePaymentRequest(config: ApplePayPaymentRequestConfig): Promise<{ success: boolean; applePay?: boolean; googlePay?: boolean; error?: string; }>; /** * Check if a PaymentRequest has been prepared and is ready to show. */ isPrepared(): boolean; /** * Clear the prepared PaymentRequest. */ clearPrepared(): void; /** * Show the prepared Apple Pay payment sheet. * MUST be called synchronously from a user click handler. * Call preparePaymentRequest() before the click to set up the PaymentRequest. */ showPreparedPaymentSheet(): Promise; /** * @deprecated Use preparePaymentRequest() + showPreparedPaymentSheet() instead. * This method creates a new PaymentRequest and shows it, which doesn't work * with browser security requirements (show() must be called synchronously). */ showPaymentSheet(config: ApplePayPaymentRequestConfig): Promise; /** * Complete the payment flow in the Apple Pay sheet. * Call this after confirming the payment on the server. * * @param evt - The PaymentRequestPaymentMethodEvent from showPaymentSheet * @param status - 'success' or 'fail' */ completePayment(evt: PaymentRequestPaymentMethodEvent, status: "success" | "fail"): void; /** * Confirm PaymentIntent with the PaymentMethod. * This is called after showPaymentSheet to finalize the payment. * * @deprecated - Server-side confirmation is preferred. The backend should * call stripe.PaymentIntent.confirm() with the payment_method_id. */ confirmPaymentIntent(clientSecret: string, paymentMethodId: string): Promise; } //#endregion export { StripeApplePayAdapter as a, ShowApplePaySheetResult as i, ApplePayPaymentRequestConfig as n, ConfirmResult as r, ApplePayMockScenario as t }; //# sourceMappingURL=stripe-apple-pay-adapter-D2OJRlAl.d.mts.map