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.
- package/dist/cjs/{factory-Cm6zUD7R.js → factory-xOoxnMhx.js} +1 -1
- package/dist/cjs/{i18n-lBbOeQt4.js → i18n-CWEsGqxV.js} +2 -2
- package/dist/cjs/ion-icon_2.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stripe-address-element.cjs.entry.js +2 -2
- package/dist/cjs/stripe-card-element.cjs.entry.js +14 -4
- package/dist/cjs/stripe-currency-selector.cjs.entry.js +2 -2
- package/dist/cjs/stripe-elements.cjs.js +1 -1
- package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +2 -2
- package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +2 -2
- package/dist/cjs/stripe-payment-element.cjs.entry.js +11 -3
- package/dist/cjs/{stripe-payment-element.helpers-CvAhIqLt.js → stripe-payment-element.helpers-lafmSRmb.js} +3 -1
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +3 -3
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +13 -3
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +3 -1
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +9 -1
- package/dist/collection/utils/i18n.js +2 -2
- package/dist/components/i18n.js +1 -1
- package/dist/components/stripe-card-element2.js +1 -1
- package/dist/components/stripe-payment-element.helpers.js +1 -1
- package/dist/components/stripe-payment-element.js +1 -1
- package/dist/esm/{factory-BaGv8K_i.js → factory-CsurRVcp.js} +1 -1
- package/dist/esm/{i18n-CL5n3bOb.js → i18n-HWdALSvT.js} +2 -2
- package/dist/esm/ion-icon_2.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stripe-address-element.entry.js +2 -2
- package/dist/esm/stripe-card-element.entry.js +14 -4
- package/dist/esm/stripe-currency-selector.entry.js +2 -2
- package/dist/esm/stripe-elements.js +1 -1
- package/dist/esm/stripe-express-checkout-element.entry.js +2 -2
- package/dist/esm/stripe-link-authentication-element.entry.js +2 -2
- package/dist/esm/stripe-payment-element.entry.js +11 -3
- package/dist/esm/{stripe-payment-element.helpers-Bu9RfxS4.js → stripe-payment-element.helpers-CklK5RlF.js} +3 -1
- package/dist/esm/stripe-payment-sheet.entry.js +3 -3
- package/dist/stripe-elements/{p-2e41699e.entry.js → p-50e495e3.entry.js} +1 -1
- package/dist/stripe-elements/p-855d1aee.entry.js +1 -0
- package/dist/stripe-elements/{p-f5552c81.entry.js → p-949a8bba.entry.js} +1 -1
- package/dist/stripe-elements/{p-DlMEZwSe.js → p-B2G-wquO.js} +1 -1
- package/dist/stripe-elements/p-BoZLkOAy.js +1 -0
- package/dist/stripe-elements/{p-CL5n3bOb.js → p-HWdALSvT.js} +1 -1
- package/dist/stripe-elements/p-a2d11152.entry.js +1 -0
- package/dist/stripe-elements/{p-b7c20e8e.entry.js → p-a45268d4.entry.js} +1 -1
- package/dist/stripe-elements/{p-3fc4583a.entry.js → p-b0f9ebba.entry.js} +1 -1
- package/dist/stripe-elements/{p-7e826964.entry.js → p-b4faa9db.entry.js} +1 -1
- package/dist/stripe-elements/{p-b62c9dae.entry.js → p-edbbe060.entry.js} +1 -1
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +6 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +5 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +2 -0
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/readme.md +62 -28
- package/dist/stripe-elements/p-BhKXGROE.js +0 -1
- package/dist/stripe-elements/p-a395a5d1.entry.js +0 -1
- package/dist/stripe-elements/p-bec62526.entry.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,a as e,h as i,g as s}from"./p-C6bbmyga.js";import{c as r,i as n}from"./p-HWdALSvT.js";import{s as o}from"./p-B2G-wquO.js";import{S as l}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const a=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},p=class{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,a(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}updateIntentClientSecret(){"success"===this.progress&&(this.progress="")}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,a(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new l(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(i){t(this,i),this.stripeLoaded=e(this,"stripeLoaded",7),this.formSubmit=e(this,"formSubmit",7),this.defaultFormSubmitResult=e(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=o.createStripeService(),this.cardElementManager=o.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,a(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const r={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,r):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,r):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:r}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=r&&t.setPaymentRequestShippingAddressEventHandler(r)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return i("p",null,n.t("Failed to load Stripe"));const s="loading"===this.progress||"success"===this.progress;return i("div",{class:"stripe-payment-sheet-wrap"},i("form",{id:"stripe-card-element"},i("div",{class:"stripe-heading"},n.t(this.sheetTitle)),i("div",{id:"stripe-payment-request-button"}),i("div",null,i("div",{class:"stripe-section-title"},n.t("Card information"))),i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,n.t("Card Number")):null,i("div",{id:"card-number"}))),i("div",{class:"stripe-input-column",style:{display:"flex"}},i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,n.t("MM / YY")):null,i("div",{id:"card-expiry"})),i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,n.t("CVC")):null,i("div",{id:"card-cvc"}))))),i("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?i("div",{style:{marginTop:"1.5rem"}},i("div",{class:"stripe-section-title"},n.t("Postal Code"))):null,this.zip?i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,n.t("Postal Code")):null,i("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:n.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,i("div",{style:{marginTop:"32px"}},i("button",{type:"submit",disabled:s},n.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}]}}};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;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.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 label{color:var(--color-label)}.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_card_element}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,a as t,h as i,d as n,g as s}from"./p-C6bbmyga.js";import{c as a,i as r}from"./p-CL5n3bOb.js";import{s as o,f as l}from"./p-DlMEZwSe.js";import{c}from"./p-BhKXGROE.js";import{S as d}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const h={phase:"idle",generation:0,pendingPresent:!1,openRequested:!1},p=[[/^pi_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"payment"],[/^seti_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"setup"]],u=e=>({state:e,effects:[]}),m=(e,t)=>e.pendingPresent?{state:Object.assign(Object.assign({},e),{pendingPresent:!1}),effects:[{type:"resolvePresent",result:t}]}:u(e),f=e=>{const t=m(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]}},y=(e,t,i)=>{if(""===t)return u(e);if("confirming"===e.phase)return u(Object.assign(Object.assign({},e),{deferredSecret:{clientSecret:t,source:i}}));const n="presented"===e.phase?f(e):u(e),s=e.generation+1,a=((e,t)=>"checkoutSession"===t?"checkoutSession":(e=>{const t=p.find((([t])=>t.test(e)));return null==t?void 0:t[1]})(e))(t,i);if(null==a){const e=m(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}]}},b=e=>{const{deferredSecret:t}=e.state;if(null==t)return e;const i=y(Object.assign(Object.assign({},e.state),{deferredSecret:void 0}),t.clientSecret,t.source);return{state:i.state,effects:[...e.effects,...i.effects]}},v=(e,t)=>"confirming"===e.phase&&e.generation===t;var g=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 w=["merchantDisplayName","paymentMethodLayout","defaultBillingDetails","returnURL","style","billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"],O={horizontal:"tabs",vertical:"accordion",automatic:"auto"},j={alwaysLight:"stripe",alwaysDark:"night"},S=e=>Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e))),k=e=>{const{postalCode:t}=e,i=g(e,["postalCode"]);return S(Object.assign(Object.assign({},i),{postal_code:t}))},C=e=>null==e?void 0:e?"auto":"never",_=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=S({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=S({applePay:C(a),googlePay:C(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=O[i]),null!=n){const{address:e}=n,t=g(n,["address"]),i=S(t);null!=e&&(i.address=k(e)),o.defaultValues={billingDetails:i}}return o},x=e=>{if(null!=e)return{theme:j[e]}},D=e=>{const{name:t,phone:i,address:n}=e,s=null==n?void 0:n.country;return S({name:t,phone:i,address:null==s||""===s?void 0:Object.assign(Object.assign({},k(n)),{country:s})})},P=e=>null==e||""===e,F=(e,t)=>new Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${e} is 'never', so defaultBillingDetails.${t} is required`),R=e=>Object.assign(new Error(e),{type:"validation_error",sheetValidation:!0}),q=["card_error","validation_error","api_connection_error","rate_limit_error","api_error"],E=e=>{const t=x(null==e?void 0:e.style);return null==t?void 0:{appearance:t}},L=(e,t)=>{if(null!=e&&"open"!==e.type)throw new d({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.`})},A=e=>null==e||""===e?void 0:e,z=class{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(i){e(this,i),this.paymentSheetLoaded=t(this,"paymentSheetLoaded",7),this.paymentSheetFailedToLoad=t(this,"paymentSheetFailedToLoad",7),this.paymentSheetCompleted=t(this,"paymentSheetCompleted",7),this.paymentSheetCanceled=t(this,"paymentSheetCanceled",7),this.paymentSheetFailed=t(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=h,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=o.createStripeService(),this.paymentElementManager=o.createPaymentElementManager(this.stripeService),this.billingAddressElementManager=o.createAddressElementManager(this.stripeService),this.shippingAddressElementManager=o.createAddressElementManager(this.stripeService),this.emailElementManager=o.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.open&&this.dispatch({type:"openRequested"}),this.startLoading()}componentDidLoad(){this.el.classList.add(a())}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=A(this.publishableKey);if(null==t)return;const i=A(this.checkoutSessionClientSecret),n=A(this.intentClientSecret),[s,a]=null!=i?[i,"checkoutSession"]:[n,"intent"];return null!=s?{key:JSON.stringify([t,null!==(e=A(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 y(e,t.clientSecret,t.source);case"loadSucceeded":{if(t.generation!==e.generation||"loading"!==e.phase)return u(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 u(e);const i=m(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 u(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 u(Object.assign(Object.assign({},e),{pendingPresent:!0,openRequested:!0}));case"presented":case"confirming":return u(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"}]}:u("idle"===e.phase||"loading"===e.phase?Object.assign(Object.assign({},e),{openRequested:!0}):e);case"closeRequested":if("presented"===e.phase){const t=f(e);return{state:Object.assign(Object.assign({},t.state),{phase:"ready"}),effects:t.effects}}return"idle"!==e.phase&&"loading"!==e.phase||!e.openRequested?u(e):f(e);case"submitted":return"presented"!==e.phase||null==e.intentKind?u(e):{state:Object.assign(Object.assign({},e),{phase:"confirming"}),effects:[{type:"confirm",generation:e.generation,intentKind:e.intentKind}]};case"confirmSucceeded":{if(!v(e,t.generation))return u(e);const i=m(Object.assign(Object.assign({},e),{phase:"completed"}),"paymentSheetCompleted");return b({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetCompleted"},...i.effects]})}case"confirmDeclined":return v(e,t.generation)?b({state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"showError",message:t.message}]}):u(e);case"confirmFailed":{if(!v(e,t.generation))return u(e);const i=m(Object.assign(Object.assign({},e),{phase:"errored"}),"paymentSheetFailed");return b({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(P(d[e]))throw F(e,e);h[e]=d[e]}})),"never"===c.address){const e=d.address;if(null==e||P(e.country))throw F("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:D(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=P(d.email)?{}:{defaultValues:{email:d.email}});const m=null==e?void 0:e.shippingDetails;if(null!=m&&"payment"===t){const e={mode:"shipping",defaultValues:D(m)};P(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 new Error("Failed to load Stripe.js");const r=x(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,_(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 l(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 R("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(P(a))throw R("Please enter your email address.");if(!1===t.emailComplete||null==t.emailComplete&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))throw R("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 c(this.stripeService.getStripe(),n,t,a,r)}))}async runConfirm(e,t){var i,n;try{this.lastResult=await t(),this.dispatch({type:"confirmSucceeded",generation:e})}catch(t){const s=null!==(i=t.message)&&void 0!==i?i:String(t),a=!0===(null==(n=t)?void 0:n.sheetValidation)?r.t(s):s;if((e=>{const t=null==e?void 0:e.type;return"string"==typeof t&&q.includes(t)})(t))return void this.dispatch({type:"confirmDeclined",generation:e,message:a});this.lastError=t,this.dispatch({type:"confirmFailed",generation:e,message:a})}}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:E(this.options)}),e!==this.sheet.generation)return;if("success"!==this.stripeService.state.loadStripeStatus)throw new Error("Failed to load Stripe.js");await this.paymentElementManager.initialize(this.el,(e=>{const{layout:t}=_(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 new Error("Checkout Session is not initialized");return(async(e,t,i)=>{const n=await e.loadActions();if("error"===n.type)throw new d({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};L(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(L(a(),t),"paymentFailed"===e)throw new d({type:"card_error",code:e,message:t});throw new d({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&&!w.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,s;const{phase:a}=this.sheet,o="confirming"===a;return i(n,{key:"e6b2c3cb168039eb428eaaee1dce598f534c18e7"},i("stripe-modal",{key:"ef1515b07cca402c4db8818e2e94ca80e4d954c2",open:this.visible,showCloseButton:!o,onClose:this.handleModalClose},i("div",{key:"9252fa1653b206d211756c94325c73a8ec482a37",class:"stripe-payment-sheet-wrap"},i("form",{key:"904a54f2439e0356c2cbf9227326efe446aa08ce",id:"stripe-payment-sheet",onSubmit:this.handleSubmit},i("div",{key:"103d81e3c56cfba1c421e1bf140a49e2b392c6b5",class:"stripe-heading"},r.t(this.sheetTitle)),i("div",{key:"cda58a48db7b04af1981407b7100def815404e35",class:"payment-info visible"},i("div",{key:"cbe248666aa4807c25d492df1ab1de017bc78e2c",class:"stripe-payment-sheet-email"},null!=(null===(e=this.collection)||void 0===e?void 0:e.emailElement)&&i("div",{key:"b0210c6cce85d1affaa83e3fa30785158c9bab98",id:"link-authentication-element"})),i("div",{key:"2420956298e5b36c63f3fbea6b4e32429b7ace27",class:"stripe-payment-sheet-shipping-address"},null!=(null===(t=this.collection)||void 0===t?void 0:t.shippingAddressElement)&&i("div",{key:"ae41335a42c59598e1addbfdea0a13342c026456",id:"address-element"})),i("div",{key:"3196844c9396c40548a3c632733565027df3cea7",class:"stripe-payment-sheet-billing-address"},null!=(null===(s=this.collection)||void 0===s?void 0:s.billingAddressElement)&&i("div",{key:"269a99368975db70722fc181a1c099859f23d3d6",id:"address-element"})),i("div",{key:"2a63173a607501ff08ac072956cdbe462a4400c1",id:"payment-element"})),i("div",{key:"7a72a86097aca2af6491c56b52258286ef820283",class:"stripe-element-errors",role:"alert"},this.errorMessage),i("div",{key:"10f05d5ecfa53cde350f00acffd86e232e370fe7",class:"stripe-submit"},i("button",{key:"a7ad3e538b94403bd8c71b31bd405c1b0c59543c",type:"submit",disabled:"presented"!==a},r.t(o?"Loading":this.buttonLabel)))))))}get el(){return s(this)}static get watchers(){return{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}}};z.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{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)}';export{z as stripe_payment_sheet}
|
|
1
|
+
import{r as e,a as t,h as i,d as s,g as n}from"./p-C6bbmyga.js";import{c as a,i as r}from"./p-HWdALSvT.js";import{s as o,f as l}from"./p-B2G-wquO.js";import{c}from"./p-BoZLkOAy.js";import{S as d}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const h={phase:"idle",generation:0,pendingPresent:!1,openRequested:!1},p=[[/^pi_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"payment"],[/^seti_[A-Za-z0-9]+_secret_[A-Za-z0-9]+$/,"setup"]],u=e=>({state:e,effects:[]}),m=(e,t)=>e.pendingPresent?{state:Object.assign(Object.assign({},e),{pendingPresent:!1}),effects:[{type:"resolvePresent",result:t}]}:u(e),f=e=>{const t=m(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]}},y=(e,t,i)=>{if(""===t)return u(e);if("confirming"===e.phase)return u(Object.assign(Object.assign({},e),{deferredSecret:{clientSecret:t,source:i}}));const s="presented"===e.phase?f(e):u(e),n=e.generation+1,a=((e,t)=>"checkoutSession"===t?"checkoutSession":(e=>{const t=p.find((([t])=>t.test(e)));return null==t?void 0:t[1]})(e))(t,i);if(null==a){const e=m(Object.assign(Object.assign({},s.state),{phase:"loadFailed",generation:n,intentKind:void 0,openRequested:!1}),"paymentSheetFailed");return{state:e.state,effects:[...s.effects,{type:"emit",event:"paymentSheetFailedToLoad"},...e.effects]}}return{state:Object.assign(Object.assign({},s.state),{phase:"loading",generation:n,intentKind:a}),effects:[...s.effects,{type:"load",generation:n,clientSecret:t,intentKind:a}]}},b=e=>{const{deferredSecret:t}=e.state;if(null==t)return e;const i=y(Object.assign(Object.assign({},e.state),{deferredSecret:void 0}),t.clientSecret,t.source);return{state:i.state,effects:[...e.effects,...i.effects]}},v=(e,t)=>"confirming"===e.phase&&e.generation===t;var g=function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(i[s[n]]=e[s[n]])}return i};const w=["merchantDisplayName","paymentMethodLayout","defaultBillingDetails","returnURL","style","billingDetailsCollectionConfiguration","shippingDetails","enableApplePay","enableGooglePay"],O={horizontal:"tabs",vertical:"accordion",automatic:"auto"},j={alwaysLight:"stripe",alwaysDark:"night"},S=e=>Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e))),k=e=>{const{postalCode:t}=e,i=g(e,["postalCode"]);return S(Object.assign(Object.assign({},i),{postal_code:t}))},C=e=>null==e?void 0:e?"auto":"never",_=e=>{if(null==e)return{};const{merchantDisplayName:t,paymentMethodLayout:i,defaultBillingDetails:s,billingDetailsCollectionConfiguration:n,enableApplePay:a,enableGooglePay:r}=e,o={},l=(e=>{if(null==e)return;const{email:t,name:i,phone:s,address:n}=e,a=S({email:"never"===t||"always"===t?"never":void 0,name:"never"===i?"never":void 0,phone:"never"===s||"always"===s&&"full"===n?"never":void 0,address:"never"===n||"full"===n?"never":void 0});return 0===Object.keys(a).length?void 0:a})(n),c=S({applePay:C(a),googlePay:C(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=O[i]),null!=s){const{address:e}=s,t=g(s,["address"]),i=S(t);null!=e&&(i.address=k(e)),o.defaultValues={billingDetails:i}}return o},x=e=>{if(null!=e)return{theme:j[e]}},D=e=>{const{name:t,phone:i,address:s}=e,n=null==s?void 0:s.country;return S({name:t,phone:i,address:null==n||""===n?void 0:Object.assign(Object.assign({},k(s)),{country:n})})},P=e=>null==e||""===e,F=(e,t)=>new Error(`<stripe-payment-sheet>: billingDetailsCollectionConfiguration.${e} is 'never', so defaultBillingDetails.${t} is required`),q=e=>Object.assign(new Error(e),{type:"validation_error",sheetValidation:!0}),R=["card_error","validation_error","api_connection_error","rate_limit_error","api_error"],A=e=>{const t=x(null==e?void 0:e.style);return null==t?void 0:{appearance:t}},L=(e,t)=>{if(null!=e&&"open"!==e.type)throw new d({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.`})},E=e=>null==e||""===e?void 0:e,z=class{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(i){e(this,i),this.paymentSheetLoaded=t(this,"paymentSheetLoaded",7),this.paymentSheetFailedToLoad=t(this,"paymentSheetFailedToLoad",7),this.paymentSheetCompleted=t(this,"paymentSheetCompleted",7),this.paymentSheetCanceled=t(this,"paymentSheetCanceled",7),this.paymentSheetFailed=t(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=h,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=o.createStripeService(),this.paymentElementManager=o.createPaymentElementManager(this.stripeService),this.billingAddressElementManager=o.createAddressElementManager(this.stripeService),this.shippingAddressElementManager=o.createAddressElementManager(this.stripeService),this.emailElementManager=o.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.open&&this.dispatch({type:"openRequested"}),this.startLoading()}componentDidLoad(){this.el.classList.add(a())}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=E(this.publishableKey);if(null==t)return;const i=E(this.checkoutSessionClientSecret),s=E(this.intentClientSecret),[n,a]=null!=i?[i,"checkoutSession"]:[s,"intent"];return null!=n?{key:JSON.stringify([t,null!==(e=E(this.stripeAccount))&&void 0!==e?e:null,a,n]),clientSecret:n,source:a}:void 0}dispatch(e){const{state:t,effects:i}=((e,t)=>{switch(t.type){case"secretChanged":return y(e,t.clientSecret,t.source);case"loadSucceeded":{if(t.generation!==e.generation||"loading"!==e.phase)return u(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 u(e);const i=m(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 u(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 u(Object.assign(Object.assign({},e),{pendingPresent:!0,openRequested:!0}));case"presented":case"confirming":return u(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"}]}:u("idle"===e.phase||"loading"===e.phase?Object.assign(Object.assign({},e),{openRequested:!0}):e);case"closeRequested":if("presented"===e.phase){const t=f(e);return{state:Object.assign(Object.assign({},t.state),{phase:"ready"}),effects:t.effects}}return"idle"!==e.phase&&"loading"!==e.phase||!e.openRequested?u(e):f(e);case"submitted":return"presented"!==e.phase||null==e.intentKind?u(e):{state:Object.assign(Object.assign({},e),{phase:"confirming"}),effects:[{type:"confirm",generation:e.generation,intentKind:e.intentKind}]};case"confirmSucceeded":{if(!v(e,t.generation))return u(e);const i=m(Object.assign(Object.assign({},e),{phase:"completed"}),"paymentSheetCompleted");return b({state:i.state,effects:[{type:"hide"},{type:"emit",event:"paymentSheetCompleted"},...i.effects]})}case"confirmDeclined":return v(e,t.generation)?b({state:Object.assign(Object.assign({},e),{phase:"presented"}),effects:[{type:"showError",message:t.message}]}):u(e);case"confirmFailed":{if(!v(e,t.generation))return u(e);const i=m(Object.assign(Object.assign({},e),{phase:"errored"}),"paymentSheetFailed");return b({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 s;this.warnUnsupportedOptions(i);const n=()=>e!==this.sheet.generation;try{const a=((e,t)=>{var i,s,n,a,r,o,l;const c=null!==(i=null==e?void 0:e.billingDetailsCollectionConfiguration)&&void 0!==i?i:{},d=null!==(s=null==e?void 0:e.defaultBillingDetails)&&void 0!==s?s:{},h={};if(["email","name","phone"].forEach((e=>{if("never"===c[e]){if(P(d[e]))throw F(e,e);h[e]=d[e]}})),"never"===c.address){const e=d.address;if(null==e||P(e.country))throw F("address","address.country");h.address={line1:null!==(n=e.line1)&&void 0!==n?n:"",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:D(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=P(d.email)?{}:{defaultValues:{email:d.email}});const m=null==e?void 0:e.shippingDetails;if(null!=m&&"payment"===t){const e={mode:"shipping",defaultValues:D(m)};P(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}),n())return;if("success"!==this.stripeService.state.loadStripeStatus)throw new Error("Failed to load Stripe.js");const r=x(null===(s=this.options)||void 0===s?void 0:s.style);if(null!=r&&(await this.stripeService.getElements().update({appearance:r}),n()))return;if(!await this.mountExtraElements(a,n))return;await this.paymentElementManager.initialize(this.el,_(this.options)),this.dispatch({type:"loadSucceeded",generation:e})}catch(t){if(n())return;this.lastError=t,this.dispatch({type:"loadFailed",generation:e})}}async mountExtraElements(e,t){this.collection=e;const{emailElement:i,shippingAddressElement:s,billingAddressElement:n}=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:s&&(e=>this.shippingAddressElementManager.initialize(e,s))},{manager:this.billingAddressElementManager,selector:".stripe-payment-sheet-billing-address",mount:n&&(e=>this.billingAddressElementManager.initialize(e,n))}];for(const{manager:e,selector:i,mount:s}of a){if(null==s){e.unmount();continue}const n=await l(this.el,i);if(t())return!1;if(await s(n),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,s=null!=t.emailElement?this.emailElementManager.getState():void 0,n=((e,t)=>{var i,s;const n={};if(null!=e.billingAddressElement){const i=t.billingAddress;if(null==i||!i.complete)throw q("Please complete your billing address.");n.name=i.value.name,n.address=i.value.address,e.collectPhoneFromAddress&&(n.phone=i.value.phone)}if(null!=e.emailElement){const a=null!==(i=t.email)&&void 0!==i?i:null===(s=e.emailElement.defaultValues)||void 0===s?void 0:s.email;if(P(a))throw q("Please enter your email address.");if(!1===t.emailComplete||null==t.emailComplete&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))throw q("Please enter a valid email address.");n.email=a}return Object.assign(n,e.fixedBillingDetails),0===Object.keys(n).length?void 0:n})(t,{billingAddress:i,email:null==s?void 0:s.email,emailComplete:null==s?void 0:s.complete});return null==n?void 0:{payment_method_data:{billing_details:n}}}confirm(e,t){return this.runConfirm(e,(async()=>{var e,i;const s=this.stripeService.getElements(),{error:n}=await s.submit();if(null!=n)throw n;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 c(this.stripeService.getStripe(),s,t,a,r)}))}async runConfirm(e,t){var i,s;try{this.lastResult=await t(),this.dispatch({type:"confirmSucceeded",generation:e})}catch(t){const n=null!==(i=t.message)&&void 0!==i?i:String(t),a=!0===(null==(s=t)?void 0:s.sheetValidation)?r.t(n):n;if((e=>{const t=null==e?void 0:e.type;return"string"==typeof t&&R.includes(t)})(t))return void this.dispatch({type:"confirmDeclined",generation:e,message:a});this.lastError=t,this.dispatch({type:"confirmFailed",generation:e,message:a})}}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:A(this.options)}),e!==this.sheet.generation)return;if("success"!==this.stripeService.state.loadStripeStatus)throw new Error("Failed to load Stripe.js");await this.paymentElementManager.initialize(this.el,(e=>{const{layout:t}=_(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 s=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 new Error("Checkout Session is not initialized");return(async(e,t,i)=>{const s=await e.loadActions();if("error"===s.type)throw new d({type:"api_error",code:"checkout_session_error",message:s.error.message});const{actions:n}=s,a=()=>{var e,t;return null===(t=null===(e=n.getSession)||void 0===e?void 0:e.call(n))||void 0===t?void 0:t.status};L(a());const r=await n.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(L(a(),t),"paymentFailed"===e)throw new d({type:"card_error",code:e,message:t});throw new d({type:"api_error",code:"checkout_session_error",message:t})}return r})(i,s,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&&!w.includes(e))).map((([e])=>e)),s=e.billingDetailsCollectionConfiguration;return"always"===(null==s?void 0:s.name)&&i.push("billingDetailsCollectionConfiguration.name"),"always"===(null==s?void 0:s.phone)&&"full"!==s.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,s=["name","phone","address"].filter((e=>null!=(null==i?void 0:i[e]))).map((e=>`defaultBillingDetails.${e}`));return null!=t&&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,n;const{phase:a}=this.sheet,o="confirming"===a;return i(s,{key:"e6b2c3cb168039eb428eaaee1dce598f534c18e7"},i("stripe-modal",{key:"ef1515b07cca402c4db8818e2e94ca80e4d954c2",open:this.visible,showCloseButton:!o,onClose:this.handleModalClose},i("div",{key:"9252fa1653b206d211756c94325c73a8ec482a37",class:"stripe-payment-sheet-wrap"},i("form",{key:"904a54f2439e0356c2cbf9227326efe446aa08ce",id:"stripe-payment-sheet",onSubmit:this.handleSubmit},i("div",{key:"103d81e3c56cfba1c421e1bf140a49e2b392c6b5",class:"stripe-heading"},r.t(this.sheetTitle)),i("div",{key:"cda58a48db7b04af1981407b7100def815404e35",class:"payment-info visible"},i("div",{key:"cbe248666aa4807c25d492df1ab1de017bc78e2c",class:"stripe-payment-sheet-email"},null!=(null===(e=this.collection)||void 0===e?void 0:e.emailElement)&&i("div",{key:"b0210c6cce85d1affaa83e3fa30785158c9bab98",id:"link-authentication-element"})),i("div",{key:"2420956298e5b36c63f3fbea6b4e32429b7ace27",class:"stripe-payment-sheet-shipping-address"},null!=(null===(t=this.collection)||void 0===t?void 0:t.shippingAddressElement)&&i("div",{key:"ae41335a42c59598e1addbfdea0a13342c026456",id:"address-element"})),i("div",{key:"3196844c9396c40548a3c632733565027df3cea7",class:"stripe-payment-sheet-billing-address"},null!=(null===(n=this.collection)||void 0===n?void 0:n.billingAddressElement)&&i("div",{key:"269a99368975db70722fc181a1c099859f23d3d6",id:"address-element"})),i("div",{key:"2a63173a607501ff08ac072956cdbe462a4400c1",id:"payment-element"})),i("div",{key:"7a72a86097aca2af6491c56b52258286ef820283",class:"stripe-element-errors",role:"alert"},this.errorMessage),i("div",{key:"10f05d5ecfa53cde350f00acffd86e232e370fe7",class:"stripe-submit"},i("button",{key:"a7ad3e538b94403bd8c71b31bd405c1b0c59543c",type:"submit",disabled:"presented"!==a},r.t(o?"Loading":this.buttonLabel)))))))}get el(){return n(this)}static get watchers(){return{publishableKey:[{handleSecretChange:0}],intentClientSecret:[{handleSecretChange:0}],checkoutSessionClientSecret:[{handleSecretChange:0}],stripeAccount:[{handleSecretChange:0}],open:[{handleOpenChange:0}]}}};z.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{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)}';export{z as stripe_payment_sheet}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,a as e,h as s,g as i}from"./p-C6bbmyga.js";import{c as r,i as o}from"./p-
|
|
1
|
+
import{r as t,a as e,h as s,g as i}from"./p-C6bbmyga.js";import{c as r,i as o}from"./p-HWdALSvT.js";import{s as n}from"./p-B2G-wquO.js";import{S as a}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const c=class{updatePublishableKey(t){const e={};e.stripeAccount=this.stripeService.state.stripeAccount;const s=Object.values(e).filter(Boolean).length>0;this.initStripe(t,s?e:void 0)}updateStripeAccountId(t){this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:t})}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.expressCheckoutManager.setError(t),this}async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName,clientSecret:this.clientSecret,elementsOptions:this.buildElementsOptions()}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}buildElementsOptions(){if(null!=this.currency&&""!==this.currency){if("setup"===this.intentType)return{mode:"setup",currency:this.currency};if(void 0!==this.amount)return{mode:"payment",amount:this.amount,currency:this.currency}}}async updateElementOptions(t){return this.expressCheckoutManager.update(t),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async defaultConfirmResultHandler(t){this.defaultConfirmResult.emit(t)}constructor(s){t(this,s),this.stripeLoaded=e(this,"stripeLoaded",7),this.confirm=e(this,"confirm",7),this.expressCheckoutClick=e(this,"expressCheckoutClick",7),this.cancel=e(this,"cancel",7),this.defaultConfirmResult=e(this,"defaultConfirmResult",7),this.intentType="payment",this.applicationName="stripe-pwa-elements",this.shouldUseDefaultConfirmAction=!0,this.progress="",this.stripeService=n.createStripeService(),this.expressCheckoutManager=n.createExpressCheckoutElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}componentWillUpdate(){null!=this.stripeService.state.publishableKey&&""!==this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}async defaultConfirmAction(t){try{this.progress="loading";const e=this.stripeService.getStripe(),{intentType:s,clientSecret:i}=this;if(null==e)throw new Error("Stripe not initialized");if(null==i||""===i)throw new Error("Client secret is required");const r=await(()=>"payment"===s?e.confirmPayment({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}):e.confirmSetup({elements:this.stripeService.getElements(),clientSecret:i,confirmParams:{return_url:`${window.location.origin}${window.location.pathname}`},redirect:"if_required"}))();if(null!=r.error)throw new a(r.error);t.complete("success"),this.progress="success",this.defaultConfirmResultHandler(r)}catch(e){console.error(e),t.complete("fail"),this.expressCheckoutManager.setError(e.message),this.progress="failure",this.defaultConfirmResultHandler(e)}}async initElement(){const t={mode:"payment"===this.intentType?"payment":"setup"};if(void 0!==this.amount&&(t.amount=this.amount),null!=this.currency&&""!==this.currency&&(t.currency=this.currency),null!=this.buttonHeight&&""!==this.buttonHeight)if("string"==typeof this.buttonHeight){const e=parseInt(this.buttonHeight.replace("px",""),10);isNaN(e)||(t.buttonHeight=e)}else t.buttonHeight=this.buttonHeight;await this.expressCheckoutManager.initialize(this.el,t,{onConfirm:async t=>{this.confirm.emit(t),this.shouldUseDefaultConfirmAction&&null!=this.clientSecret&&""!==this.clientSecret&&await this.defaultConfirmAction(t)},onClick:t=>{this.expressCheckoutClick.emit(t)},onCancel:()=>{this.cancel.emit(),this.progress=""}})}componentDidLoad(){this.el.classList.add(r())}disconnectedCallback(){this.expressCheckoutManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e,isReady:i}=this.expressCheckoutManager.getState();return"failure"===t?s("p",null,o.t("Failed to load Stripe")):"loading"===t?s("p",null,o.t("Loading")):s("div",{class:"stripe-express-checkout-wrap"},s("div",{id:"express-checkout-element"}),e&&s("div",{id:"express-checkout-errors",class:"stripe-element-errors"},e),!i&&"success"===t&&s("div",{class:"stripe-express-checkout-loading"},o.t("Loading")))}get el(){return i(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};c.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-express-checkout-wrap{width:100%;max-width:500px;margin:0 auto;padding:1rem 0}.stripe-express-checkout-wrap #express-checkout-element{margin-bottom:1rem}.stripe-express-checkout-wrap .stripe-element-errors{color:var(--stripe-error-color, #fa755a);font-size:14px;margin-top:0.5rem;padding:0.5rem;background-color:var(--stripe-error-bg, #fff5f5);border:1px solid var(--stripe-error-border, #fdd);border-radius:6px}.stripe-express-checkout-wrap .stripe-express-checkout-loading{text-align:center;padding:1rem;color:var(--stripe-loading-color, #6772e5);font-size:14px}";export{c as stripe_express_checkout_element}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,r as t,f as i,h as e,d as n,g as s,a as r}from"./p-C6bbmyga.js";import{c as a,i as l}from"./p-CL5n3bOb.js";let c;const d=(o,t,i,e,n)=>(i="ios"===(i&&b(i))?"ios":"md",e&&"ios"===i?o=b(e):n&&"md"===i?o=b(n):(o||!t||u(t)||(o=t),f(o)&&(o=b(o))),f(o)&&""!==o.trim()?""!==o.replace(/[a-z]|-|\d/gi,"")?null:o:null),h=o=>f(o)&&(o=o.trim(),u(o))?o:null,u=o=>o.length>0&&/(\/|\.)/.test(o),f=o=>"string"==typeof o,b=o=>o.toLowerCase(),m=o=>{if(1===o.nodeType){if("script"===o.nodeName.toLowerCase())return!1;for(let t=0;t<o.attributes.length;t++){const i=o.attributes[t].name;if(f(i)&&0===i.toLowerCase().indexOf("on"))return!1}for(let t=0;t<o.childNodes.length;t++)if(!m(o.childNodes[t]))return!1}return!0},p=new Map,y=new Map;let v;function g(o){return p.set(o,""),""}const x=class{constructor(o){t(this,o),this.iconName=null,this.inheritedAttributes={},this.didLoadIcon=!1,this.isVisible=!1,this.mode=w(),this.lazy=!1,this.sanitize=!0}componentWillLoad(){this.inheritedAttributes=((o,t=[])=>{const i={};return t.forEach((t=>{o.hasAttribute(t)&&(null!==o.getAttribute(t)&&(i[t]=o.getAttribute(t)),o.removeAttribute(t))})),i})(this.el,["aria-label"])}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=!0,this.loadIcon()}))}componentDidLoad(){this.didLoadIcon||this.loadIcon()}disconnectedCallback(){this.io&&(this.io.disconnect(),this.io=void 0)}waitUntilVisible(o,t,e){if(!Boolean(i.isBrowser&&this.lazy&&"undefined"!=typeof window&&window.IntersectionObserver))return e();const n=this.io=new window.IntersectionObserver((o=>{o[0].isIntersecting&&(n.disconnect(),this.io=void 0,e())}),{rootMargin:t});n.observe(o)}loadIcon(){if(i.isBrowser&&this.isVisible){const t=(t=>{let i=h(t.src);if(i)return i;if(i=d(t.name,t.icon,t.mode,t.ios,t.md),i)return((t,i)=>{const e=(()=>{if("undefined"==typeof window)return new Map;if(!c){const o=window;o.Ionicons=o.Ionicons||{},c=o.Ionicons.map=o.Ionicons.map||new Map}return c})().get(t);if(e)return e;try{return o(`svg/${t}.svg`)}catch(o){console.log("e",o),console.warn(`[Ionicons Warning]: Could not load icon with name "${t}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`,i)}})(i,t);if(t.icon){if(i=h(t.icon),i)return i;if(i=h(t.icon[t.mode]),i)return i}return null})(this);t&&(p.has(t)?this.svgContent=p.get(t):((o,t)=>y.get(o)||("undefined"!=typeof fetch&&"undefined"!=typeof document?(o=>o.startsWith("data:image/svg+xml"))(o)&&(o=>-1!==o.indexOf(";utf8,"))(o)?Promise.resolve(function(o){v||(v=new DOMParser);const t=v.parseFromString(o,"text/html").querySelector("svg");if(t)return p.set(o,t.outerHTML),t.outerHTML;throw new Error(`Could not parse svg from ${o}`)}(o)):function(o,t){const i=fetch(o).then((i=>i.text().then((i=>{i&&!1!==t&&(i=(o=>{const t=document.createElement("div");t.innerHTML=o;for(let o=t.childNodes.length-1;o>=0;o--)"svg"!==t.childNodes[o].nodeName.toLowerCase()&&t.removeChild(t.childNodes[o]);const i=t.firstElementChild;if(i&&"svg"===i.nodeName.toLowerCase()){const o=i.getAttribute("class")||"";if(i.setAttribute("class",(o+" s-ion-icon").trim()),m(i))return t.innerHTML}return""})(i));const e=i||"";return p.set(o,e),e})).catch((()=>g(o))))).catch((()=>g(o)));return y.set(o,i),i}(o,t):Promise.resolve(g(o))))(t,this.sanitize).then((()=>this.svgContent=p.get(t))),this.didLoadIcon=!0)}this.iconName=d(this.name,this.icon,this.mode,this.ios,this.md)}render(){const{flipRtl:o,iconName:t,inheritedAttributes:s,el:r}=this,a=this.mode||"md",l=!!t&&(t.includes("arrow")||t.includes("chevron"))&&!1!==o,c=o||l;return e(n,Object.assign({key:"0578c899781ca145dd8205acd9670af39b57cf2e",role:"img",class:Object.assign(Object.assign({[a]:!0},k(this.color)),{[`icon-${this.size}`]:!!this.size,"flip-rtl":c,"icon-rtl":c&&(d=r,d&&""!==d.dir?"rtl"===d.dir.toLowerCase():"rtl"===(null===document||void 0===document?void 0:document.dir.toLowerCase()))})},s),e("div",i.isBrowser&&this.svgContent?{class:"icon-inner",innerHTML:this.svgContent}:{class:"icon-inner"}));var d}static get assetsDirs(){return["svg"]}get el(){return s(this)}static get watchers(){return{name:[{loadIcon:0}],src:[{loadIcon:0}],icon:[{loadIcon:0}],ios:[{loadIcon:0}],md:[{loadIcon:0}]}}},w=()=>i.isBrowser&&"undefined"!=typeof document&&document.documentElement.getAttribute("mode")||"md",k=o=>o?{"ion-color":!0,[`ion-color-${o}`]:!0}:null;x.style=":host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}";const C=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","audio[controls]","video[controls]","summary",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(","),M=o=>{if(!o.matches(C))return!1;const t=o.getAttribute("tabindex");if(null!==t&&Number(t)<0)return!1;if(o.hasAttribute("hidden")||null!==o.closest("[inert]"))return!1;const{checkVisibility:i}=o;return!("function"==typeof i&&!i.call(o,{visibilityProperty:!0}))},F=o=>{const t=[],i=o=>{for(const e of(o=>{if(o instanceof Element&&"SLOT"===o.tagName){const t=o,i="function"==typeof t.assignedElements?t.assignedElements({flatten:!0}):[];return i.length>0?i:Array.from(t.children)}return o instanceof Element&&null!=o.shadowRoot?Array.from(o.shadowRoot.children):Array.from(o.children)})(o))M(e)&&t.push(e),i(e)};return i(o),t},I=(o=document)=>{var t,i;let e=null!==(t=o.activeElement)&&void 0!==t?t:null;for(;null!=(null===(i=null==e?void 0:e.shadowRoot)||void 0===i?void 0:i.activeElement);)e=e.shadowRoot.activeElement;return e},O=class{constructor(o){t(this,o),this.close=r(this,"close",7),this.showCloseButton=!0,this.open=!1,this.renderedOpen=!1,this.returnFocusElement=null,this.shouldFocusOnRender=!1,this.lastFocusedInside=null,this.handleKeyDown=o=>{this.open&&"Escape"===o.key&&(o.isComposing||229===o.keyCode||o.defaultPrevented||(o.preventDefault(),o.stopPropagation(),this.closeModal()))},this.handleFocusIn=o=>{var t,i;const e=null!==(i=null===(t=o.composedPath)||void 0===t?void 0:t.call(o)[0])&&void 0!==i?i:o.target;void 0===(null==e?void 0:e.classList)||e.classList.contains("focus-guard")||(this.lastFocusedInside=e)},this.handleStartGuardFocus=o=>{this.cameFromFocusableInside(o)?this.focusLastElement():this.focusFirstElement()},this.handleEndGuardFocus=o=>{this.isInsideModal(this.getFocusOrigin(o))?this.focusFirstElement():this.focusLastElement()}}onOpenChange(o){o?(this.rememberFocus(),this.openModalAnimation()):(this.renderedOpen=!1,this.shouldFocusOnRender=!1,this.lastFocusedInside=null,this.close.emit(),this.restoreFocus())}async toggleModal(){this.open?await this.closeModal():await this.openModal()}async openModal(){this.open=!0}async closeModal(){this.open=!1}componentDidLoad(){const o=a();o&&this.el.classList.add(o),this.open&&(this.rememberFocus(),this.openModalAnimation())}componentDidRender(){this.shouldFocusOnRender&&this.renderedOpen&&(this.shouldFocusOnRender=!1,this.focusFirstElement())}rememberFocus(){var o;if("undefined"==typeof document)return;const t=I(document);null===t||t===document.body||this.el.contains(t)||!0===(null===(o=this.el.shadowRoot)||void 0===o?void 0:o.contains(t))||(this.returnFocusElement=t)}restoreFocus(){const o=this.returnFocusElement;this.returnFocusElement=null,null!=o&&o.isConnected&&"function"==typeof o.focus&&o.focus()}getTabbableElements(){return void 0===this.dialogElement?[]:F(this.dialogElement).filter((o=>!o.classList.contains("focus-guard")))}isInsideModal(o){var t;return null!==o&&(this.el.contains(o)||!0===(null===(t=this.dialogElement)||void 0===t?void 0:t.contains(o)))}getFocusOrigin(o){var t;return null!==(t=o.relatedTarget)&&void 0!==t?t:this.lastFocusedInside}cameFromFocusableInside(o){const t=this.getFocusOrigin(o);return t!==this.dialogElement&&this.isInsideModal(t)}focusContentAfterLoading(){var o;if(!this.open||void 0===this.contentElement)return;const t=I(document);(null===t||t===document.body||t===this.dialogElement||t===this.closeButtonElement)&&(null===(o=F(this.contentElement)[0])||void 0===o||o.focus())}focusFirstElement(){var o;const[t]=this.getTabbableElements();null===(o=null!=t?t:this.dialogElement)||void 0===o||o.focus()}focusLastElement(){var o,t;const i=this.getTabbableElements();null===(t=null!==(o=i[i.length-1])&&void 0!==o?o:this.dialogElement)||void 0===t||t.focus()}openModalAnimation(){if(this.shouldFocusOnRender=!0,!this.el.shadowRoot)return void(this.renderedOpen=!0);const o=this.el.shadowRoot.querySelector(".modal-child");o.scrollTop=0,o.classList.add("loading"),o.style.willChange="transform",o.addEventListener("transitionend",(()=>{o.style.willChange="auto",o.classList.remove("loading"),this.focusContentAfterLoading()}),{once:!0}),requestAnimationFrame((()=>{this.renderedOpen=this.open}))}render(){const{renderedOpen:o,showCloseButton:t}=this,i=o?0:-1;return e(n,{key:"55e0d63b18df165313ea3dd8b8f17aa0e0d0a253",role:o?"dialog":void 0,"aria-modal":o?"true":void 0,onKeyDown:this.handleKeyDown,onFocusin:this.handleFocusIn},e("div",{key:"adb0b493c0ae525f275025c03e1b8f02b04de1af",class:"modal-row"+(o?" open":""),onClick:()=>this.closeModal()},e("div",{key:"478bdad2ad481bfc2d8ffcf552788292fa93daed",class:"modal-child",tabindex:"-1",ref:o=>this.dialogElement=o,onClick:o=>o.stopPropagation()},e("div",{key:"8cc68ecefa37ec1db65f6c910d1da40f9144e722",class:"focus-guard",tabindex:i,onFocus:this.handleStartGuardFocus}),t?e("div",{class:"modal-close-button-wrap"},e("button",{type:"button",class:"modal-close-button","aria-label":l.t("Close"),ref:o=>this.closeButtonElement=o,onClick:()=>this.closeModal()},e("ion-icon",{name:"close",size:"large","aria-hidden":"true"}))):null,e("div",{key:"26271a75906a72e9944599f98da007bfebc2e348",class:"modal-loading"},e("svg",{key:"bc6b1267e2f3b6b1dd7209db55be717fddf9acd4",version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 2400 2400"},e("g",{key:"00ed54798ac376ed71f87a088fad2519cb1262dc","stroke-width":"200","stroke-linecap":"round",stroke:"currentColor",fill:"none",id:"spinner"},e("line",{key:"98242d65eb9470430bd5cc656cbb479232782746",x1:"1200",y1:"600",x2:"1200",y2:"100"}),e("line",{key:"2e2f0538a6d048465ef5f8a3d5ed1932f6c59270",opacity:"0.5",x1:"1200",y1:"2300",x2:"1200",y2:"1800"}),e("line",{key:"11f850b0e7dc0d259f35f56aab17068d4d25ca95",opacity:"0.917",x1:"900",y1:"680.4",x2:"650",y2:"247.4"}),e("line",{key:"14c3226b5d2741902f428a208966adf016c1bb7e",opacity:"0.417",x1:"1750",y1:"2152.6",x2:"1500",y2:"1719.6"}),e("line",{key:"d41da322484b62c1db1df72b9bd1bcc0dbb85a2c",opacity:"0.833",x1:"680.4",y1:"900",x2:"247.4",y2:"650"}),e("line",{key:"246dcdd4a011775dc8fea8a05cfcfc429d5bd03c",opacity:"0.333",x1:"2152.6",y1:"1750",x2:"1719.6",y2:"1500"}),e("line",{key:"f0a2d217a33a8caa6995a30d840002cb8c076e8d",opacity:"0.75",x1:"600",y1:"1200",x2:"100",y2:"1200"}),e("line",{key:"7552fb2c04f85c54b8bcc2235a32690e4489177f",opacity:"0.25",x1:"2300",y1:"1200",x2:"1800",y2:"1200"}),e("line",{key:"7b5a62164a0ef759b057f9100c7c5af834c9f6b7",opacity:"0.667",x1:"680.4",y1:"1500",x2:"247.4",y2:"1750"}),e("line",{key:"d36af9d23059da4ca91147084e47ba94e19f5ada",opacity:"0.167",x1:"2152.6",y1:"650",x2:"1719.6",y2:"900"}),e("line",{key:"f8eed2a97d817b68e0b29f5b5037d34d46a79a46",opacity:"0.583",x1:"900",y1:"1719.6",x2:"650",y2:"2152.6"}),e("line",{key:"1641d577b703e213157bc553966e434a40ba7158",opacity:"0.083",x1:"1750",y1:"247.4",x2:"1500",y2:"680.4"}),e("animateTransform",{key:"60fb2d30c248db1b4195d6015dc96225a15e4010",attributeName:"transform",attributeType:"XML",type:"rotate",keyTimes:"0;0.08333;0.16667;0.25;0.33333;0.41667;0.5;0.58333;0.66667;0.75;0.83333;0.91667",values:"0 1199 1199;30 1199 1199;60 1199 1199;90 1199 1199;120 1199 1199;150 1199 1199;180 1199 1199;210 1199 1199;240 1199 1199;270 1199 1199;300 1199 1199;330 1199 1199",dur:"0.83333s",begin:"0s",repeatCount:"indefinite",calcMode:"discrete"})))),e("div",{key:"27d3b71da43e5935dff3eff2e1bc507a24261b70",class:"modal-content",ref:o=>this.contentElement=o},e("slot",{key:"641408238d3969b830d1f3e9398be6f05bc1f65b"})),e("div",{key:"c6178542b98a99d6a50b74270adc273671d5cc19",class:"focus-guard",tabindex:i,onFocus:this.handleEndGuardFocus}))))}get el(){return s(this)}static get watchers(){return{open:[{onOpenChange:0}]}}};O.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}: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}.modal-row{opacity:0;pointer-events:none;will-change:transform;visibility:hidden}.modal-row.open{opacity:1;pointer-events:auto;visibility:visible;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:1ch;background:rgba(0, 0, 0, 0.3)}.modal-row .modal-child{transform:translateY(100%);transition:transform 420ms ease;position:relative}.modal-row .modal-child .modal-loading{display:none;position:absolute;top:160px;left:50%;transform:translateX(-50%);width:24px;height:24px}.modal-row .modal-child.loading .modal-loading{display:flex;justify-content:center;align-items:center}.modal-row .modal-child.loading .modal-loading svg{width:24px;height:24px}.modal-row .modal-child.loading .modal-content{visibility:hidden}.modal-row.open .modal-child{transform:translateY(0%)}.modal-child{padding:16px 8px 24px;background-color:#fff;width:100%;max-height:100vh;max-height:100dvh;overflow-y:auto;overscroll-behavior:contain}.modal-close-button-wrap{padding-left:8px}.modal-close-button-wrap .modal-close-button{display:block;width:32px;cursor:pointer;border-radius:4px}.modal-close-button-wrap .modal-close-button:focus-visible{outline:2px solid var(--color-label, #000);outline-offset:2px}.modal-close-button-wrap .modal-close-button ion-icon{width:32px;display:block;fill:var(--color-label)}.modal-child:focus{outline:none}.focus-guard{position:absolute;width:1px;height:1px;overflow:hidden}';export{x as ion_icon,O as stripe_modal}
|
|
1
|
+
import{e as o,r as t,f as i,h as e,d as n,g as s,a as r}from"./p-C6bbmyga.js";import{c as a,i as l}from"./p-HWdALSvT.js";let c;const d=(o,t,i,e,n)=>(i="ios"===(i&&b(i))?"ios":"md",e&&"ios"===i?o=b(e):n&&"md"===i?o=b(n):(o||!t||u(t)||(o=t),f(o)&&(o=b(o))),f(o)&&""!==o.trim()?""!==o.replace(/[a-z]|-|\d/gi,"")?null:o:null),h=o=>f(o)&&(o=o.trim(),u(o))?o:null,u=o=>o.length>0&&/(\/|\.)/.test(o),f=o=>"string"==typeof o,b=o=>o.toLowerCase(),m=o=>{if(1===o.nodeType){if("script"===o.nodeName.toLowerCase())return!1;for(let t=0;t<o.attributes.length;t++){const i=o.attributes[t].name;if(f(i)&&0===i.toLowerCase().indexOf("on"))return!1}for(let t=0;t<o.childNodes.length;t++)if(!m(o.childNodes[t]))return!1}return!0},p=new Map,y=new Map;let v;function g(o){return p.set(o,""),""}const x=class{constructor(o){t(this,o),this.iconName=null,this.inheritedAttributes={},this.didLoadIcon=!1,this.isVisible=!1,this.mode=w(),this.lazy=!1,this.sanitize=!0}componentWillLoad(){this.inheritedAttributes=((o,t=[])=>{const i={};return t.forEach((t=>{o.hasAttribute(t)&&(null!==o.getAttribute(t)&&(i[t]=o.getAttribute(t)),o.removeAttribute(t))})),i})(this.el,["aria-label"])}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=!0,this.loadIcon()}))}componentDidLoad(){this.didLoadIcon||this.loadIcon()}disconnectedCallback(){this.io&&(this.io.disconnect(),this.io=void 0)}waitUntilVisible(o,t,e){if(!Boolean(i.isBrowser&&this.lazy&&"undefined"!=typeof window&&window.IntersectionObserver))return e();const n=this.io=new window.IntersectionObserver((o=>{o[0].isIntersecting&&(n.disconnect(),this.io=void 0,e())}),{rootMargin:t});n.observe(o)}loadIcon(){if(i.isBrowser&&this.isVisible){const t=(t=>{let i=h(t.src);if(i)return i;if(i=d(t.name,t.icon,t.mode,t.ios,t.md),i)return((t,i)=>{const e=(()=>{if("undefined"==typeof window)return new Map;if(!c){const o=window;o.Ionicons=o.Ionicons||{},c=o.Ionicons.map=o.Ionicons.map||new Map}return c})().get(t);if(e)return e;try{return o(`svg/${t}.svg`)}catch(o){console.log("e",o),console.warn(`[Ionicons Warning]: Could not load icon with name "${t}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`,i)}})(i,t);if(t.icon){if(i=h(t.icon),i)return i;if(i=h(t.icon[t.mode]),i)return i}return null})(this);t&&(p.has(t)?this.svgContent=p.get(t):((o,t)=>y.get(o)||("undefined"!=typeof fetch&&"undefined"!=typeof document?(o=>o.startsWith("data:image/svg+xml"))(o)&&(o=>-1!==o.indexOf(";utf8,"))(o)?Promise.resolve(function(o){v||(v=new DOMParser);const t=v.parseFromString(o,"text/html").querySelector("svg");if(t)return p.set(o,t.outerHTML),t.outerHTML;throw new Error(`Could not parse svg from ${o}`)}(o)):function(o,t){const i=fetch(o).then((i=>i.text().then((i=>{i&&!1!==t&&(i=(o=>{const t=document.createElement("div");t.innerHTML=o;for(let o=t.childNodes.length-1;o>=0;o--)"svg"!==t.childNodes[o].nodeName.toLowerCase()&&t.removeChild(t.childNodes[o]);const i=t.firstElementChild;if(i&&"svg"===i.nodeName.toLowerCase()){const o=i.getAttribute("class")||"";if(i.setAttribute("class",(o+" s-ion-icon").trim()),m(i))return t.innerHTML}return""})(i));const e=i||"";return p.set(o,e),e})).catch((()=>g(o))))).catch((()=>g(o)));return y.set(o,i),i}(o,t):Promise.resolve(g(o))))(t,this.sanitize).then((()=>this.svgContent=p.get(t))),this.didLoadIcon=!0)}this.iconName=d(this.name,this.icon,this.mode,this.ios,this.md)}render(){const{flipRtl:o,iconName:t,inheritedAttributes:s,el:r}=this,a=this.mode||"md",l=!!t&&(t.includes("arrow")||t.includes("chevron"))&&!1!==o,c=o||l;return e(n,Object.assign({key:"0578c899781ca145dd8205acd9670af39b57cf2e",role:"img",class:Object.assign(Object.assign({[a]:!0},k(this.color)),{[`icon-${this.size}`]:!!this.size,"flip-rtl":c,"icon-rtl":c&&(d=r,d&&""!==d.dir?"rtl"===d.dir.toLowerCase():"rtl"===(null===document||void 0===document?void 0:document.dir.toLowerCase()))})},s),e("div",i.isBrowser&&this.svgContent?{class:"icon-inner",innerHTML:this.svgContent}:{class:"icon-inner"}));var d}static get assetsDirs(){return["svg"]}get el(){return s(this)}static get watchers(){return{name:[{loadIcon:0}],src:[{loadIcon:0}],icon:[{loadIcon:0}],ios:[{loadIcon:0}],md:[{loadIcon:0}]}}},w=()=>i.isBrowser&&"undefined"!=typeof document&&document.documentElement.getAttribute("mode")||"md",k=o=>o?{"ion-color":!0,[`ion-color-${o}`]:!0}:null;x.style=":host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}";const C=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","audio[controls]","video[controls]","summary",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(","),M=o=>{if(!o.matches(C))return!1;const t=o.getAttribute("tabindex");if(null!==t&&Number(t)<0)return!1;if(o.hasAttribute("hidden")||null!==o.closest("[inert]"))return!1;const{checkVisibility:i}=o;return!("function"==typeof i&&!i.call(o,{visibilityProperty:!0}))},F=o=>{const t=[],i=o=>{for(const e of(o=>{if(o instanceof Element&&"SLOT"===o.tagName){const t=o,i="function"==typeof t.assignedElements?t.assignedElements({flatten:!0}):[];return i.length>0?i:Array.from(t.children)}return o instanceof Element&&null!=o.shadowRoot?Array.from(o.shadowRoot.children):Array.from(o.children)})(o))M(e)&&t.push(e),i(e)};return i(o),t},I=(o=document)=>{var t,i;let e=null!==(t=o.activeElement)&&void 0!==t?t:null;for(;null!=(null===(i=null==e?void 0:e.shadowRoot)||void 0===i?void 0:i.activeElement);)e=e.shadowRoot.activeElement;return e},L=class{constructor(o){t(this,o),this.close=r(this,"close",7),this.showCloseButton=!0,this.open=!1,this.renderedOpen=!1,this.returnFocusElement=null,this.shouldFocusOnRender=!1,this.lastFocusedInside=null,this.handleKeyDown=o=>{this.open&&"Escape"===o.key&&(o.isComposing||229===o.keyCode||o.defaultPrevented||(o.preventDefault(),o.stopPropagation(),this.closeModal()))},this.handleFocusIn=o=>{var t,i;const e=null!==(i=null===(t=o.composedPath)||void 0===t?void 0:t.call(o)[0])&&void 0!==i?i:o.target;void 0===(null==e?void 0:e.classList)||e.classList.contains("focus-guard")||(this.lastFocusedInside=e)},this.handleStartGuardFocus=o=>{this.cameFromFocusableInside(o)?this.focusLastElement():this.focusFirstElement()},this.handleEndGuardFocus=o=>{this.isInsideModal(this.getFocusOrigin(o))?this.focusFirstElement():this.focusLastElement()}}onOpenChange(o){o?(this.rememberFocus(),this.openModalAnimation()):(this.renderedOpen=!1,this.shouldFocusOnRender=!1,this.lastFocusedInside=null,this.close.emit(),this.restoreFocus())}async toggleModal(){this.open?await this.closeModal():await this.openModal()}async openModal(){this.open=!0}async closeModal(){this.open=!1}componentDidLoad(){const o=a();o&&this.el.classList.add(o),this.open&&(this.rememberFocus(),this.openModalAnimation())}componentDidRender(){this.shouldFocusOnRender&&this.renderedOpen&&(this.shouldFocusOnRender=!1,this.focusFirstElement())}rememberFocus(){var o;if("undefined"==typeof document)return;const t=I(document);null===t||t===document.body||this.el.contains(t)||!0===(null===(o=this.el.shadowRoot)||void 0===o?void 0:o.contains(t))||(this.returnFocusElement=t)}restoreFocus(){const o=this.returnFocusElement;this.returnFocusElement=null,null!=o&&o.isConnected&&"function"==typeof o.focus&&o.focus()}getTabbableElements(){return void 0===this.dialogElement?[]:F(this.dialogElement).filter((o=>!o.classList.contains("focus-guard")))}isInsideModal(o){var t;return null!==o&&(this.el.contains(o)||!0===(null===(t=this.dialogElement)||void 0===t?void 0:t.contains(o)))}getFocusOrigin(o){var t;return null!==(t=o.relatedTarget)&&void 0!==t?t:this.lastFocusedInside}cameFromFocusableInside(o){const t=this.getFocusOrigin(o);return t!==this.dialogElement&&this.isInsideModal(t)}focusContentAfterLoading(){var o;if(!this.open||void 0===this.contentElement)return;const t=I(document);(null===t||t===document.body||t===this.dialogElement||t===this.closeButtonElement)&&(null===(o=F(this.contentElement)[0])||void 0===o||o.focus())}focusFirstElement(){var o;const[t]=this.getTabbableElements();null===(o=null!=t?t:this.dialogElement)||void 0===o||o.focus()}focusLastElement(){var o,t;const i=this.getTabbableElements();null===(t=null!==(o=i[i.length-1])&&void 0!==o?o:this.dialogElement)||void 0===t||t.focus()}openModalAnimation(){if(this.shouldFocusOnRender=!0,!this.el.shadowRoot)return void(this.renderedOpen=!0);const o=this.el.shadowRoot.querySelector(".modal-child");o.scrollTop=0,o.classList.add("loading"),o.style.willChange="transform",o.addEventListener("transitionend",(()=>{o.style.willChange="auto",o.classList.remove("loading"),this.focusContentAfterLoading()}),{once:!0}),requestAnimationFrame((()=>{this.renderedOpen=this.open}))}render(){const{renderedOpen:o,showCloseButton:t}=this,i=o?0:-1;return e(n,{key:"55e0d63b18df165313ea3dd8b8f17aa0e0d0a253",role:o?"dialog":void 0,"aria-modal":o?"true":void 0,onKeyDown:this.handleKeyDown,onFocusin:this.handleFocusIn},e("div",{key:"adb0b493c0ae525f275025c03e1b8f02b04de1af",class:"modal-row"+(o?" open":""),onClick:()=>this.closeModal()},e("div",{key:"478bdad2ad481bfc2d8ffcf552788292fa93daed",class:"modal-child",tabindex:"-1",ref:o=>this.dialogElement=o,onClick:o=>o.stopPropagation()},e("div",{key:"8cc68ecefa37ec1db65f6c910d1da40f9144e722",class:"focus-guard",tabindex:i,onFocus:this.handleStartGuardFocus}),t?e("div",{class:"modal-close-button-wrap"},e("button",{type:"button",class:"modal-close-button","aria-label":l.t("Close"),ref:o=>this.closeButtonElement=o,onClick:()=>this.closeModal()},e("ion-icon",{name:"close",size:"large","aria-hidden":"true"}))):null,e("div",{key:"26271a75906a72e9944599f98da007bfebc2e348",class:"modal-loading"},e("svg",{key:"bc6b1267e2f3b6b1dd7209db55be717fddf9acd4",version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 2400 2400"},e("g",{key:"00ed54798ac376ed71f87a088fad2519cb1262dc","stroke-width":"200","stroke-linecap":"round",stroke:"currentColor",fill:"none",id:"spinner"},e("line",{key:"98242d65eb9470430bd5cc656cbb479232782746",x1:"1200",y1:"600",x2:"1200",y2:"100"}),e("line",{key:"2e2f0538a6d048465ef5f8a3d5ed1932f6c59270",opacity:"0.5",x1:"1200",y1:"2300",x2:"1200",y2:"1800"}),e("line",{key:"11f850b0e7dc0d259f35f56aab17068d4d25ca95",opacity:"0.917",x1:"900",y1:"680.4",x2:"650",y2:"247.4"}),e("line",{key:"14c3226b5d2741902f428a208966adf016c1bb7e",opacity:"0.417",x1:"1750",y1:"2152.6",x2:"1500",y2:"1719.6"}),e("line",{key:"d41da322484b62c1db1df72b9bd1bcc0dbb85a2c",opacity:"0.833",x1:"680.4",y1:"900",x2:"247.4",y2:"650"}),e("line",{key:"246dcdd4a011775dc8fea8a05cfcfc429d5bd03c",opacity:"0.333",x1:"2152.6",y1:"1750",x2:"1719.6",y2:"1500"}),e("line",{key:"f0a2d217a33a8caa6995a30d840002cb8c076e8d",opacity:"0.75",x1:"600",y1:"1200",x2:"100",y2:"1200"}),e("line",{key:"7552fb2c04f85c54b8bcc2235a32690e4489177f",opacity:"0.25",x1:"2300",y1:"1200",x2:"1800",y2:"1200"}),e("line",{key:"7b5a62164a0ef759b057f9100c7c5af834c9f6b7",opacity:"0.667",x1:"680.4",y1:"1500",x2:"247.4",y2:"1750"}),e("line",{key:"d36af9d23059da4ca91147084e47ba94e19f5ada",opacity:"0.167",x1:"2152.6",y1:"650",x2:"1719.6",y2:"900"}),e("line",{key:"f8eed2a97d817b68e0b29f5b5037d34d46a79a46",opacity:"0.583",x1:"900",y1:"1719.6",x2:"650",y2:"2152.6"}),e("line",{key:"1641d577b703e213157bc553966e434a40ba7158",opacity:"0.083",x1:"1750",y1:"247.4",x2:"1500",y2:"680.4"}),e("animateTransform",{key:"60fb2d30c248db1b4195d6015dc96225a15e4010",attributeName:"transform",attributeType:"XML",type:"rotate",keyTimes:"0;0.08333;0.16667;0.25;0.33333;0.41667;0.5;0.58333;0.66667;0.75;0.83333;0.91667",values:"0 1199 1199;30 1199 1199;60 1199 1199;90 1199 1199;120 1199 1199;150 1199 1199;180 1199 1199;210 1199 1199;240 1199 1199;270 1199 1199;300 1199 1199;330 1199 1199",dur:"0.83333s",begin:"0s",repeatCount:"indefinite",calcMode:"discrete"})))),e("div",{key:"27d3b71da43e5935dff3eff2e1bc507a24261b70",class:"modal-content",ref:o=>this.contentElement=o},e("slot",{key:"641408238d3969b830d1f3e9398be6f05bc1f65b"})),e("div",{key:"c6178542b98a99d6a50b74270adc273671d5cc19",class:"focus-guard",tabindex:i,onFocus:this.handleEndGuardFocus}))))}get el(){return s(this)}static get watchers(){return{open:[{onOpenChange:0}]}}};L.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}: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}.modal-row{opacity:0;pointer-events:none;will-change:transform;visibility:hidden}.modal-row.open{opacity:1;pointer-events:auto;visibility:visible;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:1ch;background:rgba(0, 0, 0, 0.3)}.modal-row .modal-child{transform:translateY(100%);transition:transform 420ms ease;position:relative}.modal-row .modal-child .modal-loading{display:none;position:absolute;top:160px;left:50%;transform:translateX(-50%);width:24px;height:24px}.modal-row .modal-child.loading .modal-loading{display:flex;justify-content:center;align-items:center}.modal-row .modal-child.loading .modal-loading svg{width:24px;height:24px}.modal-row .modal-child.loading .modal-content{visibility:hidden}.modal-row.open .modal-child{transform:translateY(0%)}.modal-child{padding:16px 8px 24px;background-color:#fff;width:100%;max-height:100vh;max-height:100dvh;overflow-y:auto;overscroll-behavior:contain}.modal-close-button-wrap{padding-left:8px}.modal-close-button-wrap .modal-close-button{display:block;width:32px;cursor:pointer;border-radius:4px}.modal-close-button-wrap .modal-close-button:focus-visible{outline:2px solid var(--color-label, #000);outline-offset:2px}.modal-close-button-wrap .modal-close-button ion-icon{width:32px;display:block;fill:var(--color-label)}.modal-child:focus{outline:none}.focus-guard{position:absolute;width:1px;height:1px;overflow:hidden}';export{x as ion_icon,L as stripe_modal}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,a as i,h as e,g as n}from"./p-C6bbmyga.js";import{c as s,i as a}from"./p-
|
|
1
|
+
import{r as t,a as i,h as e,g as n}from"./p-C6bbmyga.js";import{c as s,i as a}from"./p-HWdALSvT.js";import{s as r}from"./p-B2G-wquO.js";import"./p-CBXaOfXU.js";const o=class{updatePublishableKey(t){const i={};this.stripeAccount&&(i.stripeAccount=this.stripeAccount),this.initStripe(t,Object.keys(i).length?i:void 0)}updateStripeAccountId(t){const i=this.stripeService.state.publishableKey||this.publishableKey;i&&this.initStripe(i,{stripeAccount:t})}async initStripe(t,i){if(await this.stripeService.initialize(t,{stripeAccount:null==i?void 0:i.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async i=>{"success"===i&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.linkAuthenticationElementManager.setError(t),this}async getEmail(){return this.linkAuthenticationElementManager.getState().email}stripeLoadedEventHandler(){const t=this.stripeService.getStripe();if(!t)return void console.error("Stripe instance is not available");const i={stripe:t};this.stripeDidLoaded&&this.stripeDidLoaded(i),this.stripeLoaded.emit(i)}linkAuthenticationChangeEventHandler(t){const i=this.linkAuthenticationElementManager.getElement(),e=this.stripeService.getStripe();if(!i||!e)return void console.error("Link Authentication Element not initialized");const n={stripe:e,linkAuthenticationElement:i,email:t};this.handleChange&&this.handleChange(n),this.linkAuthenticationChange.emit(n)}componentWillRender(){this.stripeService.state.publishableKey&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(this.stripeService.state.publishableKey,{stripeAccount:this.stripeService.state.stripeAccount}))}constructor(e){t(this,e),this.stripeLoaded=i(this,"stripeLoaded",7),this.linkAuthenticationChange=i(this,"linkAuthenticationChange",7),this.applicationName="stripe-pwa-elements",this.progress="",this.stripeService=r.createStripeService(),this.linkAuthenticationElementManager=r.createLinkAuthenticationElementManager(this.stripeService)}componentWillLoad(){this.publishableKey&&this.initStripe(this.publishableKey,{stripeAccount:this.stripeAccount})}async initElement(){const t={};this.defaultEmail&&(t.defaultValues={email:this.defaultEmail}),await this.linkAuthenticationElementManager.initialize(this.el,Object.keys(t).length?t:void 0),this.linkAuthenticationElementManager.onChange("email",(t=>{this.linkAuthenticationChangeEventHandler(t)}))}componentDidLoad(){const t=s();t&&this.el.classList.add(t)}disconnectedCallback(){this.linkAuthenticationElementManager.unmount()}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:i}=this.linkAuthenticationElementManager.getState();return"failure"===t?e("p",null,a.t("Failed to load Stripe")):e("div",{class:"stripe-link-authentication-wrap"},e("div",{class:"stripe-link-authentication-container"},e("div",{id:"link-authentication-element"}),e("div",{id:"link-authentication-errors",class:"stripe-element-errors"},i)))}get el(){return n(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}]}}};o.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-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)}';export{o as stripe_link_authentication_element}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,B as t,c as n,w as i,N as a,H as l,b as o}from"./p-C6bbmyga.js";export{s as setNonce}from"./p-C6bbmyga.js";import{g as p}from"./p-DQuL1Twl.js";var r=e=>{const t=e.cloneNode;e.cloneNode=function(e){if("TEMPLATE"===this.nodeName)return t.call(this,e);const n=t.call(this,!1),i=this.childNodes;if(e)for(let e=0;e<i.length;e++)2!==i[e].nodeType&&n.appendChild(i[e].cloneNode(!0));return n}};(()=>{t.isDev&&!t.isTesting&&n("Running in development mode."),t.cloneNodeFix&&r(l.prototype);const s=t.scriptDataOpts?i.document&&Array.from(i.document.querySelectorAll("script")).find((e=>new RegExp(`/${a}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===a)):null,o=import.meta.url,p=t.scriptDataOpts&&(s||{})["data-opts"]||{};return""!==o&&(p.resourcesUrl=new URL(".",o).href),e(p)})().then((async e=>(await p(),o([["p-4891edf0",[[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]}]]],["p-
|
|
1
|
+
import{p as e,B as t,c as n,w as i,N as a,H as l,b as o}from"./p-C6bbmyga.js";export{s as setNonce}from"./p-C6bbmyga.js";import{g as p}from"./p-DQuL1Twl.js";var r=e=>{const t=e.cloneNode;e.cloneNode=function(e){if("TEMPLATE"===this.nodeName)return t.call(this,e);const n=t.call(this,!1),i=this.childNodes;if(e)for(let e=0;e<i.length;e++)2!==i[e].nodeType&&n.appendChild(i[e].cloneNode(!0));return n}};(()=>{t.isDev&&!t.isTesting&&n("Running in development mode."),t.cloneNodeFix&&r(l.prototype);const s=t.scriptDataOpts?i.document&&Array.from(i.document.querySelectorAll("script")).find((e=>new RegExp(`/${a}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===a)):null,o=import.meta.url,p=t.scriptDataOpts&&(s||{})["data-opts"]||{};return""!==o&&(p.resourcesUrl=new URL(".",o).href),e(p)})().then((async e=>(await p(),o([["p-4891edf0",[[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]}]]],["p-a45268d4",[[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}]}]]],["p-50e495e3",[[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}]}]]],["p-949a8bba",[[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}]}]]],["p-b0f9ebba",[[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}]}]]],["p-edbbe060",[[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}]}]]],["p-855d1aee",[[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}]}]]],["p-ba791c8f",[[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]}]]],["p-a2d11152",[[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}]}]]],["p-b4faa9db",[[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}]}]]]],e))));
|
|
@@ -146,6 +146,7 @@ export declare class StripeCardElement {
|
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
148
|
intentClientSecret?: string;
|
|
149
|
+
updateIntentClientSecret(): void;
|
|
149
150
|
/**
|
|
150
151
|
* The component will confirm the intent for you: `stripe.confirmCardPayment` when `intentType` is `'payment'`,
|
|
151
152
|
* `stripe.confirmCardSetup` when it is `'setup'`.
|
|
@@ -204,6 +205,11 @@ export declare class StripeCardElement {
|
|
|
204
205
|
private stripeLoadedEventHandler;
|
|
205
206
|
/**
|
|
206
207
|
* Form submit event
|
|
208
|
+
*
|
|
209
|
+
* Note: this event fires after the submit handling completes, not when the form is
|
|
210
|
+
* submitted. With the default submit action it is emitted only after the payment
|
|
211
|
+
* succeeds; a declined payment shows an error inside the form and this event does
|
|
212
|
+
* not fire. Listen to `defaultFormSubmitResult` for the outcome of the default action.
|
|
207
213
|
* @example
|
|
208
214
|
* ```
|
|
209
215
|
* const stripeElement = document.createElement('stripe-card-element');
|
|
@@ -209,6 +209,11 @@ export declare class StripePaymentElement {
|
|
|
209
209
|
private stripeLoadedEventHandler;
|
|
210
210
|
/**
|
|
211
211
|
* Form submit event
|
|
212
|
+
*
|
|
213
|
+
* Note: this event fires after the submit handling completes, not when the form is
|
|
214
|
+
* submitted. With the default submit action it is emitted only after the payment
|
|
215
|
+
* succeeds; a declined payment shows an error inside the form and this event does
|
|
216
|
+
* not fire. Listen to `defaultFormSubmitResult` for the outcome of the default action.
|
|
212
217
|
* @example
|
|
213
218
|
* ```
|
|
214
219
|
* const stripeElement = document.createElement('stripe-payment-element');
|
|
@@ -5,6 +5,8 @@ import type { PaymentElementSubmitEvent } from './stripe-payment-element';
|
|
|
5
5
|
* Determine whether the submit button should be disabled.
|
|
6
6
|
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
7
7
|
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
8
|
+
* The button stays disabled after a successful payment as well: the intent or
|
|
9
|
+
* checkout is already confirmed and cannot be submitted again.
|
|
8
10
|
* @param params progress / loading state and the current mode information
|
|
9
11
|
* @returns true when the submit button should be disabled
|
|
10
12
|
*/
|
|
@@ -1066,7 +1066,7 @@ declare namespace LocalJSX {
|
|
|
1066
1066
|
*/
|
|
1067
1067
|
"onDefaultFormSubmitResult"?: (event: StripeCardElementCustomEvent<DefaultFormSubmitResult>) => void;
|
|
1068
1068
|
/**
|
|
1069
|
-
* Form submit event
|
|
1069
|
+
* Form submit event Note: this event fires after the submit handling completes, not when the form is submitted. With the default submit action it is emitted only after the payment succeeds; a declined payment shows an error inside the form and this event does not fire. Listen to `defaultFormSubmitResult` for the outcome of the default action.
|
|
1070
1070
|
* @example ``` const stripeElement = document.createElement('stripe-card-element'); customElements .whenDefined('stripe-card-element') .then(() => { stripeElement .addEventListener('formSubmit', async props => { const { detail: { stripe, cardNumber, event }, } = props; const result = await stripe.createPaymentMethod({ type: 'card', card: cardNumber, }); console.log(result); }) }) ```
|
|
1071
1071
|
*/
|
|
1072
1072
|
"onFormSubmit"?: (event: StripeCardElementCustomEvent<FormSubmitEvent>) => void;
|
|
@@ -1402,7 +1402,7 @@ declare namespace LocalJSX {
|
|
|
1402
1402
|
*/
|
|
1403
1403
|
"onDefaultFormSubmitResult"?: (event: StripePaymentElementCustomEvent<DefaultFormSubmitResult>) => void;
|
|
1404
1404
|
/**
|
|
1405
|
-
* Form submit event
|
|
1405
|
+
* Form submit event Note: this event fires after the submit handling completes, not when the form is submitted. With the default submit action it is emitted only after the payment succeeds; a declined payment shows an error inside the form and this event does not fire. Listen to `defaultFormSubmitResult` for the outcome of the default action.
|
|
1406
1406
|
* @example ``` const stripeElement = document.createElement('stripe-payment-element'); customElements .whenDefined('stripe-payment-element') .then(() => { stripeElement .addEventListener('formSubmit', async props => { const { detail: { stripe, elements } } = props; console.log('Form submitted', stripe, elements); }) }) ```
|
|
1407
1407
|
*/
|
|
1408
1408
|
"onFormSubmit"?: (event: StripePaymentElementCustomEvent<PaymentElementSubmitEvent>) => void;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -29,8 +29,6 @@ There is no `<stripe-payment-element>` demo yet. See [`examples/codesandbox`](ex
|
|
|
29
29
|
|
|
30
30
|
This library powers the Web implementation of [`@capacitor-community/stripe`](https://github.com/capacitor-community/stripe), which receives 4,000+ weekly downloads. If you use Capacitor for cross-platform apps, `stripe-pwa-elements` handles all Stripe UI on the web layer.
|
|
31
31
|
|
|
32
|
-
> **Manual follow-up (external repo):** Add a reciprocal link in the [capacitor-community/stripe README](https://github.com/capacitor-community/stripe) pointing back to this package.
|
|
33
|
-
|
|
34
32
|
## Why stripe-pwa-elements?
|
|
35
33
|
|
|
36
34
|
Integrating Stripe from scratch requires wiring up several moving parts. This library collapses all of that into a single HTML element.
|
|
@@ -253,46 +251,82 @@ Combined Card Element with Modal wrapper.
|
|
|
253
251
|
|
|
254
252
|
### React
|
|
255
253
|
|
|
256
|
-
|
|
257
|
-
import { defineCustomElements } from 'stripe-pwa-elements/loader';
|
|
254
|
+
Import the component from the custom-elements build, then listen for events through a `ref`. React 18 does not attach custom element events from props, and React 19 uses the text after `on` as the event name unchanged, so `onFormSubmit` would listen for `FormSubmit` instead of `formSubmit`. `addEventListener` works in both.
|
|
258
255
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
256
|
+
```jsx
|
|
257
|
+
import { useEffect, useRef } from 'react';
|
|
258
|
+
import 'stripe-pwa-elements/dist/components/stripe-card-element';
|
|
259
|
+
|
|
260
|
+
export function PaymentForm({ publishableKey, clientSecret }) {
|
|
261
|
+
const ref = useRef(null);
|
|
262
|
+
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
const el = ref.current;
|
|
265
|
+
const onResult = (e) => {
|
|
266
|
+
if (e.detail instanceof Error) {
|
|
267
|
+
console.error('Payment failed:', e.detail.message);
|
|
268
|
+
} else {
|
|
269
|
+
console.log('Payment result:', e.detail.paymentIntent.status);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
el.addEventListener('defaultFormSubmitResult', onResult);
|
|
273
|
+
return () => el.removeEventListener('defaultFormSubmitResult', onResult);
|
|
274
|
+
}, []);
|
|
266
275
|
|
|
267
276
|
return (
|
|
268
277
|
<stripe-card-element
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
ref={ref}
|
|
279
|
+
publishable-key={publishableKey}
|
|
280
|
+
intent-client-secret={clientSecret}
|
|
272
281
|
/>
|
|
273
282
|
);
|
|
274
283
|
}
|
|
275
284
|
```
|
|
276
285
|
|
|
286
|
+
The component confirms the payment itself and emits the result on `defaultFormSubmitResult`.
|
|
287
|
+
|
|
277
288
|
### Vue
|
|
278
289
|
|
|
290
|
+
Tell the Vue compiler that `stripe-*` tags are custom elements:
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
// vite.config.js
|
|
294
|
+
import { defineConfig } from 'vite';
|
|
295
|
+
import vue from '@vitejs/plugin-vue';
|
|
296
|
+
|
|
297
|
+
export default defineConfig({
|
|
298
|
+
plugins: [
|
|
299
|
+
vue({
|
|
300
|
+
template: {
|
|
301
|
+
compilerOptions: {
|
|
302
|
+
isCustomElement: (tag) => tag.startsWith('stripe-'),
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
279
310
|
```vue
|
|
280
311
|
<template>
|
|
281
312
|
<stripe-card-element
|
|
282
|
-
publishable-key="
|
|
283
|
-
intent-client-secret="
|
|
284
|
-
@
|
|
313
|
+
:publishable-key="publishableKey"
|
|
314
|
+
:intent-client-secret="clientSecret"
|
|
315
|
+
@defaultFormSubmitResult="onResult"
|
|
285
316
|
/>
|
|
286
317
|
</template>
|
|
287
318
|
|
|
288
319
|
<script setup>
|
|
289
|
-
import
|
|
320
|
+
import 'stripe-pwa-elements/dist/components/stripe-card-element';
|
|
290
321
|
|
|
291
|
-
|
|
322
|
+
defineProps({ publishableKey: String, clientSecret: String });
|
|
292
323
|
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
324
|
+
const onResult = (e) => {
|
|
325
|
+
if (e.detail instanceof Error) {
|
|
326
|
+
console.error('Payment failed:', e.detail.message);
|
|
327
|
+
} else {
|
|
328
|
+
console.log('Payment result:', e.detail.paymentIntent.status);
|
|
329
|
+
}
|
|
296
330
|
};
|
|
297
331
|
</script>
|
|
298
332
|
```
|
|
@@ -358,20 +392,20 @@ The documentation site also serves the skill over HTTP, built from the same file
|
|
|
358
392
|
### Getting Started
|
|
359
393
|
|
|
360
394
|
```bash
|
|
361
|
-
|
|
362
|
-
|
|
395
|
+
pnpm install
|
|
396
|
+
pnpm start
|
|
363
397
|
```
|
|
364
398
|
|
|
365
399
|
To build the component for production, run:
|
|
366
400
|
|
|
367
401
|
```bash
|
|
368
|
-
|
|
402
|
+
pnpm run build
|
|
369
403
|
```
|
|
370
404
|
|
|
371
405
|
To run the unit tests for the components, run:
|
|
372
406
|
|
|
373
407
|
```bash
|
|
374
|
-
|
|
408
|
+
pnpm test
|
|
375
409
|
```
|
|
376
410
|
|
|
377
411
|
### Real-browser checks against Stripe test mode
|
|
@@ -389,7 +423,7 @@ pnpm run test:e2e:stripe
|
|
|
389
423
|
- Traces and screenshots of failed tests go to `test-reports/stripe-e2e/`.
|
|
390
424
|
- Type-check the suite with `pnpm exec tsc -p e2e/stripe/tsconfig.json`.
|
|
391
425
|
|
|
392
|
-
To add a check: add a scenario to `e2e/stripe/*.pw.ts` using `PaymentSheetHarness` (`e2e/stripe/support/payment-sheet.ts`) and the demo API helpers (`e2e/stripe/support/demo-api.ts`). Element options and attributes go through `harness.mount({ publishableKey, clientSecret, options, attributes })`. For a different page, add an HTML file to `e2e/stripe/pages/` that exposes the same `window.harness` contract and open it with `harness.goto('/e2e/<file>.html')`.
|
|
426
|
+
To add a check: add a scenario to `e2e/stripe/*.pw.ts` using `PaymentSheetHarness` (`e2e/stripe/support/payment-sheet.ts`) and the demo API helpers (`e2e/stripe/support/demo-api.ts`). Element options and attributes go through `harness.mount({ publishableKey, clientSecret, options, attributes })`. To check what Stripe received or saved (confirm request params, billing details on the PaymentMethod, shipping on the PaymentIntent), use `e2e/stripe/support/stripe-api.ts`, as `payment-sheet-billing.pw.ts` does. For a different page, add an HTML file to `e2e/stripe/pages/` that exposes the same `window.harness` contract and open it with `harness.goto('/e2e/<file>.html')`.
|
|
393
427
|
|
|
394
428
|
### Keep the Agent Skill up to date
|
|
395
429
|
|
|
@@ -472,7 +506,7 @@ The custom-elements entry `stripe-pwa-elements/dist/components/<tag>` is a suppo
|
|
|
472
506
|
|
|
473
507
|
### Semver policy
|
|
474
508
|
|
|
475
|
-
All types exported from the package root (`stripe-pwa-elements`) are considered **public API** and follow [Semantic Versioning](https://semver.org/). Within
|
|
509
|
+
All types exported from the package root (`stripe-pwa-elements`) are considered **public API** and follow [Semantic Versioning](https://semver.org/). Within a major version range (for example `^4.0.0`):
|
|
476
510
|
|
|
477
511
|
- No breaking changes will be made to the shape of any publicly exported type.
|
|
478
512
|
- New optional fields may be added to event objects without a major bump.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as e}from"./p-XRfh5Wrs.js";const r=e=>{const{progress:r,isCheckoutSession:t,loadStripeStatus:i,intentClientSecret:n}=e;return"loading"===r||!(t?"success"===i:null!=n&&""!==n)},t=async(r,t,i,n,o)=>{const s=await("payment"===i?r.confirmPayment({elements:t,confirmParams:Object.assign({return_url:n},o),redirect:"if_required"}):r.confirmSetup({elements:t,confirmParams:Object.assign({return_url:n},o),redirect:"if_required"}));if(s.error)throw new e(s.error);return s},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:o}=n,s=await o.confirm({returnUrl:t,redirect:"if_required"});if("error"===s.type){const r={type:"card_error",code:s.error.code||"payment_failed",message:s.error.message,decline_code:"paymentFailed"===s.error.code?null===(i=s.error.paymentFailed)||void 0===i?void 0:i.declineCode:void 0};throw new e(r)}return s},n=e=>{const{stripe:r,isCheckoutSession:t,checkout:i,checkoutSessionClientSecret:n,elements:o,intentClientSecret:s}=e,c={stripe:r};return t?null==i?{error:"Checkout not properly initialized"}:(c.checkout=i,c.checkoutSessionClientSecret=n,{props:c}):null==o?{error:"Elements not properly initialized"}:(c.elements=o,c.intentClientSecret=s,{props:c})};export{i as a,n as b,t as c,r as i}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,a as e,h as i,g as s}from"./p-C6bbmyga.js";import{c as r,i as n}from"./p-CL5n3bOb.js";import{s as o}from"./p-DlMEZwSe.js";import{S as l}from"./p-XRfh5Wrs.js";import"./p-CBXaOfXU.js";const a=t=>{if(null!=t&&""!==t)return{stripeAccount:t}},p=class{async initStripe(t,e){if(await this.stripeService.initialize(t,{stripeAccount:null==e?void 0:e.stripeAccount,applicationName:this.applicationName}),"success"===this.stripeService.state.loadStripeStatus)await this.initElement(),this.stripeLoadedEventHandler();else{const t=this.stripeService.onChange("loadStripeStatus",(async e=>{"success"===e&&(await this.initElement(),this.stripeLoadedEventHandler(),t())}))}}async updateProgress(t){return this.progress=t,this}async setErrorMessage(t){return this.cardElementManager.setError(t),this}updatePublishableKey(t){null!=t&&""!==t&&this.initStripe(t,a(this.stripeAccount))}updateStripeAccountId(t){const e=this.stripeService.state.publishableKey||this.publishableKey;null!=e&&""!==e&&this.initStripe(e,{stripeAccount:t})}async setPaymentRequestOption(t){return this.paymentRequestOption=t,this.createPaymentRequestButton(),this}stripeLoadedEventHandler(){const t={stripe:this.stripeService.getStripe()};null!=this.stripeDidLoaded&&this.stripeDidLoaded(t),this.stripeLoaded.emit(t)}async formSubmitEventHandler(){const t=this.cardElementManager.getElements(),e=this.stripeService.getStripe();null!=t?this.formSubmit.emit({cardCVCElement:t.cardCVC,cardExpiryElement:t.cardExpiry,cardNumberElement:t.cardNumber,stripe:e}):console.error("Card elements not initialized")}async defaultFormSubmitResultHandler(t){this.defaultFormSubmitResult.emit(t)}componentWillRender(){const{publishableKey:t}=this.stripeService.state;null!=t&&""!==t&&(["success","loading"].includes(this.stripeService.state.loadStripeStatus)||this.initStripe(t,a(this.stripeService.state.stripeAccount)))}async defaultFormSubmitAction(t,{stripe:e,cardNumberElement:i,intentClientSecret:s}){t.preventDefault();try{const t=await((t,e,i,s)=>"payment"===this.intentType?t.confirmCardPayment(i,{payment_method:{card:s}}):t.confirmCardSetup(i,{payment_method:{card:s}}))(e,0,s,i);if(null!=t.error)throw new l(t.error);this.defaultFormSubmitResultHandler(t)}catch(t){throw console.error(t),this.defaultFormSubmitResultHandler(t),t}}constructor(i){t(this,i),this.stripeLoaded=e(this,"stripeLoaded",7),this.formSubmit=e(this,"formSubmit",7),this.defaultFormSubmitResult=e(this,"defaultFormSubmitResult",7),this.paymentRequestButtonCreated=!1,this.intentType="payment",this.zip=!0,this.sheetTitle="Add your payment information",this.buttonLabel="Pay",this.progress="",this.zipCode="",this.applicationName="stripe-pwa-elements",this.showLabel=!1,this.shouldUseDefaultFormSubmitAction=!0,this.stripeService=o.createStripeService(),this.cardElementManager=o.createCardElementManager(this.stripeService)}componentWillLoad(){null!=this.publishableKey&&""!==this.publishableKey&&this.initStripe(this.publishableKey,a(this.stripeAccount))}async initElement(){await this.cardElementManager.initialize(this.el);const t=this.el.querySelector("#stripe-card-element");null!=t?t.addEventListener("submit",(async t=>{const e=this.cardElementManager.getElements(),i=this.stripeService.getStripe(),{intentClientSecret:s}=this;if(null==e||null==i)return void console.error("Stripe not properly initialized");const r={cardCVCElement:e.cardCVC,cardExpiryElement:e.cardExpiry,cardNumberElement:e.cardNumber,stripe:i,intentClientSecret:s,zipCode:this.zipCode};this.progress="loading";try{null!=this.handleSubmit?await this.handleSubmit(t,r):!0===this.shouldUseDefaultFormSubmitAction&&null!=s&&""!==s?await this.defaultFormSubmitAction(t,r):t.preventDefault(),await this.formSubmitEventHandler(),null==this.handleSubmit&&!0!==this.shouldUseDefaultFormSubmitAction||(this.progress="success")}catch(t){this.cardElementManager.setError(t.message),this.progress="failure"}})):console.error("Form element #stripe-card-element not found")}componentDidLoad(){this.el.classList.add(r())}componentDidRender(){this.showPaymentRequestButton&&this.paymentRequestOption&&!this.paymentRequestButtonCreated&&this.createPaymentRequestButton()}disconnectedCallback(){this.cardElementManager.unmount()}createPaymentRequestButton(){const{showPaymentRequestButton:t,paymentRequestOption:e}=this;if(this.paymentRequestButtonCreated)return null;if(!t||null==e)return null;if(null==document)return null;const i=this.el.querySelector("#stripe-payment-request-button");if(null==i)return console.error("Target element #stripe-payment-request-button not found"),null;if(null!=i.querySelector("stripe-payment-request-button"))return this.paymentRequestButtonCreated=!0,null;const s=document.createElement("stripe-payment-request-button");i.appendChild(s),customElements.whenDefined("stripe-payment-request-button").then((()=>(((t,e)=>{const{paymentRequestPaymentMethodHandler:i,paymentRequestShippingOptionChangeHandler:s,paymentRequestShippingAddressChangeHandler:r}=e;t.setPaymentRequestOption(e),null!=i&&t.setPaymentMethodEventHandler(i),null!=s&&t.setPaymentRequestShippingOptionEventHandler(s),null!=r&&t.setPaymentRequestShippingAddressEventHandler(r)})(s,e),s.initStripe(this.publishableKey)))),this.paymentRequestButtonCreated=!0}render(){const{loadStripeStatus:t}=this.stripeService.state,{errorMessage:e}=this.cardElementManager.getState();if("failure"===t)return i("p",null,n.t("Failed to load Stripe"));const s="loading"===this.progress;return i("div",{class:"stripe-payment-sheet-wrap"},i("form",{id:"stripe-card-element"},i("div",{class:"stripe-heading"},n.t(this.sheetTitle)),i("div",{id:"stripe-payment-request-button"}),i("div",null,i("div",{class:"stripe-section-title"},n.t("Card information"))),i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,n.t("Card Number")):null,i("div",{id:"card-number"}))),i("div",{class:"stripe-input-column",style:{display:"flex"}},i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,n.t("MM / YY")):null,i("div",{id:"card-expiry"})),i("label",{style:{width:"50%"}},this.showLabel?i("lenged",null,n.t("CVC")):null,i("div",{id:"card-cvc"}))))),i("div",{id:"card-errors",class:"stripe-element-errors"},e),this.zip?i("div",{style:{marginTop:"1.5rem"}},i("div",{class:"stripe-section-title"},n.t("Country or region"))):null,this.zip?i("div",{class:"payment-info card visible"},i("fieldset",{class:"stripe-input-box"},i("div",null,i("label",null,this.showLabel?i("lenged",null,n.t("Postal Code")):null,i("input",{id:"zip",name:"zip",type:"text",inputmode:"numeric",class:"StripeElement",style:{width:"100%"},placeholder:n.t("Postal Code"),value:this.zipCode,onInput:t=>{this.zipCode=t.target.value}}))))):null,i("div",{style:{marginTop:"32px"}},i("button",{type:"submit",disabled:s},n.t("loading"===this.progress?"Loading":this.buttonLabel)))))}get el(){return s(this)}static get watchers(){return{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId: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;display:flex;justify-content:center;align-items:center}.stripe-payment-sheet-wrap .StripeElement>.__PrivateStripeElement{width:100%}.stripe-payment-sheet-wrap .stripe-input-box{background-color:#fff;border-radius:6px;border:1px solid var(--color-input-border);overflow:hidden;filter:drop-shadow(0 0 2px var(--color-input-border-shadow))}.stripe-payment-sheet-wrap .stripe-input-box>*{border-bottom:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-box>*:last-child{border-bottom:none}.stripe-payment-sheet-wrap .stripe-input-column>*{border-right:1px solid var(--color-input-border)}.stripe-payment-sheet-wrap .stripe-input-column>*:last-child{border-right:none}.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 label{color:var(--color-label)}.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_card_element}
|