import { EventEmitter } from '../../stencil-public-runtime'; import { StripeDidLoadedHandler, StripeLoadedEvent, ProgressStatus, IntentType, DefaultFormSubmitResult, InitStripeOptions } from '../../interfaces'; import type { CheckoutSessionOptions } from '../../services/interfaces'; import type { Stripe, StripeElements, StripeCheckout, StripeCheckoutConfirmResult } from '@stripe/stripe-js'; /** * Payment Element submit event */ export type PaymentElementSubmitEvent = { stripe: Stripe; elements?: StripeElements; intentClientSecret?: string; checkout?: StripeCheckout; checkoutSessionClientSecret?: string; }; /** * Checkout Session submit event result */ export type CheckoutSessionFormSubmitResult = StripeCheckoutConfirmResult | Error; /** * Payment Element submit handler */ export type PaymentElementSubmitHandler = (event: Event, props: PaymentElementSubmitEvent) => Promise; /** * Checkout Session initialization options */ export type InitCheckoutSessionOptions = InitStripeOptions & CheckoutSessionOptions; export declare class StripePaymentElement { el: HTMLStripePaymentElementElement; private stripeService; private paymentElementManager; private _submitHandler; /** * Default submit handle type. * If you want to use `setupIntent`, should update this attribute. */ readonly intentType: IntentType; /** * Payment sheet title * By default we recommended to use these string * - 'Add your payment information' -> PaymentSheet / PaymentFlow(Android) * - 'Add a card' -> PaymentFlow(iOS) * These strings will translated automatically by this library. */ readonly sheetTitle: string; /** * Submit button label * By default we recommended to use these string * - 'Pay' -> PaymentSheet * - 'Add' -> PaymentFlow(Android) * - 'Add card' -> PaymentFlow(iOS) * - 'Add a card' -> PaymentFlow(iOS) * These strings will translated automatically by this library. */ readonly buttonLabel: string; /** * Get Stripe.js, and initialize elements * @param publishableKey * @param options * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.initStripe('pk_test_XXXXXXXXX') * }) * ``` */ initStripe(publishableKey: string, options?: InitStripeOptions): Promise; /** * Get Stripe.js and initialize with Checkout Session mode * Use this method when you have a Checkout Session client secret instead of Payment/Setup Intent * @param publishableKey - Your Stripe publishable API key * @param checkoutSessionClientSecret - The client secret from Checkout Session * @param options - Optional configuration * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.initStripeWithCheckoutSession( * 'pk_test_XXXXXXXXX', * 'cs_xxx_secret_xxx' * ) * }) * ``` */ initStripeWithCheckoutSession(publishableKey: string, checkoutSessionClientSecret: string, options?: InitCheckoutSessionOptions): Promise; /** * The progress status of the checkout process */ progress: ProgressStatus; /** * Update the form submit progress * @param progress * @returns * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.updateProgress('success') * }) * ``` */ updateProgress(progress: ProgressStatus): Promise; /** * Set error message * @param errorMessage string * @returns * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.setErrorMessage('Payment failed') * }) * ``` */ setErrorMessage(errorMessage: string): Promise; /** * Your Stripe publishable API key. */ readonly publishableKey: string; updatePublishableKey(publishableKey: string): void; /** * Optional. Making API calls for connected accounts * @info https://stripe.com/docs/connect/authentication */ readonly stripeAccount: string; updateStripeAccountId(stripeAccount: string): void; /** * Overwrite the application name that registered * For wrapper library (like Capacitor) */ readonly applicationName: string; /** * The client secret from paymentIntent.create or setupIntent.create response * Use this for Payment Intent / Setup Intent mode * * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.setAttribute('intent-client-secret', 'pi_xxx_secret_xxx') * }) * ``` * * @example * ``` * * ``` */ readonly intentClientSecret?: string; updateIntentClientSecret(): Promise; /** * The client secret from checkout session response * Use this for Checkout Session mode instead of intentClientSecret * When this prop is set, the component will use Checkout Session API * * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.initStripeWithCheckoutSession('pk_test_xxx', 'cs_xxx_secret_xxx') * }) * ``` */ readonly checkoutSessionClientSecret?: string; updateCheckoutSessionClientSecret(newValue: string): Promise; /** * The component will provide a function to call the `stripe.confirmPayment` API. * If you want to customize the behavior, should set false. * And listen the 'formSubmit' event on the element */ readonly shouldUseDefaultFormSubmitAction: boolean; /** * Form submit event handler */ handleSubmit: PaymentElementSubmitHandler; /** * Stripe.js class loaded handler */ stripeDidLoaded?: StripeDidLoadedHandler; /** * Stripe Client loaded event * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement * .addEventListener('stripeLoaded', async ({ detail: {stripe} }) => { * console.log('Stripe loaded:', stripe); * }); * }) * ``` */ stripeLoaded: EventEmitter; private stripeLoadedEventHandler; /** * Form submit event * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement * .addEventListener('formSubmit', async props => { * const { detail: { stripe, elements } } = props; * console.log('Form submitted', stripe, elements); * }) * }) * ``` */ formSubmit: EventEmitter; private formSubmitEventHandler; /** * Receive the result of defaultFormSubmit event * This event is emitted when using Payment Intent / Setup Intent mode * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.addEventListener('defaultFormSubmitResult', async ({detail}) => { * if (detail instanceof Error) { * console.error(detail) * } else { * console.log(detail) * } * }) * }) * ``` */ defaultFormSubmitResult: EventEmitter; private defaultFormSubmitResultHandler; /** * Receive the result of checkout session confirm * This event is emitted when using Checkout Session mode * @example * ``` * const stripeElement = document.createElement('stripe-payment-element'); * customElements * .whenDefined('stripe-payment-element') * .then(() => { * stripeElement.addEventListener('checkoutSessionConfirmResult', async ({detail}) => { * if (detail instanceof Error) { * console.error(detail) * } else if (detail.type === 'success') { * console.log('Payment successful:', detail.session) * } else { * console.error('Payment failed:', detail.error) * } * }) * }) * ``` */ checkoutSessionConfirmResult: EventEmitter; private checkoutSessionConfirmResultHandler; componentWillRender(): void; /** * Default form submit action for Payment Intent / Setup Intent mode * Calls confirmPayment or confirmSetup based on intentType * If you don't want use it, please set `should-use-default-form-submit-action="false"` * @param event * @param param1 */ private defaultFormSubmitAction; /** * Checkout Session form submit action * Uses checkout.loadActions().confirm() to confirm the payment * @param event * @param checkout - The Stripe Checkout instance */ private checkoutSessionFormSubmitAction; constructor(); /** * Initialize Component using Stripe Element */ private initElement; componentDidLoad(): void; disconnectedCallback(): void; render(): any; }