stripe-pwa-elements 4.0.4 → 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 (66) hide show
  1. package/dist/cjs/{factory-Cm6zUD7R.js → factory-yd5HDEZn.js} +2 -1
  2. package/dist/cjs/{i18n-lBbOeQt4.js → i18n-CWEsGqxV.js} +2 -2
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +1 -1
  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 +3 -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 +19 -8
  12. package/dist/cjs/stripe-payment-element.helpers-D1JnhTa-.js +182 -0
  13. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +73 -58
  14. package/dist/collection/components/stripe-card-element/stripe-card-element.js +2 -2
  15. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +9 -32
  16. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +88 -6
  17. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +60 -48
  18. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +5 -2
  19. package/dist/collection/services/stripe-service.js +1 -0
  20. package/dist/collection/utils/checkout-confirm.js +84 -0
  21. package/dist/collection/utils/i18n.js +2 -2
  22. package/dist/components/factory.js +1 -1
  23. package/dist/components/i18n.js +1 -1
  24. package/dist/components/stripe-card-element2.js +1 -1
  25. package/dist/components/stripe-payment-element.helpers.js +1 -1
  26. package/dist/components/stripe-payment-element.js +1 -1
  27. package/dist/components/stripe-payment-sheet.js +1 -1
  28. package/dist/esm/{factory-BaGv8K_i.js → factory-B_WxdnxM.js} +2 -1
  29. package/dist/esm/{i18n-CL5n3bOb.js → i18n-HWdALSvT.js} +2 -2
  30. package/dist/esm/ion-icon_2.entry.js +1 -1
  31. package/dist/esm/loader.js +1 -1
  32. package/dist/esm/stripe-address-element.entry.js +2 -2
  33. package/dist/esm/stripe-card-element.entry.js +3 -3
  34. package/dist/esm/stripe-currency-selector.entry.js +2 -2
  35. package/dist/esm/stripe-elements.js +1 -1
  36. package/dist/esm/stripe-express-checkout-element.entry.js +2 -2
  37. package/dist/esm/stripe-link-authentication-element.entry.js +2 -2
  38. package/dist/esm/stripe-payment-element.entry.js +19 -8
  39. package/dist/esm/stripe-payment-element.helpers-PuWxhMNR.js +176 -0
  40. package/dist/esm/stripe-payment-sheet.entry.js +73 -58
  41. package/dist/stripe-elements/{p-f5552c81.entry.js → p-2e2bf0fe.entry.js} +1 -1
  42. package/dist/stripe-elements/{p-3fc4583a.entry.js → p-32a2d5a4.entry.js} +1 -1
  43. package/dist/stripe-elements/{p-b62c9dae.entry.js → p-84d45b48.entry.js} +1 -1
  44. package/dist/stripe-elements/{p-CL5n3bOb.js → p-HWdALSvT.js} +1 -1
  45. package/dist/stripe-elements/{p-5d3d93ec.entry.js → p-a266da6f.entry.js} +1 -1
  46. package/dist/stripe-elements/{p-7e826964.entry.js → p-b4faa9db.entry.js} +1 -1
  47. package/dist/stripe-elements/p-c4a0e310.entry.js +1 -0
  48. package/dist/stripe-elements/{p-2e41699e.entry.js → p-e660d76a.entry.js} +1 -1
  49. package/dist/stripe-elements/p-eeebfbbf.entry.js +1 -0
  50. package/dist/stripe-elements/p-n0XJSLU3.js +1 -0
  51. package/dist/stripe-elements/p-wrjrFokg.js +1 -0
  52. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  53. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -0
  54. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +38 -0
  55. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +8 -2
  56. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +19 -11
  57. package/dist/types/components.d.ts +36 -4
  58. package/dist/types/services/interfaces.d.ts +3 -1
  59. package/dist/types/utils/checkout-confirm.d.ts +35 -0
  60. package/package.json +1 -1
  61. package/dist/cjs/stripe-payment-element.helpers-lafmSRmb.js +0 -121
  62. package/dist/esm/stripe-payment-element.helpers-CklK5RlF.js +0 -116
  63. package/dist/stripe-elements/p-7a8f783c.entry.js +0 -1
  64. package/dist/stripe-elements/p-BoZLkOAy.js +0 -1
  65. package/dist/stripe-elements/p-DlMEZwSe.js +0 -1
  66. package/dist/stripe-elements/p-b69f6103.entry.js +0 -1
