stripe-pwa-elements 4.0.3 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/{factory-Cm6zUD7R.js → factory-xOoxnMhx.js} +1 -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 +14 -4
  7. package/dist/cjs/stripe-currency-selector.cjs.entry.js +2 -2
  8. package/dist/cjs/stripe-elements.cjs.js +1 -1
  9. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +2 -2
  10. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +2 -2
  11. package/dist/cjs/stripe-payment-element.cjs.entry.js +11 -3
  12. package/dist/cjs/{stripe-payment-element.helpers-CvAhIqLt.js → stripe-payment-element.helpers-lafmSRmb.js} +3 -1
  13. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +3 -3
  14. package/dist/collection/components/stripe-card-element/stripe-card-element.js +13 -3
  15. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +3 -1
  16. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +9 -1
  17. package/dist/collection/utils/i18n.js +2 -2
  18. package/dist/components/i18n.js +1 -1
  19. package/dist/components/stripe-card-element2.js +1 -1
  20. package/dist/components/stripe-payment-element.helpers.js +1 -1
  21. package/dist/components/stripe-payment-element.js +1 -1
  22. package/dist/esm/{factory-BaGv8K_i.js → factory-CsurRVcp.js} +1 -1
  23. package/dist/esm/{i18n-CL5n3bOb.js → i18n-HWdALSvT.js} +2 -2
  24. package/dist/esm/ion-icon_2.entry.js +1 -1
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/stripe-address-element.entry.js +2 -2
  27. package/dist/esm/stripe-card-element.entry.js +14 -4
  28. package/dist/esm/stripe-currency-selector.entry.js +2 -2
  29. package/dist/esm/stripe-elements.js +1 -1
  30. package/dist/esm/stripe-express-checkout-element.entry.js +2 -2
  31. package/dist/esm/stripe-link-authentication-element.entry.js +2 -2
  32. package/dist/esm/stripe-payment-element.entry.js +11 -3
  33. package/dist/esm/{stripe-payment-element.helpers-Bu9RfxS4.js → stripe-payment-element.helpers-CklK5RlF.js} +3 -1
  34. package/dist/esm/stripe-payment-sheet.entry.js +3 -3
  35. package/dist/stripe-elements/{p-2e41699e.entry.js → p-50e495e3.entry.js} +1 -1
  36. package/dist/stripe-elements/p-855d1aee.entry.js +1 -0
  37. package/dist/stripe-elements/{p-f5552c81.entry.js → p-949a8bba.entry.js} +1 -1
  38. package/dist/stripe-elements/{p-DlMEZwSe.js → p-B2G-wquO.js} +1 -1
  39. package/dist/stripe-elements/p-BoZLkOAy.js +1 -0
  40. package/dist/stripe-elements/{p-CL5n3bOb.js → p-HWdALSvT.js} +1 -1
  41. package/dist/stripe-elements/p-a2d11152.entry.js +1 -0
  42. package/dist/stripe-elements/{p-b7c20e8e.entry.js → p-a45268d4.entry.js} +1 -1
  43. package/dist/stripe-elements/{p-3fc4583a.entry.js → p-b0f9ebba.entry.js} +1 -1
  44. package/dist/stripe-elements/{p-7e826964.entry.js → p-b4faa9db.entry.js} +1 -1
  45. package/dist/stripe-elements/{p-b62c9dae.entry.js → p-edbbe060.entry.js} +1 -1
  46. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  47. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +6 -0
  48. package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +5 -0
  49. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +2 -0
  50. package/dist/types/components.d.ts +2 -2
  51. package/package.json +1 -1
  52. package/readme.md +62 -28
  53. package/dist/stripe-elements/p-BhKXGROE.js +0 -1
  54. package/dist/stripe-elements/p-a395a5d1.entry.js +0 -1
  55. package/dist/stripe-elements/p-bec62526.entry.js +0 -1
