stripe-pwa-elements 4.0.4 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{factory-Cm6zUD7R.js → factory-yd5HDEZn.js} +2 -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 +3 -3
- 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 +19 -8
- package/dist/cjs/stripe-payment-element.helpers-D1JnhTa-.js +182 -0
- package/dist/cjs/stripe-payment-sheet.cjs.entry.js +73 -58
- package/dist/collection/components/stripe-card-element/stripe-card-element.js +2 -2
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +9 -32
- package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +88 -6
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +60 -48
- package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +5 -2
- package/dist/collection/services/stripe-service.js +1 -0
- package/dist/collection/utils/checkout-confirm.js +84 -0
- package/dist/collection/utils/i18n.js +2 -2
- package/dist/components/factory.js +1 -1
- 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/components/stripe-payment-sheet.js +1 -1
- package/dist/esm/{factory-BaGv8K_i.js → factory-B_WxdnxM.js} +2 -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 +3 -3
- 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 +19 -8
- package/dist/esm/stripe-payment-element.helpers-PuWxhMNR.js +176 -0
- package/dist/esm/stripe-payment-sheet.entry.js +73 -58
- package/dist/stripe-elements/{p-f5552c81.entry.js → p-2e2bf0fe.entry.js} +1 -1
- package/dist/stripe-elements/{p-3fc4583a.entry.js → p-32a2d5a4.entry.js} +1 -1
- package/dist/stripe-elements/{p-b62c9dae.entry.js → p-84d45b48.entry.js} +1 -1
- package/dist/stripe-elements/{p-CL5n3bOb.js → p-HWdALSvT.js} +1 -1
- package/dist/stripe-elements/{p-5d3d93ec.entry.js → p-a266da6f.entry.js} +1 -1
- package/dist/stripe-elements/{p-7e826964.entry.js → p-b4faa9db.entry.js} +1 -1
- package/dist/stripe-elements/p-c4a0e310.entry.js +1 -0
- package/dist/stripe-elements/{p-2e41699e.entry.js → p-e660d76a.entry.js} +1 -1
- package/dist/stripe-elements/p-eeebfbbf.entry.js +1 -0
- package/dist/stripe-elements/p-n0XJSLU3.js +1 -0
- package/dist/stripe-elements/p-wrjrFokg.js +1 -0
- package/dist/stripe-elements/stripe-elements.esm.js +1 -1
- package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +5 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.d.ts +38 -0
- package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +8 -2
- package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +19 -11
- package/dist/types/components.d.ts +36 -4
- package/dist/types/services/interfaces.d.ts +3 -1
- package/dist/types/utils/checkout-confirm.d.ts +35 -0
- package/package.json +1 -1
- package/dist/cjs/stripe-payment-element.helpers-lafmSRmb.js +0 -121
- package/dist/esm/stripe-payment-element.helpers-CklK5RlF.js +0 -116
- package/dist/stripe-elements/p-7a8f783c.entry.js +0 -1
- package/dist/stripe-elements/p-BoZLkOAy.js +0 -1
- package/dist/stripe-elements/p-DlMEZwSe.js +0 -1
- package/dist/stripe-elements/p-b69f6103.entry.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as t}from"./p-C6bbmyga.js";import{l as e}from"./p-CBXaOfXU.js";import{i}from"./p-HWdALSvT.js";const r=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const i=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(i=e))||i.isConnected);var i}));t.set(e,i)}})(...e)}),2e3)}})(),s=t.forceUpdate,n=t.getRenderingRef,o=(t,e)=>{const i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],t.length--)},l=(t,e)=>{const i=((t,e=(t,e)=>t!==e)=>{const i=()=>{return("function"==typeof(e=t)?e():e)??{};var e},r=i();let s=new Map(Object.entries(r));const n="undefined"!=typeof Proxy,l=n?null:{},a={dispose:[],get:[],set:[],reset:[]},c=new Map,h=()=>{s=new Map(Object.entries(i())),n||m(),a.reset.forEach((t=>t()))},u=t=>(a.get.forEach((e=>e(t))),s.get(t)),d=(t,i)=>{const r=s.get(t);e(i,r,t)&&(s.set(t,i),n||g(t),a.set.forEach((e=>e(t,i,r))))},v=n?new Proxy(r,{get:(t,e)=>u(e),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>s.has(e),set:(t,e,i)=>(d(e,i),!0)}):(m(),l),p=(t,e)=>(a[t].push(e),()=>{o(a[t],e)});function g(t){!n&&l&&(Object.prototype.hasOwnProperty.call(l,t)||Object.defineProperty(l,t,{configurable:!0,enumerable:!0,get:()=>u(t),set(e){d(t,e)}}))}function m(){if(n||!l)return;const t=new Set(s.keys());for(const e of Object.keys(l))t.has(e)||delete l[e];for(const e of t)g(e)}return{state:v,get:u,set:d,on:p,onChange:(t,e)=>{const r=(i,r)=>{i===t&&e(r)},s=()=>{const r=i();e(r[t])},n=p("set",r),o=p("reset",s);return c.set(e,{setHandler:r,resetHandler:s,propName:t}),()=>{n(),o(),c.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(p("set",e.set)),e.get&&t.push(p("get",e.get)),e.reset&&t.push(p("reset",e.reset)),e.dispose&&t.push(p("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),h()},reset:h,forceUpdate:t=>{const e=s.get(t);a.set.forEach((i=>i(t,e,e)))},removeListener:(t,e)=>{const i=c.get(e);i&&i.propName===t&&(o(a.set,i.setHandler),o(a.reset,i.resetHandler),c.delete(e))}}})(t,e);return i.use((()=>{if("function"!=typeof n||"function"!=typeof s)return{};const t=s,e=n,i=new Map;return{dispose:()=>i.clear(),get:t=>{const r=e();r&&((t,e,i)=>{let r=t.get(e);r||(r=[],t.set(e,r)),r.some((t=>t.deref()===i))||r.push(new WeakRef(i))})(i,t,r)},set:e=>{const s=i.get(e);if(s){const r=s.filter((e=>{const i=e.deref();return!!i&&t(i)}));i.set(e,r)}r(i)},reset:()=>{i.forEach((e=>{e.forEach((e=>{const i=e.deref();i&&t(i)}))})),r(i)}}})()),i};class a{constructor(){this.store=l({loadStripeStatus:"",applicationName:"stripe-pwa-elements",isCheckoutSession:!1}),this.initGeneration=0,this.changeListeners=new Map}get state(){return this.store.state}onChange(t,e){const i=this.store.onChange(t,e);return this.changeListeners.has(t)||this.changeListeners.set(t,[]),this.changeListeners.get(t).push(i),i}async initialize(t,i){const r=null!=(null==i?void 0:i.elementsOptions)?JSON.stringify(i.elementsOptions):void 0,s=null!=this.store.state.stripe&&!this.store.state.isCheckoutSession&&this.store.state.publishableKey===t&&this.store.state.stripeAccount===(null==i?void 0:i.stripeAccount)&&this.intentClientSecret===(null==i?void 0:i.clientSecret)&&this.elementsOptionsKey===r;if(this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!1,this.intentClientSecret=null==i?void 0:i.clientSecret,this.elementsOptionsKey=r,null!=(null==i?void 0:i.stripeAccount)&&""!==(null==i?void 0:i.stripeAccount)&&(this.store.state.stripeAccount=i.stripeAccount),null!=(null==i?void 0:i.applicationName)&&""!==(null==i?void 0:i.applicationName)&&(this.store.state.applicationName=i.applicationName),s)return;const n=++this.initGeneration;this.store.state.loadStripeStatus="loading";try{const r=await e(t,{stripeAccount:null==i?void 0:i.stripeAccount});if(n!==this.initGeneration)return;r.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=r,this.store.state.elements=null!=(null==i?void 0:i.clientSecret)&&""!==i.clientSecret?r.elements({clientSecret:i.clientSecret}):null!=(null==i?void 0:i.elementsOptions)?r.elements(i.elementsOptions):r.elements(),this.store.state.checkout=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to load Stripe.js:",t),this.store.state.loadStripeStatus="failure"}}async initializeWithCheckoutSession(t,i,r){const s=++this.initGeneration;this.store.state.publishableKey=t,this.store.state.isCheckoutSession=!0,null!=(null==r?void 0:r.stripeAccount)&&""!==(null==r?void 0:r.stripeAccount)&&(this.store.state.stripeAccount=r.stripeAccount),null!=(null==r?void 0:r.applicationName)&&""!==(null==r?void 0:r.applicationName)&&(this.store.state.applicationName=r.applicationName),this.store.state.loadStripeStatus="loading";try{const n=await e(t,{stripeAccount:null==r?void 0:r.stripeAccount});if(s!==this.initGeneration)return;n.registerAppInfo({name:this.store.state.applicationName}),this.store.state.stripe=n;const o=n.initCheckoutElementsSdk({clientSecret:i,elementsOptions:null==r?void 0:r.elementsOptions,defaultValues:null==r?void 0:r.defaultValues});this.store.state.checkout=o,this.store.state.elements=void 0,this.store.state.loadStripeStatus="success"}catch(t){console.error("Failed to initialize Stripe Checkout:",t),this.store.state.loadStripeStatus="failure"}}getStripe(){return this.store.state.stripe}getElements(){return this.store.state.elements}getCheckout(){return this.store.state.checkout}reset(){this.store.reset()}dispose(){this.changeListeners.forEach((t=>{t.forEach((t=>t()))})),this.changeListeners.clear(),this.store.dispose()}}function c(t,e,i=5e3){return new Promise(((r,s)=>{const n=t.querySelector(e);if(null!=n)return r(n);const o=setTimeout((()=>{l.disconnect(),s(new Error(`Element "${e}" not found within ${i}ms`))}),i),l=new MutationObserver((()=>{const i=t.querySelector(e);null!=i&&(clearTimeout(o),l.disconnect(),r(i))}));l.observe(t,{childList:!0,subtree:!0})}))}new a;class h{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",errorSource:void 0})}getState(){return this.store.state}async initialize(t){const e=this.stripeService.getElements();if(null==e)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.cardElements&&this.unmount();const r=e.create("cardNumber",{placeholder:i.t("Card Number")}),s=await c(t,"#card-number");r.mount(s),r.on("change",this.handleCardError("cardNumber"));const n=e.create("cardExpiry"),o=await c(t,"#card-expiry");n.mount(o),n.on("change",this.handleCardError("cardExpiry"));const l=e.create("cardCvc"),a=await c(t,"#card-cvc");return l.mount(a),l.on("change",this.handleCardError("cardCvc")),this.cardElements={cardNumber:r,cardExpiry:n,cardCVC:l},this.cardElements}getElements(){return this.cardElements}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage",""),this.store.set("errorSource",void 0)}unmount(){var t,e,i;null!=this.cardElements&&(null===(t=this.cardElements.cardNumber)||void 0===t||t.unmount(),null===(e=this.cardElements.cardExpiry)||void 0===e||e.unmount(),null===(i=this.cardElements.cardCVC)||void 0===i||i.unmount(),this.cardElements=void 0)}handleCardError(t){return({error:e})=>{if(e)return this.store.set("errorMessage",e.message),void this.store.set("errorSource",t);this.store.state.errorSource===t&&(this.store.set("errorMessage",""),this.store.set("errorSource",void 0))}}}class u{constructor(t){this.stripeService=t,this.store=l({errorMessage:""})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.state.isCheckoutSession;if(null!=this.paymentElement&&this.unmount(),i){const t=this.stripeService.getCheckout();if(null==t)throw new Error("StripeService not initialized with Checkout Session. Call StripeService.initializeWithCheckoutSession() first.");this.paymentElement=t.createPaymentElement(e)}else{const t=this.stripeService.getElements();if(null==t)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");this.paymentElement=t.create("payment",e||{})}const r=await c(t,"#payment-element");return this.paymentElement.mount(r),this.paymentElement}getElement(){return this.paymentElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.paymentElement&&(this.paymentElement.unmount(),this.paymentElement=void 0)}}class d{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isComplete:!1})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.addressElement&&this.unmount(),this.addressElement=i.create("address",e||{mode:"billing"});const r=await c(t,"#address-element");return this.addressElement.mount(r),this.addressElement.on("change",(t=>{this.store.set("errorMessage",""),this.store.set("isComplete",t.complete)})),this.addressElement}getElement(){return this.addressElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.addressElement&&(this.addressElement.unmount(),this.addressElement=void 0)}}class v{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",email:void 0,complete:void 0})}getState(){return this.store.state}onChange(t,e){return this.store.onChange(t,e)}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.linkAuthenticationElement&&this.unmount(),this.store.set("email",void 0),this.store.set("complete",void 0);const r=i.create("linkAuthentication",e),s=await c(t,"#link-authentication-element");return r.mount(s),r.on("change",(t=>{var e;this.store.set("email",null===(e=t.value)||void 0===e?void 0:e.email),this.store.set("complete",t.complete)})),this.linkAuthenticationElement=r,this.linkAuthenticationElement}getElement(){return this.linkAuthenticationElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.linkAuthenticationElement&&(this.linkAuthenticationElement.unmount(),this.linkAuthenticationElement=void 0)}}class p{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",selectedCurrency:void 0})}getState(){return this.store.state}async initialize(t,e){const i=this.stripeService.getElements();if(null==i)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.currencySelectorElement&&this.unmount();const r=await c(t,"#currency-selector");return this.currencySelectorElement=i.create("currencySelector",e||{}),this.currencySelectorElement.mount(r),this.currencySelectorElement.on("change",(t=>{var e;this.store.set("errorMessage",""),(null===(e=null==t?void 0:t.value)||void 0===e?void 0:e.currency)&&this.store.set("selectedCurrency",t.value.currency)})),this.currencySelectorElement}getElement(){return this.currencySelectorElement}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.currencySelectorElement&&(this.currencySelectorElement.unmount(),this.currencySelectorElement=void 0)}}var g=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(i[r[s]]=t[r[s]])}return i};class m{constructor(t){this.stripeService=t,this.store=l({errorMessage:"",isReady:!1})}getState(){return this.store.state}async initialize(t,e,i){const r=this.stripeService.getElements();if(null==r)throw new Error("StripeService not initialized. Call StripeService.initialize() first.");null!=this.expressCheckoutElement&&this.unmount();const s=g(e,["mode","amount","currency"]),n=Object.assign({},s);if(n.buttonHeight&&"string"==typeof n.buttonHeight){const t=parseInt(n.buttonHeight.replace("px",""),10);isNaN(t)||(n.buttonHeight=t)}const o=r.create("expressCheckout",n),l=await c(t,"#express-checkout-element");return null!=(null==i?void 0:i.onConfirm)&&o.on("confirm",i.onConfirm),null!=(null==i?void 0:i.onClick)&&o.on("click",i.onClick),null!=(null==i?void 0:i.onCancel)&&o.on("cancel",i.onCancel),null!=(null==i?void 0:i.onShippingAddressChange)&&o.on("shippingaddresschange",i.onShippingAddressChange),null!=(null==i?void 0:i.onShippingRateChange)&&o.on("shippingratechange",i.onShippingRateChange),o.on("ready",(()=>{this.store.set("isReady",!0)})),o.mount(l),this.expressCheckoutElement=o,this.expressCheckoutElement}getElement(){return this.expressCheckoutElement}update(t){var e;if(null==this.expressCheckoutElement)return void console.warn("Express Checkout Element not initialized. Cannot update options.");const{mode:i,amount:r,currency:s}=t,n=g(t,["mode","amount","currency"]),o={};void 0!==i&&(o.mode=i),void 0!==r&&(o.amount=r),void 0!==s&&(o.currency=s),Object.keys(o).length>0&&(null===(e=this.stripeService.getElements())||void 0===e||e.update(o));const l=Object.assign({},n);if(l.buttonHeight&&"string"==typeof l.buttonHeight){const t=parseInt(l.buttonHeight.replace("px",""),10);isNaN(t)||(l.buttonHeight=t)}0!==Object.keys(l).length&&this.expressCheckoutElement.update(l)}setError(t){this.store.set("errorMessage",t)}clearError(){this.store.set("errorMessage","")}unmount(){null!=this.expressCheckoutElement&&(this.expressCheckoutElement.unmount(),this.expressCheckoutElement=void 0,this.store.set("isReady",!1))}}const f=new class{createStripeService(){return new a}createCardElementManager(t){return new h(t)}createPaymentElementManager(t){return new u(t)}createAddressElementManager(t){return new d(t)}createLinkAuthenticationElementManager(t){return new v(t)}createCurrencySelectorElementManager(t){return new p(t)}createExpressCheckoutElementManager(t){return new m(t)}};export{c as f,f as s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e}from"./p-XRfh5Wrs.js";const r=e=>{const r=e instanceof Error?e.message:null==e?void 0:e.message;return"string"==typeof r&&r.includes("cannot provide `returnUrl`")},t=(r,t)=>{if(null!=r&&"open"!==r.type)throw new e({type:"invalid_request_error",code:`checkout_session_${r.type}`,message:null!=t?t:`The Checkout Session is ${r.type} and can no longer be paid.`})},n=async(n,o,s)=>{const i=await n.loadActions();if("error"===i.type)throw new e({type:"api_error",code:"checkout_session_error",message:i.error.message});const{actions:c}=i,a=()=>{var e,r;return null===(r=null===(e=c.getSession)||void 0===e?void 0:e.call(c))||void 0===r?void 0:r.status};t(a());const l=e=>c.confirm(Object.assign(Object.assign({redirect:"if_required"},e&&""!==o?{returnUrl:o}:{}),null!=s&&""!==s?{email:s}:{}));let u;try{u=await l(!0),"error"===u.type&&r(u.error)&&(u=await l(!1))}catch(e){if(!r(e))throw e;u=await l(!1)}if("error"===u.type){const{code:r,message:n}=u.error;if(t(a(),n),"paymentFailed"===r)throw new e({type:"card_error",code:r,message:n});throw new e({type:"api_error",code:"checkout_session_error",message:n})}return u},o=e=>{const{progress:r,isCheckoutSession:t,loadStripeStatus:n,intentClientSecret:o}=e;return"loading"===r||"success"===r||!(t?"success"===n:null!=o&&""!==o)},s=async(r,t,n,o,s)=>{const i=await("payment"===n?r.confirmPayment({elements:t,confirmParams:Object.assign({return_url:o},s),redirect:"if_required"}):r.confirmSetup({elements:t,confirmParams:Object.assign({return_url:o},s),redirect:"if_required"}));if(i.error)throw new e(i.error);return i},i=async(e,r,t)=>n(e,r,t),c=e=>{const{stripe:r,isCheckoutSession:t,checkout:n,checkoutSessionClientSecret:o,elements:s,intentClientSecret:i}=e,c={stripe:r};return t?null==n?{error:"Checkout not properly initialized"}:(c.checkout=n,c.checkoutSessionClientSecret=o,{props:c}):null==s?{error:"Elements not properly initialized"}:(c.elements=s,c.intentClientSecret=i,{props:c})};export{i as a,c as b,s as c,n as d,o as i}
|
|
@@ -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-eeebfbbf",[[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-e660d76a",[[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-2e2bf0fe",[[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-32a2d5a4",[[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-84d45b48",[[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-c4a0e310",[[0,"stripe-payment-element",{intentType:[1,"intent-type"],sheetTitle:[1,"sheet-title"],buttonLabel:[1,"button-label"],publishableKey:[1,"publishable-key"],stripeAccount:[1,"stripe-account"],applicationName:[1,"application-name"],intentClientSecret:[1,"intent-client-secret"],checkoutSessionClientSecret:[1,"checkout-session-client-secret"],shouldUseDefaultFormSubmitAction:[4,"should-use-default-form-submit-action"],checkoutSessionReturnUrl:[1,"checkout-session-return-url"],checkoutSessionEmail:[1,"checkout-session-email"],checkoutSessionDefaultValues:[16],handleSubmit:[1040],stripeDidLoaded:[1040],progress:[32],initStripe:[64],initStripeWithCheckoutSession:[64],updateProgress:[64],setErrorMessage:[64]},null,{publishableKey:[{updatePublishableKey:0}],stripeAccount:[{updateStripeAccountId:0}],intentClientSecret:[{updateIntentClientSecret:0}],checkoutSessionClientSecret:[{updateCheckoutSessionClientSecret:0}]}]]],["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-a266da6f",[[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))));
|
|
@@ -205,6 +205,11 @@ export declare class StripeCardElement {
|
|
|
205
205
|
private stripeLoadedEventHandler;
|
|
206
206
|
/**
|
|
207
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.
|
|
208
213
|
* @example
|
|
209
214
|
* ```
|
|
210
215
|
* const stripeElement = document.createElement('stripe-card-element');
|
|
@@ -182,6 +182,39 @@ export declare class StripePaymentElement {
|
|
|
182
182
|
* And listen the 'formSubmit' event on the element
|
|
183
183
|
*/
|
|
184
184
|
readonly shouldUseDefaultFormSubmitAction: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* URL Stripe redirects to after a redirect-based payment method (Checkout Session mode only).
|
|
187
|
+
* Used when the Checkout Session was created WITHOUT `return_url`. Defaults to the current page URL.
|
|
188
|
+
* A session created with `return_url` ignores this value: Stripe redirects there automatically.
|
|
189
|
+
* @example
|
|
190
|
+
* ```
|
|
191
|
+
* <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-return-url="https://example.com/return" />
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
readonly checkoutSessionReturnUrl?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Customer email passed to `confirm()` (Checkout Session mode only).
|
|
197
|
+
* Required when the Checkout Session was created without `customer_email` or `customer`,
|
|
198
|
+
* because confirming such a session fails with "An email address is required".
|
|
199
|
+
* @example
|
|
200
|
+
* ```
|
|
201
|
+
* <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-email="customer@example.com" />
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
readonly checkoutSessionEmail?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Prefilled values of the Checkout Elements (Checkout Session mode only): `email`, `phoneNumber`,
|
|
207
|
+
* `billingAddress` and `shippingAddress` as supported by `initCheckoutElementsSdk`.
|
|
208
|
+
* JavaScript property only: it cannot be set through an HTML attribute.
|
|
209
|
+
* @example
|
|
210
|
+
* ```
|
|
211
|
+
* const stripeElement = document.createElement('stripe-payment-element');
|
|
212
|
+
* customElements.whenDefined('stripe-payment-element').then(() => {
|
|
213
|
+
* stripeElement.checkoutSessionDefaultValues = { email: 'customer@example.com' };
|
|
214
|
+
* });
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
readonly checkoutSessionDefaultValues?: CheckoutSessionOptions['defaultValues'];
|
|
185
218
|
/**
|
|
186
219
|
* Form submit event handler
|
|
187
220
|
*/
|
|
@@ -209,6 +242,11 @@ export declare class StripePaymentElement {
|
|
|
209
242
|
private stripeLoadedEventHandler;
|
|
210
243
|
/**
|
|
211
244
|
* Form submit event
|
|
245
|
+
*
|
|
246
|
+
* Note: this event fires after the submit handling completes, not when the form is
|
|
247
|
+
* submitted. With the default submit action it is emitted only after the payment
|
|
248
|
+
* succeeds; a declined payment shows an error inside the form and this event does
|
|
249
|
+
* not fire. Listen to `defaultFormSubmitResult` for the outcome of the default action.
|
|
212
250
|
* @example
|
|
213
251
|
* ```
|
|
214
252
|
* const stripeElement = document.createElement('stripe-payment-element');
|
|
@@ -34,12 +34,18 @@ export type ExtraConfirmParams = Pick<ConfirmPaymentData & ConfirmSetupData, 'pa
|
|
|
34
34
|
export declare const confirmPaymentOrSetup: (stripe: Stripe, elements: StripeElements, intentType: IntentType, returnUrl: string, extraConfirmParams?: ExtraConfirmParams) => Promise<import("@stripe/stripe-js").PaymentIntentResult | import("@stripe/stripe-js").SetupIntentResult>;
|
|
35
35
|
/**
|
|
36
36
|
* Confirm a Checkout Session payment using the checkout actions.
|
|
37
|
+
*
|
|
38
|
+
* Stripe requires exactly one of `returnUrl` (confirm argument) or the session's `return_url`, and the client
|
|
39
|
+
* cannot tell which one a session has (`getSession()` does not expose it). The shared implementation passes
|
|
40
|
+
* `returnUrl` first and retries without it when Stripe rejects it because the session already has
|
|
41
|
+
* `return_url`. See `confirmCheckoutActions` for the full behavior and error classification.
|
|
37
42
|
* @param checkout the Stripe Checkout instance
|
|
38
|
-
* @param returnUrl
|
|
43
|
+
* @param returnUrl URL Stripe should redirect back to when the session has no `return_url`
|
|
44
|
+
* @param email customer email, required when the session was created without `customer_email` or `customer`
|
|
39
45
|
* @returns the confirmation result
|
|
40
46
|
* @throws StripeAPIError when loading actions or confirming fails
|
|
41
47
|
*/
|
|
42
|
-
export declare const confirmCheckoutSession: (checkout: StripeCheckoutElementsSdk, returnUrl: string) => Promise<StripeCheckoutConfirmResult>;
|
|
48
|
+
export declare const confirmCheckoutSession: (checkout: StripeCheckoutElementsSdk, returnUrl: string, email?: string) => Promise<StripeCheckoutConfirmResult>;
|
|
43
49
|
/**
|
|
44
50
|
* Resolve the mode-specific properties for a submit event.
|
|
45
51
|
* Picks the Checkout or Elements payload depending on the active mode and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StripeCheckoutConfirmResult, StripeCheckoutElementsOptions, StripeCheckoutElementsSdk, StripeCheckoutPaymentElementOptions } from '@stripe/stripe-js';
|
|
1
|
+
import type { StripeCheckoutConfirmResult, StripeCheckoutElementsOptions, StripeCheckoutElementsSdk, StripeCheckoutElementsSdkOptions, StripeCheckoutPaymentElementOptions } from '@stripe/stripe-js';
|
|
2
2
|
import type { PaymentSheetOptions } from './stripe-payment-sheet.helpers';
|
|
3
3
|
/**
|
|
4
4
|
* Build the Checkout Payment Element options from the payment sheet options.
|
|
@@ -7,9 +7,18 @@ import type { PaymentSheetOptions } from './stripe-payment-sheet.helpers';
|
|
|
7
7
|
* @param options - Payment sheet options
|
|
8
8
|
*/
|
|
9
9
|
export declare const toCheckoutPaymentElementOptions: (options: PaymentSheetOptions | undefined) => StripeCheckoutPaymentElementOptions;
|
|
10
|
+
type CheckoutDefaultValues = NonNullable<StripeCheckoutElementsSdkOptions['defaultValues']>;
|
|
11
|
+
/**
|
|
12
|
+
* Build the `defaultValues` passed to `initCheckoutElementsSdk` from the payment sheet options.
|
|
13
|
+
* The email and phone prefill the Checkout Elements; name and address are passed as `billingAddress`,
|
|
14
|
+
* which Stripe only accepts with a country, so a name or address without `country` cannot be prefilled.
|
|
15
|
+
* @param options - Payment sheet options
|
|
16
|
+
*/
|
|
17
|
+
export declare const toCheckoutDefaultValues: (options: PaymentSheetOptions | undefined) => CheckoutDefaultValues | undefined;
|
|
10
18
|
/**
|
|
11
19
|
* List the given options that a Checkout Session does not use, sorted by name.
|
|
12
|
-
* Name
|
|
20
|
+
* Name and address are prefilled through `defaultValues`, which Stripe only accepts with a country, so they are
|
|
21
|
+
* listed when they cannot be used. The email is passed to `confirm` and the phone prefilled through `defaultValues`.
|
|
13
22
|
* @param options - Payment sheet options
|
|
14
23
|
*/
|
|
15
24
|
export declare const checkoutIgnoredOptionKeys: (options: PaymentSheetOptions | undefined) => string[];
|
|
@@ -21,19 +30,18 @@ export declare const toCheckoutElementsOptions: (options: PaymentSheetOptions |
|
|
|
21
30
|
/**
|
|
22
31
|
* Confirm a Checkout Session from the payment sheet.
|
|
23
32
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
33
|
+
* The shared implementation (see `confirmCheckoutActions`) retries without `returnUrl` when the session was
|
|
34
|
+
* created with `return_url`, and passes `redirect: 'if_required'` so that payment methods without a redirect
|
|
35
|
+
* finish in the page and can be reported as `paymentSheetCompleted`.
|
|
26
36
|
*
|
|
27
|
-
* Errors are thrown as `StripeAPIError` with a `type` that `isRecoverableConfirmError` understands
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`, which ends the sheet
|
|
31
|
-
* - `paymentFailed` on an open session (a decline): `card_error`, which keeps the sheet open
|
|
32
|
-
* - any other confirm error on an open session, or a failure to load the actions: `api_error`, which keeps the sheet open
|
|
37
|
+
* Errors are thrown as `StripeAPIError` with a `type` that `isRecoverableConfirmError` understands:
|
|
38
|
+
* an expired or complete session is an `invalid_request_error` (unrecoverable), a decline is a `card_error`,
|
|
39
|
+
* and any other failure is an `api_error` (both recoverable).
|
|
33
40
|
* @param checkout - The Checkout instance from `initCheckoutElementsSdk`
|
|
34
|
-
* @param returnUrl - Where Stripe redirects after a redirect-based payment method
|
|
41
|
+
* @param returnUrl - Where Stripe redirects after a redirect-based payment method, when the session has no `return_url`
|
|
35
42
|
* @param email - Customer email; needed when the session was created without `customer_email` or `customer`
|
|
36
43
|
* @returns The confirmation result
|
|
37
44
|
* @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
|
|
38
45
|
*/
|
|
39
46
|
export declare const confirmCheckoutSessionSheet: (checkout: StripeCheckoutElementsSdk, returnUrl: string, email?: string) => Promise<StripeCheckoutConfirmResult>;
|
|
47
|
+
export {};
|
|
@@ -8,13 +8,13 @@ import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
|
8
8
|
import { AddressSubmitEvent, AddressSubmitHandler } from "./components/stripe-address-element/stripe-address-element";
|
|
9
9
|
import { CurrencySelectorChangeEvent, CurrencySelectorChangeHandler, DefaultFormSubmitResult, FormSubmitEvent, FormSubmitHandler, InitStripeOptions, IntentType, LinkAuthenticationElementChangeEvent, LinkAuthenticationElementChangeHandler, PaymentRequestButtonOption, PaymentRequestPaymentMethodEventHandler, PaymentRequestShippingAddressEventHandler, PaymentRequestShippingOptionEventHandler, ProgressStatus, StripeDidLoadedHandler, StripeLoadedEvent } from "./interfaces";
|
|
10
10
|
import { PaymentIntentResult, PaymentRequestOptions, PaymentRequestWallet, SetupIntentResult, StripeCheckoutConfirmResult, StripeExpressCheckoutElementClickEvent, StripeExpressCheckoutElementConfirmEvent } from "@stripe/stripe-js";
|
|
11
|
-
import { ExpressCheckoutElementOptions } from "./services/interfaces";
|
|
11
|
+
import { CheckoutSessionOptions, ExpressCheckoutElementOptions } from "./services/interfaces";
|
|
12
12
|
import { CheckoutSessionFormSubmitResult, InitCheckoutSessionOptions, PaymentElementSubmitEvent, PaymentElementSubmitHandler } from "./components/stripe-payment-element/stripe-payment-element";
|
|
13
13
|
import { PaymentSheetOptions, PaymentSheetPresentResult } from "./components/stripe-payment-sheet/stripe-payment-sheet.helpers";
|
|
14
14
|
export { AddressSubmitEvent, AddressSubmitHandler } from "./components/stripe-address-element/stripe-address-element";
|
|
15
15
|
export { CurrencySelectorChangeEvent, CurrencySelectorChangeHandler, DefaultFormSubmitResult, FormSubmitEvent, FormSubmitHandler, InitStripeOptions, IntentType, LinkAuthenticationElementChangeEvent, LinkAuthenticationElementChangeHandler, PaymentRequestButtonOption, PaymentRequestPaymentMethodEventHandler, PaymentRequestShippingAddressEventHandler, PaymentRequestShippingOptionEventHandler, ProgressStatus, StripeDidLoadedHandler, StripeLoadedEvent } from "./interfaces";
|
|
16
16
|
export { PaymentIntentResult, PaymentRequestOptions, PaymentRequestWallet, SetupIntentResult, StripeCheckoutConfirmResult, StripeExpressCheckoutElementClickEvent, StripeExpressCheckoutElementConfirmEvent } from "@stripe/stripe-js";
|
|
17
|
-
export { ExpressCheckoutElementOptions } from "./services/interfaces";
|
|
17
|
+
export { CheckoutSessionOptions, ExpressCheckoutElementOptions } from "./services/interfaces";
|
|
18
18
|
export { CheckoutSessionFormSubmitResult, InitCheckoutSessionOptions, PaymentElementSubmitEvent, PaymentElementSubmitHandler } from "./components/stripe-payment-element/stripe-payment-element";
|
|
19
19
|
export { PaymentSheetOptions, PaymentSheetPresentResult } from "./components/stripe-payment-sheet/stripe-payment-sheet.helpers";
|
|
20
20
|
export namespace Components {
|
|
@@ -510,6 +510,21 @@ export namespace Components {
|
|
|
510
510
|
* @example ``` const stripeElement = document.createElement('stripe-payment-element'); customElements .whenDefined('stripe-payment-element') .then(() => { stripeElement.initStripeWithCheckoutSession('pk_test_xxx', 'cs_xxx_secret_xxx') }) ```
|
|
511
511
|
*/
|
|
512
512
|
"checkoutSessionClientSecret"?: string;
|
|
513
|
+
/**
|
|
514
|
+
* Prefilled values of the Checkout Elements (Checkout Session mode only): `email`, `phoneNumber`, `billingAddress` and `shippingAddress` as supported by `initCheckoutElementsSdk`. JavaScript property only: it cannot be set through an HTML attribute.
|
|
515
|
+
* @example ``` const stripeElement = document.createElement('stripe-payment-element'); customElements.whenDefined('stripe-payment-element').then(() => { stripeElement.checkoutSessionDefaultValues = { email: 'customer@example.com' }; }); ```
|
|
516
|
+
*/
|
|
517
|
+
"checkoutSessionDefaultValues"?: CheckoutSessionOptions['defaultValues'];
|
|
518
|
+
/**
|
|
519
|
+
* Customer email passed to `confirm()` (Checkout Session mode only). Required when the Checkout Session was created without `customer_email` or `customer`, because confirming such a session fails with "An email address is required".
|
|
520
|
+
* @example ``` <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-email="customer@example.com" /> ```
|
|
521
|
+
*/
|
|
522
|
+
"checkoutSessionEmail"?: string;
|
|
523
|
+
/**
|
|
524
|
+
* URL Stripe redirects to after a redirect-based payment method (Checkout Session mode only). Used when the Checkout Session was created WITHOUT `return_url`. Defaults to the current page URL. A session created with `return_url` ignores this value: Stripe redirects there automatically.
|
|
525
|
+
* @example ``` <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-return-url="https://example.com/return" /> ```
|
|
526
|
+
*/
|
|
527
|
+
"checkoutSessionReturnUrl"?: string;
|
|
513
528
|
/**
|
|
514
529
|
* Form submit event handler
|
|
515
530
|
*/
|
|
@@ -1066,7 +1081,7 @@ declare namespace LocalJSX {
|
|
|
1066
1081
|
*/
|
|
1067
1082
|
"onDefaultFormSubmitResult"?: (event: StripeCardElementCustomEvent<DefaultFormSubmitResult>) => void;
|
|
1068
1083
|
/**
|
|
1069
|
-
* Form submit event
|
|
1084
|
+
* 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
1085
|
* @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
1086
|
*/
|
|
1072
1087
|
"onFormSubmit"?: (event: StripeCardElementCustomEvent<FormSubmitEvent>) => void;
|
|
@@ -1376,6 +1391,21 @@ declare namespace LocalJSX {
|
|
|
1376
1391
|
* @example ``` const stripeElement = document.createElement('stripe-payment-element'); customElements .whenDefined('stripe-payment-element') .then(() => { stripeElement.initStripeWithCheckoutSession('pk_test_xxx', 'cs_xxx_secret_xxx') }) ```
|
|
1377
1392
|
*/
|
|
1378
1393
|
"checkoutSessionClientSecret"?: string;
|
|
1394
|
+
/**
|
|
1395
|
+
* Prefilled values of the Checkout Elements (Checkout Session mode only): `email`, `phoneNumber`, `billingAddress` and `shippingAddress` as supported by `initCheckoutElementsSdk`. JavaScript property only: it cannot be set through an HTML attribute.
|
|
1396
|
+
* @example ``` const stripeElement = document.createElement('stripe-payment-element'); customElements.whenDefined('stripe-payment-element').then(() => { stripeElement.checkoutSessionDefaultValues = { email: 'customer@example.com' }; }); ```
|
|
1397
|
+
*/
|
|
1398
|
+
"checkoutSessionDefaultValues"?: CheckoutSessionOptions['defaultValues'];
|
|
1399
|
+
/**
|
|
1400
|
+
* Customer email passed to `confirm()` (Checkout Session mode only). Required when the Checkout Session was created without `customer_email` or `customer`, because confirming such a session fails with "An email address is required".
|
|
1401
|
+
* @example ``` <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-email="customer@example.com" /> ```
|
|
1402
|
+
*/
|
|
1403
|
+
"checkoutSessionEmail"?: string;
|
|
1404
|
+
/**
|
|
1405
|
+
* URL Stripe redirects to after a redirect-based payment method (Checkout Session mode only). Used when the Checkout Session was created WITHOUT `return_url`. Defaults to the current page URL. A session created with `return_url` ignores this value: Stripe redirects there automatically.
|
|
1406
|
+
* @example ``` <stripe-payment-element checkout-session-client-secret="cs_xxx_secret_xxx" checkout-session-return-url="https://example.com/return" /> ```
|
|
1407
|
+
*/
|
|
1408
|
+
"checkoutSessionReturnUrl"?: string;
|
|
1379
1409
|
/**
|
|
1380
1410
|
* Form submit event handler
|
|
1381
1411
|
*/
|
|
@@ -1402,7 +1432,7 @@ declare namespace LocalJSX {
|
|
|
1402
1432
|
*/
|
|
1403
1433
|
"onDefaultFormSubmitResult"?: (event: StripePaymentElementCustomEvent<DefaultFormSubmitResult>) => void;
|
|
1404
1434
|
/**
|
|
1405
|
-
* Form submit event
|
|
1435
|
+
* 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
1436
|
* @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
1437
|
*/
|
|
1408
1438
|
"onFormSubmit"?: (event: StripePaymentElementCustomEvent<PaymentElementSubmitEvent>) => void;
|
|
@@ -1625,6 +1655,8 @@ declare namespace LocalJSX {
|
|
|
1625
1655
|
"intentClientSecret": string;
|
|
1626
1656
|
"checkoutSessionClientSecret": string;
|
|
1627
1657
|
"shouldUseDefaultFormSubmitAction": boolean;
|
|
1658
|
+
"checkoutSessionReturnUrl": string;
|
|
1659
|
+
"checkoutSessionEmail": string;
|
|
1628
1660
|
}
|
|
1629
1661
|
interface StripePaymentRequestButtonAttributes {
|
|
1630
1662
|
"publishableKey": string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { Stripe, StripeElements, StripeCardNumberElement, StripeCardExpiryElement, StripeCardCvcElement, StripePaymentElement, StripeAddressElement, StripeLinkAuthenticationElement, StripeCurrencySelectorElement, StripeExpressCheckoutElement, StripeExpressCheckoutElementConfirmEvent, StripeExpressCheckoutElementClickEvent, StripeExpressCheckoutElementShippingAddressChangeEvent, StripeExpressCheckoutElementShippingRateChangeEvent, StripeCheckoutElementsSdk, StripeCheckoutElementsOptions } from '@stripe/stripe-js';
|
|
1
|
+
import { Stripe, StripeElements, StripeCardNumberElement, StripeCardExpiryElement, StripeCardCvcElement, StripePaymentElement, StripeAddressElement, StripeLinkAuthenticationElement, StripeCurrencySelectorElement, StripeExpressCheckoutElement, StripeExpressCheckoutElementConfirmEvent, StripeExpressCheckoutElementClickEvent, StripeExpressCheckoutElementShippingAddressChangeEvent, StripeExpressCheckoutElementShippingRateChangeEvent, StripeCheckoutElementsSdk, StripeCheckoutElementsOptions, StripeCheckoutElementsSdkOptions } from '@stripe/stripe-js';
|
|
2
2
|
import { ProgressStatus } from '../interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* Checkout session initialization options
|
|
5
5
|
*/
|
|
6
6
|
export type CheckoutSessionOptions = {
|
|
7
7
|
elementsOptions?: StripeCheckoutElementsOptions;
|
|
8
|
+
/** Prefilled values of the Checkout Elements (email, phone, billing or shipping address) */
|
|
9
|
+
defaultValues?: StripeCheckoutElementsSdkOptions['defaultValues'];
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* Stripe service state
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { StripeCheckoutConfirmResult, StripeCheckoutElementsSdk, StripeCheckoutStatus } from '@stripe/stripe-js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a confirm failure means the session was created with `return_url`, which rejects `returnUrl`.
|
|
4
|
+
* Stripe raises this before any payment processing, so retrying without `returnUrl` is safe.
|
|
5
|
+
* `actions.confirm()` reports it both as a thrown `IntegrationError` and as an error result depending on the SDK version.
|
|
6
|
+
* @param error - Error thrown by `actions.confirm()` or the error of its result
|
|
7
|
+
*/
|
|
8
|
+
export declare const isCheckoutReturnUrlConflict: (error: unknown) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Throw when the session can no longer be paid. Stripe documents an `expired` session as "No further processing will occur",
|
|
11
|
+
* and a `complete` one is already paid or being paid, so confirming again cannot succeed.
|
|
12
|
+
* @param status - `session.status` from `getSession()`; undefined when it cannot be read
|
|
13
|
+
* @param message - Message of the confirm error, if any
|
|
14
|
+
* @throws StripeAPIError of type `invalid_request_error` (unrecoverable), with the code `checkout_session_expired` or `checkout_session_complete`
|
|
15
|
+
*/
|
|
16
|
+
export declare const assertCheckoutSessionOpen: (status: StripeCheckoutStatus | undefined, message?: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Confirm a Checkout Session through the checkout actions.
|
|
19
|
+
*
|
|
20
|
+
* Stripe requires exactly one of `returnUrl` (confirm argument) or the session's `return_url`, and the client
|
|
21
|
+
* cannot tell which one a session has (`getSession()` does not expose it). So the first attempt passes
|
|
22
|
+
* `returnUrl`, and when Stripe rejects it because the session already has `return_url`, the confirmation is
|
|
23
|
+
* retried without `returnUrl` (Stripe then redirects to the session's `return_url` automatically).
|
|
24
|
+
*
|
|
25
|
+
* Errors are thrown as `StripeAPIError`:
|
|
26
|
+
* - session `expired` or `complete` (before confirming or after a failed confirm): `invalid_request_error`
|
|
27
|
+
* - `paymentFailed` on an open session (a decline): `card_error`
|
|
28
|
+
* - any other confirm error on an open session, or a failure to load the actions: `api_error`
|
|
29
|
+
* @param checkout - The Checkout instance from `initCheckoutElementsSdk`
|
|
30
|
+
* @param returnUrl - Where Stripe redirects after a redirect-based payment method, when the session has no `return_url`
|
|
31
|
+
* @param email - Customer email; needed when the session was created without `customer_email` or `customer`
|
|
32
|
+
* @returns The confirmation result
|
|
33
|
+
* @throws StripeAPIError when the actions cannot be loaded, the session can no longer be paid, or the confirmation fails
|
|
34
|
+
*/
|
|
35
|
+
export declare const confirmCheckoutActions: (checkout: StripeCheckoutElementsSdk, returnUrl: string, email?: string) => Promise<StripeCheckoutConfirmResult>;
|
package/package.json
CHANGED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var error = require('./error-FFC4kSs5.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Determine whether the submit button should be disabled.
|
|
7
|
-
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
8
|
-
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
9
|
-
* The button stays disabled after a successful payment as well: the intent or
|
|
10
|
-
* checkout is already confirmed and cannot be submitted again.
|
|
11
|
-
* @param params progress / loading state and the current mode information
|
|
12
|
-
* @returns true when the submit button should be disabled
|
|
13
|
-
*/
|
|
14
|
-
const isSubmitButtonDisabled = (params) => {
|
|
15
|
-
const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
|
|
16
|
-
const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
|
|
17
|
-
return progress === 'loading' || progress === 'success' || !hasValidSecret;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
|
|
21
|
-
* Calls `confirmPayment` or `confirmSetup` depending on the intent type.
|
|
22
|
-
* @param stripe the loaded Stripe.js instance
|
|
23
|
-
* @param elements the Stripe Elements instance bound to the payment element
|
|
24
|
-
* @param intentType the configured intent type
|
|
25
|
-
* @param returnUrl the URL Stripe should redirect back to when required
|
|
26
|
-
* @param extraConfirmParams optional params merged into `confirmParams` (for example `payment_method_data.billing_details`)
|
|
27
|
-
* @returns the confirmation result
|
|
28
|
-
* @throws StripeAPIError when Stripe returns an error
|
|
29
|
-
*/
|
|
30
|
-
const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl, extraConfirmParams) => {
|
|
31
|
-
const result = await (() => {
|
|
32
|
-
if (intentType === 'payment') {
|
|
33
|
-
return stripe.confirmPayment({
|
|
34
|
-
elements,
|
|
35
|
-
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
36
|
-
redirect: 'if_required',
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return stripe.confirmSetup({
|
|
40
|
-
elements,
|
|
41
|
-
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
42
|
-
redirect: 'if_required',
|
|
43
|
-
});
|
|
44
|
-
})();
|
|
45
|
-
if (result.error) {
|
|
46
|
-
throw new error.StripeAPIError(result.error);
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Confirm a Checkout Session payment using the checkout actions.
|
|
52
|
-
* @param checkout the Stripe Checkout instance
|
|
53
|
-
* @param returnUrl the URL Stripe should redirect back to when required
|
|
54
|
-
* @returns the confirmation result
|
|
55
|
-
* @throws StripeAPIError when loading actions or confirming fails
|
|
56
|
-
*/
|
|
57
|
-
const confirmCheckoutSession = async (checkout, returnUrl) => {
|
|
58
|
-
var _a;
|
|
59
|
-
// Load actions from the checkout session
|
|
60
|
-
const loadActionsResult = await checkout.loadActions();
|
|
61
|
-
if (loadActionsResult.type === 'error') {
|
|
62
|
-
// Create a StripeError-compatible object from the Checkout Session error
|
|
63
|
-
const stripeError = {
|
|
64
|
-
type: 'api_error',
|
|
65
|
-
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
66
|
-
message: loadActionsResult.error.message,
|
|
67
|
-
};
|
|
68
|
-
throw new error.StripeAPIError(stripeError);
|
|
69
|
-
}
|
|
70
|
-
const { actions } = loadActionsResult;
|
|
71
|
-
// Confirm the payment using checkout session actions
|
|
72
|
-
const result = await actions.confirm({
|
|
73
|
-
returnUrl,
|
|
74
|
-
redirect: 'if_required',
|
|
75
|
-
});
|
|
76
|
-
if (result.type === 'error') {
|
|
77
|
-
// Create a StripeError-compatible object from the confirm error
|
|
78
|
-
const stripeError = {
|
|
79
|
-
type: 'card_error',
|
|
80
|
-
code: result.error.code || 'payment_failed',
|
|
81
|
-
message: result.error.message,
|
|
82
|
-
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
83
|
-
};
|
|
84
|
-
throw new error.StripeAPIError(stripeError);
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Resolve the mode-specific properties for a submit event.
|
|
90
|
-
* Picks the Checkout or Elements payload depending on the active mode and
|
|
91
|
-
* reports a descriptive error string when the required instance is missing.
|
|
92
|
-
* @param params the resolved Stripe instances and client secrets for the current mode
|
|
93
|
-
* @returns the submit event props, or an error message when an instance is missing
|
|
94
|
-
*/
|
|
95
|
-
const buildSubmitEventProps = (params) => {
|
|
96
|
-
const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
|
|
97
|
-
const props = {
|
|
98
|
-
stripe,
|
|
99
|
-
};
|
|
100
|
-
if (isCheckoutSession) {
|
|
101
|
-
// Checkout Session mode
|
|
102
|
-
if (checkout == null) {
|
|
103
|
-
return { error: 'Checkout not properly initialized' };
|
|
104
|
-
}
|
|
105
|
-
props.checkout = checkout;
|
|
106
|
-
props.checkoutSessionClientSecret = checkoutSessionClientSecret;
|
|
107
|
-
return { props };
|
|
108
|
-
}
|
|
109
|
-
// Payment Intent / Setup Intent mode
|
|
110
|
-
if (elements == null) {
|
|
111
|
-
return { error: 'Elements not properly initialized' };
|
|
112
|
-
}
|
|
113
|
-
props.elements = elements;
|
|
114
|
-
props.intentClientSecret = intentClientSecret;
|
|
115
|
-
return { props };
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
exports.buildSubmitEventProps = buildSubmitEventProps;
|
|
119
|
-
exports.confirmCheckoutSession = confirmCheckoutSession;
|
|
120
|
-
exports.confirmPaymentOrSetup = confirmPaymentOrSetup;
|
|
121
|
-
exports.isSubmitButtonDisabled = isSubmitButtonDisabled;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { S as StripeAPIError } from './error-XRfh5Wrs.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Determine whether the submit button should be disabled.
|
|
5
|
-
* For Checkout Session mode: the checkout is ready once Stripe finished loading.
|
|
6
|
-
* For Payment Intent / Setup Intent mode: an intent client secret must be present.
|
|
7
|
-
* The button stays disabled after a successful payment as well: the intent or
|
|
8
|
-
* checkout is already confirmed and cannot be submitted again.
|
|
9
|
-
* @param params progress / loading state and the current mode information
|
|
10
|
-
* @returns true when the submit button should be disabled
|
|
11
|
-
*/
|
|
12
|
-
const isSubmitButtonDisabled = (params) => {
|
|
13
|
-
const { progress, isCheckoutSession, loadStripeStatus, intentClientSecret } = params;
|
|
14
|
-
const hasValidSecret = isCheckoutSession ? loadStripeStatus === 'success' : intentClientSecret != null && intentClientSecret !== '';
|
|
15
|
-
return progress === 'loading' || progress === 'success' || !hasValidSecret;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Run the default Stripe confirmation flow for Payment Intent / Setup Intent mode.
|
|
19
|
-
* Calls `confirmPayment` or `confirmSetup` depending on the intent type.
|
|
20
|
-
* @param stripe the loaded Stripe.js instance
|
|
21
|
-
* @param elements the Stripe Elements instance bound to the payment element
|
|
22
|
-
* @param intentType the configured intent type
|
|
23
|
-
* @param returnUrl the URL Stripe should redirect back to when required
|
|
24
|
-
* @param extraConfirmParams optional params merged into `confirmParams` (for example `payment_method_data.billing_details`)
|
|
25
|
-
* @returns the confirmation result
|
|
26
|
-
* @throws StripeAPIError when Stripe returns an error
|
|
27
|
-
*/
|
|
28
|
-
const confirmPaymentOrSetup = async (stripe, elements, intentType, returnUrl, extraConfirmParams) => {
|
|
29
|
-
const result = await (() => {
|
|
30
|
-
if (intentType === 'payment') {
|
|
31
|
-
return stripe.confirmPayment({
|
|
32
|
-
elements,
|
|
33
|
-
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
34
|
-
redirect: 'if_required',
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return stripe.confirmSetup({
|
|
38
|
-
elements,
|
|
39
|
-
confirmParams: Object.assign({ return_url: returnUrl }, extraConfirmParams),
|
|
40
|
-
redirect: 'if_required',
|
|
41
|
-
});
|
|
42
|
-
})();
|
|
43
|
-
if (result.error) {
|
|
44
|
-
throw new StripeAPIError(result.error);
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Confirm a Checkout Session payment using the checkout actions.
|
|
50
|
-
* @param checkout the Stripe Checkout instance
|
|
51
|
-
* @param returnUrl the URL Stripe should redirect back to when required
|
|
52
|
-
* @returns the confirmation result
|
|
53
|
-
* @throws StripeAPIError when loading actions or confirming fails
|
|
54
|
-
*/
|
|
55
|
-
const confirmCheckoutSession = async (checkout, returnUrl) => {
|
|
56
|
-
var _a;
|
|
57
|
-
// Load actions from the checkout session
|
|
58
|
-
const loadActionsResult = await checkout.loadActions();
|
|
59
|
-
if (loadActionsResult.type === 'error') {
|
|
60
|
-
// Create a StripeError-compatible object from the Checkout Session error
|
|
61
|
-
const stripeError = {
|
|
62
|
-
type: 'api_error',
|
|
63
|
-
code: loadActionsResult.error.code || 'checkout_session_error',
|
|
64
|
-
message: loadActionsResult.error.message,
|
|
65
|
-
};
|
|
66
|
-
throw new StripeAPIError(stripeError);
|
|
67
|
-
}
|
|
68
|
-
const { actions } = loadActionsResult;
|
|
69
|
-
// Confirm the payment using checkout session actions
|
|
70
|
-
const result = await actions.confirm({
|
|
71
|
-
returnUrl,
|
|
72
|
-
redirect: 'if_required',
|
|
73
|
-
});
|
|
74
|
-
if (result.type === 'error') {
|
|
75
|
-
// Create a StripeError-compatible object from the confirm error
|
|
76
|
-
const stripeError = {
|
|
77
|
-
type: 'card_error',
|
|
78
|
-
code: result.error.code || 'payment_failed',
|
|
79
|
-
message: result.error.message,
|
|
80
|
-
decline_code: result.error.code === 'paymentFailed' ? (_a = result.error.paymentFailed) === null || _a === void 0 ? void 0 : _a.declineCode : undefined,
|
|
81
|
-
};
|
|
82
|
-
throw new StripeAPIError(stripeError);
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Resolve the mode-specific properties for a submit event.
|
|
88
|
-
* Picks the Checkout or Elements payload depending on the active mode and
|
|
89
|
-
* reports a descriptive error string when the required instance is missing.
|
|
90
|
-
* @param params the resolved Stripe instances and client secrets for the current mode
|
|
91
|
-
* @returns the submit event props, or an error message when an instance is missing
|
|
92
|
-
*/
|
|
93
|
-
const buildSubmitEventProps = (params) => {
|
|
94
|
-
const { stripe, isCheckoutSession, checkout, checkoutSessionClientSecret, elements, intentClientSecret } = params;
|
|
95
|
-
const props = {
|
|
96
|
-
stripe,
|
|
97
|
-
};
|
|
98
|
-
if (isCheckoutSession) {
|
|
99
|
-
// Checkout Session mode
|
|
100
|
-
if (checkout == null) {
|
|
101
|
-
return { error: 'Checkout not properly initialized' };
|
|
102
|
-
}
|
|
103
|
-
props.checkout = checkout;
|
|
104
|
-
props.checkoutSessionClientSecret = checkoutSessionClientSecret;
|
|
105
|
-
return { props };
|
|
106
|
-
}
|
|
107
|
-
// Payment Intent / Setup Intent mode
|
|
108
|
-
if (elements == null) {
|
|
109
|
-
return { error: 'Elements not properly initialized' };
|
|
110
|
-
}
|
|
111
|
-
props.elements = elements;
|
|
112
|
-
props.intentClientSecret = intentClientSecret;
|
|
113
|
-
return { props };
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export { confirmCheckoutSession as a, buildSubmitEventProps as b, confirmPaymentOrSetup as c, isSubmitButtonDisabled as i };
|