@@ -1 +1 @@
1
- import{S as e}from"./error.js";const r=e=>{const{progress:r,isCheckoutSession:t,loadStripeStatus:i,intentClientSecret:n}=e;return"loading"===r||"success"===r||!(t?"success"===i:null!=n&&""!==n)},t=async(r,t,i,n,s)=>{const o=await("payment"===i?r.confirmPayment({elements:t,confirmParams:Object.assign({return_url:n},s),redirect:"if_required"}):r.confirmSetup({elements:t,confirmParams:Object.assign({return_url:n},s),redirect:"if_required"}));if(o.error)throw new e(o.error);return o},i=async(r,t)=>{var i;const n=await r.loadActions();if("error"===n.type)throw new e({type:"api_error",code:n.error.code||"checkout_session_error",message:n.error.message});const{actions:s}=n,o=await s.confirm({returnUrl:t,redirect:"if_required"});if("error"===o.type){const r={type:"card_error",code:o.error.code||"payment_failed",message:o.error.message,decline_code:"paymentFailed"===o.error.code?null===(i=o.error.paymentFailed)||void 0===i?void 0:i.declineCode:void 0};throw new e(r)}return o},n=e=>{const{stripe:r,isCheckoutSession:t,checkout:i,checkoutSessionClientSecret:n,elements:s,intentClientSecret:o}=e,c={stripe:r};return t?null==i?{error:"Checkout not properly initialized"}:(c.checkout=i,c.checkoutSessionClientSecret=n,{props:c}):null==s?{error:"Elements not properly initialized"}:(c.elements=s,c.intentClientSecret=o,{props:c})};export{i as a,n as b,t as c,r as i}
1
+ import{S as e}from"./error.js";const r=e=>{const r=e instanceof Error?e.message:null==e?void 0:e.message;return"string"==typeof r&&r.includes("cannot provide `returnUrl`")},t=(r,t)=>{if(null!=r&&"open"!==r.type)throw new e({type:"invalid_request_error",code:`checkout_session_${r.type}`,message:null!=t?t:`The Checkout Session is ${r.type} and can no longer be paid.`})},o=async(o,n,s)=>{const i=await o.loadActions();if("error"===i.type)throw new e({type:"api_error",code:"checkout_session_error",message:i.error.message});const{actions:c}=i,a=()=>{var e,r;return null===(r=null===(e=c.getSession)||void 0===e?void 0:e.call(c))||void 0===r?void 0:r.status};t(a());const l=e=>c.confirm(Object.assign(Object.assign({redirect:"if_required"},e&&""!==n?{returnUrl:n}:{}),null!=s&&""!==s?{email:s}:{}));let u;try{u=await l(!0),"error"===u.type&&r(u.error)&&(u=await l(!1))}catch(e){if(!r(e))throw e;u=await l(!1)}if("error"===u.type){const{code:r,message:o}=u.error;if(t(a(),o),"paymentFailed"===r)throw new e({type:"card_error",code:r,message:o});throw new e({type:"api_error",code:"checkout_session_error",message:o})}return u},n=e=>{const{progress:r,isCheckoutSession:t,loadStripeStatus:o,intentClientSecret:n}=e;return"loading"===r||"success"===r||!(t?"success"===o:null!=n&&""!==n)},s=async(r,t,o,n,s)=>{const i=await("payment"===o?r.confirmPayment({elements:t,confirmParams:Object.assign({return_url:n},s),redirect:"if_required"}):r.confirmSetup({elements:t,confirmParams:Object.assign({return_url:n},s),redirect:"if_required"}));if(i.error)throw new e(i.error);return i},i=async(e,r,t)=>o(e,r,t),c=e=>{const{stripe:r,isCheckoutSession:t,checkout:o,checkoutSessionClientSecret:n,elements:s,intentClientSecret:i}=e,c={stripe:r};return t?null==o?{error:"Checkout not properly initialized"}:(c.checkout=o,c.checkoutSessionClientSecret=n,{props:c}):null==s?{error:"Elements not properly initialized"}:(c.elements=s,c.intentClientSecret=i,{props:c})};export{i as a,c as b,s as c,o as d,n as i}
@@ -1 +1 @@
1
- import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as o,i as r}from"./i18n.js";import{s as a}from"./factory.js";import{b as c,c as l,a as h,i as p}from"./stripe-payment-element.helpers.js";const u=e(class extends i{async initStripe(t,e){const i=++this.initGeneration;await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName,clientSecret:this.intentClientSecret}),await this.mountWhenLoaded(i)}async initStripeWithCheckoutSession(t,e,i){const s=++this.initGeneration;await this.stripeService.initializeWithCheckoutSession(t,e,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName,elementsOptions:null==i?void 0:i.elementsOptions}),await this.mountWhenLoaded(s)}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.paymentElementManager.setError(t),this}updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const i=Object.values(e).filter((t=>null!=t&&""!==t)).length>0;this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(t,this.checkoutSessionClientSecret,{stripeAccount:e.stripeAccount}):this.initStripe(t,i?e:void 0)}updateStripeAccountId(t){this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:t}):this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateIntentClientSecret(){if(null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret)return;const{publishableKey:t,stripeAccount:e}=this.stripeService.state;null!=t&&""!==t&&(await this.initStripe(t,{stripeAccount:e}),"success"===this.progress&&(this.progress=""))}async updateCheckoutSessionClientSecret(t){null!=this.publishableKey&&""!==this.publishableKey&&null!=t&&""!==t&&(await this.initStripeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount}),"success"===this.progress&&(this.progress=""))}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.stripeService.getStripe(),e=!0===this.stripeService.state.isCheckoutSession;if(null==t)return void console.error("Stripe not properly initialized");const i=c({stripe:t,isCheckoutSession:e,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});"error"in i?console.error(i.error):this.formSubmit.emit(i.props)}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}async checkoutSessionConfirmResultHandler(t){this.checkoutSessionConfirmResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}):this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeService.state.stripeAccount})))}async defaultFormSubmitAction(t,{stripe:e,elements:i}){t.preventDefault();try{const t=window.location.href,s=await l(e,i,this.intentType,t);this.defaultFormSubmitResultHandler(s)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}async checkoutSessionFormSubmitAction(t,e){t.preventDefault();try{const t=window.location.href,i=await h(e,t);this.checkoutSessionConfirmResultHandler(i)}catch(t){throw console.error(t),this.checkoutSessionConfirmResultHandler(t instanceof Error?t:Error(t+"")),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.checkoutSessionConfirmResult=s(this,"checkoutSessionConfirmResult",7),this.initGeneration=0,this.intentType="payment",this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=a.createStripeService(),this.paymentElementManager=a.createPaymentElementManager(this.stripeService)}componentWillLoad(){this.startStripe()}async mountWhenLoaded(t){if(t!==this.initGeneration)return;if("success"===this.stripeService.state.loadStripeStatus){if(await this.initElement(),t!==this.initGeneration)return;return void this.stripeLoadedEventHandler()}const e=this.stripeService.onChange("loadStripeStatus",(async i=>{t===this.initGeneration?"success"===i&&(await this.initElement(),t===this.initGeneration?(this.stripeLoadedEventHandler(),e()):e()):e()}))}hasCheckoutSessionClientSecret(){return null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret}startStripe(){null!=this.publishableKey&&""!==this.publishableKey&&(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount}):this.initStripeWithCheckoutSession(this.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeAccount}))}async initElement(){await this.paymentElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-payment-element");null!=t?(null!=this._submitHandler&&t.removeEventListener("submit",this._submitHandler),this._submitHandler=async t=>{const e=this.stripeService.getStripe(),i=!0===this.stripeService.state.isCheckoutSession;if(null==e)return void console.error("Stripe not properly initialized");const s=c({stripe:e,isCheckoutSession:i,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});if("error"in s)return void console.error(s.error);const n=s.props;this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction?i&&null!=n.checkout?await this.checkoutSessionFormSubmitAction(t,n.checkout):null!=this.intentClientSecret&&""!==this.intentClientSecret?await this.defaultFormSubmitAction(t,n):t.preventDefault():t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.paymentElementManager.setError(t instanceof Error?t.message:t+""),this.progress="failure"}},t.addEventListener("submit",this._submitHandler)):console.error("Form element #stripe-payment-element not found")}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){if(this.paymentElementManager.unmount(),null!=this._submitHandler){const t=this.el.querySelector("#stripe-payment-element");null!=t&&t.removeEventListener("submit",this._submitHandler)}}render(){const{loadStripeStatus:t,isCheckoutSession:e}=this.stripeService.state,{errorMessage:i}=this.paymentElementManager.getState();if("failure"===t)return n("p",null,r.t("Failed to load Stripe"));const s=p({progress:this.progress,isCheckoutSession:!0===e,loadStripeStatus:t,intentClientSecret:this.intentClientSecret});return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-payment-element"},n("div",{class:"stripe-heading"},r.t(this.sheetTitle)),n("div",null,n("div",{class:"stripe-section-title"},r.t("Payment information"))),n("div",{class:"payment-info visible"},n("div",{id:"payment-element"})),n("div",{id:"payment-errors",class:"stripe-element-errors"},i),n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:s},r.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}}static get style(){return':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 .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.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{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 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)}'}},[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]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}]);function d(){"undefined"!=typeof customElements&&["stripe-payment-element"].forEach((e=>{"stripe-payment-element"===e&&(customElements.get(t(e))||customElements.define(t(e),u))}))}d();const m=u,b=d;export{m as StripePaymentElement,b as defineCustomElement}
1
+ import{transformTag as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,h as n}from"@stencil/core/internal/client";import{c as o,i as r}from"./i18n.js";import{s as a}from"./factory.js";import{b as l,c,a as h,i as p}from"./stripe-payment-element.helpers.js";const u=e(class extends i{async initStripe(t,e){const i=++this.initGeneration;await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName,clientSecret:this.intentClientSecret}),await this.mountWhenLoaded(i)}async initStripeWithCheckoutSession(t,e,i){const s=++this.initGeneration;await this.stripeService.initializeWithCheckoutSession(t,e,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName,elementsOptions:null==i?void 0:i.elementsOptions,defaultValues:null==i?void 0:i.defaultValues}),await this.mountWhenLoaded(s)}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.paymentElementManager.setError(t),this}updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const i=Object.values(e).filter((t=>null!=t&&""!==t)).length>0;this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(t,this.checkoutSessionClientSecret,{stripeAccount:e.stripeAccount,defaultValues:this.checkoutSessionDefaultValues}):this.initStripe(t,i?e:void 0)}updateStripeAccountId(t){this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:t,defaultValues:this.checkoutSessionDefaultValues}):this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateIntentClientSecret(){if(null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret)return;const{publishableKey:t,stripeAccount:e}=this.stripeService.state;null!=t&&""!==t&&(await this.initStripe(t,{stripeAccount:e}),"success"===this.progress&&(this.progress=""))}async updateCheckoutSessionClientSecret(t){null!=this.publishableKey&&""!==this.publishableKey&&null!=t&&""!==t&&(await this.initStripeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount,defaultValues:this.checkoutSessionDefaultValues}),"success"===this.progress&&(this.progress=""))}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.stripeService.getStripe(),e=!0===this.stripeService.state.isCheckoutSession;if(null==t)return void console.error("Stripe not properly initialized");const i=l({stripe:t,isCheckoutSession:e,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});"error"in i?console.error(i.error):this.formSubmit.emit(i.props)}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}async checkoutSessionConfirmResultHandler(t){this.checkoutSessionConfirmResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}):this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeService.state.stripeAccount,defaultValues:this.checkoutSessionDefaultValues})))}async defaultFormSubmitAction(t,{stripe:e,elements:i}){t.preventDefault();try{const t=window.location.href,s=await c(e,i,this.intentType,t);this.defaultFormSubmitResultHandler(s)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}async checkoutSessionFormSubmitAction(t,e){var i;t.preventDefault();try{const t=await h(e,null!==(i=this.checkoutSessionReturnUrl)&&void 0!==i?i:window.location.href,this.checkoutSessionEmail);this.checkoutSessionConfirmResultHandler(t)}catch(t){throw console.error(t),this.checkoutSessionConfirmResultHandler(t instanceof Error?t:Error(t+"")),t}}constructor(t){super(),!1!==t&&this.__registerHost(),this.stripeLoaded=s(this,"stripeLoaded",7),this.formSubmit=s(this,"formSubmit",7),this.defaultFormSubmitResult=s(this,"defaultFormSubmitResult",7),this.checkoutSessionConfirmResult=s(this,"checkoutSessionConfirmResult",7),this.initGeneration=0,this.intentType="payment",this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=a.createStripeService(),this.paymentElementManager=a.createPaymentElementManager(this.stripeService)}componentWillLoad(){this.startStripe()}async mountWhenLoaded(t){if(t!==this.initGeneration)return;if("success"===this.stripeService.state.loadStripeStatus){if(await this.initElement(),t!==this.initGeneration)return;return void this.stripeLoadedEventHandler()}const e=this.stripeService.onChange("loadStripeStatus",(async i=>{t===this.initGeneration?"success"===i&&(await this.initElement(),t===this.initGeneration?(this.stripeLoadedEventHandler(),e()):e()):e()}))}hasCheckoutSessionClientSecret(){return null!=this.checkoutSessionClientSecret&&""!==this.checkoutSessionClientSecret}startStripe(){null!=this.publishableKey&&""!==this.publishableKey&&(null==this.checkoutSessionClientSecret||""===this.checkoutSessionClientSecret?this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount}):this.initStripeWithCheckoutSession(this.publishableKey,this.checkoutSessionClientSecret,{stripeAccount:this.stripeAccount,defaultValues:this.checkoutSessionDefaultValues}))}async initElement(){await this.paymentElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-payment-element");null!=t?(null!=this._submitHandler&&t.removeEventListener("submit",this._submitHandler),this._submitHandler=async t=>{const e=this.stripeService.getStripe(),i=!0===this.stripeService.state.isCheckoutSession;if(null==e)return void console.error("Stripe not properly initialized");const s=l({stripe:e,isCheckoutSession:i,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});if("error"in s)return void console.error(s.error);const n=s.props;this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,n):!0===this.shouldUseDefaultFormSubmitAction?i&&null!=n.checkout?await this.checkoutSessionFormSubmitAction(t,n.checkout):null!=this.intentClientSecret&&""!==this.intentClientSecret?await this.defaultFormSubmitAction(t,n):t.preventDefault():t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.paymentElementManager.setError(t instanceof Error?t.message:t+""),this.progress="failure"}},t.addEventListener("submit",this._submitHandler)):console.error("Form element #stripe-payment-element not found")}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){if(this.paymentElementManager.unmount(),null!=this._submitHandler){const t=this.el.querySelector("#stripe-payment-element");null!=t&&t.removeEventListener("submit",this._submitHandler)}}render(){const{loadStripeStatus:t,isCheckoutSession:e}=this.stripeService.state,{errorMessage:i}=this.paymentElementManager.getState();if("failure"===t)return n("p",null,r.t("Failed to load Stripe"));const s=p({progress:this.progress,isCheckoutSession:!0===e,loadStripeStatus:t,intentClientSecret:this.intentClientSecret});return n("div",{class:"stripe-payment-sheet-wrap"},n("form",{id:"stripe-payment-element"},n("div",{class:"stripe-heading"},r.t(this.sheetTitle)),n("div",null,n("div",{class:"stripe-section-title"},r.t("Payment information"))),n("div",{class:"payment-info visible"},n("div",{id:"payment-element"})),n("div",{id:"payment-errors",class:"stripe-element-errors"},i),n("div",{style:{marginTop:"32px"}},n("button",{type:"submit",disabled:s},r.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return this}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}}static get style(){return':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 .StripeElement{padding:8px 16px;min-height:64px;border-radius:6px;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.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{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 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)}'}},[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]},void 0,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}]);function d(){"undefined"!=typeof customElements&&["stripe-payment-element"].forEach((e=>{"stripe-payment-element"===e&&(customElements.get(t(e))||customElements.define(t(e),u))}))}d();const m=u,b=d;export{m as StripePaymentElement,b as defineCustomElement}
@@ -1 +1 @@
1
- import{transformTag as e,proxyCustomElement as t,HTMLElement as i,createEvent as n,h as s,Host as a}from"@stencil/core/internal/client";import{c as r,i as o}from"./i18n.js";import{s as l,f as c}from"./factory.js";import{c as d}from"./stripe-payment-element.helpers.js";import{S as h}from"./error.js";import{d as p}from"./icon.js";import{d as u}from"./stripe-modal2.js";const m={phase:"idle",generation:0,pendingPresent:!1,openRequested:!1},f=[[/^pi_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"payment"],[/^seti_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"setup"]],y=e=>({state:e,effects:[]}),b=(e,t)=>e.pendingPresent?{state:Object.assign(Object.assign({},e),{pendingPresent:!1}),effects:[{type:"resolvePresent",result:t}]}:y(e),v=e=>{const t=b(Object.assign(Object.assign({},e),{openRequested:!1}),"paymentSheetCanceled");return{state:t.state,effects:[..."presented"===e.phase||"confirming"===e.phase?[{type:"hide"}]:[],{type:"emit",event:"paymentSheetCanceled"},...t.effects]}},g=(e,t,i)=>{if(""===t)return y(e);if("confirming"===e.phase)return y(Object.assign(Object.assign({},e),{deferredSecret:{clientSecret:t,source:i}}));const n="presented"===e.phase?v(e):y(e),s=e.generation+1,a=((e,t)=>"checkoutSession"===t?"checkoutSession":(e=>{const t=f.find((([t])=>t.test(e)));return null==t?void 0:t[1]})(e))(t,i);if(null==a){const e=b(Object.assign(Object.assign({},n.state),{phase:"loadFailed",generation:s,intentKind:void 0,openRequested:!1}),"paymentSheetFailed");return{state:e.state,effects:[...n.effects,{type:"emit",event:"paymentSheetFailedToLoad"},...e.effects]}}return{state:Object.assign(Object.assign({},n.state),{phase:"loading",generation:s,intentKind:a}),effects:[...n.effects,{type:"load",generation:s,clientSecret:t,intentKind:a}]}},w=e=>{const{deferredSecret:t}=e.state;if(null==t)return e;const i=g(Object.assign(Object.assign({},e.state),{deferredSecret:void 0}),t.clientSecret,t.source);return{state:i.state,effects:[...e.effects,...i.effects]}},S=(e,t)=>"confirming"===e.phase&&e.generation===t;var j=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i};const O=["merchantDisplayName","paymentMethodLayout","defaultBillingDetails","returnURL","style","billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"],k={horizontal:"tabs",vertical:"accordion",automatic:"auto"},C={alwaysLight:"stripe",alwaysDark:"night"},x=e=>Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e))),_=e=>{const{postalCode:t}=e,i=j(e,["postalCode"]);return x(Object.assign(Object.assign({},i),{postal_code:t}))},D=e=>null==e?void 0:e?"auto":"never",P=e=>{if(null==e)return{};const{merchantDisplayName:t,paymentMethodLayout:i,defaultBillingDetails:n,billingDetailsCollectionConfiguration:s,enableApplePay:a,enableGooglePay:r}=e,o={},l=(e=>{if(null==e)return;const{email:t,name:i,phone:n,address:s}=e,a=x({email:"never"===t||"always"===t?"never":void 0,name:"never"===i?"never":void 0,phone:"never"===n||"always"===n&&"full"===s?"never":void 0,address:"never"===s||"full"===s?"never":void 0});return 0===Object.keys(a).length?void 0:a})(s),c=x({applePay:D(a),googlePay:D(r)});if(null!=l&&(o.fields={billingDetails:l}),Object.keys(c).length>0&&(o.wallets=c),null!=t&&(o.business={name:t}),null!=i&&(o.layout=k[i]),null!=n){const{address:e}=n,t=j(n,["address"]),i=x(t);null!=e&&(i.address=_(e)),o.defaultValues={billingDetails:i}}return o},F=e=>{if(null!=e)return{theme:C[e]}},q=e=>{const{name:t,phone:i,address:n}=e,s=null==n?void 0:n.country;return x({name:t,phone:i,address:null==s||""===s?void 0:Object.assign(Object.assign({},_(n)),{country:s})})},E=e=>null==e||""===e,R=(e,t)=>Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${e} is 'never', so defaultBillingDetails.${t} is required`),A=e=>Object.assign(Error(e),{type:"validation_error",sheetValidation:!0}),L=["card_error","validation_error","api_connection_error","rate_limit_error","api_error"],z=e=>{const t=F(null==e?void 0:e.style);return null==t?void 0:{appearance:t}},N=(e,t)=>{if(null!=e&&"open"!==e.type)throw new h({type:"invalid_request_error",code:"checkout_session_"+e.type,message:null!=t?t:`The Checkout Session is ${e.type} and can no longer be paid.`})},B=e=>null==e||""===e?void 0:e,K=t(class extends i{async present(){null==this.presentPromise&&(this.presentPromise=new Promise((e=>{this.resolvePresent=e})));const e=this.presentPromise;return this.dispatch({type:"presentRequested"}),e}handleSecretChange(){this.startLoading()}handleOpenChange(e){this.dispatch({type:e?"openRequested":"closeRequested"})}constructor(e){super(),!1!==e&&this.__registerHost(),this.paymentSheetLoaded=n(this,"paymentSheetLoaded",7),this.paymentSheetFailedToLoad=n(this,"paymentSheetFailedToLoad",7),this.paymentSheetCompleted=n(this,"paymentSheetCompleted",7),this.paymentSheetCanceled=n(this,"paymentSheetCanceled",7),this.paymentSheetFailed=n(this,"paymentSheetFailed",7),this.warnedUnsupportedOptions=!1,this.warnedCheckoutIgnoredOptions=!1,this.open=!1,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.applicationName="stripe-pwa-elements",this.sheet=m,this.visible=!1,this.errorMessage="",this.handleSubmit=e=>{e.preventDefault(),this.errorMessage="",this.dispatch({type:"submitted"})},this.handleModalClose=()=>{var e;this.dispatch({type:"closeRequested"}),this.visible&&(null===(e=this.el.querySelector("stripe-modal"))||void 0===e||e.openModal())},this.stripeService=l.createStripeService(),this.paymentElementManager=l.createPaymentElementManager(this.stripeService),this.billingAddressElementManager=l.createAddressElementManager(this.stripeService),this.shippingAddressElementManager=l.createAddressElementManager(this.stripeService),this.emailElementManager=l.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.open&&this.dispatch({type:"openRequested"}),this.startLoading()}componentDidLoad(){this.el.classList.add(r())}disconnectedCallback(){this.paymentElementManager.unmount(),this.unmountExtraElements()}unmountExtraElements(){this.billingAddressElementManager.unmount(),this.shippingAddressElementManager.unmount(),this.emailElementManager.unmount()}startLoading(){const e=this.loadTarget();null!=e&&e.key!==this.lastLoadKey&&(this.lastLoadKey=e.key,this.dispatch({type:"secretChanged",clientSecret:e.clientSecret,source:e.source}))}loadTarget(){var e;const t=B(this.publishableKey);if(null==t)return;const i=B(this.checkoutSessionClientSecret),n=B(this.intentClientSecret),[s,a]=null!=i?[i,"checkoutSession"]:[n,"intent"];return null!=s?{key:JSON.stringify([t,null!==(e=B(this.stripeAccount))&&void 0!==e?e:null,a,s]),clientSecret:s,source:a}:void 0}dispatch(e){const{state:t,effects:i}=((e,t)=>{switch(t.type){case"secretChanged":return g(e,t.clientSecret,t.source);case"loadSucceeded":{if(t.generation!==e.generation||"loading"!==e.phase)return y(e);const i=e.openRequested;return{state:Object.assign(Object.assign({},e),{phase:i?"presented":"ready",openRequested:!1}),effects:[{type:"emit",event:"paymentSheetLoaded"},...i?[{type:"show"}]:[]]}}case"loadFailed":{if(t.generation!==e.generation||"loading"!==e.phase)return y(e);const i=b(Object.assign(Object.assign({},e),{phase:"loadFailed",openRequested:!1}),"paymentSheetFailed");return{state:i.state,effects:[{type:"emit",event:"paymentSheetFailedToLoad"},...i.effects]}}case"presentRequested":if(e.pendingPresent)return y(e);switch(e.phase){case"ready":return{state:Object.assign(Object.assign({},e),{phase:"presented",pendingPresent:!0}),effects:[{type:"show"}]};case"idle":case"loading":return y(Object.assign(Object.assign({},e),{pendingPresent:!0,openRequested:!0}));case"presented":case"confirming":return y(Object.assign(Object.assign({},e),{pendingPresent:!0}));default:return{state:e,effects:[{type:"resolvePresent",result:"paymentSheetFailed"}]}}case"openRequested":return"ready"===e.phase?{state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"show"}]}:y("idle"===e.phase||"loading"===e.phase?Object.assign(Object.assign({},e),{openRequested:!0}):e);case"closeRequested":if("presented"===e.phase){const t=v(e);return{state:Object.assign(Object.assign({},t.state),{phase:"ready"}),effects:t.effects}}return"idle"!==e.phase&&"loading"!==e.phase||!e.openRequested?y(e):v(e);case"submitted":return"presented"!==e.phase||null==e.intentKind?y(e):{state:Object.assign(Object.assign({},e),{phase:"confirming"}),effects:[{type:"confirm",generation:e.generation,intentKind:e.intentKind}]};case"confirmSucceeded":{if(!S(e,t.generation))return y(e);const i=b(Object.assign(Object.assign({},e),{phase:"completed"}),"paymentSheetCompleted");return w({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetCompleted"},...i.effects]})}case"confirmDeclined":return S(e,t.generation)?w({state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"showError",message:t.message}]}):y(e);case"confirmFailed":{if(!S(e,t.generation))return y(e);const i=b(Object.assign(Object.assign({},e),{phase:"errored"}),"paymentSheetFailed");return w({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetFailed"},...i.effects]})}}})(this.sheet,e);this.sheet=t,i.forEach((e=>this.perform(e)))}perform(e){var t;switch(e.type){case"load":"checkoutSession"===e.intentKind?this.loadCheckoutSession(e.generation,e.clientSecret):this.load(e.generation,e.clientSecret,e.intentKind);break;case"show":this.visible=!0,this.open=!0;break;case"hide":this.visible=!1,this.open=!1;break;case"confirm":"checkoutSession"===e.intentKind?this.confirmCheckoutSession(e.generation):this.confirm(e.generation,e.intentKind);break;case"showError":this.errorMessage=e.message;break;case"emit":this.emit(e.event);break;case"resolvePresent":null===(t=this.resolvePresent)||void 0===t||t.call(this,{paymentResult:e.result}),this.presentPromise=void 0,this.resolvePresent=void 0}}async load(e,t,i){var n;this.warnUnsupportedOptions(i);const s=()=>e!==this.sheet.generation;try{const a=((e,t)=>{var i,n,s,a,r,o,l;const c=null!==(i=null==e?void 0:e.billingDetailsCollectionConfiguration)&&void 0!==i?i:{},d=null!==(n=null==e?void 0:e.defaultBillingDetails)&&void 0!==n?n:{},h={};if(["email","name","phone"].forEach((e=>{if("never"===c[e]){if(E(d[e]))throw R(e,e);h[e]=d[e]}})),"never"===c.address){const e=d.address;if(null==e||E(e.country))throw R("address","address.country");h.address={line1:null!==(s=e.line1)&&void 0!==s?s:"",line2:null!==(a=e.line2)&&void 0!==a?a:"",city:null!==(r=e.city)&&void 0!==r?r:"",state:null!==(o=e.state)&&void 0!==o?o:"",postal_code:null!==(l=e.postalCode)&&void 0!==l?l:"",country:e.country}}const p="full"===c.address&&"always"===c.phone,u={fixedBillingDetails:h,collectPhoneFromAddress:p};if("full"===c.address){const e={mode:"billing",defaultValues:q(d)};p?(e.fields={phone:"always"},e.validation={phone:{required:"always"}}):"never"===c.phone&&(e.fields={phone:"never"}),u.billingAddressElement=e}"always"===c.email&&(u.emailElement=E(d.email)?{}:{defaultValues:{email:d.email}});const m=null==e?void 0:e.shippingDetails;if(null!=m&&"payment"===t){const e={mode:"shipping",defaultValues:q(m)};E(m.phone)||(e.fields={phone:"always"}),u.shippingAddressElement=e}return u})(this.options,i);if(await this.stripeService.initialize(this.publishableKey,{stripeAccount:this.stripeAccount,applicationName:this.applicationName,clientSecret:t}),s())return;if("success"!==this.stripeService.state.loadStripeStatus)throw Error("Failed to load Stripe.js");const r=F(null===(n=this.options)||void 0===n?void 0:n.style);if(null!=r&&(await this.stripeService.getElements().update({appearance:r}),s()))return;if(!await this.mountExtraElements(a,s))return;await this.paymentElementManager.initialize(this.el,P(this.options)),this.dispatch({type:"loadSucceeded",generation:e})}catch(t){if(s())return;this.lastError=t,this.dispatch({type:"loadFailed",generation:e})}}async mountExtraElements(e,t){this.collection=e;const{emailElement:i,shippingAddressElement:n,billingAddressElement:s}=e,a=[{manager:this.emailElementManager,selector:".stripe-payment-sheet-email",mount:i&&(e=>this.emailElementManager.initialize(e,i))},{manager:this.shippingAddressElementManager,selector:".stripe-payment-sheet-shipping-address",mount:n&&(e=>this.shippingAddressElementManager.initialize(e,n))},{manager:this.billingAddressElementManager,selector:".stripe-payment-sheet-billing-address",mount:s&&(e=>this.billingAddressElementManager.initialize(e,s))}];for(const{manager:e,selector:i,mount:n}of a){if(null==n){e.unmount();continue}const s=await c(this.el,i);if(t())return!1;if(await n(s),t())return!1}return!0}async confirmParams(){var e;const t=this.collection;if(null==t)return;const i=null!=t.billingAddressElement?await(null===(e=this.billingAddressElementManager.getElement())||void 0===e?void 0:e.getValue()):void 0,n=null!=t.emailElement?this.emailElementManager.getState():void 0,s=((e,t)=>{var i,n;const s={};if(null!=e.billingAddressElement){const i=t.billingAddress;if(null==i||!i.complete)throw A("Please complete your billing address.");s.name=i.value.name,s.address=i.value.address,e.collectPhoneFromAddress&&(s.phone=i.value.phone)}if(null!=e.emailElement){const a=null!==(i=t.email)&&void 0!==i?i:null===(n=e.emailElement.defaultValues)||void 0===n?void 0:n.email;if(E(a))throw A("Please enter your email address.");if(!1===t.emailComplete||null==t.emailComplete&&!(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(a))throw A("Please enter a valid email address.");s.email=a}return Object.assign(s,e.fixedBillingDetails),0===Object.keys(s).length?void 0:s})(t,{billingAddress:i,email:null==n?void 0:n.email,emailComplete:null==n?void 0:n.complete});return null==s?void 0:{payment_method_data:{billing_details:s}}}confirm(e,t){return this.runConfirm(e,(async()=>{var e,i;const n=this.stripeService.getElements(),{error:s}=await n.submit();if(null!=s)throw s;const a=null!==(i=null===(e=this.options)||void 0===e?void 0:e.returnURL)&&void 0!==i?i:window.location.href,r=await this.confirmParams();return d(this.stripeService.getStripe(),n,t,a,r)}))}async runConfirm(e,t){var i;try{this.lastResult=await t(),this.dispatch({type:"confirmSucceeded",generation:e})}catch(t){const n=null!==(i=t.message)&&void 0!==i?i:t+"",s=(e=>!0===(null==e?void 0:e.sheetValidation))(t)?o.t(n):n;if((e=>{const t=null==e?void 0:e.type;return"string"==typeof t&&L.includes(t)})(t))return void this.dispatch({type:"confirmDeclined",generation:e,message:s});this.lastError=t,this.dispatch({type:"confirmFailed",generation:e,message:s})}}async loadCheckoutSession(e,t){this.warnUnsupportedOptions("checkoutSession"),this.warnCheckoutIgnoredOptions(),this.collection=void 0,this.unmountExtraElements();try{if(await this.stripeService.initializeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount,applicationName:this.applicationName,elementsOptions:z(this.options)}),e!==this.sheet.generation)return;if("success"!==this.stripeService.state.loadStripeStatus)throw Error("Failed to load Stripe.js");await this.paymentElementManager.initialize(this.el,(e=>{const{layout:t}=P(e);return null==t?{}:{layout:t}})(this.options)),this.dispatch({type:"loadSucceeded",generation:e})}catch(t){if(e!==this.sheet.generation)return;this.lastError=t,this.dispatch({type:"loadFailed",generation:e})}}confirmCheckoutSession(e){var t,i;const n=null!==(i=null===(t=this.options)||void 0===t?void 0:t.returnURL)&&void 0!==i?i:window.location.href;return this.runConfirm(e,(async()=>{var e,t;const i=this.stripeService.getCheckout();if(null==i)throw Error("Checkout Session is not initialized");return(async(e,t,i)=>{const n=await e.loadActions();if("error"===n.type)throw new h({type:"api_error",code:"checkout_session_error",message:n.error.message});const{actions:s}=n,a=()=>{var e,t;return null===(t=null===(e=s.getSession)||void 0===e?void 0:e.call(s))||void 0===t?void 0:t.status};N(a());const r=await s.confirm(Object.assign({returnUrl:t,redirect:"if_required"},null!=i&&""!==i?{email:i}:{}));if("error"===r.type){const{code:e,message:t}=r.error;if(N(a(),t),"paymentFailed"===e)throw new h({type:"card_error",code:e,message:t});throw new h({type:"api_error",code:"checkout_session_error",message:t})}return r})(i,n,null===(t=null===(e=this.options)||void 0===e?void 0:e.defaultBillingDetails)||void 0===t?void 0:t.email)}))}emit(e){switch(e){case"paymentSheetLoaded":this.paymentSheetLoaded.emit({stripe:this.stripeService.getStripe()});break;case"paymentSheetFailedToLoad":this.paymentSheetFailedToLoad.emit(this.lastError);break;case"paymentSheetCompleted":this.paymentSheetCompleted.emit(this.lastResult);break;case"paymentSheetCanceled":this.paymentSheetCanceled.emit();break;case"paymentSheetFailed":this.paymentSheetFailed.emit(this.lastError)}}warnUnsupportedOptions(e){const t=((e,t)=>{if(null==e)return[];const i=Object.entries(e).filter((([e,t])=>void 0!==t&&!O.includes(e))).map((([e])=>e)),n=e.billingDetailsCollectionConfiguration;return"always"===(null==n?void 0:n.name)&&i.push("billingDetailsCollectionConfiguration.name"),"always"===(null==n?void 0:n.phone)&&"full"!==n.address&&i.push("billingDetailsCollectionConfiguration.phone"),null!=e.shippingDetails&&"setup"===t&&i.push("shippingDetails"),i.sort()})(this.options,e);this.warnedUnsupportedOptions||0===t.length||(this.warnedUnsupportedOptions=!0,console.warn("<stripe-payment-sheet>: these options have no effect on the web yet: "+t.join(", ")))}warnCheckoutIgnoredOptions(){const e=(e=>{if(null==e)return[];const{merchantDisplayName:t,defaultBillingDetails:i}=e,n=["name","phone","address"].filter((e=>null!=(null==i?void 0:i[e]))).map((e=>"defaultBillingDetails."+e));return null!=t&&n.push("merchantDisplayName"),["billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"].filter((t=>void 0!==e[t])).forEach((e=>n.push(e))),n.sort()})(this.options);this.warnedCheckoutIgnoredOptions||0===e.length||(this.warnedCheckoutIgnoredOptions=!0,console.warn("<stripe-payment-sheet>: these options have no effect with a Checkout Session: "+e.join(", ")))}render(){var e,t,i;const{phase:n}=this.sheet,r="confirming"===n;return s(a,{key:"e6b2c3cb168039eb428eaaee1dce598f534c18e7"},s("stripe-modal",{key:"ef1515b07cca402c4db8818e2e94ca80e4d954c2",open:this.visible,showCloseButton:!r,onClose:this.handleModalClose},s("div",{key:"9252fa1653b206d211756c94325c73a8ec482a37",class:"stripe-payment-sheet-wrap"},s("form",{key:"904a54f2439e0356c2cbf9227326efe446aa08ce",id:"stripe-payment-sheet",onSubmit:this.handleSubmit},s("div",{key:"103d81e3c56cfba1c421e1bf140a49e2b392c6b5",class:"stripe-heading"},o.t(this.sheetTitle)),s("div",{key:"cda58a48db7b04af1981407b7100def815404e35",class:"payment-info visible"},s("div",{key:"cbe248666aa4807c25d492df1ab1de017bc78e2c",class:"stripe-payment-sheet-email"},null!=(null===(e=this.collection)||void 0===e?void 0:e.emailElement)&&s("div",{key:"b0210c6cce85d1affaa83e3fa30785158c9bab98",id:"link-authentication-element"})),s("div",{key:"2420956298e5b36c63f3fbea6b4e32429b7ace27",class:"stripe-payment-sheet-shipping-address"},null!=(null===(t=this.collection)||void 0===t?void 0:t.shippingAddressElement)&&s("div",{key:"ae41335a42c59598e1addbfdea0a13342c026456",id:"address-element"})),s("div",{key:"3196844c9396c40548a3c632733565027df3cea7",class:"stripe-payment-sheet-billing-address"},null!=(null===(i=this.collection)||void 0===i?void 0:i.billingAddressElement)&&s("div",{key:"269a99368975db70722fc181a1c099859f23d3d6",id:"address-element"})),s("div",{key:"2a63173a607501ff08ac072956cdbe462a4400c1",id:"payment-element"})),s("div",{key:"7a72a86097aca2af6491c56b52258286ef820283",class:"stripe-element-errors",role:"alert"},this.errorMessage),s("div",{key:"10f05d5ecfa53cde350f00acffd86e232e370fe7",class:"stripe-submit"},s("button",{key:"a7ad3e538b94403bd8c71b31bd405c1b0c59543c",type:"submit",disabled:"presented"!==n},o.t(r?"Loading":this.buttonLabel)))))))}get el(){return this}static get watchers(){return{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}}static get style(){return':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)}'}},[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]},void 0,{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}]);function T(){"undefined"!=typeof customElements&&["stripe-payment-sheet","ion-icon","stripe-modal"].forEach((t=>{switch(t){case"stripe-payment-sheet":customElements.get(e(t))||customElements.define(e(t),K);break;case"ion-icon":customElements.get(e(t))||p();break;case"stripe-modal":customElements.get(e(t))||u()}}))}T();const $=K,V=T;export{$ as StripePaymentSheet,V as defineCustomElement}
1
+ import{transformTag as e,proxyCustomElement as t,HTMLElement as i,createEvent as n,h as s,Host as a}from"@stencil/core/internal/client";import{c as o,i as r}from"./i18n.js";import{s as l,f as c}from"./factory.js";import{d,c as h}from"./stripe-payment-element.helpers.js";import{d as p}from"./icon.js";import{d as u}from"./stripe-modal2.js";const f={phase:"idle",generation:0,pendingPresent:!1,openRequested:!1},m=[[/^pi_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"payment"],[/^seti_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"setup"]],b=e=>({state:e,effects:[]}),y=(e,t)=>e.pendingPresent?{state:Object.assign(Object.assign({},e),{pendingPresent:!1}),effects:[{type:"resolvePresent",result:t}]}:b(e),v=e=>{const t=y(Object.assign(Object.assign({},e),{openRequested:!1}),"paymentSheetCanceled");return{state:t.state,effects:[..."presented"===e.phase||"confirming"===e.phase?[{type:"hide"}]:[],{type:"emit",event:"paymentSheetCanceled"},...t.effects]}},g=(e,t,i)=>{if(""===t)return b(e);if("confirming"===e.phase)return b(Object.assign(Object.assign({},e),{deferredSecret:{clientSecret:t,source:i}}));const n="presented"===e.phase?v(e):b(e),s=e.generation+1,a=((e,t)=>"checkoutSession"===t?"checkoutSession":(e=>{const t=m.find((([t])=>t.test(e)));return null==t?void 0:t[1]})(e))(t,i);if(null==a){const e=y(Object.assign(Object.assign({},n.state),{phase:"loadFailed",generation:s,intentKind:void 0,openRequested:!1}),"paymentSheetFailed");return{state:e.state,effects:[...n.effects,{type:"emit",event:"paymentSheetFailedToLoad"},...e.effects]}}return{state:Object.assign(Object.assign({},n.state),{phase:"loading",generation:s,intentKind:a}),effects:[...n.effects,{type:"load",generation:s,clientSecret:t,intentKind:a}]}},w=e=>{const{deferredSecret:t}=e.state;if(null==t)return e;const i=g(Object.assign(Object.assign({},e.state),{deferredSecret:void 0}),t.clientSecret,t.source);return{state:i.state,effects:[...e.effects,...i.effects]}},S=(e,t)=>"confirming"===e.phase&&e.generation===t;var j=function(e,t){var i={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(i[n[s]]=e[n[s]])}return i};const O=["merchantDisplayName","paymentMethodLayout","defaultBillingDetails","returnURL","style","billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"],k={horizontal:"tabs",vertical:"accordion",automatic:"auto"},C={alwaysLight:"stripe",alwaysDark:"night"},x=e=>Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e))),D=e=>{const{postalCode:t}=e,i=j(e,["postalCode"]);return x(Object.assign(Object.assign({},i),{postal_code:t}))},P=e=>null==e?void 0:e?"auto":"never",F=e=>{if(null==e)return{};const{merchantDisplayName:t,paymentMethodLayout:i,defaultBillingDetails:n,billingDetailsCollectionConfiguration:s,enableApplePay:a,enableGooglePay:o}=e,r={},l=(e=>{if(null==e)return;const{email:t,name:i,phone:n,address:s}=e,a=x({email:"never"===t||"always"===t?"never":void 0,name:"never"===i?"never":void 0,phone:"never"===n||"always"===n&&"full"===s?"never":void 0,address:"never"===s||"full"===s?"never":void 0});return 0===Object.keys(a).length?void 0:a})(s),c=x({applePay:P(a),googlePay:P(o)});if(null!=l&&(r.fields={billingDetails:l}),Object.keys(c).length>0&&(r.wallets=c),null!=t&&(r.business={name:t}),null!=i&&(r.layout=k[i]),null!=n){const{address:e}=n,t=j(n,["address"]),i=x(t);null!=e&&(i.address=D(e)),r.defaultValues={billingDetails:i}}return r},_=e=>{if(null!=e)return{theme:C[e]}},E=e=>{const{name:t,phone:i,address:n}=e,s=null==n?void 0:n.country;return x({name:t,phone:i,address:null==s||""===s?void 0:Object.assign(Object.assign({},D(n)),{country:s})})},R=e=>null==e||""===e,q=(e,t)=>Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${e} is 'never', so defaultBillingDetails.${t} is required`),A=e=>Object.assign(Error(e),{type:"validation_error",sheetValidation:!0}),L=["card_error","validation_error","api_connection_error","rate_limit_error","api_error"],z=e=>{var t,i;const n=null==e?void 0:e.defaultBillingDetails;if(null==n)return;const s={};null!=n.email&&""!==n.email&&(s.email=n.email),null!=n.phone&&""!==n.phone&&(s.phoneNumber=n.phone);const a=null===(t=n.address)||void 0===t?void 0:t.country;if(null!=a&&""!==a){const e=n.address,t=(e=>Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e))))({country:a,line1:null==e?void 0:e.line1,line2:null==e?void 0:e.line2,city:null==e?void 0:e.city,postal_code:null==e?void 0:e.postalCode,state:null==e?void 0:e.state}),o={name:null!==(i=n.name)&&void 0!==i?i:null,address:t};s.billingAddress=o}return 0===Object.keys(s).length?void 0:s},N=e=>{const t=_(null==e?void 0:e.style);return null==t?void 0:{appearance:t}},B=e=>null==e||""===e?void 0:e,K=t(class extends i{async present(){null==this.presentPromise&&(this.presentPromise=new Promise((e=>{this.resolvePresent=e})));const e=this.presentPromise;return this.dispatch({type:"presentRequested"}),e}handleSecretChange(){this.startLoading()}handleOpenChange(e){this.dispatch({type:e?"openRequested":"closeRequested"})}constructor(e){super(),!1!==e&&this.__registerHost(),this.paymentSheetLoaded=n(this,"paymentSheetLoaded",7),this.paymentSheetFailedToLoad=n(this,"paymentSheetFailedToLoad",7),this.paymentSheetCompleted=n(this,"paymentSheetCompleted",7),this.paymentSheetCanceled=n(this,"paymentSheetCanceled",7),this.paymentSheetFailed=n(this,"paymentSheetFailed",7),this.warnedUnsupportedOptions=!1,this.warnedCheckoutIgnoredOptions=!1,this.open=!1,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.applicationName="stripe-pwa-elements",this.sheet=f,this.visible=!1,this.errorMessage="",this.handleSubmit=e=>{e.preventDefault(),this.errorMessage="",this.dispatch({type:"submitted"})},this.handleModalClose=()=>{var e;this.dispatch({type:"closeRequested"}),this.visible&&(null===(e=this.el.querySelector("stripe-modal"))||void 0===e||e.openModal())},this.stripeService=l.createStripeService(),this.paymentElementManager=l.createPaymentElementManager(this.stripeService),this.billingAddressElementManager=l.createAddressElementManager(this.stripeService),this.shippingAddressElementManager=l.createAddressElementManager(this.stripeService),this.emailElementManager=l.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.open&&this.dispatch({type:"openRequested"}),this.startLoading()}componentDidLoad(){this.el.classList.add(o())}disconnectedCallback(){this.paymentElementManager.unmount(),this.unmountExtraElements()}unmountExtraElements(){this.billingAddressElementManager.unmount(),this.shippingAddressElementManager.unmount(),this.emailElementManager.unmount()}startLoading(){const e=this.loadTarget();null!=e&&e.key!==this.lastLoadKey&&(this.lastLoadKey=e.key,this.dispatch({type:"secretChanged",clientSecret:e.clientSecret,source:e.source}))}loadTarget(){var e;const t=B(this.publishableKey);if(null==t)return;const i=B(this.checkoutSessionClientSecret),n=B(this.intentClientSecret),[s,a]=null!=i?[i,"checkoutSession"]:[n,"intent"];return null!=s?{key:JSON.stringify([t,null!==(e=B(this.stripeAccount))&&void 0!==e?e:null,a,s]),clientSecret:s,source:a}:void 0}dispatch(e){const{state:t,effects:i}=((e,t)=>{switch(t.type){case"secretChanged":return g(e,t.clientSecret,t.source);case"loadSucceeded":{if(t.generation!==e.generation||"loading"!==e.phase)return b(e);const i=e.openRequested;return{state:Object.assign(Object.assign({},e),{phase:i?"presented":"ready",openRequested:!1}),effects:[{type:"emit",event:"paymentSheetLoaded"},...i?[{type:"show"}]:[]]}}case"loadFailed":{if(t.generation!==e.generation||"loading"!==e.phase)return b(e);const i=y(Object.assign(Object.assign({},e),{phase:"loadFailed",openRequested:!1}),"paymentSheetFailed");return{state:i.state,effects:[{type:"emit",event:"paymentSheetFailedToLoad"},...i.effects]}}case"presentRequested":if(e.pendingPresent)return b(e);switch(e.phase){case"ready":return{state:Object.assign(Object.assign({},e),{phase:"presented",pendingPresent:!0}),effects:[{type:"show"}]};case"idle":case"loading":return b(Object.assign(Object.assign({},e),{pendingPresent:!0,openRequested:!0}));case"presented":case"confirming":return b(Object.assign(Object.assign({},e),{pendingPresent:!0}));default:return{state:e,effects:[{type:"resolvePresent",result:"paymentSheetFailed"}]}}case"openRequested":return"ready"===e.phase?{state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"show"}]}:b("idle"===e.phase||"loading"===e.phase?Object.assign(Object.assign({},e),{openRequested:!0}):e);case"closeRequested":if("presented"===e.phase){const t=v(e);return{state:Object.assign(Object.assign({},t.state),{phase:"ready"}),effects:t.effects}}return"idle"!==e.phase&&"loading"!==e.phase||!e.openRequested?b(e):v(e);case"submitted":return"presented"!==e.phase||null==e.intentKind?b(e):{state:Object.assign(Object.assign({},e),{phase:"confirming"}),effects:[{type:"confirm",generation:e.generation,intentKind:e.intentKind}]};case"confirmSucceeded":{if(!S(e,t.generation))return b(e);const i=y(Object.assign(Object.assign({},e),{phase:"completed"}),"paymentSheetCompleted");return w({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetCompleted"},...i.effects]})}case"confirmDeclined":return S(e,t.generation)?w({state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"showError",message:t.message}]}):b(e);case"confirmFailed":{if(!S(e,t.generation))return b(e);const i=y(Object.assign(Object.assign({},e),{phase:"errored"}),"paymentSheetFailed");return w({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetFailed"},...i.effects]})}}})(this.sheet,e);this.sheet=t,i.forEach((e=>this.perform(e)))}perform(e){var t;switch(e.type){case"load":"checkoutSession"===e.intentKind?this.loadCheckoutSession(e.generation,e.clientSecret):this.load(e.generation,e.clientSecret,e.intentKind);break;case"show":this.visible=!0,this.open=!0;break;case"hide":this.visible=!1,this.open=!1;break;case"confirm":"checkoutSession"===e.intentKind?this.confirmCheckoutSession(e.generation):this.confirm(e.generation,e.intentKind);break;case"showError":this.errorMessage=e.message;break;case"emit":this.emit(e.event);break;case"resolvePresent":null===(t=this.resolvePresent)||void 0===t||t.call(this,{paymentResult:e.result}),this.presentPromise=void 0,this.resolvePresent=void 0}}async load(e,t,i){var n;this.warnUnsupportedOptions(i);const s=()=>e!==this.sheet.generation;try{const a=((e,t)=>{var i,n,s,a,o,r,l;const c=null!==(i=null==e?void 0:e.billingDetailsCollectionConfiguration)&&void 0!==i?i:{},d=null!==(n=null==e?void 0:e.defaultBillingDetails)&&void 0!==n?n:{},h={};if(["email","name","phone"].forEach((e=>{if("never"===c[e]){if(R(d[e]))throw q(e,e);h[e]=d[e]}})),"never"===c.address){const e=d.address;if(null==e||R(e.country))throw q("address","address.country");h.address={line1:null!==(s=e.line1)&&void 0!==s?s:"",line2:null!==(a=e.line2)&&void 0!==a?a:"",city:null!==(o=e.city)&&void 0!==o?o:"",state:null!==(r=e.state)&&void 0!==r?r:"",postal_code:null!==(l=e.postalCode)&&void 0!==l?l:"",country:e.country}}const p="full"===c.address&&"always"===c.phone,u={fixedBillingDetails:h,collectPhoneFromAddress:p};if("full"===c.address){const e={mode:"billing",defaultValues:E(d)};p?(e.fields={phone:"always"},e.validation={phone:{required:"always"}}):"never"===c.phone&&(e.fields={phone:"never"}),u.billingAddressElement=e}"always"===c.email&&(u.emailElement=R(d.email)?{}:{defaultValues:{email:d.email}});const f=null==e?void 0:e.shippingDetails;if(null!=f&&"payment"===t){const e={mode:"shipping",defaultValues:E(f)};R(f.phone)||(e.fields={phone:"always"}),u.shippingAddressElement=e}return u})(this.options,i);if(await this.stripeService.initialize(this.publishableKey,{stripeAccount:this.stripeAccount,applicationName:this.applicationName,clientSecret:t}),s())return;if("success"!==this.stripeService.state.loadStripeStatus)throw Error("Failed to load Stripe.js");const o=_(null===(n=this.options)||void 0===n?void 0:n.style);if(null!=o&&(await this.stripeService.getElements().update({appearance:o}),s()))return;if(!await this.mountExtraElements(a,s))return;await this.paymentElementManager.initialize(this.el,F(this.options)),this.dispatch({type:"loadSucceeded",generation:e})}catch(t){if(s())return;this.lastError=t,this.dispatch({type:"loadFailed",generation:e})}}async mountExtraElements(e,t){this.collection=e;const{emailElement:i,shippingAddressElement:n,billingAddressElement:s}=e,a=[{manager:this.emailElementManager,selector:".stripe-payment-sheet-email",mount:i&&(e=>this.emailElementManager.initialize(e,i))},{manager:this.shippingAddressElementManager,selector:".stripe-payment-sheet-shipping-address",mount:n&&(e=>this.shippingAddressElementManager.initialize(e,n))},{manager:this.billingAddressElementManager,selector:".stripe-payment-sheet-billing-address",mount:s&&(e=>this.billingAddressElementManager.initialize(e,s))}];for(const{manager:e,selector:i,mount:n}of a){if(null==n){e.unmount();continue}const s=await c(this.el,i);if(t())return!1;if(await n(s),t())return!1}return!0}async confirmParams(){var e;const t=this.collection;if(null==t)return;const i=null!=t.billingAddressElement?await(null===(e=this.billingAddressElementManager.getElement())||void 0===e?void 0:e.getValue()):void 0,n=null!=t.emailElement?this.emailElementManager.getState():void 0,s=((e,t)=>{var i,n;const s={};if(null!=e.billingAddressElement){const i=t.billingAddress;if(null==i||!i.complete)throw A("Please complete your billing address.");s.name=i.value.name,s.address=i.value.address,e.collectPhoneFromAddress&&(s.phone=i.value.phone)}if(null!=e.emailElement){const a=null!==(i=t.email)&&void 0!==i?i:null===(n=e.emailElement.defaultValues)||void 0===n?void 0:n.email;if(R(a))throw A("Please enter your email address.");if(!1===t.emailComplete||null==t.emailComplete&&!(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))(a))throw A("Please enter a valid email address.");s.email=a}return Object.assign(s,e.fixedBillingDetails),0===Object.keys(s).length?void 0:s})(t,{billingAddress:i,email:null==n?void 0:n.email,emailComplete:null==n?void 0:n.complete});return null==s?void 0:{payment_method_data:{billing_details:s}}}confirm(e,t){return this.runConfirm(e,(async()=>{var e,i;const n=this.stripeService.getElements(),{error:s}=await n.submit();if(null!=s)throw s;const a=null!==(i=null===(e=this.options)||void 0===e?void 0:e.returnURL)&&void 0!==i?i:window.location.href,o=await this.confirmParams();return h(this.stripeService.getStripe(),n,t,a,o)}))}async runConfirm(e,t){var i;try{this.lastResult=await t(),this.dispatch({type:"confirmSucceeded",generation:e})}catch(t){const n=null!==(i=t.message)&&void 0!==i?i:t+"",s=(e=>!0===(null==e?void 0:e.sheetValidation))(t)?r.t(n):n;if((e=>{const t=null==e?void 0:e.type;return"string"==typeof t&&L.includes(t)})(t))return void this.dispatch({type:"confirmDeclined",generation:e,message:s});this.lastError=t,this.dispatch({type:"confirmFailed",generation:e,message:s})}}async loadCheckoutSession(e,t){this.warnUnsupportedOptions("checkoutSession"),this.warnCheckoutIgnoredOptions(),this.collection=void 0,this.unmountExtraElements();try{if(await this.stripeService.initializeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount,applicationName:this.applicationName,elementsOptions:N(this.options),defaultValues:z(this.options)}),e!==this.sheet.generation)return;if("success"!==this.stripeService.state.loadStripeStatus)throw Error("Failed to load Stripe.js");await this.paymentElementManager.initialize(this.el,(e=>{const{layout:t}=F(e);return null==t?{}:{layout:t}})(this.options)),this.dispatch({type:"loadSucceeded",generation:e})}catch(t){if(e!==this.sheet.generation)return;this.lastError=t,this.dispatch({type:"loadFailed",generation:e})}}confirmCheckoutSession(e){var t,i;const n=null!==(i=null===(t=this.options)||void 0===t?void 0:t.returnURL)&&void 0!==i?i:window.location.href;return this.runConfirm(e,(async()=>{var e,t;const i=this.stripeService.getCheckout();if(null==i)throw Error("Checkout Session is not initialized");return(async(e,t,i)=>d(e,t,i))(i,n,null===(t=null===(e=this.options)||void 0===e?void 0:e.defaultBillingDetails)||void 0===t?void 0:t.email)}))}emit(e){switch(e){case"paymentSheetLoaded":this.paymentSheetLoaded.emit({stripe:this.stripeService.getStripe()});break;case"paymentSheetFailedToLoad":this.paymentSheetFailedToLoad.emit(this.lastError);break;case"paymentSheetCompleted":this.paymentSheetCompleted.emit(this.lastResult);break;case"paymentSheetCanceled":this.paymentSheetCanceled.emit();break;case"paymentSheetFailed":this.paymentSheetFailed.emit(this.lastError)}}warnUnsupportedOptions(e){const t=((e,t)=>{if(null==e)return[];const i=Object.entries(e).filter((([e,t])=>void 0!==t&&!O.includes(e))).map((([e])=>e)),n=e.billingDetailsCollectionConfiguration;return"always"===(null==n?void 0:n.name)&&i.push("billingDetailsCollectionConfiguration.name"),"always"===(null==n?void 0:n.phone)&&"full"!==n.address&&i.push("billingDetailsCollectionConfiguration.phone"),null!=e.shippingDetails&&"setup"===t&&i.push("shippingDetails"),i.sort()})(this.options,e);this.warnedUnsupportedOptions||0===t.length||(this.warnedUnsupportedOptions=!0,console.warn("<stripe-payment-sheet>: these options have no effect on the web yet: "+t.join(", ")))}warnCheckoutIgnoredOptions(){const e=(e=>{var t;if(null==e)return[];const{merchantDisplayName:i,defaultBillingDetails:n}=e,s=[],a=null===(t=null==n?void 0:n.address)||void 0===t?void 0:t.country;if(!(null==(null==n?void 0:n.name)&&null==(null==n?void 0:n.address)||null!=a&&""!==a))for(const e of["name","address"])null!=(null==n?void 0:n[e])&&s.push("defaultBillingDetails."+e);return null!=i&&s.push("merchantDisplayName"),["billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"].filter((t=>void 0!==e[t])).forEach((e=>s.push(e))),s.sort()})(this.options);this.warnedCheckoutIgnoredOptions||0===e.length||(this.warnedCheckoutIgnoredOptions=!0,console.warn("<stripe-payment-sheet>: these options have no effect with a Checkout Session: "+e.join(", ")))}render(){var e,t,i;const{phase:n}=this.sheet,o="confirming"===n;return s(a,{key:"52591afbd5af5ceb2530a37248e3bb1f410f880c"},s("stripe-modal",{key:"607c26d28f381b5017f9714fca398c2f5eb9c066",open:this.visible,showCloseButton:!o,onClose:this.handleModalClose},s("div",{key:"44cfb1929b178257878d5a42d8441b2f7f823436",class:"stripe-payment-sheet-wrap"},s("form",{key:"20be8d4cb150883936241639c299a86d081c1903",id:"stripe-payment-sheet",onSubmit:this.handleSubmit},s("div",{key:"14e5c98793de6d2ebb1a1cc755e501b427915d9f",class:"stripe-heading"},r.t(this.sheetTitle)),s("div",{key:"235ac34c0c2260793756960caa75ef9f62e401fd",class:"payment-info visible"},s("div",{key:"10ed4c9be02a08429b8bfd028f40be409613250b",class:"stripe-payment-sheet-email"},null!=(null===(e=this.collection)||void 0===e?void 0:e.emailElement)&&s("div",{key:"5a21882fc11b839287bd499f9441b7a37b2f7e4d",id:"link-authentication-element"})),s("div",{key:"d88e637fcecc62bba18fc25cdf674a03624ceb8a",class:"stripe-payment-sheet-shipping-address"},null!=(null===(t=this.collection)||void 0===t?void 0:t.shippingAddressElement)&&s("div",{key:"934f6b59ce787c6452191f1df14b1848f847db4a",id:"address-element"})),s("div",{key:"1fe9f0371e0669c6b5485b19672ee02169312674",class:"stripe-payment-sheet-billing-address"},null!=(null===(i=this.collection)||void 0===i?void 0:i.billingAddressElement)&&s("div",{key:"fb548084588b34ffcd8534cc2b0a402e1af60d76",id:"address-element"})),s("div",{key:"8dec277132c63cc11c49962f136b67685e810ccb",id:"payment-element"})),s("div",{key:"e0f20ba527fb9b941cc8d70d7631a03dcfc2c370",class:"stripe-element-errors",role:"alert"},this.errorMessage),s("div",{key:"db7357b49c141ff9272f1b4690f933ea54d9bfb3",class:"stripe-submit"},s("button",{key:"9112ed21047df0b2fdfa5f8d6b7872f878062dc1",type:"submit",disabled:"presented"!==n},r.t(o?"Loading":this.buttonLabel)))))))}get el(){return this}static get watchers(){return{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}}static get style(){return':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)}'}},[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]},void 0,{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}]);function T(){"undefined"!=typeof customElements&&["stripe-payment-sheet","ion-icon","stripe-modal"].forEach((t=>{switch(t){case"stripe-payment-sheet":customElements.get(e(t))||customElements.define(e(t),K);break;case"ion-icon":customElements.get(e(t))||p();break;case"stripe-modal":customElements.get(e(t))||u()}}))}T();const V=K,$=T;export{V as StripePaymentSheet,$ as defineCustomElement}
@@ -1,6 +1,6 @@
1
1
  import { S as StencilCore } from './index-C6bbmyga.js';
