"use strict";exports.id=2362,exports.ids=[2362],exports.modules={72362:(e,t,a)=>{a.a(e,async(e,n)=>{try{a.d(t,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var s=a(20997),r=a(11377),m=a(64515),c=a(16689),i=a(44555),u=a(86201),d=a(45009),_=a(70574),y=a(17610),l=e([i,u,_]);[i,u,_]=l.then?(await l)():l;let PaymentForm=({paymentIntentInfo:e,trackingNumber:t,paymentGateway:a})=>{let{t:n}=(0,r.useTranslation)("common"),y=(0,m.useStripe)(),l=(0,m.useElements)(),[o,p]=(0,c.useState)(!1),[g,f]=(0,c.useState)(!1),{closeModal:h}=(0,d.SO)(),{createOrderPayment:w}=(0,i.fY)(),{savePaymentMethod:E}=(0,i.MH)(),[S,b]=(0,c.useState)(""),handleSubmit=async a=>{if(a.preventDefault(),!y||!l)return;let s=l.getElement(m.CardNumberElement);if(p(!0),g){let{error:r,paymentMethod:m}=await y.createPaymentMethod({type:"card",card:s,billing_details:{name:a?.target?.owner_name?.value}});r?(b(r?.message),p(!1)):await E({method_key:m?.id,payment_intent:e?.payment_id,save_card:g,tracking_number:t,payment_gateway:"stripe"},{onSuccess:async a=>{let s=await y.confirmCardPayment(e?.client_secret,{payment_method:a.method_key,setup_future_usage:"on_session"});await w({tracking_number:t,payment_gateway:"stripe"}),s?.paymentIntent?.status==="succeeded"?(u.default.success(n("text-payment-successful")),p(!1),h()):(b(s?.error?.message),p(!1))}})}else{let a=await y.confirmCardPayment(e?.client_secret,{payment_method:{card:s}});await w({tracking_number:t,payment_gateway:"stripe"}),a?.paymentIntent?.status==="succeeded"?(u.default.success(n("text-payment-successful")),p(!1),h()):(b(a?.error?.message),p(!1))}};return s.jsx(_.Z,{handleSubmit:handleSubmit,type:"checkout",loading:o,cardError:S,changeSaveCard:function(){f(!g)},saveCard:g})},__WEBPACK_DEFAULT_EXPORT__=({paymentGateway:e,paymentIntentInfo:t,trackingNumber:a})=>s.jsx(m.Elements,{stripe:(0,y.Z)(),children:s.jsx(PaymentForm,{paymentIntentInfo:t,trackingNumber:a,paymentGateway:e})});n()}catch(e){n(e)}})}};