stripe-pwa-elements 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/cjs/factory-Cm6zUD7R.js +1206 -0
  2. package/dist/cjs/{factory-Cd2VI_N2.js → i18n-lBbOeQt4.js} +12 -1149
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +725 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stripe-address-element.cjs.entry.js +5 -4
  6. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +3 -2
  7. package/dist/cjs/{stripe-card-element_2.cjs.entry.js → stripe-card-element.cjs.entry.js} +8 -93
  8. package/dist/cjs/stripe-currency-selector.cjs.entry.js +4 -3
  9. package/dist/cjs/stripe-elements.cjs.js +1 -1
  10. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +24 -5
  11. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +4 -3
  12. package/dist/cjs/stripe-payment-element.cjs.entry.js +12 -124
  13. package/dist/cjs/stripe-payment-element.helpers-CvAhIqLt.js +119 -0
  14. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
  15. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +987 -0
  16. package/dist/collection/collection-manifest.json +2 -1
  17. package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
  18. package/dist/collection/components/stripe-card-element/stripe-card-element.js +3 -2
  19. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
  20. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +18 -0
  21. package/dist/collection/components/stripe-modal/stripe-modal.css +27 -1
  22. package/dist/collection/components/stripe-modal/stripe-modal.js +132 -1
  23. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +4 -7
  24. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +4 -4
  25. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +3 -3
  26. package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +193 -0
  27. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
  28. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.css +68 -0
  29. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +274 -0
  30. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +763 -0
  31. package/dist/collection/services/express-checkout-element-manager.js +36 -2
  32. package/dist/collection/services/link-authentication-element-manager.js +5 -0
  33. package/dist/collection/services/stripe-service.js +20 -6
  34. package/dist/collection/utils/focus.js +76 -0
  35. package/dist/collection/utils/i18n.js +12 -0
  36. package/dist/components/factory.js +1 -1
  37. package/dist/components/i18n.js +1 -0
  38. package/dist/components/stripe-address-element.js +1 -1
  39. package/dist/components/stripe-card-element-modal.js +1 -1
  40. package/dist/components/stripe-card-element2.js +1 -1
  41. package/dist/components/stripe-currency-selector.js +1 -1
  42. package/dist/components/stripe-express-checkout-element.js +1 -1
  43. package/dist/components/stripe-link-authentication-element.js +1 -1
  44. package/dist/components/stripe-modal2.js +1 -1
  45. package/dist/components/stripe-payment-element.helpers.js +1 -0
  46. package/dist/components/stripe-payment-element.js +1 -1
  47. package/dist/components/stripe-payment-request-button2.js +1 -1
  48. package/dist/components/stripe-payment-sheet.d.ts +11 -0
  49. package/dist/components/stripe-payment-sheet.js +1 -0
  50. package/dist/esm/factory-BaGv8K_i.js +1203 -0
  51. package/dist/esm/{factory-VTa1Gc94.js → i18n-CL5n3bOb.js} +13 -1149
  52. package/dist/esm/ion-icon_2.entry.js +722 -0
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/stripe-address-element.entry.js +2 -1
  55. package/dist/esm/stripe-card-element-modal.entry.js +3 -2
  56. package/dist/esm/{stripe-card-element_2.entry.js → stripe-card-element.entry.js} +6 -90
  57. package/dist/esm/stripe-currency-selector.entry.js +2 -1
  58. package/dist/esm/stripe-elements.js +1 -1
  59. package/dist/esm/stripe-express-checkout-element.entry.js +20 -1
  60. package/dist/esm/stripe-link-authentication-element.entry.js +2 -1
  61. package/dist/esm/stripe-payment-element.entry.js +4 -116
  62. package/dist/esm/stripe-payment-element.helpers-Bu9RfxS4.js +114 -0
  63. package/dist/esm/stripe-payment-request-button.entry.js +2 -2
  64. package/dist/esm/stripe-payment-sheet.entry.js +985 -0
  65. package/dist/stripe-elements/p-2e41699e.entry.js +1 -0
  66. package/dist/stripe-elements/p-3fc4583a.entry.js +1 -0
  67. package/dist/stripe-elements/{p-ae0c336e.entry.js → p-4891edf0.entry.js} +1 -1
  68. package/dist/stripe-elements/p-7e826964.entry.js +1 -0
  69. package/dist/stripe-elements/p-BhKXGROE.js +1 -0
  70. package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
  71. package/dist/stripe-elements/p-DlMEZwSe.js +1 -0
  72. package/dist/stripe-elements/p-a395a5d1.entry.js +1 -0
  73. package/dist/stripe-elements/p-b62c9dae.entry.js +1 -0
  74. package/dist/stripe-elements/p-b7c20e8e.entry.js +1 -0
  75. package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
  76. package/dist/stripe-elements/p-bec62526.entry.js +1 -0
  77. package/dist/stripe-elements/p-f5552c81.entry.js +1 -0
  78. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  79. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +2 -1
  80. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
  81. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +5 -0
  82. package/dist/types/components/stripe-modal/stripe-modal.d.ts +43 -0
  83. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +7 -2
  84. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +1 -1
  85. package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +121 -0
  86. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
  87. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +157 -0
  88. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +153 -0
  89. package/dist/types/components.d.ts +182 -10
  90. package/dist/types/index.d.ts +2 -0
  91. package/dist/types/services/interfaces.d.ts +3 -0
  92. package/dist/types/services/stripe-service.d.ts +7 -2
  93. package/dist/types/utils/focus.d.ts +15 -0
  94. package/package.json +7 -3
  95. package/readme.md +59 -6
  96. package/dist/cjs/ion-icon.cjs.entry.js +0 -431
  97. package/dist/components/utils.js +0 -1
  98. package/dist/esm/ion-icon.entry.js +0 -429
  99. package/dist/stripe-elements/p-1bd46766.entry.js +0 -1
  100. package/dist/stripe-elements/p-1c6e0a45.entry.js +0 -1
  101. package/dist/stripe-elements/p-3f42ca0c.entry.js +0 -1
  102. package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
  103. package/dist/stripe-elements/p-74de1556.entry.js +0 -1
  104. package/dist/stripe-elements/p-76e57d78.entry.js +0 -1
  105. package/dist/stripe-elements/p-840d499f.entry.js +0 -1
  106. package/dist/stripe-elements/p-CrjrbGJ3.js +0 -1
  107. package/dist/stripe-elements/p-cfd8e081.entry.js +0 -1