2
2
  import { l as loadStripe } from './index-CBXaOfXU.js';
3
- import { i as i18n } from './i18n-CL5n3bOb.js';
3
+ import { i as i18n } from './i18n-HWdALSvT.js';
4
4
 
5
5
  const appendToMap = (map, propName, value) => {
6
6
  let refs = map.get(propName);
@@ -413,6 +413,7 @@ class StripeServiceClass {
413
413
  const checkout = stripe.initCheckoutElementsSdk({
414
414
  clientSecret: checkoutSessionClientSecret,
415
415
  elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
416
+ defaultValues: options === null || options === void 0 ? void 0 : options.defaultValues,
416
417
  });
417
418
  this.store.state.checkout = checkout;
418
419
  this.store.state.elements = undefined;
@@ -2769,6 +2769,8 @@ Browser.type = 'languageDetector';
2769
2769
  instance.use(Browser).init({
2770
2770
  fallbackLng: 'en',
2771
2771
  debug: false,
2772
+ // i18next prints a one-time Locize promo to the console unless this is false
2773
+ showSupportNotice: false,
2772
2774
  resources: {
2773
2775
  'en': {
2774
2776
  translation: {},
@@ -2785,7 +2787,6 @@ instance.use(Browser).init({
2785
2787
  'Card Number': 'カード番号',
2786
2788
  'MM / YY': '月 / 年',
2787
2789
  'CVC': 'セキュリティコード(CVC)',
2788
- 'Country or region': '地域',
2789
2790
  'Postal Code': '郵便番号',
2790
2791
  'Close': '閉じる',
2791
2792
  'Loading': '読み込み中',
@@ -2809,7 +2810,6 @@ instance.use(Browser).init({
2809
2810
  'Card Number': 'Número do Cartão',
2810
2811
  'MM / YY': 'MM / AA',
2811
2812
  'CVC': 'Número de Segurança(CVC)',
2812
- 'Country or region': 'País ou região',
2813
2813
  'Postal Code': 'Cep',
2814
2814
  'Close': 'Fechar',
2815
2815
  'Please complete your billing address.': 'Preencha seu endereço de cobrança.',
@@ -1,5 +1,5 @@
1
1
  import { e as getAssetPath, r as registerInstance, f as Build, h, d as Host, g as getElement, a as createEvent } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
3
 
4
4
  let CACHED_MAP;
5
5
  const getIconMap = () => {
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-DQuL1Twl.js';
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["stripe-card-element-modal",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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);
8
+ return bootstrapLazy([["stripe-card-element-modal",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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
9
  };
10
10
 
11
11
  export { defineCustomElements };
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
4
  import './index-CBXaOfXU.js';
5
5
 
6
6
  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)}`;
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
4
  import { S as StripeAPIError } from './error-XRfh5Wrs.js';
5
5
  import './index-CBXaOfXU.js';
6
6
 
@@ -428,7 +428,7 @@ const StripeCardElement = class {
428
428
  // NOTE: `stripe-payment-sheet-wrap` is a legacy class name (leftover from a former
429
429
  // component name). External consumers may target it in their own CSS, so it is a
430
430
  // public DOM contract that MUST be kept for backward compatibility. Do not remove it.
431
- h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-card-element" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { id: "stripe-payment-request-button" }), h("div", null, h("div", { class: "stripe-section-title" }, i18n.t('Card information'))), h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Card Number')) : null, h("div", { id: "card-number" }))), h("div", { class: "stripe-input-column", style: { display: 'flex' } }, h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('MM / YY')) : null, h("div", { id: "card-expiry" })), h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('CVC')) : null, h("div", { id: "card-cvc" }))))), h("div", { id: "card-errors", class: "stripe-element-errors" }, errorMessage), this.zip ? (h("div", { style: { marginTop: '1.5rem' } }, h("div", { class: "stripe-section-title" }, i18n.t('Country or region')))) : null, this.zip ? (h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Postal Code')) : null, h("input", { id: "zip", name: "zip", type: "text", inputmode: "numeric", class: "StripeElement", style: { width: '100%' }, placeholder: i18n.t('Postal Code'), value: this.zipCode, onInput: e => {
431
+ h("div", { class: "stripe-payment-sheet-wrap" }, h("form", { id: "stripe-card-element" }, h("div", { class: "stripe-heading" }, i18n.t(this.sheetTitle)), h("div", { id: "stripe-payment-request-button" }), h("div", null, h("div", { class: "stripe-section-title" }, i18n.t('Card information'))), h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Card Number')) : null, h("div", { id: "card-number" }))), h("div", { class: "stripe-input-column", style: { display: 'flex' } }, h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('MM / YY')) : null, h("div", { id: "card-expiry" })), h("label", { style: { width: '50%' } }, this.showLabel ? h("lenged", null, i18n.t('CVC')) : null, h("div", { id: "card-cvc" }))))), h("div", { id: "card-errors", class: "stripe-element-errors" }, errorMessage), this.zip ? (h("div", { style: { marginTop: '1.5rem' } }, h("div", { class: "stripe-section-title" }, i18n.t('Postal Code')))) : null, this.zip ? (h("div", { class: "payment-info card visible" }, h("fieldset", { class: "stripe-input-box" }, h("div", null, h("label", null, this.showLabel ? h("lenged", null, i18n.t('Postal Code')) : null, h("input", { id: "zip", name: "zip", type: "text", inputmode: "numeric", class: "StripeElement", style: { width: '100%' }, placeholder: i18n.t('Postal Code'), value: this.zipCode, onInput: e => {
432
432
  this.zipCode = e.target.value;
433
433
  } })))))) : null, h("div", { style: { marginTop: '32px' } }, h("button", { type: "submit", disabled: disabled }, this.progress === 'loading' ? i18n.t('Loading') : i18n.t(this.buttonLabel))))));
434
434
  }
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
4
  import './index-CBXaOfXU.js';
5
5
 
6
6
  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}`;
@@ -44,5 +44,5 @@ var patchCloneNodeFix = (HTMLElementPrototype) => {
44
44
 
45
45
  patchBrowser().then(async (options) => {
46
46
  await globalScripts();
47
- return bootstrapLazy([["stripe-card-element-modal",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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);
47
+ return bootstrapLazy([["stripe-card-element-modal",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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",[[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);
48
48
  });
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
4
  import { S as StripeAPIError } from './error-XRfh5Wrs.js';
5
5
  import './index-CBXaOfXU.js';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
4
  import './index-CBXaOfXU.js';
5
5
 
6
6
  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)}`;
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, a as createEvent, h, g as getElement } from './index-C6bbmyga.js';
2
- import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
- import { s as serviceFactory } from './factory-BaGv8K_i.js';
4
- import { b as buildSubmitEventProps, c as confirmPaymentOrSetup, a as confirmCheckoutSession, i as isSubmitButtonDisabled } from './stripe-payment-element.helpers-CklK5RlF.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-HWdALSvT.js';
3
+ import { s as serviceFactory } from './factory-B_WxdnxM.js';
4
+ import { b as buildSubmitEventProps, c as confirmPaymentOrSetup, a as confirmCheckoutSession, i as isSubmitButtonDisabled } from './stripe-payment-element.helpers-PuWxhMNR.js';
5
5
  import './index-CBXaOfXU.js';
6
6
  import './error-XRfh5Wrs.js';
7
7
 
@@ -57,6 +57,7 @@ const StripePaymentElement = class {
57
57
  stripeAccount: options === null || options === void 0 ? void 0 : options.stripeAccount,
58
58
  applicationName: this.applicationName,
59
59
  elementsOptions: options === null || options === void 0 ? void 0 : options.elementsOptions,
60
+ defaultValues: options === null || options === void 0 ? void 0 : options.defaultValues,
60
61
  });
61
62
  await this.mountWhenLoaded(generation);
62
63
  }
@@ -101,14 +102,20 @@ const StripePaymentElement = class {
101
102
  options.stripeAccount = this.stripeService.state.stripeAccount;
102
103
  const hasOptionValue = Object.values(options).filter(value => value != null && value !== '').length > 0;
103
104
  if (this.hasCheckoutSessionClientSecret()) {
104
- this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, { stripeAccount: options.stripeAccount });
105
+ this.initStripeWithCheckoutSession(publishableKey, this.checkoutSessionClientSecret, {
106
+ stripeAccount: options.stripeAccount,
107
+ defaultValues: this.checkoutSessionDefaultValues,
108
+ });
105
109
  return;
106
110
  }
107
111
  this.initStripe(publishableKey, hasOptionValue ? options : undefined);
108
112
  }
109
113
  updateStripeAccountId(stripeAccount) {
110
114
  if (this.hasCheckoutSessionClientSecret()) {
111
- this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, { stripeAccount });
115
+ this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
116
+ stripeAccount: stripeAccount,
117
+ defaultValues: this.checkoutSessionDefaultValues,
118
+ });
112
119
  return;
113
120
  }
114
121
  this.initStripe(this.stripeService.state.publishableKey, {
@@ -136,6 +143,7 @@ const StripePaymentElement = class {
136
143
  if (this.publishableKey != null && this.publishableKey !== '' && newValue != null && newValue !== '') {
137
144
  await this.initStripeWithCheckoutSession(this.publishableKey, newValue, {
138
145
  stripeAccount: this.stripeAccount,
146
+ defaultValues: this.checkoutSessionDefaultValues,
139
147
  });
140
148
  // A new secret starts a fresh payment, so re-enable the submit button after a previous success
141
149
  if (this.progress === 'success') {
@@ -191,6 +199,7 @@ const StripePaymentElement = class {
191
199
  if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
192
200
  this.initStripeWithCheckoutSession(this.stripeService.state.publishableKey, this.checkoutSessionClientSecret, {
193
201
  stripeAccount: this.stripeService.state.stripeAccount,
202
+ defaultValues: this.checkoutSessionDefaultValues,
194
203
  });
195
204
  return;
196
205
  }
@@ -226,11 +235,12 @@ const StripePaymentElement = class {
226
235
  * @param checkout - The Stripe Checkout instance
227
236
  */
228
237
  async checkoutSessionFormSubmitAction(event, checkout) {
238
+ var _a;
229
239
  event.preventDefault();
230
240
  try {
231
- // Get current page URL for return_url
232
- const returnUrl = window.location.href;
233
- const result = await confirmCheckoutSession(checkout, returnUrl);
241
+ // returnUrl defaults to the current page; confirmCheckoutSession retries without it when the
242
+ // session was created with `return_url` (which rejects the argument before processing)
243
+ const result = await confirmCheckoutSession(checkout, (_a = this.checkoutSessionReturnUrl) !== null && _a !== void 0 ? _a : window.location.href, this.checkoutSessionEmail);
234
244
  this.checkoutSessionConfirmResultHandler(result);
235
245
  }
236
246
  catch (e) {
@@ -347,6 +357,7 @@ const StripePaymentElement = class {
347
357
  if (this.checkoutSessionClientSecret != null && this.checkoutSessionClientSecret !== '') {
348
358
  this.initStripeWithCheckoutSession(this.publishableKey, this.checkoutSessionClientSecret, {
349
359
  stripeAccount: this.stripeAccount,
360
+ defaultValues: this.checkoutSessionDefaultValues,
350
361
  });
351
362
  return;
352
363
  }