stripe-pwa-elements 4.0.5 → 4.1.0

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 (55) hide show
  1. package/dist/cjs/{factory-xOoxnMhx.js → factory-yd5HDEZn.js} +1 -0
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/stripe-address-element.cjs.entry.js +1 -1
  4. package/dist/cjs/stripe-card-element.cjs.entry.js +1 -1
  5. package/dist/cjs/stripe-currency-selector.cjs.entry.js +1 -1
  6. package/dist/cjs/stripe-elements.cjs.js +1 -1
  7. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +1 -1
  8. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +1 -1
  9. package/dist/cjs/stripe-payment-element.cjs.entry.js +18 -7
  10. package/dist/cjs/stripe-payment-element.helpers-D1JnhTa-.js +182 -0
  11. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +72 -57
  12. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +9 -32
  13. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +87 -5
  14. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +60 -48
  15. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +5 -2
  16. package/dist/collection/services/stripe-service.js +1 -0
  17. package/dist/collection/utils/checkout-confirm.js +84 -0
  18. package/dist/components/factory.js +1 -1
  19. package/dist/components/stripe-payment-element.helpers.js +1 -1
  20. package/dist/components/stripe-payment-element.js +1 -1
  21. package/dist/components/stripe-payment-sheet.js +1 -1
  22. package/dist/esm/{factory-CsurRVcp.js → factory-B_WxdnxM.js} +1 -0
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/stripe-address-element.entry.js +1 -1
  25. package/dist/esm/stripe-card-element.entry.js +1 -1
  26. package/dist/esm/stripe-currency-selector.entry.js +1 -1
  27. package/dist/esm/stripe-elements.js +1 -1
  28. package/dist/esm/stripe-express-checkout-element.entry.js +1 -1
  29. package/dist/esm/stripe-link-authentication-element.entry.js +1 -1
  30. package/dist/esm/stripe-payment-element.entry.js +18 -7
  31. package/dist/esm/stripe-payment-element.helpers-PuWxhMNR.js +176 -0
  32. package/dist/esm/stripe-payment-sheet.entry.js +72 -57
  33. package/dist/stripe-elements/{p-949a8bba.entry.js → p-2e2bf0fe.entry.js} +1 -1
  34. package/dist/stripe-elements/{p-b0f9ebba.entry.js → p-32a2d5a4.entry.js} +1 -1
  35. package/dist/stripe-elements/{p-edbbe060.entry.js → p-84d45b48.entry.js} +1 -1
  36. package/dist/stripe-elements/{p-a2d11152.entry.js → p-a266da6f.entry.js} +1 -1
  37. package/dist/stripe-elements/p-c4a0e310.entry.js +1 -0
  38. package/dist/stripe-elements/{p-50e495e3.entry.js → p-e660d76a.entry.js} +1 -1
  39. package/dist/stripe-elements/p-eeebfbbf.entry.js +1 -0
  40. package/dist/stripe-elements/p-n0XJSLU3.js +1 -0
  41. package/dist/stripe-elements/p-wrjrFokg.js +1 -0
  42. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  43. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +33 -0
  44. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +8 -2
  45. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +19 -11
  46. package/dist/types/components.d.ts +34 -2
  47. package/dist/types/services/interfaces.d.ts +3 -1
  48. package/dist/types/utils/checkout-confirm.d.ts +35 -0
  49. package/package.json +1 -1
  50. package/dist/cjs/stripe-payment-element.helpers-lafmSRmb.js +0 -121
  51. package/dist/esm/stripe-payment-element.helpers-CklK5RlF.js +0 -116
  52. package/dist/stripe-elements/p-855d1aee.entry.js +0 -1
  53. package/dist/stripe-elements/p-B2G-wquO.js +0 -1
  54. package/dist/stripe-elements/p-BoZLkOAy.js +0 -1
  55. package/dist/stripe-elements/p-a45268d4.entry.js +0 -1