@@ -1,4 +1,4 @@
1
- import type { Stripe, StripeElements, StripeCheckoutElementsSdk, StripeCheckoutConfirmResult } from '@stripe/stripe-js';
1
+ import type { Stripe, StripeElements, StripeCheckoutElementsSdk, StripeCheckoutConfirmResult, ConfirmPaymentData, ConfirmSetupData } from '@stripe/stripe-js';
2
2
  import type { IntentType, ProgressStatus } from '../../interfaces';
3
3
  import type { PaymentElementSubmitEvent } from './stripe-payment-element';
4
4
  /**
@@ -14,6 +14,10 @@ export declare const isSubmitButtonDisabled: (params: {
14
14
  loadStripeStatus: ProgressStatus;
15
15
  intentClientSecret?: string;
16
16
  }) => boolean;
17
+ /**
18
+ * Params accepted by both `confirmPayment` and `confirmSetup` on top of `return_url`
19
+ */
20
+ export type ExtraConfirmParams = Pick<ConfirmPaymentData & ConfirmSetupData, 'payment_method_data'>;
17
21
  /**
18
22
  * Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
19
23
  * Calls `confirmPayment` or `confirmSetup` depending on the intent type.
@@ -21,10 +25,11 @@ export declare const isSubmitButtonDisabled: (params: {
21
25
  * @param elements the Stripe Elements instance bound to the payment element
22
26
  * @param intentType the configured intent type
23
27
  * @param returnUrl the URL Stripe should redirect back to when required
28
+ * @param extraConfirmParams optional params merged into `confirmParams` (for example `payment_method_data.billing_details`)
24
29
  * @returns the confirmation result
25
30
  * @throws StripeAPIError when Stripe returns an error
26
31
  */
