stripe-pwa-elements 4.0.2 → 4.0.4

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 (72) hide show
  1. package/dist/cjs/{factory-tenFFIul.js → factory-Cm6zUD7R.js} +7 -1
  2. package/dist/cjs/{i18n-FhEOc8vz.js → i18n-lBbOeQt4.js} +6 -0
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +5 -3
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stripe-address-element.cjs.entry.js +2 -2
  6. package/dist/cjs/stripe-card-element.cjs.entry.js +13 -3
  7. package/dist/cjs/stripe-currency-selector.cjs.entry.js +2 -2
  8. package/dist/cjs/stripe-elements.cjs.js +1 -1
  9. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +2 -2
  10. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +2 -2
  11. package/dist/cjs/stripe-payment-element.cjs.entry.js +11 -3
  12. package/dist/cjs/{stripe-payment-element.helpers-DukP33RI.js → stripe-payment-element.helpers-lafmSRmb.js} +7 -8
  13. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +516 -35
  14. package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
  15. package/dist/collection/components/stripe-card-element/stripe-card-element.js +11 -1
  16. package/dist/collection/components/stripe-modal/stripe-modal.css +4 -0
  17. package/dist/collection/components/stripe-modal/stripe-modal.js +3 -1
  18. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +7 -8
  19. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +12 -4
  20. package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +21 -7
  21. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
  22. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +193 -9
  23. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +240 -21
  24. package/dist/collection/services/link-authentication-element-manager.js +5 -0
  25. package/dist/collection/utils/i18n.js +6 -0
  26. package/dist/components/factory.js +1 -1
  27. package/dist/components/i18n.js +1 -1
  28. package/dist/components/stripe-card-element2.js +1 -1
  29. package/dist/components/stripe-modal2.js +1 -1
  30. package/dist/components/stripe-payment-element.helpers.js +1 -1
  31. package/dist/components/stripe-payment-element.js +1 -1
  32. package/dist/components/stripe-payment-sheet.js +1 -1
  33. package/dist/esm/{factory-Cd6OGTWN.js → factory-BaGv8K_i.js} +7 -2
  34. package/dist/esm/{i18n-B6JoQetF.js → i18n-CL5n3bOb.js} +6 -0
  35. package/dist/esm/ion-icon_2.entry.js +5 -3
  36. package/dist/esm/loader.js +1 -1
  37. package/dist/esm/stripe-address-element.entry.js +2 -2
  38. package/dist/esm/stripe-card-element.entry.js +13 -3
  39. package/dist/esm/stripe-currency-selector.entry.js +2 -2
  40. package/dist/esm/stripe-elements.js +1 -1
  41. package/dist/esm/stripe-express-checkout-element.entry.js +2 -2
  42. package/dist/esm/stripe-link-authentication-element.entry.js +2 -2
  43. package/dist/esm/stripe-payment-element.entry.js +11 -3
  44. package/dist/esm/{stripe-payment-element.helpers-CipV87b8.js → stripe-payment-element.helpers-CklK5RlF.js} +7 -8
  45. package/dist/esm/stripe-payment-sheet.entry.js +516 -35
  46. package/dist/stripe-elements/{p-f892e375.entry.js → p-2e41699e.entry.js} +1 -1
  47. package/dist/stripe-elements/{p-6a9c8b7a.entry.js → p-3fc4583a.entry.js} +1 -1
  48. package/dist/stripe-elements/p-5d3d93ec.entry.js +1 -0
  49. package/dist/stripe-elements/p-7a8f783c.entry.js +1 -0
  50. package/dist/stripe-elements/{p-915b86ed.entry.js → p-7e826964.entry.js} +1 -1
  51. package/dist/stripe-elements/p-BoZLkOAy.js +1 -0
  52. package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
  53. package/dist/stripe-elements/{p-C7MQk9FK.js → p-DlMEZwSe.js} +1 -1
  54. package/dist/stripe-elements/{p-5338bc5e.entry.js → p-b62c9dae.entry.js} +1 -1
  55. package/dist/stripe-elements/p-b69f6103.entry.js +1 -0
  56. package/dist/stripe-elements/{p-7fe4a287.entry.js → p-f5552c81.entry.js} +1 -1
  57. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  58. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +1 -0
  59. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +9 -2
  60. package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +21 -4
  61. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
  62. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +50 -5
  63. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +66 -8
  64. package/dist/types/components.d.ts +22 -9
  65. package/dist/types/services/interfaces.d.ts +2 -0
  66. package/package.json +4 -2
  67. package/readme.md +78 -27
  68. package/dist/stripe-elements/p-B6JoQetF.js +0 -1
  69. package/dist/stripe-elements/p-DFAhQS0n.js +0 -1
  70. package/dist/stripe-elements/p-b06a254f.entry.js +0 -1
  71. package/dist/stripe-elements/p-b91c4fa7.entry.js +0 -1
  72. package/dist/stripe-elements/p-e7372ca7.entry.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { r as registerInstance, a as createEvent, h, d as Host, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-B6JoQetF.js';
3
- import { s as serviceFactory } from './factory-Cd6OGTWN.js';
4
- import { c as confirmPaymentOrSetup } from './stripe-payment-element.helpers-CipV87b8.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
+ import { s as serviceFactory, f as findElement } from './factory-BaGv8K_i.js';
4
+ import { c as confirmPaymentOrSetup } from './stripe-payment-element.helpers-CklK5RlF.js';
5
+ import { S as StripeAPIError } from './error-XRfh5Wrs.js';
5
6
  import './index-CBXaOfXU.js';
6
- import './error-XRfh5Wrs.js';
7
7
 
8
8
  /**
9
9
  * State machine behind `<stripe-payment-sheet>`.
@@ -31,6 +31,20 @@ const intentKindFromClientSecret = (clientSecret) => {
31
31
  const match = CLIENT_SECRET_PATTERNS.find(([pattern]) => pattern.test(clientSecret));
32
32
  return match === null || match === void 0 ? void 0 : match[1];
33
33
  };
34
+ /**
35
+ * Tell what a client secret belongs to.
36
+ * A secret from `checkout-session-client-secret` is always a Checkout Session: Stripe does not document the format
37
+ * of a Checkout Session client secret, so it is never inspected. Intent secrets are told apart by their prefix.
38
+ * @param clientSecret - The client secret
39
+ * @param source - The attribute the secret was set through
40
+ * @returns The kind, or undefined when an intent secret has an unknown format
41
+ */
42
+ const intentKindOf = (clientSecret, source) => {
43
+ if (source === 'checkoutSession') {
44
+ return 'checkoutSession';
45
+ }
46
+ return intentKindFromClientSecret(clientSecret);
47
+ };
34
48
  const unchanged = (state) => ({ state, effects: [] });
35
49
  /**
36
50
  * Resolve the pending `present()` promise, if any.
@@ -52,17 +66,17 @@ const cancel = (state) => {
52
66
  effects: [...(visible ? [{ type: 'hide' }] : []), { type: 'emit', event: 'paymentSheetCanceled' }, ...resolved.effects],
53
67
  };
54
68
  };
55
- const changeSecret = (state, clientSecret) => {
69
+ const changeSecret = (state, clientSecret, source) => {
56
70
  if (clientSecret === '') {
57
71
  return unchanged(state);
58
72
  }
59
73
  // Never drop the result of a running confirmation; apply the new secret once it finishes
60
74
  if (state.phase === 'confirming') {
61
- return unchanged(Object.assign(Object.assign({}, state), { deferredClientSecret: clientSecret }));
75
+ return unchanged(Object.assign(Object.assign({}, state), { deferredSecret: { clientSecret, source } }));
62
76
  }
63
77
  const canceled = state.phase === 'presented' ? cancel(state) : unchanged(state);
64
78
  const generation = state.generation + 1;
65
- const intentKind = intentKindFromClientSecret(clientSecret);
79
+ const intentKind = intentKindOf(clientSecret, source);
66
80
  if (intentKind == null) {
67
81
  const resolved = resolvePending(Object.assign(Object.assign({}, canceled.state), { phase: 'loadFailed', generation, intentKind: undefined, openRequested: false }), 'paymentSheetFailed');
68
82
  return {
@@ -79,11 +93,11 @@ const changeSecret = (state, clientSecret) => {
79
93
  * Apply a secret that arrived while confirming.
80
94
  */
81
95
  const applyDeferredSecret = (result) => {
82
- const { deferredClientSecret } = result.state;
83
- if (deferredClientSecret == null) {
96
+ const { deferredSecret } = result.state;
97
+ if (deferredSecret == null) {
84
98
  return result;
85
99
  }
86
- const next = changeSecret(Object.assign(Object.assign({}, result.state), { deferredClientSecret: undefined }), deferredClientSecret);
100
+ const next = changeSecret(Object.assign(Object.assign({}, result.state), { deferredSecret: undefined }), deferredSecret.clientSecret, deferredSecret.source);
87
101
  return { state: next.state, effects: [...result.effects, ...next.effects] };
88
102
  };
89
103
  const isCurrentConfirmation = (state, generation) => state.phase === 'confirming' && state.generation === generation;
@@ -95,7 +109,7 @@ const isCurrentConfirmation = (state, generation) => state.phase === 'confirming
95
109
  const transition = (state, event) => {
96
110
  switch (event.type) {
97
111
  case 'secretChanged':
98
- return changeSecret(state, event.clientSecret);
112
+ return changeSecret(state, event.clientSecret, event.source);
99
113
  case 'loadSucceeded': {
100
114
  if (event.generation !== state.generation || state.phase !== 'loading') {
101
115
  return unchanged(state);
@@ -197,7 +211,17 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
197
211
  }
198
212
  return t;
199
213
  };
200
- const SUPPORTED_OPTION_KEYS = ['merchantDisplayName', 'paymentMethodLayout', 'defaultBillingDetails', 'returnURL', 'style'];
214
+ const SUPPORTED_OPTION_KEYS = [
215
+ 'merchantDisplayName',
216
+ 'paymentMethodLayout',
217
+ 'defaultBillingDetails',
218
+ 'returnURL',
219
+ 'style',
220
+ 'billingDetailsCollectionConfiguration',
221
+ 'shippingDetails',
222
+ 'enableApplePay',
223
+ 'enableGooglePay',
224
+ ];
201
225
  const LAYOUTS = {
202
226
  horizontal: 'tabs',
203
227
  vertical: 'accordion',
@@ -211,6 +235,34 @@ const THEMES = {
211
235
  * Drop keys whose value is undefined.
212
236
  */
213
237
  const compact = (value) => Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
238
+ /**
239
+ * Convert a Capacitor address to the Stripe shape (`postalCode` → `postal_code`), dropping keys that are not given.
240
+ */
241
+ const toStripeAddress = (address) => {
242
+ const { postalCode } = address, rest = __rest(address, ["postalCode"]);
243
+ return compact(Object.assign(Object.assign({}, rest), { postal_code: postalCode }));
244
+ };
245
+ /**
246
+ * Payment Element billing fields to turn off: the `never` ones (passed from `defaultBillingDetails` at confirmation)
247
+ * and the ones collected by a separate element (email element, billing Address Element).
248
+ */
249
+ const toBillingDetailsFields = (config) => {
250
+ if (config == null) {
251
+ return undefined;
252
+ }
253
+ const { email, name, phone, address } = config;
254
+ const fields = compact({
255
+ email: email === 'never' || email === 'always' ? 'never' : undefined,
256
+ name: name === 'never' ? 'never' : undefined,
257
+ phone: phone === 'never' || (phone === 'always' && address === 'full') ? 'never' : undefined,
258
+ address: address === 'never' || address === 'full' ? 'never' : undefined,
259
+ });
260
+ return Object.keys(fields).length === 0 ? undefined : fields;
261
+ };
262
+ /**
263
+ * `true` → `auto` (shown when available), `false` → `never`, undefined → left to Stripe
264
+ */
265
+ const toWalletOption = (enabled) => (enabled == null ? undefined : enabled ? 'auto' : 'never');
214
266
  /**
215
267
  * Build the Payment Element options from the payment sheet options.
216
268
  * @param options - Payment sheet options
@@ -219,8 +271,16 @@ const toPaymentElementOptions = (options) => {
219
271
  if (options == null) {
220
272
  return {};
221
273
  }
222
- const { merchantDisplayName, paymentMethodLayout, defaultBillingDetails } = options;
274
+ const { merchantDisplayName, paymentMethodLayout, defaultBillingDetails, billingDetailsCollectionConfiguration, enableApplePay, enableGooglePay } = options;
223
275
  const elementOptions = {};
276
+ const billingDetailsFields = toBillingDetailsFields(billingDetailsCollectionConfiguration);
277
+ const wallets = compact({ applePay: toWalletOption(enableApplePay), googlePay: toWalletOption(enableGooglePay) });
278
+ if (billingDetailsFields != null) {
279
+ elementOptions.fields = { billingDetails: billingDetailsFields };
280
+ }
281
+ if (Object.keys(wallets).length > 0) {
282
+ elementOptions.wallets = wallets;
283
+ }
224
284
  if (merchantDisplayName != null) {
225
285
  elementOptions.business = { name: merchantDisplayName };
226
286
  }
@@ -231,8 +291,7 @@ const toPaymentElementOptions = (options) => {
231
291
  const { address } = defaultBillingDetails, contact = __rest(defaultBillingDetails, ["address"]);
232
292
  const billingDetails = compact(contact);
233
293
  if (address != null) {
234
- const { postalCode } = address, rest = __rest(address, ["postalCode"]);
235
- billingDetails.address = compact(Object.assign(Object.assign({}, rest), { postal_code: postalCode }));
294
+ billingDetails.address = toStripeAddress(address);
236
295
  }
237
296
  elementOptions.defaultValues = { billingDetails };
238
297
  }
@@ -249,17 +308,156 @@ const toAppearance = (style) => {
249
308
  return { theme: THEMES[style] };
250
309
  };
251
310
  /**
252
- * List the given options that have no effect on the web (yet), sorted by name.
311
+ * List the given options (or option values, as `option.key`) that have no effect on the web (yet), sorted by name.
253
312
  * @param options - Payment sheet options
313
+ * @param intentKind - Kind of the intent, when known
254
314
  */
255
- const unsupportedOptionKeys = (options) => {
315
+ const unsupportedOptionKeys = (options, intentKind) => {
256
316
  if (options == null) {
257
317
  return [];
258
318
  }
259
- return Object.entries(options)
319
+ const keys = Object.entries(options)
260
320
  .filter(([key, value]) => value !== undefined && !SUPPORTED_OPTION_KEYS.includes(key))
261
- .map(([key]) => key)
262
- .sort();
321
+ .map(([key]) => key);
322
+ const config = options.billingDetailsCollectionConfiguration;
323
+ // `fields.billingDetails.name: 'always'` of the Payment Element requires Stripe beta access, so it is not sent
324
+ if ((config === null || config === void 0 ? void 0 : config.name) === 'always') {
325
+ keys.push('billingDetailsCollectionConfiguration.name');
326
+ }
327
+ // The phone can only be required through the billing Address Element
328
+ if ((config === null || config === void 0 ? void 0 : config.phone) === 'always' && config.address !== 'full') {
329
+ keys.push('billingDetailsCollectionConfiguration.phone');
330
+ }
331
+ // A SetupIntent has no shipping details
332
+ if (options.shippingDetails != null && intentKind === 'setup') {
333
+ keys.push('shippingDetails');
334
+ }
335
+ return keys.sort();
336
+ };
337
+ /**
338
+ * Prefill values of an Address Element. The address is left out without a country, which the Address Element requires.
339
+ */
340
+ const toAddressDefaultValues = (details) => {
341
+ const { name, phone, address } = details;
342
+ const country = address === null || address === void 0 ? void 0 : address.country;
343
+ return compact({ name, phone, address: country == null || country === '' ? undefined : Object.assign(Object.assign({}, toStripeAddress(address)), { country }) });
344
+ };
345
+ const isBlank = (value) => value == null || value === '';
346
+ /**
347
+ * Loose email check, used only when the email element has not told whether its value is complete (a prefilled value nobody edited)
348
+ */
349
+ const looksLikeEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
350
+ /**
351
+ * Error for a `never` field without a default value. Thrown while loading so that Stripe never rejects the confirmation.
352
+ */
353
+ const missingDefaultError = (field, defaultKey) => new Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${field} is 'never', so defaultBillingDetails.${defaultKey} is required`);
354
+ /**
355
+ * Error the customer can fix in the open sheet (handled like a Stripe `validation_error`).
356
+ * Its message is an English i18n key, translated when it is shown (see `isSheetValidationError`).
357
+ */
358
+ const validationError = (message) => Object.assign(new Error(message), { type: 'validation_error', sheetValidation: true });
359
+ /**
360
+ * Tell whether an error was raised by this sheet's own validation (its message is an i18n key), rather than by Stripe (already localized).
361
+ * @param error - Error thrown while confirming
362
+ */
363
+ const isSheetValidationError = (error) => (error === null || error === void 0 ? void 0 : error.sheetValidation) === true;
364
+ /**
365
+ * Decide which extra elements to show and which billing details to pass at confirmation (PaymentIntent / SetupIntent mode).
366
+ * @param options - Payment sheet options
367
+ * @param intentKind - Kind of the intent being confirmed
368
+ * @throws Error when a `never` field has no value in `defaultBillingDetails`
369
+ */
370
+ const planBillingDetailsCollection = (options, intentKind) => {
371
+ var _a, _b, _c, _d, _e, _f, _g;
372
+ const config = (_a = options === null || options === void 0 ? void 0 : options.billingDetailsCollectionConfiguration) !== null && _a !== void 0 ? _a : {};
373
+ const defaults = (_b = options === null || options === void 0 ? void 0 : options.defaultBillingDetails) !== null && _b !== void 0 ? _b : {};
374
+ const fixedBillingDetails = {};
375
+ ['email', 'name', 'phone'].forEach(field => {
376
+ if (config[field] !== 'never') {
377
+ return;
378
+ }
379
+ if (isBlank(defaults[field])) {
380
+ throw missingDefaultError(field, field);
381
+ }
382
+ fixedBillingDetails[field] = defaults[field];
383
+ });
384
+ if (config.address === 'never') {
385
+ const address = defaults.address;
386
+ if (address == null || isBlank(address.country)) {
387
+ throw missingDefaultError('address', 'address.country');
388
+ }
389
+ // Every key is passed: the Payment Element does not collect any part of the address
390
+ fixedBillingDetails.address = {
391
+ line1: (_c = address.line1) !== null && _c !== void 0 ? _c : '',
392
+ line2: (_d = address.line2) !== null && _d !== void 0 ? _d : '',
393
+ city: (_e = address.city) !== null && _e !== void 0 ? _e : '',
394
+ state: (_f = address.state) !== null && _f !== void 0 ? _f : '',
395
+ postal_code: (_g = address.postalCode) !== null && _g !== void 0 ? _g : '',
396
+ country: address.country,
397
+ };
398
+ }
399
+ const collectPhoneFromAddress = config.address === 'full' && config.phone === 'always';
400
+ const plan = { fixedBillingDetails, collectPhoneFromAddress };
401
+ if (config.address === 'full') {
402
+ const billingAddressElement = { mode: 'billing', defaultValues: toAddressDefaultValues(defaults) };
403
+ if (collectPhoneFromAddress) {
404
+ billingAddressElement.fields = { phone: 'always' };
405
+ billingAddressElement.validation = { phone: { required: 'always' } };
406
+ }
407
+ else if (config.phone === 'never') {
408
+ billingAddressElement.fields = { phone: 'never' };
409
+ }
410
+ plan.billingAddressElement = billingAddressElement;
411
+ }
412
+ if (config.email === 'always') {
413
+ plan.emailElement = isBlank(defaults.email) ? {} : { defaultValues: { email: defaults.email } };
414
+ }
415
+ const shippingDetails = options === null || options === void 0 ? void 0 : options.shippingDetails;
416
+ if (shippingDetails != null && intentKind === 'payment') {
417
+ const shippingAddressElement = { mode: 'shipping', defaultValues: toAddressDefaultValues(shippingDetails) };
418
+ // The Address Element hides the phone field by default; show it so that the given phone is kept and editable
419
+ if (!isBlank(shippingDetails.phone)) {
420
+ shippingAddressElement.fields = { phone: 'always' };
421
+ }
422
+ plan.shippingAddressElement = shippingAddressElement;
423
+ }
424
+ return plan;
425
+ };
426
+ /**
427
+ * Build `payment_method_data.billing_details` for the confirmation.
428
+ * Values fixed by a `never` field win over the values typed into the extra elements.
429
+ * @param plan - Result of `planBillingDetailsCollection`
430
+ * @param collected - Values read from the extra elements
431
+ * @returns The billing details, or undefined when nothing has to be passed
432
+ * @throws Error with `type: 'validation_error'` when an extra element is not complete
433
+ */
434
+ const collectedBillingDetails = (plan, collected) => {
435
+ var _a, _b;
436
+ const details = {};
437
+ if (plan.billingAddressElement != null) {
438
+ const billingAddress = collected.billingAddress;
439
+ if (billingAddress == null || !billingAddress.complete) {
440
+ throw validationError('Please complete your billing address.');
441
+ }
442
+ details.name = billingAddress.value.name;
443
+ details.address = billingAddress.value.address;
444
+ if (plan.collectPhoneFromAddress) {
445
+ details.phone = billingAddress.value.phone;
446
+ }
447
+ }
448
+ if (plan.emailElement != null) {
449
+ // Before any change event the element shows its prefilled value
450
+ const email = (_a = collected.email) !== null && _a !== void 0 ? _a : (_b = plan.emailElement.defaultValues) === null || _b === void 0 ? void 0 : _b.email;
451
+ if (isBlank(email)) {
452
+ throw validationError('Please enter your email address.');
453
+ }
454
+ if (collected.emailComplete === false || (collected.emailComplete == null && !looksLikeEmail(email))) {
455
+ throw validationError('Please enter a valid email address.');
456
+ }
457
+ details.email = email;
458
+ }
459
+ Object.assign(details, plan.fixedBillingDetails);
460
+ return Object.keys(details).length === 0 ? undefined : details;
263
461
  };
264
462
  /**
265
463
  * Stripe error types after which the customer can fix the input or simply try again.
@@ -276,8 +474,102 @@ const isRecoverableConfirmError = (error) => {
276
474
  return typeof type === 'string' && RECOVERABLE_ERROR_TYPES.includes(type);
277
475
  };
278
476
 
477
+ /**
478
+ * Build the Checkout Payment Element options from the payment sheet options.
479
+ * The Checkout Payment Element takes fewer options than the regular one: `business` and `defaultValues` are not
480
+ * available, so only the layout is passed.
481
+ * @param options - Payment sheet options
482
+ */
483
+ const toCheckoutPaymentElementOptions = (options) => {
484
+ const { layout } = toPaymentElementOptions(options);
485
+ return layout == null ? {} : { layout };
486
+ };
487
+ /**
488
+ * List the given options that a Checkout Session does not use, sorted by name.
489
+ * Name, phone and address come from the session or from other Checkout elements; the email is passed to `confirm`.
490
+ * @param options - Payment sheet options
491
+ */
492
+ const checkoutIgnoredOptionKeys = (options) => {
493
+ if (options == null) {
494
+ return [];
495
+ }
496
+ const { merchantDisplayName, defaultBillingDetails } = options;
497
+ const keys = ['name', 'phone', 'address'].filter(key => (defaultBillingDetails === null || defaultBillingDetails === void 0 ? void 0 : defaultBillingDetails[key]) != null).map(key => `defaultBillingDetails.${key}`);
498
+ if (merchantDisplayName != null) {
499
+ keys.push('merchantDisplayName');
500
+ }
501
+ // The extra billing elements and the wallet mapping are implemented for PaymentIntent / SetupIntent mode only
502
+ ['billingDetailsCollectionConfiguration', 'shippingDetails', 'enableApplePay', 'enableGooglePay']
503
+ .filter(key => options[key] !== undefined)
504
+ .forEach(key => keys.push(key));
505
+ return keys.sort();
506
+ };
507
+ /**
508
+ * Build the `elementsOptions` passed to `initCheckoutElementsSdk` from the payment sheet options.
509
+ * @param options - Payment sheet options
510
+ */
511
+ const toCheckoutElementsOptions = (options) => {
512
+ const appearance = toAppearance(options === null || options === void 0 ? void 0 : options.style);
513
+ return appearance == null ? undefined : { appearance };
514
+ };
515
+ /**
516
+ * Throw when the session can no longer be paid. Stripe documents an `expired` session as "No further processing will occur",
517
+ * and a `complete` one is already paid or being paid, so confirming again cannot succeed.
518
+ * @param status - `session.status` from `getSession()`; undefined when it cannot be read
519
+ * @param message - Message of the confirm error, if any
520
+ * @throws StripeAPIError of type `invalid_request_error` (unrecoverable), with the code `checkout_session_expired` or `checkout_session_complete`
521
+ */
522
+ const assertSessionOpen = (status, message) => {
523
+ if (status == null || status.type === 'open') {
524
+ return;
525
+ }
526
+ throw new StripeAPIError({
527
+ type: 'invalid_request_error',
528
+ code: `checkout_session_${status.type}`,
529
+ message: message !== null && message !== void 0 ? message : `The Checkout Session is ${status.type} and can no longer be paid.`,
530
+ });
531
+ };
532
+ /**
533
+ * Confirm a Checkout Session from the payment sheet.
534
+ *
535
+ * Unlike the default of `confirm`, which always redirects to `returnUrl`, this passes `redirect: 'if_required'`
536
+ * so that payment methods without a redirect finish in the page and can be reported as `paymentSheetCompleted`.
537
+ *
538
+ * Errors are thrown as `StripeAPIError` with a `type` that `isRecoverableConfirmError` understands.
539
+ * A confirm error only carries `code: 'paymentFailed'` or `code: null` (`StripeCheckoutConfirmResult` in @stripe/stripe-js),
540
+ * so whether the session can still be paid is read from `session.status`:
541
+ * - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`, which ends the sheet
542
+ * - `paymentFailed` on an open session (a decline): `card_error`, which keeps the sheet open
543
+ * - any other confirm error on an open session, or a failure to load the actions: `api_error`, which keeps the sheet open
544
+ * @param checkout - The Checkout instance from `initCheckoutElementsSdk`
545
+ * @param returnUrl - Where Stripe redirects after a redirect-based payment method
546
+ * @param email - Customer email; needed when the session was created without `customer_email` or `customer`
547
+ * @returns The confirmation result
548
+ * @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
549
+ */
550
+ const confirmCheckoutSessionSheet = async (checkout, returnUrl, email) => {
551
+ const loadActionsResult = await checkout.loadActions();
552
+ if (loadActionsResult.type === 'error') {
553
+ throw new StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message: loadActionsResult.error.message });
554
+ }
555
+ const { actions } = loadActionsResult;
556
+ const sessionStatus = () => { var _a, _b; return (_b = (_a = actions.getSession) === null || _a === void 0 ? void 0 : _a.call(actions)) === null || _b === void 0 ? void 0 : _b.status; };
557
+ assertSessionOpen(sessionStatus());
558
+ const result = await actions.confirm(Object.assign({ returnUrl, redirect: 'if_required' }, (email != null && email !== '' ? { email } : {})));
559
+ if (result.type === 'error') {
560
+ const { code, message } = result.error;
561
+ assertSessionOpen(sessionStatus(), message);
562
+ if (code === 'paymentFailed') {
563
+ throw new StripeAPIError({ type: 'card_error', code, message });
564
+ }
565
+ throw new StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message });
566
+ }
567
+ return result;
568
+ };
569
+
279
570
  const stripePaymentSheetCss = () => `:root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}stripe-payment-sheet{display:contents}.stripe-payment-sheet-wrap{box-sizing:border-box}.stripe-payment-sheet-wrap *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}.stripe-payment-sheet-wrap button{cursor:pointer}.stripe-payment-sheet-wrap{display:block;width:100%;background:#fff;padding:32px 16px}.stripe-payment-sheet-wrap .stripe-heading{font-size:24px;font-weight:bold;color:var(--color-heading-text);margin-bottom:24px}.stripe-payment-sheet-wrap .payment-info{margin-top:8px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .stripe-submit{margin-top:32px}.stripe-payment-sheet-wrap button{display:block;color:var(--color-button-text);background-color:var(--color-primary);width:100%;text-align:center;padding:16px 16px;font-size:18px;border-radius:6px;min-height:42px}.stripe-payment-sheet-wrap button:disabled{color:var(--color-button-text-disabled)}`;
280
571
 
572
+ const nonEmpty = (value) => (value == null || value === '' ? undefined : value);
281
573
  const StripePaymentSheet = class {
282
574
  /**
283
575
  * Show the sheet and wait for its result.
@@ -313,6 +605,7 @@ const StripePaymentSheet = class {
313
605
  this.paymentSheetCanceled = createEvent(this, "paymentSheetCanceled", 7);
314
606
  this.paymentSheetFailed = createEvent(this, "paymentSheetFailed", 7);
315
607
  this.warnedUnsupportedOptions = false;
608
+ this.warnedCheckoutIgnoredOptions = false;
316
609
  /**
317
610
  * Whether the sheet is shown. Setting it to false closes the sheet as canceled.
318
611
  */
@@ -349,6 +642,9 @@ const StripePaymentSheet = class {
349
642
  };
350
643
  this.stripeService = serviceFactory.createStripeService();
351
644
  this.paymentElementManager = serviceFactory.createPaymentElementManager(this.stripeService);
645
+ this.billingAddressElementManager = serviceFactory.createAddressElementManager(this.stripeService);
646
+ this.shippingAddressElementManager = serviceFactory.createAddressElementManager(this.stripeService);
647
+ this.emailElementManager = serviceFactory.createLinkAuthenticationElementManager(this.stripeService);
352
648
  }
353
649
  /**
354
650
  * Props are not yet populated inside the constructor with the custom-elements build,
@@ -365,12 +661,43 @@ const StripePaymentSheet = class {
365
661
  }
366
662
  disconnectedCallback() {
367
663
  this.paymentElementManager.unmount();
664
+ this.unmountExtraElements();
665
+ }
666
+ unmountExtraElements() {
667
+ this.billingAddressElementManager.unmount();
668
+ this.shippingAddressElementManager.unmount();
669
+ this.emailElementManager.unmount();
368
670
  }
671
+ /**
672
+ * Decide what to load from the attributes and load it only when it differs from the last load.
673
+ * A change that does not alter the result (the attribute that is not used, or an empty value that means unset)
674
+ * must neither reload Stripe.js nor cancel an open sheet.
675
+ */
369
676
  startLoading() {
370
- if (this.publishableKey == null || this.publishableKey === '' || this.intentClientSecret == null) {
677
+ const target = this.loadTarget();
678
+ if (target == null || target.key === this.lastLoadKey) {
371
679
  return;
372
680
  }
373
- this.dispatch({ type: 'secretChanged', clientSecret: this.intentClientSecret });
681
+ this.lastLoadKey = target.key;
682
+ this.dispatch({ type: 'secretChanged', clientSecret: target.clientSecret, source: target.source });
683
+ }
684
+ /**
685
+ * The secret to load and a key of everything the load depends on, or undefined when nothing can be loaded.
686
+ * The Checkout Session wins when both secrets are set (the same rule as `stripe-payment-element`).
687
+ */
688
+ loadTarget() {
689
+ var _a;
690
+ const publishableKey = nonEmpty(this.publishableKey);
691
+ if (publishableKey == null) {
692
+ return undefined;
693
+ }
694
+ const checkoutSessionClientSecret = nonEmpty(this.checkoutSessionClientSecret);
695
+ const intentClientSecret = nonEmpty(this.intentClientSecret);
696
+ const [clientSecret, source] = checkoutSessionClientSecret != null ? [checkoutSessionClientSecret, 'checkoutSession'] : [intentClientSecret, 'intent'];
697
+ if (clientSecret == null) {
698
+ return undefined;
699
+ }
700
+ return { key: JSON.stringify([publishableKey, (_a = nonEmpty(this.stripeAccount)) !== null && _a !== void 0 ? _a : null, source, clientSecret]), clientSecret, source };
374
701
  }
375
702
  dispatch(event) {
376
703
  const { state, effects } = transition(this.sheet, event);
@@ -381,7 +708,12 @@ const StripePaymentSheet = class {
381
708
  var _a;
382
709
  switch (effect.type) {
383
710
  case 'load':
384
- this.load(effect.generation, effect.clientSecret);
711
+ if (effect.intentKind === 'checkoutSession') {
712
+ this.loadCheckoutSession(effect.generation, effect.clientSecret);
713
+ }
714
+ else {
715
+ this.load(effect.generation, effect.clientSecret, effect.intentKind);
716
+ }
385
717
  break;
386
718
  case 'show':
387
719
  this.visible = true;
@@ -392,7 +724,12 @@ const StripePaymentSheet = class {
392
724
  this.open = false;
393
725
  break;
394
726
  case 'confirm':
395
- this.confirm(effect.generation, effect.intentKind);
727
+ if (effect.intentKind === 'checkoutSession') {
728
+ this.confirmCheckoutSession(effect.generation);
729
+ }
730
+ else {
731
+ this.confirm(effect.generation, effect.intentKind);
732
+ }
396
733
  break;
397
734
  case 'showError':
398
735
  this.errorMessage = effect.message;
@@ -407,16 +744,20 @@ const StripePaymentSheet = class {
407
744
  break;
408
745
  }
409
746
  }
410
- async load(generation, clientSecret) {
747
+ async load(generation, clientSecret, intentKind) {
411
748
  var _a;
412
- this.warnUnsupportedOptions();
749
+ this.warnUnsupportedOptions(intentKind);
750
+ // A newer load started while this one was waiting: stop before touching the elements, so that only the latest load mounts and emits
751
+ const superseded = () => generation !== this.sheet.generation;
413
752
  try {
753
+ // Fails before loading Stripe.js when a `never` field has no default value, so that Stripe never rejects the confirmation
754
+ const collection = planBillingDetailsCollection(this.options, intentKind);
414
755
  await this.stripeService.initialize(this.publishableKey, {
415
756
  stripeAccount: this.stripeAccount,
416
757
  applicationName: this.applicationName,
417
758
  clientSecret,
418
759
  });
419
- if (generation !== this.sheet.generation) {
760
+ if (superseded()) {
420
761
  return;
421
762
  }
422
763
  if (this.stripeService.state.loadStripeStatus !== 'success') {
@@ -425,24 +766,110 @@ const StripePaymentSheet = class {
425
766
  const appearance = toAppearance((_a = this.options) === null || _a === void 0 ? void 0 : _a.style);
426
767
  if (appearance != null) {
427
768
  await this.stripeService.getElements().update({ appearance });
769
+ if (superseded()) {
770
+ return;
771
+ }
772
+ }
773
+ if (!(await this.mountExtraElements(collection, superseded))) {
774
+ return;
428
775
  }
429
776
  await this.paymentElementManager.initialize(this.el, toPaymentElementOptions(this.options));
430
777
  this.dispatch({ type: 'loadSucceeded', generation });
431
778
  }
432
779
  catch (e) {
780
+ if (superseded()) {
781
+ return;
782
+ }
433
783
  this.lastError = e;
434
784
  this.dispatch({ type: 'loadFailed', generation });
435
785
  }
436
786
  }
437
- async confirm(generation, intentKind) {
438
- var _a, _b, _c;
439
- try {
787
+ /**
788
+ * 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
789
+ * (the managers unmount their previous element themselves when initialized again).
790
+ */
791
+ async mountExtraElements(collection, superseded) {
792
+ this.collection = collection;
793
+ const { emailElement, shippingAddressElement, billingAddressElement } = collection;
794
+ const extraElements = [
795
+ {
796
+ manager: this.emailElementManager,
797
+ selector: '.stripe-payment-sheet-email',
798
+ mount: emailElement && (container => this.emailElementManager.initialize(container, emailElement)),
799
+ },
800
+ {
801
+ manager: this.shippingAddressElementManager,
802
+ selector: '.stripe-payment-sheet-shipping-address',
803
+ mount: shippingAddressElement && (container => this.shippingAddressElementManager.initialize(container, shippingAddressElement)),
804
+ },
805
+ {
806
+ manager: this.billingAddressElementManager,
807
+ selector: '.stripe-payment-sheet-billing-address',
808
+ mount: billingAddressElement && (container => this.billingAddressElementManager.initialize(container, billingAddressElement)),
809
+ },
810
+ ];
811
+ for (const { manager, selector, mount } of extraElements) {
812
+ if (mount == null) {
813
+ manager.unmount();
814
+ continue;
815
+ }
816
+ // The container is looked up with findElement, which waits for it in case the sheet has not rendered yet
817
+ const container = await findElement(this.el, selector);
818
+ if (superseded()) {
819
+ return false;
820
+ }
821
+ await mount(container);
822
+ if (superseded()) {
823
+ return false;
824
+ }
825
+ }
826
+ return true;
827
+ }
828
+ /**
829
+ * Billing details read from the extra elements and the `never` fields, as extra confirm params
830
+ */
831
+ async confirmParams() {
832
+ var _a;
833
+ const collection = this.collection;
834
+ if (collection == null) {
835
+ return undefined;
836
+ }
837
+ const billingAddress = collection.billingAddressElement != null ? await ((_a = this.billingAddressElementManager.getElement()) === null || _a === void 0 ? void 0 : _a.getValue()) : undefined;
838
+ const emailState = collection.emailElement != null ? this.emailElementManager.getState() : undefined;
839
+ const billingDetails = collectedBillingDetails(collection, { billingAddress, email: emailState === null || emailState === void 0 ? void 0 : emailState.email, emailComplete: emailState === null || emailState === void 0 ? void 0 : emailState.complete });
840
+ return billingDetails == null ? undefined : { payment_method_data: { billing_details: billingDetails } };
841
+ }
842
+ confirm(generation, intentKind) {
843
+ return this.runConfirm(generation, async () => {
844
+ var _a, _b;
845
+ const elements = this.stripeService.getElements();
846
+ // elements.submit() comes first, with nothing awaited before it, as in Stripe's submit handler examples:
847
+ // it validates the elements and collects what wallets (Apple Pay, Google Pay) need while the customer's click still counts,
848
+ // and other asynchronous work may follow once it has resolved
849
+ const { error: submitError } = await elements.submit();
850
+ if (submitError != null) {
851
+ throw submitError;
852
+ }
440
853
  const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
441
- this.lastResult = await confirmPaymentOrSetup(this.stripeService.getStripe(), this.stripeService.getElements(), intentKind, returnUrl);
854
+ const extraConfirmParams = await this.confirmParams();
855
+ return confirmPaymentOrSetup(this.stripeService.getStripe(), elements, intentKind, returnUrl, extraConfirmParams);
856
+ });
857
+ }
858
+ /**
859
+ * Run a confirmation and report its result to the state machine.
860
+ * `confirm` is called synchronously, so that its first step still runs inside the customer's submit event.
861
+ * Errors the customer can fix or retry keep the sheet open; others end it with `paymentSheetFailed`.
862
+ */
863
+ async runConfirm(generation, confirm) {
864
+ var _a;
865
+ try {
866
+ this.lastResult = await confirm();
442
867
  this.dispatch({ type: 'confirmSucceeded', generation });
443
868
  }
444
869
  catch (e) {
445
- const message = (_c = e.message) !== null && _c !== void 0 ? _c : String(e);
870
+ const rawMessage = (_a = e.message) !== null && _a !== void 0 ? _a : String(e);
871
+ // Stripe's messages are already localized; the sheet's own validation messages are i18n keys
872
+ const message = isSheetValidationError(e) ? i18n.t(rawMessage) : rawMessage;
446
873
  if (isRecoverableConfirmError(e)) {
447
874
  this.dispatch({ type: 'confirmDeclined', generation, message });
448
875
  return;
@@ -451,6 +878,48 @@ const StripePaymentSheet = class {
451
878
  this.dispatch({ type: 'confirmFailed', generation, message });
452
879
  }
453
880
  }
881
+ async loadCheckoutSession(generation, clientSecret) {
882
+ this.warnUnsupportedOptions('checkoutSession');
883
+ this.warnCheckoutIgnoredOptions();
884
+ // The extra billing elements belong to intent mode; remove those of an earlier intent load
885
+ this.collection = undefined;
886
+ this.unmountExtraElements();
887
+ try {
888
+ await this.stripeService.initializeWithCheckoutSession(this.publishableKey, clientSecret, {
889
+ stripeAccount: this.stripeAccount,
890
+ applicationName: this.applicationName,
891
+ elementsOptions: toCheckoutElementsOptions(this.options),
892
+ });
893
+ if (generation !== this.sheet.generation) {
894
+ return;
895
+ }
896
+ if (this.stripeService.state.loadStripeStatus !== 'success') {
897
+ throw new Error('Failed to load Stripe.js');
898
+ }
899
+ await this.paymentElementManager.initialize(this.el, toCheckoutPaymentElementOptions(this.options));
900
+ this.dispatch({ type: 'loadSucceeded', generation });
901
+ }
902
+ catch (e) {
903
+ // An error of a load that a newer load replaced is not reported
904
+ if (generation !== this.sheet.generation) {
905
+ return;
906
+ }
907
+ this.lastError = e;
908
+ this.dispatch({ type: 'loadFailed', generation });
909
+ }
910
+ }
911
+ confirmCheckoutSession(generation) {
912
+ var _a, _b;
913
+ const returnUrl = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.returnURL) !== null && _b !== void 0 ? _b : window.location.href;
914
+ return this.runConfirm(generation, async () => {
915
+ var _a, _b;
916
+ const checkout = this.stripeService.getCheckout();
917
+ if (checkout == null) {
918
+ throw new Error('Checkout Session is not initialized');
919
+ }
920
+ return confirmCheckoutSessionSheet(checkout, returnUrl, (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.defaultBillingDetails) === null || _b === void 0 ? void 0 : _b.email);
921
+ });
922
+ }
454
923
  emit(event) {
455
924
  switch (event) {
456
925
  case 'paymentSheetLoaded':
@@ -470,18 +939,27 @@ const StripePaymentSheet = class {
470
939
  break;
471
940
  }
472
941
  }
473
- warnUnsupportedOptions() {
474
- const keys = unsupportedOptionKeys(this.options);
942
+ warnUnsupportedOptions(intentKind) {
943
+ const keys = unsupportedOptionKeys(this.options, intentKind);
475
944
  if (this.warnedUnsupportedOptions || keys.length === 0) {
476
945
  return;
477
946
  }
478
947
  this.warnedUnsupportedOptions = true;
479
948
  console.warn(`<stripe-payment-sheet>: these options have no effect on the web yet: ${keys.join(', ')}`);
480
949
  }
950
+ warnCheckoutIgnoredOptions() {
951
+ const keys = checkoutIgnoredOptionKeys(this.options);
952
+ if (this.warnedCheckoutIgnoredOptions || keys.length === 0) {
953
+ return;
954
+ }
955
+ this.warnedCheckoutIgnoredOptions = true;
956
+ console.warn(`<stripe-payment-sheet>: these options have no effect with a Checkout Session: ${keys.join(', ')}`);
957
+ }
481
958
  render() {
959
+ var _a, _b, _c;
482
960
  const { phase } = this.sheet;
483
961
  const confirming = phase === 'confirming';
484
- return (h(Host, { key: 'ecb6de4b0674af9f5ecf86acce93e092c3bee881' }, h("stripe-modal", { key: '137473608d8cc3c0833c34529f1dafb9fc0cba34', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '0da153ef48ddc5464f050ea1921a69f975a7d8e1', class: "stripe-payment-sheet-wrap" }, h("form", { key: '6f6653aee9d0ad54c8bf935ace2f6d4fdc648e1f', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '85d3e28a20679051decdb02d590c2144e652f0bd', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: 'f6b8d90a3731732c0b36af0512a5ace87a12f98d', class: "payment-info visible" }, h("div", { key: '813a1ad3a0db2efa650aceff828412999f34ff2b', id: "payment-element" })), h("div", { key: '63bd6a8c20dd7b8b92aa2171553c13570ab17808', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: 'f70e9b353ae9eecd1300bbbd40ebb731ef44c344', class: "stripe-submit" }, h("button", { key: '6f32a7b94132091348680476b0e7292072800dbf', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
962
+ return (h(Host, { key: 'e6b2c3cb168039eb428eaaee1dce598f534c18e7' }, h("stripe-modal", { key: 'ef1515b07cca402c4db8818e2e94ca80e4d954c2', open: this.visible, showCloseButton: !confirming, onClose: this.handleModalClose }, h("div", { key: '9252fa1653b206d211756c94325c73a8ec482a37', class: "stripe-payment-sheet-wrap" }, h("form", { key: '904a54f2439e0356c2cbf9227326efe446aa08ce', id: "stripe-payment-sheet", onSubmit: this.handleSubmit }, h("div", { key: '103d81e3c56cfba1c421e1bf140a49e2b392c6b5', class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { key: 'cda58a48db7b04af1981407b7100def815404e35', class: "payment-info visible" }, h("div", { key: 'cbe248666aa4807c25d492df1ab1de017bc78e2c', class: "stripe-payment-sheet-email" }, ((_a = this.collection) === null || _a === void 0 ? void 0 : _a.emailElement) != null && h("div", { key: 'b0210c6cce85d1affaa83e3fa30785158c9bab98', id: "link-authentication-element" })), h("div", { key: '2420956298e5b36c63f3fbea6b4e32429b7ace27', class: "stripe-payment-sheet-shipping-address" }, ((_b = this.collection) === null || _b === void 0 ? void 0 : _b.shippingAddressElement) != null && h("div", { key: 'ae41335a42c59598e1addbfdea0a13342c026456', id: "address-element" })), h("div", { key: '3196844c9396c40548a3c632733565027df3cea7', class: "stripe-payment-sheet-billing-address" }, ((_c = this.collection) === null || _c === void 0 ? void 0 : _c.billingAddressElement) != null && h("div", { key: '269a99368975db70722fc181a1c099859f23d3d6', id: "address-element" })), h("div", { key: '2a63173a607501ff08ac072956cdbe462a4400c1', id: "payment-element" })), h("div", { key: '7a72a86097aca2af6491c56b52258286ef820283', class: "stripe-element-errors", role: "alert" }, this.errorMessage), h("div", { key: '10f05d5ecfa53cde350f00acffd86e232e370fe7', class: "stripe-submit" }, h("button", { key: 'a7ad3e538b94403bd8c71b31bd405c1b0c59543c', type: "submit", disabled: phase !== 'presented' }, confirming ? i18n.t('Loading') : i18n.t(this.buttonLabel))))))));
485
963
  }
486
964
  get el() { return getElement(this); }
487
965
  static get watchers() { return {
@@ -491,6 +969,9 @@ const StripePaymentSheet = class {
491
969
  "intentClientSecret": [{
492
970
  "handleSecretChange": 0
493
971
  }],
972
+ "checkoutSessionClientSecret": [{
973
+ "handleSecretChange": 0
974
+ }],
494
975
  "stripeAccount": [{
495
976
  "handleSecretChange": 0
496
977
  }],