import { PaymentRequestUpdateOptions } from '@stripe/stripe-js'; import { PaymentMethod, PaymentRequestButtonElement, DigitalWalletsOptions, Environment, CanMakePaymentResult, SupportedCountries } from '../../types'; export declare class DigitalWallets { private environment; private stripe?; private digitalWalletsOptions?; private paymentEvent?; private paymentRequest?; private defaultPaymentRequestOptions; canMakePayment: CanMakePaymentResult | null; paymentButton?: PaymentRequestButtonElement; constructor(environment?: Environment); /** * Initializes a digital wallet's payment request so that a `DigitalWallets` button can be created. * * @param options Digital wallets options containing style and payment request options. * @example * HTML *
* * @example * JS * const digitalWallets = new DigitalWallets(); * await digitalWallets.initialize(options); * * // Will return an object of { applePay: false, googlePay: false } * const canMakePayment = digitalWallets.canMakePayment; */ initialize(options: DigitalWalletsOptions): Promise; /** * Appends a `Stripe Elements` Payment Request Button to an element marked with a matching `data-olo-pay-payment-button` attribute. * @param callback Function to execute after the payment is submitted in the digital wallets payment sheet. * * @example * HTML *
* * @example * JS * const digitalWallets = new DigitalWallets(); * await digitalWallets.initialize(options); * digitalWallets.mountButton(callback); */ mountButton(callback: (paymentMethod: PaymentMethod) => void, target?: string | HTMLElement): void; /** * Initiates a payment by showing the Google Pay or Apple Pay payment sheet. * This can be triggered when using a custom payment button, * or in scenarios where preventing the default 'click' event behavior is necessary * (i.e. proper form validation prior to initiating the payment). * * @example * const digitalWallets = new DigitalWallets(); * await digitalWallets.initialize(options); * * digitalWallets.paymentButton.on('click', (event) => { * event.preventDefault(); * * // Launch payment sheet if form is valid * if (formIsValid) { * dw.initiatePayment(); * } * }); */ initiatePayment(): void; /** * Determines which digital wallets are available in the current browser context. * * @example * const canRenderButton = await digitalWallets.canRenderButton(); * if (canRenderButton && (canRenderButton.applePay || canRenderButton.googlePay)) { * // Do something * } */ canRenderButton(country?: SupportedCountries): Promise; /** * Updates payment details to be reflected on the payment sheet */ updatePaymentDetails(options: PaymentRequestUpdateOptions): void; /** * Completes the pending payment event to close the active payment sheet */ completePaymentEvent(): void; /** * Fails the pending payment event */ failPaymentEvent(): void; /** * Removes the element from the DOM and destroys it. * A destroyed element can not be re-activated or re-mounted to the DOM. */ destroy(): void; /** * Unmounts the element from the DOM. Call element.mount to re-attach it to the DOM. */ unmount(): void; } declare global { interface Window { PaymentRequest: any; } }