27
- export declare const confirmPaymentOrSetup: (stripe: Stripe, elements: StripeElements, intentType: IntentType, returnUrl: string) => Promise<import("@stripe/stripe-js").PaymentIntentResult | import("@stripe/stripe-js").SetupIntentResult>;
32
+ export declare const confirmPaymentOrSetup: (stripe: Stripe, elements: StripeElements, intentType: IntentType, returnUrl: string, extraConfirmParams?: ExtraConfirmParams) => Promise<import("@stripe/stripe-js").PaymentIntentResult | import("@stripe/stripe-js").SetupIntentResult>;
28
33
  /**
29
34
  * Confirm a Checkout Session payment using the checkout actions.
30
35
  * @param checkout the Stripe Checkout instance
@@ -6,7 +6,7 @@ import { StripeDidLoadedHandler, StripeLoadedEvent, PaymentRequestShippingAddres
6
6
  * `stripe.paymentRequest()` is being removed in Stripe.js 9.x (deprecated as of 2025-09-30 / 2026-03-25).
7
7
  * Please migrate to `<stripe-express-checkout-element>` which supports Apple Pay, Google Pay, Link, PayPal,
8
8
  * and more via the modern Express Checkout Element API.
9
- * Migration guide: https://hideokamoto.github.io/stripe-pwa-elements/guides/migrate-payment-request-button-to-express-checkout/
9
+ * Migration guide: https://stripe-pwa-elements-docs.wp-kyoto.workers.dev/guides/migrate-payment-request-button-to-express-checkout/
10
10
  */