@@ -415,6 +415,7 @@ class StripeServiceClass {
415
415
  const checkout = stripe.initCheckoutElementsSdk({
416
416
  clientSecret: checkoutSessionClientSecret,
417
417
  elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
418
+ defaultValues: options === null || options === void 0 ? void 0 : options.defaultValues,
418
419
  });
419
420
  this.store.state.checkout = checkout;
420
421
  this.store.state.elements = undefined;
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
8
  await appGlobals.globalScripts();
9
- return index.bootstrapLazy([["stripe-card-element-modal.cjs",[[0,"stripe-card-element-modal",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"intentType":[1,"intent-type"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"showCloseButton":[4,"show-close-button"],"zip":[4],"open":[4],"getStripeCardElementElement":[64],"present":[64],"updateProgress":[64],"destroy":[64],"setPaymentRequestButton":[64]}]]],["stripe-payment-sheet.cjs",[[0,"stripe-payment-sheet",{"publishableKey":[1,"publishable-key"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"stripeAccount":[1,"stripe-account"],"open":[1540],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"applicationName":[1,"application-name"],"options":[16],"sheet":[32],"visible":[32],"errorMessage":[32],"collection":[32],"present":[64]},null,{"publishableKey":[{"handleSecretChange":0}],"intentClientSecret":[{"handleSecretChange":0}],"checkoutSessionClientSecret":[{"handleSecretChange":0}],"stripeAccount":[{"handleSecretChange":0}],"open":[{"handleOpenChange":0}]}]]],["stripe-address-element.cjs",[[0,"stripe-address-element",{"mode":[1],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"defaultCountry":[1,"default-country"],"allowedCountries":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getValue":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-currency-selector.cjs",[[0,"stripe-currency-selector",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"handleCurrencyChange":[1040],"stripeDidLoaded":[1040],"initStripe":[64],"setErrorMessage":[64],"getSelectedCurrency":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-express-checkout-element.cjs",[[0,"stripe-express-checkout-element",{"intentType":[1,"intent-type"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"amount":[2],"currency":[1],"buttonHeight":[1,"button-height"],"shouldUseDefaultConfirmAction":[4,"should-use-default-confirm-action"],"stripeDidLoaded":[1040],"progress":[32],"updateProgress":[64],"setErrorMessage":[64],"initStripe":[64],"updateElementOptions":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-link-authentication-element.cjs",[[0,"stripe-link-authentication-element",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"defaultEmail":[1,"default-email"],"handleChange":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getEmail":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-payment-element.cjs",[[0,"stripe-payment-element",{"intentType":[1,"intent-type"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"initStripeWithCheckoutSession":[64],"updateProgress":[64],"setErrorMessage":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}],"checkoutSessionClientSecret":[{"updateCheckoutSessionClientSecret":0}]}]]],["stripe-payment-request-button.cjs",[[260,"stripe-payment-request-button",{"paymentMethodEventHandler":[16],"shippingOptionEventHandler":[16],"shippingAddressEventHandler":[16],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"stripeDidLoaded":[1040],"loadStripeStatus":[32],"stripe":[32],"paymentRequestOption":[32],"isAvailable":[64],"setPaymentMethodEventHandler":[64],"setPaymentRequestShippingOptionEventHandler":[64],"setPaymentRequestShippingAddressEventHandler":[64],"setPaymentRequestOption":[64],"initStripe":[64]}]]],["stripe-card-element.cjs",[[0,"stripe-card-element",{"intentType":[1,"intent-type"],"zip":[4],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"showPaymentRequestButton":[4,"show-payment-request-button"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"zipCode":[32],"paymentRequestOption":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"setPaymentRequestOption":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}]}]]],["ion-icon_2.cjs",[[257,"stripe-modal",{"showCloseButton":[4,"show-close-button"],"open":[1028],"renderedOpen":[32],"toggleModal":[64],"openModal":[64],"closeModal":[64]},null,{"open":[{"onOpenChange":0}]}],[1,"ion-icon",{"mode":[1025],"color":[1],"ios":[1],"md":[1],"flipRtl":[4,"flip-rtl"],"name":[513],"src":[1],"icon":[8],"size":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":[{"loadIcon":0}],"src":[{"loadIcon":0}],"icon":[{"loadIcon":0}],"ios":[{"loadIcon":0}],"md":[{"loadIcon":0}]}]]]], options);
9
+ return index.bootstrapLazy([["stripe-card-element-modal.cjs",[[0,"stripe-card-element-modal",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"intentType":[1,"intent-type"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"showCloseButton":[4,"show-close-button"],"zip":[4],"open":[4],"getStripeCardElementElement":[64],"present":[64],"updateProgress":[64],"destroy":[64],"setPaymentRequestButton":[64]}]]],["stripe-payment-sheet.cjs",[[0,"stripe-payment-sheet",{"publishableKey":[1,"publishable-key"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"stripeAccount":[1,"stripe-account"],"open":[1540],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"applicationName":[1,"application-name"],"options":[16],"sheet":[32],"visible":[32],"errorMessage":[32],"collection":[32],"present":[64]},null,{"publishableKey":[{"handleSecretChange":0}],"intentClientSecret":[{"handleSecretChange":0}],"checkoutSessionClientSecret":[{"handleSecretChange":0}],"stripeAccount":[{"handleSecretChange":0}],"open":[{"handleOpenChange":0}]}]]],["stripe-address-element.cjs",[[0,"stripe-address-element",{"mode":[1],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"defaultCountry":[1,"default-country"],"allowedCountries":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getValue":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-currency-selector.cjs",[[0,"stripe-currency-selector",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"handleCurrencyChange":[1040],"stripeDidLoaded":[1040],"initStripe":[64],"setErrorMessage":[64],"getSelectedCurrency":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-express-checkout-element.cjs",[[0,"stripe-express-checkout-element",{"intentType":[1,"intent-type"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"amount":[2],"currency":[1],"buttonHeight":[1,"button-height"],"shouldUseDefaultConfirmAction":[4,"should-use-default-confirm-action"],"stripeDidLoaded":[1040],"progress":[32],"updateProgress":[64],"setErrorMessage":[64],"initStripe":[64],"updateElementOptions":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-link-authentication-element.cjs",[[0,"stripe-link-authentication-element",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"defaultEmail":[1,"default-email"],"handleChange":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getEmail":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-payment-element.cjs",[[0,"stripe-payment-element",{"intentType":[1,"intent-type"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"checkoutSessionReturnUrl":[1,"checkout-session-return-url"],"checkoutSessionEmail":[1,"checkout-session-email"],"checkoutSessionDefaultValues":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"initStripeWithCheckoutSession":[64],"updateProgress":[64],"setErrorMessage":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}],"checkoutSessionClientSecret":[{"updateCheckoutSessionClientSecret":0}]}]]],["stripe-payment-request-button.cjs",[[260,"stripe-payment-request-button",{"paymentMethodEventHandler":[16],"shippingOptionEventHandler":[16],"shippingAddressEventHandler":[16],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"stripeDidLoaded":[1040],"loadStripeStatus":[32],"stripe":[32],"paymentRequestOption":[32],"isAvailable":[64],"setPaymentMethodEventHandler":[64],"setPaymentRequestShippingOptionEventHandler":[64],"setPaymentRequestShippingAddressEventHandler":[64],"setPaymentRequestOption":[64],"initStripe":[64]}]]],["stripe-card-element.cjs",[[0,"stripe-card-element",{"intentType":[1,"intent-type"],"zip":[4],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"showPaymentRequestButton":[4,"show-payment-request-button"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"zipCode":[32],"paymentRequestOption":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"setPaymentRequestOption":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}]}]]],["ion-icon_2.cjs",[[257,"stripe-modal",{"showCloseButton":[4,"show-close-button"],"open":[1028],"renderedOpen":[32],"toggleModal":[64],"openModal":[64],"closeModal":[64]},null,{"open":[{"onOpenChange":0}]}],[1,"ion-icon",{"mode":[1025],"color":[1],"ios":[1],"md":[1],"flipRtl":[4,"flip-rtl"],"name":[513],"src":[1],"icon":[8],"size":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":[{"loadIcon":0}],"src":[{"loadIcon":0}],"icon":[{"loadIcon":0}],"ios":[{"loadIcon":0}],"md":[{"loadIcon":0}]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
6
  require('./index-CYbA1N_k.js');
7
7
 
8
8
  const stripeAddressElementCss = () => `: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-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 #address-element{margin-top: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 .stripe-section-title{font-size:14px;font-weight:bold;color:var(--color-label);margin-bottom:8px}.stripe-payment-sheet-wrap .payment-info.address{margin-bottom:16px}.stripe-payment-sheet-wrap .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}.stripe-payment-sheet-wrap .submit-button-wrapper{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)}`;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
6
  var error = require('./error-FFC4kSs5.js');
7
7
  require('./index-CYbA1N_k.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
6
  require('./index-CYbA1N_k.js');
7
7
 
8
8
  const stripeCurrencySelectorCss = () => `: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}:host{box-sizing:border-box}:host *: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}:host button{cursor:pointer}:host{display:block;width:100%}.stripe-currency-selector-wrap{width:100%;padding:0;margin:0}.stripe-currency-selector-wrap #currency-selector{width:100%;min-height:40px}.stripe-currency-selector-wrap #currency-selector-errors{margin-top:8px}`;
@@ -46,7 +46,7 @@ var patchCloneNodeFix = (HTMLElementPrototype) => {
46
46
 
47
47
  patchBrowser().then(async (options) => {
48
48
  await appGlobals.globalScripts();
49
- return index.bootstrapLazy([["stripe-card-element-modal.cjs",[[0,"stripe-card-element-modal",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"intentType":[1,"intent-type"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"showCloseButton":[4,"show-close-button"],"zip":[4],"open":[4],"getStripeCardElementElement":[64],"present":[64],"updateProgress":[64],"destroy":[64],"setPaymentRequestButton":[64]}]]],["stripe-payment-sheet.cjs",[[0,"stripe-payment-sheet",{"publishableKey":[1,"publishable-key"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"stripeAccount":[1,"stripe-account"],"open":[1540],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"applicationName":[1,"application-name"],"options":[16],"sheet":[32],"visible":[32],"errorMessage":[32],"collection":[32],"present":[64]},null,{"publishableKey":[{"handleSecretChange":0}],"intentClientSecret":[{"handleSecretChange":0}],"checkoutSessionClientSecret":[{"handleSecretChange":0}],"stripeAccount":[{"handleSecretChange":0}],"open":[{"handleOpenChange":0}]}]]],["stripe-address-element.cjs",[[0,"stripe-address-element",{"mode":[1],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"defaultCountry":[1,"default-country"],"allowedCountries":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getValue":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-currency-selector.cjs",[[0,"stripe-currency-selector",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"handleCurrencyChange":[1040],"stripeDidLoaded":[1040],"initStripe":[64],"setErrorMessage":[64],"getSelectedCurrency":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-express-checkout-element.cjs",[[0,"stripe-express-checkout-element",{"intentType":[1,"intent-type"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"amount":[2],"currency":[1],"buttonHeight":[1,"button-height"],"shouldUseDefaultConfirmAction":[4,"should-use-default-confirm-action"],"stripeDidLoaded":[1040],"progress":[32],"updateProgress":[64],"setErrorMessage":[64],"initStripe":[64],"updateElementOptions":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-link-authentication-element.cjs",[[0,"stripe-link-authentication-element",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"defaultEmail":[1,"default-email"],"handleChange":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getEmail":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-payment-element.cjs",[[0,"stripe-payment-element",{"intentType":[1,"intent-type"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"initStripeWithCheckoutSession":[64],"updateProgress":[64],"setErrorMessage":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}],"checkoutSessionClientSecret":[{"updateCheckoutSessionClientSecret":0}]}]]],["stripe-payment-request-button.cjs",[[260,"stripe-payment-request-button",{"paymentMethodEventHandler":[16],"shippingOptionEventHandler":[16],"shippingAddressEventHandler":[16],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"stripeDidLoaded":[1040],"loadStripeStatus":[32],"stripe":[32],"paymentRequestOption":[32],"isAvailable":[64],"setPaymentMethodEventHandler":[64],"setPaymentRequestShippingOptionEventHandler":[64],"setPaymentRequestShippingAddressEventHandler":[64],"setPaymentRequestOption":[64],"initStripe":[64]}]]],["stripe-card-element.cjs",[[0,"stripe-card-element",{"intentType":[1,"intent-type"],"zip":[4],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"showPaymentRequestButton":[4,"show-payment-request-button"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"zipCode":[32],"paymentRequestOption":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"setPaymentRequestOption":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}]}]]],["ion-icon_2.cjs",[[257,"stripe-modal",{"showCloseButton":[4,"show-close-button"],"open":[1028],"renderedOpen":[32],"toggleModal":[64],"openModal":[64],"closeModal":[64]},null,{"open":[{"onOpenChange":0}]}],[1,"ion-icon",{"mode":[1025],"color":[1],"ios":[1],"md":[1],"flipRtl":[4,"flip-rtl"],"name":[513],"src":[1],"icon":[8],"size":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":[{"loadIcon":0}],"src":[{"loadIcon":0}],"icon":[{"loadIcon":0}],"ios":[{"loadIcon":0}],"md":[{"loadIcon":0}]}]]]], options);
49
+ return index.bootstrapLazy([["stripe-card-element-modal.cjs",[[0,"stripe-card-element-modal",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"intentType":[1,"intent-type"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"showCloseButton":[4,"show-close-button"],"zip":[4],"open":[4],"getStripeCardElementElement":[64],"present":[64],"updateProgress":[64],"destroy":[64],"setPaymentRequestButton":[64]}]]],["stripe-payment-sheet.cjs",[[0,"stripe-payment-sheet",{"publishableKey":[1,"publishable-key"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"stripeAccount":[1,"stripe-account"],"open":[1540],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"applicationName":[1,"application-name"],"options":[16],"sheet":[32],"visible":[32],"errorMessage":[32],"collection":[32],"present":[64]},null,{"publishableKey":[{"handleSecretChange":0}],"intentClientSecret":[{"handleSecretChange":0}],"checkoutSessionClientSecret":[{"handleSecretChange":0}],"stripeAccount":[{"handleSecretChange":0}],"open":[{"handleOpenChange":0}]}]]],["stripe-address-element.cjs",[[0,"stripe-address-element",{"mode":[1],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"defaultCountry":[1,"default-country"],"allowedCountries":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getValue":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-currency-selector.cjs",[[0,"stripe-currency-selector",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"handleCurrencyChange":[1040],"stripeDidLoaded":[1040],"initStripe":[64],"setErrorMessage":[64],"getSelectedCurrency":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-express-checkout-element.cjs",[[0,"stripe-express-checkout-element",{"intentType":[1,"intent-type"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"clientSecret":[1,"client-secret"],"amount":[2],"currency":[1],"buttonHeight":[1,"button-height"],"shouldUseDefaultConfirmAction":[4,"should-use-default-confirm-action"],"stripeDidLoaded":[1040],"progress":[32],"updateProgress":[64],"setErrorMessage":[64],"initStripe":[64],"updateElementOptions":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-link-authentication-element.cjs",[[0,"stripe-link-authentication-element",{"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"defaultEmail":[1,"default-email"],"handleChange":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"getEmail":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}]}]]],["stripe-payment-element.cjs",[[0,"stripe-payment-element",{"intentType":[1,"intent-type"],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"intentClientSecret":[1,"intent-client-secret"],"checkoutSessionClientSecret":[1,"checkout-session-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"checkoutSessionReturnUrl":[1,"checkout-session-return-url"],"checkoutSessionEmail":[1,"checkout-session-email"],"checkoutSessionDefaultValues":[16],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"initStripe":[64],"initStripeWithCheckoutSession":[64],"updateProgress":[64],"setErrorMessage":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}],"checkoutSessionClientSecret":[{"updateCheckoutSessionClientSecret":0}]}]]],["stripe-payment-request-button.cjs",[[260,"stripe-payment-request-button",{"paymentMethodEventHandler":[16],"shippingOptionEventHandler":[16],"shippingAddressEventHandler":[16],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"stripeDidLoaded":[1040],"loadStripeStatus":[32],"stripe":[32],"paymentRequestOption":[32],"isAvailable":[64],"setPaymentMethodEventHandler":[64],"setPaymentRequestShippingOptionEventHandler":[64],"setPaymentRequestShippingAddressEventHandler":[64],"setPaymentRequestOption":[64],"initStripe":[64]}]]],["stripe-card-element.cjs",[[0,"stripe-card-element",{"intentType":[1,"intent-type"],"zip":[4],"sheetTitle":[1,"sheet-title"],"buttonLabel":[1,"button-label"],"publishableKey":[1,"publishable-key"],"stripeAccount":[1,"stripe-account"],"applicationName":[1,"application-name"],"showLabel":[4,"show-label"],"intentClientSecret":[1,"intent-client-secret"],"shouldUseDefaultFormSubmitAction":[4,"should-use-default-form-submit-action"],"showPaymentRequestButton":[4,"show-payment-request-button"],"handleSubmit":[1040],"stripeDidLoaded":[1040],"progress":[32],"zipCode":[32],"paymentRequestOption":[32],"initStripe":[64],"updateProgress":[64],"setErrorMessage":[64],"setPaymentRequestOption":[64]},null,{"publishableKey":[{"updatePublishableKey":0}],"stripeAccount":[{"updateStripeAccountId":0}],"intentClientSecret":[{"updateIntentClientSecret":0}]}]]],["ion-icon_2.cjs",[[257,"stripe-modal",{"showCloseButton":[4,"show-close-button"],"open":[1028],"renderedOpen":[32],"toggleModal":[64],"openModal":[64],"closeModal":[64]},null,{"open":[{"onOpenChange":0}]}],[1,"ion-icon",{"mode":[1025],"color":[1],"ios":[1],"md":[1],"flipRtl":[4,"flip-rtl"],"name":[513],"src":[1],"icon":[8],"size":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":[{"loadIcon":0}],"src":[{"loadIcon":0}],"icon":[{"loadIcon":0}],"ios":[{"loadIcon":0}],"md":[{"loadIcon":0}]}]]]], options);
50
50
  });
51
51
 
52
52
  exports.setNonce = index.setNonce;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
6
  var error = require('./error-FFC4kSs5.js');
7
7
  require('./index-CYbA1N_k.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
6
  require('./index-CYbA1N_k.js');
7
7
 
8
8
  const stripeLinkAuthenticationElementCss = () => `: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-link-authentication-wrap{box-sizing:border-box}.stripe-link-authentication-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-link-authentication-wrap button{cursor:pointer}.stripe-link-authentication-wrap{display:block;width:100%;background:#fff;padding:16px}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-link-authentication-wrap .stripe-link-authentication-container #link-authentication-element .StripeElement>.__PrivateStripeElement{width:100%}.stripe-link-authentication-wrap .stripe-link-authentication-container .stripe-element-errors{margin-top:8px;font-size:14px;color:var(--color-text-error)}`;
@@ -2,8 +2,8 @@
2
2
 
3
3
  var index = require('./index-Dkb0SxZc.js');
4
4
  var i18n = require('./i18n-CWEsGqxV.js');
5
- var factory = require('./factory-xOoxnMhx.js');
6
- var stripePaymentElement_helpers = require('./stripe-payment-element.helpers-lafmSRmb.js');
5
+ var factory = require('./factory-yd5HDEZn.js');
6
+ var stripePaymentElement_helpers = require('./stripe-payment-element.helpers-D1JnhTa-.js');
7
7
  require('./index-CYbA1N_k.js');
8
8
  require('./error-FFC4kSs5.js');
9
9
 
@@ -59,6 +59,7 @@ const StripePaymentElement = class {
59
59
  stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
60
60
  applicationName: this.applicationName,
61
61
  elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
62
+ defaultValues: options === null || options === void 0 ? void 0 : options.defaultValues,
62
63
  });
63
64
  await this.mountWhenLoaded(generation);
64
65
  }
@@ -103,14 +104,20 @@ const StripePaymentElement = class {
103
104
  options.stripeAccount = this.stripeService.state.stripeAccount;
104
105
  const hasOptionValue = Object.values(options).filter(value => value != null && value !== '').length > 0;
105
106
  if (this.hasCheckoutSessionClientSecret()) {
106
- this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, { stripeAccount: options.stripeAccount });
107
+ this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, {
108
+ stripeAccount: options.stripeAccount,
109
+ defaultValues: this.checkoutSessionDefaultValues,
110
+ });
107
111
  return;
108
112
  }
109
113
  this.initStripe(publishableKey, hasOptionValue ? options : undefined);
110
114
  }
111
115
  updateStripeAccountId(stripeAccount) {
112
116
  if (this.hasCheckoutSessionClientSecret()) {
113
- this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, { stripeAccount });
117
+ this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
118
+ stripeAccount: stripeAccount,
119
+ defaultValues: this.checkoutSessionDefaultValues,
120
+ });
114
121
  return;
115
122
  }
116
123
  this.initStripe(this.stripeService.state.publishableKey, {
@@ -138,6 +145,7 @@ const StripePaymentElement = class {
138
145
  if (this.publishableKey != null && this.publishableKey !== '' && newValue != null && newValue !== '') {
139
146
  await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
140
147
  stripeAccount: this.stripeAccount,
148
+ defaultValues: this.checkoutSessionDefaultValues,
141
149
  });
142
150
  // A new secret starts a fresh payment, so re-enable the submit button after a previous success
143
151
  if (this.progress === 'success') {
@@ -193,6 +201,7 @@ const StripePaymentElement = class {
193
201
  if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
194
202
  this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
195
203
  stripeAccount: this.stripeService.state.stripeAccount,
204
+ defaultValues: this.checkoutSessionDefaultValues,
196
205
  });
197
206
  return;
198
207
  }
@@ -228,11 +237,12 @@ const StripePaymentElement = class {
228
237
  * @param checkout - The Stripe Checkout instance
229
238
  */
230
239
  async checkoutSessionFormSubmitAction(event, checkout) {
240
+ var _a;
231
241
  event.preventDefault();
232
242
  try {
233
- // Get current page URL for return_url
234
- const returnUrl = window.location.href;
235
- const result = await stripePaymentElement_helpers.confirmCheckoutSession(checkout, returnUrl);
243
+ // returnUrl defaults to the current page; confirmCheckoutSession retries without it when the
244
+ // session was created with `return_url` (which rejects the argument before processing)
245
+ const result = await stripePaymentElement_helpers.confirmCheckoutSession(checkout, (_a = this.checkoutSessionReturnUrl) !== null && _a !== void 0 ? _a : window.location.href, this.checkoutSessionEmail);
236
246
  this.checkoutSessionConfirmResultHandler(result);
237
247
  }
238
248
  catch (e) {
@@ -349,6 +359,7 @@ const StripePaymentElement = class {
349
359
  if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
350
360
  this.initStripeWithCheckoutSession(this.publishableKey, this.checkoutSessionClientSecret, {
351
361
  stripeAccount: this.stripeAccount,
362
+ defaultValues: this.checkoutSessionDefaultValues,
352
363
  });
353
364
  return;
354
365
  }
@@ -0,0 +1,182 @@
1
+ 'use strict';
2
+
3
+ var error = require('./error-FFC4kSs5.js');
4
+
5
+ /**
6
+ * Whether a confirm failure means the session was created with `return_url`, which rejects `returnUrl`.
7
+ * Stripe raises this before any payment processing, so retrying without `returnUrl` is safe.
8
+ * `actions.confirm()` reports it both as a thrown `IntegrationError` and as an error result depending on the SDK version.
9
+ * @param error - Error thrown by `actions.confirm()` or the error of its result
10
+ */
11
+ const isCheckoutReturnUrlConflict = (error) => {
12
+ const message = error instanceof Error ? error.message : error === null || error === void 0 ? void 0 : error.message;
13
+ return typeof message === 'string' && message.includes('cannot provide `returnUrl`');
14
+ };
15
+ /**
16
+ * Throw when the session can no longer be paid. Stripe documents an `expired` session as "No further processing will occur",
17
+ * and a `complete` one is already paid or being paid, so confirming again cannot succeed.
18
+ * @param status - `session.status` from `getSession()`; undefined when it cannot be read
19
+ * @param message - Message of the confirm error, if any
20
+ * @throws StripeAPIError of type `invalid_request_error` (unrecoverable), with the code `checkout_session_expired` or `checkout_session_complete`
21
+ */
22
+ const assertCheckoutSessionOpen = (status, message) => {
23
+ if (status == null || status.type === 'open') {
24
+ return;
25
+ }
26
+ throw new error.StripeAPIError({
27
+ type: 'invalid_request_error',
28
+ code: `checkout_session_${status.type}`,
29
+ message: message !== null && message !== void 0 ? message : `The Checkout Session is ${status.type} and can no longer be paid.`,
30
+ });
31
+ };
32
+ /**
33
+ * Confirm a Checkout Session through the checkout actions.
34
+ *
35
+ * Stripe requires exactly one of `returnUrl` (confirm argument) or the session's `return_url`, and the client
36
+ * cannot tell which one a session has (`getSession()` does not expose it). So the first attempt passes
37
+ * `returnUrl`, and when Stripe rejects it because the session already has `return_url`, the confirmation is
38
+ * retried without `returnUrl` (Stripe then redirects to the session's `return_url` automatically).
39
+ *
40
+ * Errors are thrown as `StripeAPIError`:
41
+ * - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`
42
+ * - `paymentFailed` on an open session (a decline): `card_error`
43
+ * - any other confirm error on an open session, or a failure to load the actions: `api_error`
44
+ * @param checkout - The Checkout instance from `initCheckoutElementsSdk`
45
+ * @param returnUrl - Where Stripe redirects after a redirect-based payment method, when the session has no `return_url`
46
+ * @param email - Customer email; needed when the session was created without `customer_email` or `customer`
47
+ * @returns The confirmation result
48
+ * @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
49
+ */
50
+ const confirmCheckoutActions = async (checkout, returnUrl, email) => {
51
+ const loadActionsResult = await checkout.loadActions();
52
+ if (loadActionsResult.type === 'error') {
53
+ throw new error.StripeAPIError({
54
+ type: 'api_error',
55
+ code: 'checkout_session_error',
56
+ message: loadActionsResult.error.message,
57
+ });
58
+ }
59
+ const { actions } = loadActionsResult;
60
+ 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; };
61
+ assertCheckoutSessionOpen(sessionStatus());
62
+ const confirmWith = (withReturnUrl) => actions.confirm(Object.assign(Object.assign({ redirect: 'if_required' }, (withReturnUrl && returnUrl !== '' ? { returnUrl } : {})), (email != null && email !== '' ? { email } : {})));
63
+ // First attempt with returnUrl; a session created with `return_url` rejects it before processing.
64
+ // The rejection can arrive either as a thrown error or as an error result, so both are retried without it.
65
+ let result;
66
+ try {
67
+ result = await confirmWith(true);
68
+ if (result.type === 'error' && isCheckoutReturnUrlConflict(result.error)) {
69
+ result = await confirmWith(false);
70
+ }
71
+ }
72
+ catch (e) {
73
+ if (!isCheckoutReturnUrlConflict(e)) {
74
+ throw e;
75
+ }
76
+ result = await confirmWith(false);
77
+ }
78
+ if (result.type === 'error') {
79
+ const { code, message } = result.error;
80
+ assertCheckoutSessionOpen(sessionStatus(), message);
81
+ if (code === 'paymentFailed') {
82
+ throw new error.StripeAPIError({ type: 'card_error', code, message });
83
+ }
84
+ throw new error.StripeAPIError({ type: 'api_error', code: 'checkout_session_error', message });
85
+ }
86
+ return result;
87
+ };
88
+
89
+ /**
90
+ * Determine whether the submit button should be disabled.
91
+ * For Checkout Session mode: the checkout is ready once Stripe finished loading.
92
+ * For Payment Intent / Setup Intent mode: an intent client secret must be present.
93
+ * The button stays disabled after a successful payment as well: the intent or
94
+ * checkout is already confirmed and cannot be submitted again.
95
+ * @param params progress / loading state and the current mode information
96
+ * @returns true when the submit button should be disabled
97
+ */
98
+ const isSubmitButtonDisabled = (params) => {
99
+ const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
100
+ const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
101
+ return progress === 'loading' || progress === 'success' || !hasValidSecret;
102
+ };
103
+ /**
104
+ * Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
105
+ * Calls `confirmPayment` or `confirmSetup` depending on the intent type.
106
+ * @param stripe the loaded Stripe.js instance
107
+ * @param elements the Stripe Elements instance bound to the payment element
108
+ * @param intentType the configured intent type
109
+ * @param returnUrl the URL Stripe should redirect back to when required
110
+ * @param extraConfirmParams optional params merged into `confirmParams` (for example `payment_method_data.billing_details`)
111
+ * @returns the confirmation result
112
+ * @throws StripeAPIError when Stripe returns an error
113
+ */
114
+ const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl, extraConfirmParams) => {
115
+ const result = await (() => {
116
+ if (intentType === 'payment') {
117
+ return stripe.confirmPayment({
118
+ elements,
119
+ confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
120
+ redirect: 'if_required',
121
+ });
122
+ }
123
+ return stripe.confirmSetup({
124
+ elements,
125
+ confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
126
+ redirect: 'if_required',
127
+ });
128
+ })();
129
+ if (result.error) {
130
+ throw new error.StripeAPIError(result.error);
131
+ }
132
+ return result;
133
+ };
134
+ /**
135
+ * Confirm a Checkout Session payment using the checkout actions.
136
+ *
137
+ * Stripe requires exactly one of `returnUrl` (confirm argument) or the session's `return_url`, and the client
138
+ * cannot tell which one a session has (`getSession()` does not expose it). The shared implementation passes
139
+ * `returnUrl` first and retries without it when Stripe rejects it because the session already has
140
+ * `return_url`. See `confirmCheckoutActions` for the full behavior and error classification.
141
+ * @param checkout the Stripe Checkout instance
142
+ * @param returnUrl URL Stripe should redirect back to when the session has no `return_url`
143
+ * @param email customer email, required when the session was created without `customer_email` or `customer`
144
+ * @returns the confirmation result
145
+ * @throws StripeAPIError when loading actions or confirming fails
146
+ */
147
+ const confirmCheckoutSession = async (checkout, returnUrl, email) => confirmCheckoutActions(checkout, returnUrl, email);
148
+ /**
149
+ * Resolve the mode-specific properties for a submit event.
150
+ * Picks the Checkout or Elements payload depending on the active mode and
151
+ * reports a descriptive error string when the required instance is missing.
152
+ * @param params the resolved Stripe instances and client secrets for the current mode
153
+ * @returns the submit event props, or an error message when an instance is missing
154
+ */
155
+ const buildSubmitEventProps = (params) => {
156
+ const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
157
+ const props = {
158
+ stripe,
159
+ };
160
+ if (isCheckoutSession) {
161
+ // Checkout Session mode
162
+ if (checkout == null) {
163
+ return { error: 'Checkout not properly initialized' };
164
+ }
165
+ props.checkout = checkout;
166
+ props.checkoutSessionClientSecret = checkoutSessionClientSecret;
167
+ return { props };
168
+ }
169
+ // Payment Intent / Setup Intent mode
170
+ if (elements == null) {
171
+ return { error: 'Elements not properly initialized' };
172
+ }
173
+ props.elements = elements;
174
+ props.intentClientSecret = intentClientSecret;
175
+ return { props };
176
+ };
177
+
178
+ exports.buildSubmitEventProps = buildSubmitEventProps;
179
+ exports.confirmCheckoutActions = confirmCheckoutActions;
180
+ exports.confirmCheckoutSession = confirmCheckoutSession;
181
+ exports.confirmPaymentOrSetup = confirmPaymentOrSetup;
182
+ exports.isSubmitButtonDisabled = isSubmitButtonDisabled;