@@ -1 +0,0 @@
1
- import{r as t,a as i,h as e,g as s}from"./p-C6bbmyga.js";import{c as n,i as r}from"./p-CL5n3bOb.js";import{s as o}from"./p-DlMEZwSe.js";import{b as a,c as h,a as l,i as c}from"./p-BhKXGROE.js";import"./p-CBXaOfXU.js";import"./p-XRfh5Wrs.js";const p=class{async initStripe(t,i){const e=++this.initGeneration;await this.stripeService.initialize(t,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName,clientSecret:this.intentClientSecret}),await this.mountWhenLoaded(e)}async initStripeWithCheckoutSession(t,i,e){const s=++this.initGeneration;await this.stripeService.initializeWithCheckoutSession(t,i,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName,elementsOptions:null==e?void 0:e.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 i={};i.stripeAccount=this.stripeService.state.stripeAccount;const e=Object.values(i).filter((t=>null!=t&&""!==t)).length>0;this.hasCheckoutSessionClientSecret()?this.initStripeWithCheckoutSession(t,this.checkoutSessionClientSecret,{stripeAccount:i.stripeAccount}):this.initStripe(t,e?i: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:i}=this.stripeService.state;null!=t&&""!==t&&await this.initStripe(t,{stripeAccount:i})}async updateCheckoutSessionClientSecret(t){null!=this.publishableKey&&""!==this.publishableKey&&null!=t&&""!==t&&await this.initStripeWithCheckoutSession(this.publishableKey,t,{stripeAccount:this.stripeAccount})}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.stripeService.getStripe(),i=!0===this.stripeService.state.isCheckoutSession;if(null==t)return void console.error("Stripe not properly initialized");const e=a({stripe:t,isCheckoutSession:i,checkout:this.stripeService.getCheckout(),checkoutSessionClientSecret:this.checkoutSessionClientSecret,elements:this.stripeService.getElements(),intentClientSecret:this.intentClientSecret});"error"in e?console.error(e.error):this.formSubmit.emit(e.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:i,elements:e}){t.preventDefault();try{const t=window.location.href,s=await h(i,e,this.intentType,t);this.defaultFormSubmitResultHandler(s)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}async checkoutSessionFormSubmitAction(t,i){t.preventDefault();try{const t=window.location.href,e=await l(i,t);this.checkoutSessionConfirmResultHandler(e)}catch(t){throw console.error(t),this.checkoutSessionConfirmResultHandler(t instanceof Error?t:new Error(String(t))),t}}constructor(e){t(this,e),this.stripeLoaded=i(this,"stripeLoaded",7),this.formSubmit=i(this,"formSubmit",7),this.defaultFormSubmitResult=i(this,"defaultFormSubmitResult",7),this.checkoutSessionConfirmResult=i(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=o.createStripeService(),this.paymentElementManager=o.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 i=this.stripeService.onChange("loadStripeStatus",(async e=>{t===this.initGeneration?"success"===e&&(await this.initElement(),t===this.initGeneration?(this.stripeLoadedEventHandler(),i()):i()):i()}))}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 i=this.stripeService.getStripe(),e=!0===this.stripeService.state.isCheckoutSession;if(null==i)return void console.error("Stripe not properly initialized");const s=a({stripe:i,isCheckoutSession:e,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?e&&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){const i=t instanceof Error?t.message:String(t);this.paymentElementManager.setError(i),this.progress="failure"}},t.addEventListener("submit",this._submitHandler)):console.error("Form element #stripe-payment-element not found")}componentDidLoad(){this.el.classList.add(n())}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:i}=this.stripeService.state,{errorMessage:s}=this.paymentElementManager.getState();if("failure"===t)return e("p",null,r.t("Failed to load Stripe"));const n=c({progress:this.progress,isCheckoutSession:!0===i,loadStripeStatus:t,intentClientSecret:this.intentClientSecret});return e("div",{class:"stripe-payment-sheet-wrap"},e("form",{id:"stripe-payment-element"},e("div",{class:"stripe-heading"},r.t(this.sheetTitle)),e("div",null,e("div",{class:"stripe-section-title"},r.t("Payment information"))),e("div",{class:"payment-info visible"},e("div",{id:"payment-element"})),e("div",{id:"payment-errors",class:"stripe-element-errors"},s),e("div",{style:{marginTop:"32px"}},e("button",{type:"submit",disabled:n},r.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return s(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}}};p.style=':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)}';export{p as stripe_payment_element}