11
11
  export declare class StripePaymentRequestButton {
12
12
  el: HTMLStripePaymentRequestButtonElement;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * State machine behind `<stripe-payment-sheet>`.
3
+ *
4
+ * Pure functions only: the component feeds events in and performs the returned effects
5
+ * (loading Stripe.js, showing the modal, confirming, emitting events, resolving `present()`).
6
+ * The same rules are model-checked in Quint; see the exhaustive test next to this file.
7
+ */
8
+ /**
9
+ * What a client secret belongs to: a PaymentIntent, a SetupIntent or a Checkout Session
10
+ */
11
+ export type IntentKind = 'payment' | 'setup' | 'checkoutSession';
12
+ /**
13
+ * Attribute a client secret was set through: `intent-client-secret` or `checkout-session-client-secret`
14
+ */
15
+ export type SecretSource = 'intent' | 'checkoutSession';
16
+ /**
17
+ * Lifecycle phase of the sheet
18
+ */
19
+ export type SheetPhase = 'idle' | 'loading' | 'ready' | 'loadFailed' | 'presented' | 'confirming' | 'completed' | 'errored';
20
+ /**
21
+ * DOM events emitted by the sheet (same names as Capacitor's PaymentSheetEventsEnum)
22
+ */
23
+ export type PaymentSheetEventName = 'paymentSheetLoaded' | 'paymentSheetFailedToLoad' | 'paymentSheetCompleted' | 'paymentSheetCanceled' | 'paymentSheetFailed';
24
+ /**
25
+ * Result of `present()` (same values as Capacitor's PaymentSheetResultInterface)
26
+ */
27
+ export type PaymentSheetResult = 'paymentSheetCompleted' | 'paymentSheetCanceled' | 'paymentSheetFailed';
28
+ export type SheetState = Readonly<{
29
+ phase: SheetPhase;
30
+ /** Incremented on every accepted secret change so that results of older loads and confirmations are ignored */
31
+ generation: number;
32
+ intentKind?: IntentKind;
33
+ /** Whether a `present()` promise is waiting for a result (at most one) */
34
+ pendingPresent: boolean;
35
+ /** Whether the sheet should open as soon as loading finishes */
36
+ openRequested: boolean;
37
+ /** Secret received while confirming; applied once the confirmation finishes */
38
+ deferredSecret?: {
39
+ clientSecret: string;
40
+ source: SecretSource;
41
+ };
42
+ }>;
43
+ export type SheetEvent = {
44
+ type: 'secretChanged';
45
+ clientSecret: string;
46
+ source: SecretSource;
47
+ } | {
48
+ type: 'loadSucceeded';
49
+ generation: number;
50
+ } | {
51
+ type: 'loadFailed';
52
+ generation: number;
53
+ } | {
54
+ type: 'presentRequested';
55
+ } | {
56
+ type: 'openRequested';
57
+ } | {
58
+ type: 'closeRequested';
59
+ } | {
60
+ type: 'submitted';
61
+ } | {
62
+ type: 'confirmSucceeded';
63
+ generation: number;
64
+ } | {
65
+ type: 'confirmDeclined';
66
+ generation: number;
67
+ message: string;
68
+ } | {
69
+ type: 'confirmFailed';
70
+ generation: number;
71
+ message: string;
72
+ };
73
+ export type SheetEffect = {
74
+ type: 'load';
75
+ generation: number;
76
+ clientSecret: string;
77
+ intentKind: IntentKind;
78
+ } | {
79
+ type: 'show';
80
+ } | {
81
+ type: 'hide';
82
+ } | {
83
+ type: 'confirm';
84
+ generation: number;
85
+ intentKind: IntentKind;
86
+ } | {
87
+ type: 'showError';
88
+ message: string;
89
+ } | {
90
+ type: 'emit';
91
+ event: PaymentSheetEventName;
92
+ } | {
93
+ type: 'resolvePresent';
94
+ result: PaymentSheetResult;
95
+ };
96
+ export type Transition = {
97
+ state: SheetState;
98
+ effects: SheetEffect[];
99
+ };
100
+ export declare const initialSheetState: SheetState;
101
+ /**
102
+ * Tell whether a client secret belongs to a PaymentIntent or a SetupIntent from its prefix.
103
+ * @param clientSecret - The `client_secret` of a PaymentIntent (`pi_..._secret_...`) or SetupIntent (`seti_..._secret_...`)
104
+ * @returns The intent kind, or undefined when the format is not recognized
105
+ */
106
+ export declare const intentKindFromClientSecret: (clientSecret: string) => "payment" | "setup" | undefined;
107
+ /**
108
+ * Tell what a client secret belongs to.
109
+ * A secret from `checkout-session-client-secret` is always a Checkout Session: Stripe does not document the format
110
+ * of a Checkout Session client secret, so it is never inspected. Intent secrets are told apart by their prefix.
111
+ * @param clientSecret - The client secret
112
+ * @param source - The attribute the secret was set through
113
+ * @returns The kind, or undefined when an intent secret has an unknown format
114
+ */
115
+ export declare const intentKindOf: (clientSecret: string, source: SecretSource) => IntentKind | undefined;
116
+ /**
117
+ * Compute the next state and the effects to perform for an event.
118
+ * @param state - Current state
119
+ * @param event - Event to handle
120
+ */
121
+ export declare const transition: (state: SheetState, event: SheetEvent) => Transition;
@@ -0,0 +1,39 @@
1
+ import type { StripeCheckoutConfirmResult, StripeCheckoutElementsOptions, StripeCheckoutElementsSdk, StripeCheckoutPaymentElementOptions } from '@stripe/stripe-js';
2
+ import type { PaymentSheetOptions } from './stripe-payment-sheet.helpers';
3
+ /**
4
+ * Build the Checkout Payment Element options from the payment sheet options.
5
+ * The Checkout Payment Element takes fewer options than the regular one: `business` and `defaultValues` are not
6
+ * available, so only the layout is passed.
7
+ * @param options - Payment sheet options
8
+ */
9
+ export declare const toCheckoutPaymentElementOptions: (options: PaymentSheetOptions | undefined) => StripeCheckoutPaymentElementOptions;
10
+ /**
11
+ * List the given options that a Checkout Session does not use, sorted by name.
12
+ * Name, phone and address come from the session or from other Checkout elements; the email is passed to `confirm`.
13
+ * @param options - Payment sheet options
14
+ */
15
+ export declare const checkoutIgnoredOptionKeys: (options: PaymentSheetOptions | undefined) => string[];
16
+ /**
17
+ * Build the `elementsOptions` passed to `initCheckoutElementsSdk` from the payment sheet options.
18
+ * @param options - Payment sheet options
19
+ */
20
+ export declare const toCheckoutElementsOptions: (options: PaymentSheetOptions | undefined) => StripeCheckoutElementsOptions | undefined;
21
+ /**
22
+ * Confirm a Checkout Session from the payment sheet.
23
+ *
24
+ * Unlike the default of `confirm`, which always redirects to `returnUrl`, this passes `redirect: 'if_required'`
25
+ * so that payment methods without a redirect finish in the page and can be reported as `paymentSheetCompleted`.
26
+ *
27
+ * Errors are thrown as `StripeAPIError` with a `type` that `isRecoverableConfirmError` understands.
28
+ * A confirm error only carries `code: 'paymentFailed'` or `code: null` (`StripeCheckoutConfirmResult` in @stripe/stripe-js),
29
+ * so whether the session can still be paid is read from `session.status`:
30
+ * - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`, which ends the sheet
31
+ * - `paymentFailed` on an open session (a decline): `card_error`, which keeps the sheet open
32
+ * - any other confirm error on an open session, or a failure to load the actions: `api_error`, which keeps the sheet open
33
+ * @param checkout - The Checkout instance from `initCheckoutElementsSdk`
34
+ * @param returnUrl - Where Stripe redirects after a redirect-based payment method
35
+ * @param email - Customer email; needed when the session was created without `customer_email` or `customer`
36
+ * @returns The confirmation result
37
+ * @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
38
+ */
39
+ export declare const confirmCheckoutSessionSheet: (checkout: StripeCheckoutElementsSdk, returnUrl: string, email?: string) => Promise<StripeCheckoutConfirmResult>;
@@ -0,0 +1,157 @@
1
+ import { EventEmitter } from '../../stencil-public-runtime';
2
+ import type { PaymentIntentResult, SetupIntentResult, StripeCheckoutConfirmResult } from '@stripe/stripe-js';
3
+ import type { StripeLoadedEvent } from '../../interfaces';
4
+ import type { SheetState } from './payment-sheet-state';
5
+ import type { BillingDetailsCollectionPlan, PaymentSheetOptions, PaymentSheetPresentResult } from './stripe-payment-sheet.helpers';
6
+ /**
7
+ * A payment sheet: the Payment Element in a modal, with the same events and results as the native PaymentSheet
8
+ * of `@capacitor-community/stripe`. PaymentIntent and SetupIntent are told apart by the client secret prefix;
9
+ * a Checkout Session is used when `checkout-session-client-secret` is set.
10
+ */
11
+ export declare class StripePaymentSheet {
12
+ el: HTMLStripePaymentSheetElement;
13
+ private stripeService;
14
+ private paymentElementManager;
15
+ /** Extra elements, created from the same Elements instance as the Payment Element so that their values combine */
16
+ private billingAddressElementManager;
17
+ private shippingAddressElementManager;
18
+ private emailElementManager;
19
+ /** Pending `present()` promise; at most one */
20
+ private presentPromise?;
21
+ private resolvePresent?;
22
+ /** Details for the next emitted event */
23
+ private lastError?;
24
+ private lastResult?;
25
+ /** Key of the last requested load (see `loadTarget`), so that unchanged values do not reload */
26
+ private lastLoadKey?;
27
+ private warnedUnsupportedOptions;
28
+ private warnedCheckoutIgnoredOptions;
29
+ /**
30
+ * Your Stripe publishable API key.
31
+ */
32
+ readonly publishableKey?: string;
33
+ /**
34
+ * The client secret of a PaymentIntent (`pi_..._secret_...`) or a SetupIntent (`seti_..._secret_...`).
35
+ * The prefix decides whether `confirmPayment` or `confirmSetup` is used.
36
+ */
37
+ readonly intentClientSecret?: string;
38
+ /**
39
+ * The client secret of a Checkout Session created with `ui_mode: 'elements'` (named `custom` in older Stripe API versions). Its format is not inspected.
40
+ * When it is set, it is used instead of `intent-client-secret` (the same rule as `stripe-payment-element`).
41
+ * Create the session with `customer_email` or `customer`, or pass `options.defaultBillingDetails.email`, because the sheet has no email field.
42
+ */
43
+ readonly checkoutSessionClientSecret?: string;
44
+ /**
45
+ * Optional. Making API calls for connected accounts
46
+ * @info https://stripe.com/docs/connect/authentication
47
+ */
48
+ readonly stripeAccount?: string;
49
+ /**
50
+ * Whether the sheet is shown. Setting it to false closes the sheet as canceled.
51
+ */
52
+ open: boolean;
53
+ /**
54
+ * Sheet title. Translated automatically by this library.
55
+ */
56
+ readonly sheetTitle: string;
57
+ /**
58
+ * Submit button label. Translated automatically by this library.
59
+ */
60
+ readonly buttonLabel: string;
61
+ /**
62
+ * Application name registered to Stripe.js, for wrapper libraries such as `@capacitor-community/stripe`.
63
+ */
64
+ readonly applicationName: string;
65
+ /**
66
+ * Options with the same keys as `CreatePaymentSheetOption` of `@capacitor-community/stripe`. JavaScript property only.
67
+ */
68
+ readonly options?: PaymentSheetOptions;
69
+ sheet: SheetState;
70
+ visible: boolean;
71
+ errorMessage: string;
72
+ /** Extra elements of the current load and the billing details passed at confirmation */
73
+ collection?: BillingDetailsCollectionPlan;
74
+ /**
75
+ * Stripe.js and the Payment Element are ready
76
+ */
77
+ paymentSheetLoaded: EventEmitter<StripeLoadedEvent>;
78
+ /**
79
+ * Stripe.js or the Payment Element failed to load, or the client secret format is unknown
80
+ */
81
+ paymentSheetFailedToLoad: EventEmitter<unknown>;
82
+ /**
83
+ * The payment or setup succeeded. In Checkout Session mode the detail is the result of `confirm` (`{ type: 'success', session }`)
84
+ */
85
+ paymentSheetCompleted: EventEmitter<PaymentIntentResult | SetupIntentResult | StripeCheckoutConfirmResult>;
86
+ /**
87
+ * The customer closed the sheet
88
+ */
89
+ paymentSheetCanceled: EventEmitter<void>;
90
+ /**
91
+ * The confirmation failed with an error the customer cannot fix in the sheet
92
+ */
93
+ paymentSheetFailed: EventEmitter<unknown>;
94
+ /**
95
+ * Show the sheet and wait for its result.
96
+ * Calling it again while a result is pending returns the same promise.
97
+ * @returns `{ paymentResult }`, where `paymentResult` is `paymentSheetCompleted`, `paymentSheetCanceled` or `paymentSheetFailed`
98
+ * @example
99
+ * ```
100
+ * const sheet = document.querySelector('stripe-payment-sheet');
101
+ * const { paymentResult } = await sheet.present();
102
+ * ```
103
+ */
104
+ present(): Promise<PaymentSheetPresentResult>;
105
+ handleSecretChange(): void;
106
+ handleOpenChange(open: boolean): void;
107
+ constructor();
108
+ /**
109
+ * Props are not yet populated inside the constructor with the custom-elements build,
110
+ * so loading starts here.
111
+ */
112
+ componentWillLoad(): void;
113
+ componentDidLoad(): void;
114
+ disconnectedCallback(): void;
115
+ private unmountExtraElements;
116
+ /**
117
+ * Decide what to load from the attributes and load it only when it differs from the last load.
118
+ * A change that does not alter the result (the attribute that is not used, or an empty value that means unset)
119
+ * must neither reload Stripe.js nor cancel an open sheet.
120
+ */
121
+ private startLoading;
122
+ /**
123
+ * The secret to load and a key of everything the load depends on, or undefined when nothing can be loaded.
124
+ * The Checkout Session wins when both secrets are set (the same rule as `stripe-payment-element`).
125
+ */
126
+ private loadTarget;
127
+ private dispatch;
128
+ private perform;
129
+ private load;
130
+ /**
131
+ * Render the mount points of the plan's extra elements and mount them. Elements a previous load needed but this one does not are unmounted
132
+ * (the managers unmount their previous element themselves when initialized again).
133
+ */
134
+ private mountExtraElements;
135
+ /**
136
+ * Billing details read from the extra elements and the `never` fields, as extra confirm params
137
+ */
138
+ private confirmParams;
139
+ private confirm;
140
+ /**
141
+ * Run a confirmation and report its result to the state machine.
142
+ * `confirm` is called synchronously, so that its first step still runs inside the customer's submit event.
143
+ * Errors the customer can fix or retry keep the sheet open; others end it with `paymentSheetFailed`.
144
+ */
145
+ private runConfirm;
146
+ private loadCheckoutSession;
147
+ private confirmCheckoutSession;
148
+ private emit;
149
+ private warnUnsupportedOptions;
150
+ private warnCheckoutIgnoredOptions;
151
+ private handleSubmit;
152
+ /**
153
+ * The modal closes itself on a backdrop or close button click. Keep it open when the sheet refuses to close (while confirming).
154
+ */
155
+ private handleModalClose;
156
+ render(): any;
157
+ }
@@ -0,0 +1,153 @@
1
+ import type { Appearance, StripeAddressElementChangeEvent, StripeAddressElementOptions, StripeLinkAuthenticationElementOptions, StripePaymentElementOptions } from '@stripe/stripe-js';
2
+ import type { ExtraConfirmParams } from '../stripe-payment-element/stripe-payment-element.helpers';
3
+ import type { IntentKind, PaymentSheetResult } from './payment-sheet-state';
4
+ /**
5
+ * Value returned by `present()` (same shape as `presentPaymentSheet()` of `@capacitor-community/stripe`)
6
+ */
7
+ export type PaymentSheetPresentResult = {
8
+ paymentResult: PaymentSheetResult;
9
+ };
10
+ /**
11
+ * Address in the shape of `@capacitor-community/stripe`
12
+ */
13
+ export type PaymentSheetAddress = {
14
+ country?: string;
15
+ city?: string;
16
+ line1?: string;
17
+ line2?: string;
18
+ postalCode?: string;
19
+ state?: string;
20
+ };
21
+ /**
22
+ * Options of `<stripe-payment-sheet>`, using the same keys as `CreatePaymentSheetOption` of `@capacitor-community/stripe`
23
+ * (without the client secrets, which are passed as the `intent-client-secret` attribute).
24
+ * Options marked "no effect on the web" are accepted so that the same object can be passed through, and are reported once with `console.warn`.
25
+ */
26
+ export type PaymentSheetOptions = {
27
+ /** Shown as the business name in the Payment Element */
28
+ merchantDisplayName?: string;
29
+ /** `horizontal` = tabs, `vertical` = accordion, `automatic` = auto */
30
+ paymentMethodLayout?: 'horizontal' | 'vertical' | 'automatic';
31
+ /** Prefilled billing details */
32
+ defaultBillingDetails?: {
33
+ email?: string;
34
+ name?: string;
35
+ phone?: string;
36
+ address?: PaymentSheetAddress;
37
+ };
38
+ /** Where Stripe redirects after a redirect-based payment method. Defaults to the current page */
39
+ returnURL?: string;
40
+ /** `alwaysLight` = Stripe theme, `alwaysDark` = Night theme */
41
+ style?: 'alwaysLight' | 'alwaysDark';
42
+ /**
43
+ * Which billing details are collected (PaymentIntent / SetupIntent).
44
+ * `never` hides the field and sends the `defaultBillingDetails` value instead (loading fails when it is missing).
45
+ * `email: 'always'` shows an email (Link Authentication) element, `address: 'full'` shows a billing Address Element,
46
+ * `phone: 'always'` asks for the phone in that Address Element (no effect without `address: 'full'`),
47
+ * `name: 'always'` has no effect on the web (it needs Stripe beta access).
48
+ */
49
+ billingDetailsCollectionConfiguration?: {
50
+ email?: 'automatic' | 'always' | 'never';
51
+ name?: 'automatic' | 'always' | 'never';
52
+ phone?: 'automatic' | 'always' | 'never';
53
+ address?: 'automatic' | 'full' | 'never';
54
+ };
55
+ /** Shows a shipping Address Element prefilled with these values (PaymentIntent only; no effect for a SetupIntent) */
56
+ shippingDetails?: {
57
+ name?: string;
58
+ phone?: string;
59
+ address?: PaymentSheetAddress;
60
+ };
61
+ /** `true` shows Apple Pay when available, `false` hides it */
62
+ enableApplePay?: boolean;
63
+ /** `true` shows Google Pay when available, `false` hides it */
64
+ enableGooglePay?: boolean;
65
+ /** No effect on the web (the web uses CustomerSession instead) */
66
+ customerId?: string;
67
+ /** No effect on the web (the web uses CustomerSession instead) */
68
+ customerEphemeralKeySecret?: string;
69
+ /** No effect on the web */
70
+ applePayMerchantId?: string;
71
+ /** No effect on the web */
72
+ GooglePayIsTesting?: boolean;
73
+ /** No effect on the web */
74
+ countryCode?: string;
75
+ /** No effect on the web */
76
+ currencyCode?: string;
77
+ /** No effect on the web */
78
+ withZipCode?: boolean;
79
+ /** No effect on the web */
80
+ allowsDelayedPaymentMethods?: boolean;
81
+ };
82
+ /**
83
+ * Build the Payment Element options from the payment sheet options.
84
+ * @param options - Payment sheet options
85
+ */
86
+ export declare const toPaymentElementOptions: (options: PaymentSheetOptions | undefined) => StripePaymentElementOptions;
87
+ /**
88
+ * Build the Elements appearance from the payment sheet style.
89
+ * @param style - `alwaysLight` or `alwaysDark`
90
+ */
91
+ export declare const toAppearance: (style: PaymentSheetOptions["style"]) => Appearance | undefined;
92
+ /**
93
+ * List the given options (or option values, as `option.key`) that have no effect on the web (yet), sorted by name.
94
+ * @param options - Payment sheet options
95
+ * @param intentKind - Kind of the intent, when known
96
+ */
97
+ export declare const unsupportedOptionKeys: (options: PaymentSheetOptions | undefined, intentKind?: IntentKind) => string[];
98
+ /**
99
+ * `payment_method_data.billing_details` passed to `confirmPayment` / `confirmSetup`
100
+ */
101
+ export type ConfirmBillingDetails = NonNullable<NonNullable<ExtraConfirmParams['payment_method_data']>['billing_details']>;
102
+ /**
103
+ * Extra elements to show next to the Payment Element, and the billing details to pass at confirmation
104
+ */
105
+ export type BillingDetailsCollectionPlan = {
106
+ /** Billing details whose Payment Element field is `never`, taken from `defaultBillingDetails` */
107
+ fixedBillingDetails: ConfirmBillingDetails;
108
+ /** Whether the phone typed into the billing Address Element is passed at confirmation */
109
+ collectPhoneFromAddress: boolean;
110
+ /** Options of the billing Address Element (`address: 'full'`) */
111
+ billingAddressElement?: StripeAddressElementOptions;
112
+ /** Options of the shipping Address Element (`shippingDetails`, PaymentIntent only) */
113
+ shippingAddressElement?: StripeAddressElementOptions;
114
+ /** Options of the email (Link Authentication) element (`email: 'always'`) */
115
+ emailElement?: StripeLinkAuthenticationElementOptions;
116
+ };
117
+ /**
118
+ * Values read from the extra elements right before confirmation
119
+ */
120
+ export type CollectedDetails = {
121
+ billingAddress?: Pick<StripeAddressElementChangeEvent, 'complete' | 'value'>;
122
+ /** Email of the latest change event of the email element; undefined until it reports one */
123
+ email?: string;
124
+ /** `complete` of the latest change event of the email element; undefined until it reports one */
125
+ emailComplete?: boolean;
126
+ };
127
+ /**
128
+ * Tell whether an error was raised by this sheet's own validation (its message is an i18n key), rather than by Stripe (already localized).
129
+ * @param error - Error thrown while confirming
130
+ */
131
+ export declare const isSheetValidationError: (error: unknown) => boolean;
132
+ /**
133
+ * Decide which extra elements to show and which billing details to pass at confirmation (PaymentIntent / SetupIntent mode).
134
+ * @param options - Payment sheet options
135
+ * @param intentKind - Kind of the intent being confirmed
136
+ * @throws Error when a `never` field has no value in `defaultBillingDetails`
137
+ */
138
+ export declare const planBillingDetailsCollection: (options: PaymentSheetOptions | undefined, intentKind: IntentKind) => BillingDetailsCollectionPlan;
139
+ /**
140
+ * Build `payment_method_data.billing_details` for the confirmation.
141
+ * Values fixed by a `never` field win over the values typed into the extra elements.
142
+ * @param plan - Result of `planBillingDetailsCollection`
143
+ * @param collected - Values read from the extra elements
144
+ * @returns The billing details, or undefined when nothing has to be passed
145
+ * @throws Error with `type: 'validation_error'` when an extra element is not complete
146
+ */
147
+ export declare const collectedBillingDetails: (plan: BillingDetailsCollectionPlan, collected: CollectedDetails) => ConfirmBillingDetails | undefined;
148
+ /**
149
+ * Tell whether a confirmation error lets the customer try again in the open sheet.
150
+ * Other errors (for example `invalid_request_error` for an intent that already succeeded) end the sheet with `paymentSheetFailed`.
151
+ * @param error - Error thrown while confirming
152
+ */
153
+ export declare const isRecoverableConfirmError: (error: unknown) => boolean;