1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[252],{9586:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/payment",function(){return t(9719)}])},9719:function(e,n,t){"use strict";t.r(n),t.d(n,{CheckoutForm:function(){return d},default:function(){return h}});var r=t(4051),a=t.n(r),s=t(5893),i=t(6664),c=t(4465),u=t(1163),o=t(7294),l=t(1861),m=t(8847);function p(e,n,t,r,a,s,i){try{var c=e[s](i),u=c.value}catch(o){return void t(o)}c.done?n(u):Promise.resolve(u).then(r,a)}function d(e){var n=e.clientSecret,t=(0,i.useStripe)(),r=(0,i.useElements)(),c=(0,o.useState)(""),u=(c[0],c[1]),l=(0,o.useState)(""),m=l[0],d=l[1],f=(0,o.useState)(!1),h=f[0],v=f[1];(0,o.useEffect)((function(){if(t){var e=new URLSearchParams(window.location.search).get("payment_intent_client_secret");e&&t.retrievePaymentIntent(e).then((function(e){var n=e.paymentIntent;switch(null===n||void 0===n?void 0:n.status){case"succeeded":d("Payment succeeded!");break;case"processing":d("Your payment is processing.");break;case"requires_payment_method":d("Your payment was not successful, please try again.");break;default:d("Something went wrong.")}}))}}),[t]);var y=function(){var e,s=(e=a().mark((function e(s){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s.preventDefault(),t&&r){e.next=3;break}return e.abrupt("return");case 3:return v(!0),e.next=6,t.confirmPayment({elements:r,confirmParams:{return_url:"http://preview.writtenshape.com/checkout/result?cs=".concat(n)}});case 6:"card_error"===(i=e.sent.error).type||"validation_error"===i.type?d(i.message):d("An unexpected error occurred."),v(!1);case 9:case"end":return e.stop()}}),e)})),function(){var n=this,t=arguments;return new Promise((function(r,a){var s=e.apply(n,t);function i(e){p(s,r,a,i,c,"next",e)}function c(e){p(s,r,a,i,c,"throw",e)}i(void 0)}))});return function(e){return s.apply(this,arguments)}}();return(0,s.jsxs)("form",{id:"payment-form",onSubmit:y,children:[(0,s.jsxs)("div",{className:"payment-form-wrapper",children:[(0,s.jsxs)("div",{className:"payment-form-card",children:[(0,s.jsx)(i.LinkAuthenticationElement,{id:"link-authentication-element",onChange:function(e){return u(e.target.value)},className:"payment-mail"}),(0,s.jsx)(i.AddressElement,{className:"payment-address",options:{mode:"billing",display:{name:"split"},fields:{phone:"always"}}})]}),(0,s.jsxs)("div",{className:"payment-form-card",children:[(0,s.jsx)(i.PaymentElement,{id:"payment-element",className:"payment-card"}),(0,s.jsx)("button",{disabled:h||!t||!r,id:"submit",className:"payment-form-submit",children:(0,s.jsx)("span",{id:"button-text",children:h?(0,s.jsx)("div",{className:"spinner",id:"spinner"}):"Pay now"})})]})]}),m&&(0,s.jsx)("div",{className:"payment-form-message",children:m})]})}var f=(0,c.J)("pk_live_51Lpa4NKQpYteHCNMjuOD2YHA3L7u3OMnJ9uWbxMpVu2yXqhfuZwazicrzbUtAkGk7m6cDMwpJvclhD5R115uz2mc00Tlznsqj2",{locale:"en"});function h(){var e=(0,o.useState)(""),n=e[0],t=e[1],r=(0,o.useState)(""),a=r[0],c=r[1],p=(0,o.useState)(""),h=p[0],v=p[1],y=(0,o.useState)(!1),x=y[0],j=y[1],w=(0,u.useRouter)().back,b=(0,l.g1)().cartDetails;(0,o.useEffect)((function(){!(0,m.Qr)(b)&&x&&fetch("/api/create-payment-intent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:b,customer:a,email:h})}).then((function(e){return e.json()})).then((function(e){return t(e.clientSecret)})).catch((function(e){return console.log(e)}))}),[b,x]);var N={clientSecret:n,appearance:{theme:"flat",rules:{".Input":{borderRadius:"6px",background:"#fff",border:"solid 1px #000"}}}};return(0,s.jsxs)("div",{className:"payment",children:[(0,s.jsxs)("h2",{children:["Checkout ",(0,s.jsx)("span",{onClick:w,children:"\u21a9"})]}),!x&&(0,s.jsxs)("div",{className:"license",children:[(0,s.jsx)("label",{htmlFor:"text",children:"Who will own the license?"}),(0,s.jsx)("input",{className:"license-input",type:"text",onChange:function(e){return c(e.target.value)}}),(0,s.jsx)("label",{htmlFor:"text",children:"Email"}),(0,s.jsx)("input",{className:"license-input",type:"text",onChange:function(e){return v(e.target.value)}}),(0,s.jsx)("button",{className:"license-btn",onClick:function(){return j(!0)},children:"next step"})]}),!(0,m.Qr)(b)&&a&&x&&h&&n&&(0,s.jsx)(i.Elements,{options:N,stripe:f,children:(0,s.jsx)(d,{clientSecret:n})})]})}}},function(e){e.O(0,[774,888,179],(function(){return n=9586,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.