declare global { interface Window { wco?: { injected: true; listening: boolean; frames: Map void>; identifiedFrames: Map; submit: ( identifier: string, data?: WhopCheckoutSubmitDetails, ) => Promise; getEmail: (identifier: string, timeout?: number) => Promise; setEmail: ( identifier: string, email: string, timeout?: number, ) => Promise; getAddress: ( identifier: string, timeout?: number, ) => Promise<{ address: WhopCheckoutAddress; isComplete: boolean; }>; setAddress: ( identifier: string, address: WhopCheckoutAddress, timeout?: number, ) => Promise; }; Plaid?: Plaid; } } type Plaid = { create(options: { token: string; onSuccess: (public_token: string) => void; onExit: ( err: { error_type: string; error_code: string; error_message: string; display_message: string; } | null, ) => void; }): { open(): void; destroy(): void; }; }; type WhopCheckoutSubmitDetails = Record; type WhopCheckoutAddress = { name: string; country: string; line1: string; line2?: string; city: string; state: string; postalCode: string; }; declare global { // oxlint-disable-next-line no-var var PaymentRequest: { prototype: PaymentRequest; new ( methodData: PaymentMethodData[], details: PaymentDetailsInit, options?: PaymentOptions, ): PaymentRequest; }; interface Window { PaymentRequest: { prototype: PaymentRequest; new ( methodData: PaymentMethodData[], details: PaymentDetailsInit, options?: PaymentOptions, ): PaymentRequest; }; } interface PaymentOptions { requestPayerName?: boolean; requestBillingAddress?: boolean; requestPayerEmail?: boolean; requestPayerPhone?: boolean; requestShipping?: boolean; shippingType?: "shipping" | "delivery" | "pickup"; } interface ApplyPayPaymentRequestPaymentOptions { requestPayerName?: boolean; requestBillingAddress?: boolean; requestPayerEmail?: boolean; requestPayerPhone?: boolean; requestShipping?: boolean; shippingType?: "shipping" | "delivery" | "pickup"; } interface PaymentRequest { /** * Apple Pay–specific event fired when Apple Pay * needs merchant validation. */ onmerchantvalidation?: (event: ApplePayMerchantValidationEvent) => void; /** * Apple Pay–specific event fired when the user changes * payment method details (e.g., coupon code). */ onpaymentmethodchange?: (event: ApplePayPaymentMethodChangeEvent) => void; /** * Apple Pay–specific event fired when the user changes * shipping option (if you requested shipping). */ onshippingoptionchange?: (event: ApplePayShippingOptionChangeEvent) => void; /** * Apple Pay–specific event fired when the user changes * shipping address (if you requested shipping). */ onshippingaddresschange?: ( event: ApplePayShippingAddressChangeEvent, ) => void; } /** * The event object passed to onmerchantvalidation. */ interface ApplePayMerchantValidationEvent extends Event { complete: ( merchantSession: | ApplePayMerchantSession | Promise, ) => void; methodName: string; validationURL: string; } interface ApplePayPaymentContact { addressLines: string[]; administrativeArea: string; country: string; countryCode: string; familyName: string; givenName: string; locality: string; phoneticFamilyName: string; phoneticGivenName: string; postalCode: string; subAdministrativeArea: string; subLocality: string; } /** * The event object passed to onpaymentmethodchange. * For example, you may check `event.methodDetails.couponCode`. */ interface ApplePayPaymentMethodChangeEvent extends Event { methodDetails?: | { type: string; billingContact: ApplePayPaymentContact; } | { couponCode: string; }; updateWith: ( details: PaymentDetailsUpdate | Promise, ) => void; } interface ApplePayShippingOptionChangeEvent extends Event { updateWith: (details: PaymentDetailsUpdate) => void; } interface ApplePayShippingAddressChangeEvent extends Event { updateWith: (details: PaymentDetailsUpdate) => void; } /** * A helper interface if you need to pass dynamic updates to `updateWith()`. * This extends PaymentDetails with extra optional fields that Safari may expect. */ interface PaymentDetailsUpdate extends PaymentDetails { error?: string; shippingOptions?: PaymentShippingOption[]; modifiers?: PaymentDetailsModifier[]; } // Add this new interface for the merchant session interface ApplePayMerchantSession { merchantIdentifier: string; merchantSessionIdentifier: string; nonce: string; domainName: string; displayName: string; signature: string; epoch: string; expiresAt: number; } } type WhopCheckoutState = "loading" | "ready" | "disabled"; type EmbeddedCheckoutBaseEvent> = { __scope: "whop-embedded-checkout"; event_id: string; } & T; type PaymentRequestCreateRequest = EmbeddedCheckoutBaseEvent<{ event: "payment-request-create-request"; method_data: PaymentMethodData[]; details: PaymentDetailsInit; options?: PaymentOptions; }>; type PaymentRequestUpdateRequest = EmbeddedCheckoutBaseEvent<{ event: "payment-request-update-request"; id: string; method_data?: PaymentMethodData[]; details?: PaymentDetailsInit; options?: PaymentOptions; active?: boolean; }>; type PaymentRequestEventResult = EmbeddedCheckoutBaseEvent<{ event: "payment-request-event-result"; } & ({ ok: true; details: PaymentDetailsUpdate; } | { ok: false; error: string; })>; type PaymentRequestMerchantValidationResult = EmbeddedCheckoutBaseEvent<{ event: "payment-request-merchant-validation-result"; } & ({ ok: true; merchantSession: ApplePayMerchantSession; } | { ok: false; error: string; })>; type PlaidTokenRequest = EmbeddedCheckoutBaseEvent<{ event: "plaid-token-request"; token: string; }>; type PlaidReadyEvent = EmbeddedCheckoutBaseEvent<{ event: "plaid-ready"; }>; type WhopCheckoutMessage = { event: "resize"; height: number; } | { event: "center"; } | { event: "complete"; receipt_id?: string; setup_intent_id?: string; plan_id: string; } | { event: "state"; state: WhopCheckoutState; } | { event: "get-email-result"; email: string; event_id: string; } | { event: "set-email-result"; ok: true; error?: never; event_id: string; } | { event: "set-email-result"; ok: false; error: string; event_id: string; } | { event: "set-address-result"; ok: true; error?: never; event_id: string; } | { event: "set-address-result"; ok: false; error: string; event_id: string; } | { event: "get-address-result"; ok: true; address: WhopCheckoutAddress; is_complete: boolean; event_id: string; } | { event: "get-address-result"; ok: false; error: string; event_id: string; } | { event: "address-validation-error"; error_message: string; error_code: string; } | PaymentRequestMerchantValidationResult | PaymentRequestUpdateRequest | PaymentRequestCreateRequest | PaymentRequestEventResult | PlaidTokenRequest | PlaidReadyEvent; declare function isWhopCheckoutMessage(event: MessageEvent): event is MessageEvent; declare function onWhopCheckoutMessage(iframe: HTMLIFrameElement, callback: (message: Exclude>) => void): () => void; declare function setEmail(frame: HTMLIFrameElement, email: string, timeout?: number): Promise; declare function getEmail(frame: HTMLIFrameElement, timeout?: number): Promise; declare function setAddress(frame: HTMLIFrameElement, address: WhopCheckoutAddress, timeout?: number): Promise; declare function getAddress(frame: HTMLIFrameElement, timeout?: number): Promise<{ address: WhopCheckoutAddress; isComplete: boolean; }>; declare function submitCheckoutFrame(frame: HTMLIFrameElement, _data?: WhopCheckoutSubmitDetails): Promise; declare function parseSetupFutureUsage(val?: string): "off_session" | undefined; interface WhopEmbeddedCheckoutStyleOptions { container?: { paddingTop?: number | string; paddingBottom?: number | string; paddingY?: number | string; }; } interface WhopEmbeddedCheckoutPrefillOptions { email?: string; address?: Partial; } interface WhopEmbeddedCheckoutThemeOptions { accentColor?: string; highContrast?: boolean; } type WhopEmbeddedCheckoutEnvironment = "production" | "sandbox"; declare function isWhopEmbeddedCheckoutEnvironment(environment: unknown): environment is WhopEmbeddedCheckoutEnvironment; declare function toWhopEmbeddedCheckoutEnvironment(environment: unknown): WhopEmbeddedCheckoutEnvironment; declare function getEmbeddedCheckoutIframeUrl(planId?: string, theme?: "light" | "dark" | "system", sessionId?: string, origin?: string, hidePrice?: boolean, skipRedirect?: boolean, utm?: Record, styles?: WhopEmbeddedCheckoutStyleOptions, prefill?: WhopEmbeddedCheckoutPrefillOptions, themeOptions?: WhopEmbeddedCheckoutThemeOptions, hideSubmitButton?: boolean, hideTermsAndConditions?: boolean, hideEmail?: boolean, disableEmail?: boolean, hideAddressForm?: boolean, affiliateCode?: string, setupFutureUsage?: "off_session", paymentRedirectUrl?: string, stateId?: string, promoCode?: string, environment?: WhopEmbeddedCheckoutEnvironment): string; declare const EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST: string[]; declare const EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING = "document-domain; execution-while-not-rendered; execution-while-out-of-viewport; payment; paymentRequest; sync-script;"; export { EMBEDDED_CHECKOUT_IFRAME_SANDBOX_LIST as E, type WhopCheckoutSubmitDetails as W, type WhopCheckoutAddress as a, type WhopCheckoutState as b, type WhopEmbeddedCheckoutStyleOptions as c, type WhopEmbeddedCheckoutPrefillOptions as d, type WhopEmbeddedCheckoutEnvironment as e, type WhopCheckoutMessage as f, getEmail as g, setAddress as h, isWhopCheckoutMessage as i, getAddress as j, submitCheckoutFrame as k, type WhopEmbeddedCheckoutThemeOptions as l, isWhopEmbeddedCheckoutEnvironment as m, getEmbeddedCheckoutIframeUrl as n, onWhopCheckoutMessage as o, parseSetupFutureUsage as p, EMBEDDED_CHECKOUT_IFRAME_ALLOW_STRING as q, setEmail as s, toWhopEmbeddedCheckoutEnvironment as t };