@arcblock/www-wallet
Version:
Start experiencing your digital world with ABT Wallet
2 lines • 3.18 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[36],{"1TXt":function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return E}));var n=r("kD0k"),a=r.n(n),o=(r("ls82"),r("/S4K")),i=r("8o2o"),s=r("q1tI"),c=r.n(s),u="https://js.stripe.com/v3",l=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,d="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",p=null,f=function(e){return null!==p?p:p=new Promise((function(t,r){if("undefined"!=typeof window)if(window.Stripe&&e&&console.warn(d),window.Stripe)t(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(u,'"]')),t=0;t<e.length;t++){var r=e[t];if(l.test(r.src))return r}return null}();n&&e?console.warn(d):n||(n=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(u).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(r),r}(e)),n.addEventListener("load",(function(){window.Stripe?t(window.Stripe):r(new Error("Stripe.js not available"))})),n.addEventListener("error",(function(){r(new Error("Failed to load Stripe.js"))}))}catch(a){return void r(a)}else t(null)}))},v=function(e,t,r){if(null===e)return null;var n=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"1.10.0",startTime:t})}(n,r),n},w=Promise.resolve().then((function(){return f(null)})),m=!1;w.catch((function(e){m||console.warn(e)}));var b=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];m=!0;var n=Date.now();return w.then((function(e){return v(e,t,n)}))},y=r("vDqi"),h=r.n(y),S=r("vOnD"),j=r("j9Lo"),g=r.n(j),k=r("Wqr9"),x=r("iae6");function E(e){var t=Object(k.mergeProps)(e,E),r=t.payServer;"undefined"===r&&(r="https://pay.arcblock.io/create-session");var n=t.buttonName,u=t.stripePK,l=t.priceId,d=t.payMode,p=Object(i.a)(t,["buttonName","stripePK","priceId","payMode"]);console.log(t);var f=Object(s.useState)(!1),v=f[0],w=f[1],m=function(){var e=Object(o.a)(a.a.mark((function e(t){var n,o,i,s;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w(!0),e.prev=1,e.next=4,b(u);case 4:return n=e.sent,e.next=7,h.a.post(r,{priceId:l,payMode:d});case 7:return o=e.sent,i=o.data,e.next=11,n.redirectToCheckout({sessionId:i.id});case 11:s=e.sent,w(!1),s.error,e.next=19;break;case 16:e.prev=16,e.t0=e.catch(1),w(!1);case 19:case"end":return e.stop()}}),e,null,[[1,16]])})));return function(t){return e.apply(this,arguments)}}();return c.a.createElement(P,Object.assign({variant:"outlined",color:"default",disabled:v,className:"button",size:"small",onClick:m},p),v&&c.a.createElement(x.a,{size:15}),n)}E.defaultProps={buttonName:"Subscribe",payServer:"https://pay.arcblock.io/create-session",stripePK:"pk_live_aDxtzzyDIWNN6naU3RGK4RRf00xWJGGkFA"};var P=Object(S.default)(g.a).withConfig({displayName:"stripe_pay__StyledButton",componentId:"sc-1i0n421-0"})([""])}}]);
//# sourceMappingURL=36-61916ef4329923df30bc.js.map