Module 495263

2,882 characters · in no known chunk
Dependencies
Required by (1)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{l:()=>m});var r=n(284009),i=n.n(r),s=n(73153),a=n(391048),o=n(158032),l=n(830382),u=n(323082),c=n(272207),d=n(954571),_=n(927578),f=n(566980),p=n(652215),h=n(788868);async function m(e){let{setPurchaseState:t,setHasAcceptedTerms:n,setIsSubmitting:r,setPurchaseError:m,hasRedirectURL:E,setHasRedirectURL:g,isGift:A,baseAnalyticsData:I,analyticsLocation:T,analyticsLocations:S,flowStartTime:y,subscriptionPlan:v,planGroup:N,trialId:C,priceOptions:R,paymentSource:O,isPrepaidPaymentPastDue:b,openInvoiceId:D,premiumSubscription:L,onNext:w,metadata:M,sku:P,skuPricePreview:x,purchaseType:k,referralCode:U,loadId:G,giftInfoOptions:F,invoicePreview:V,orderId:B}=e;t(f.h.PURCHASING),n(!0),r(!0),s.h.wait(a.ET),m(null);try{let e,n,r,s;if(d.default.track(p.HAw.PAYMENT_FLOW_COMPLETED,{...I,subtotal:V?.subtotal,tax:V?.tax,expected_amount:V?.total,expected_currency:V?.currency,duration_ms:Date.now()-y}),E)return;if(k===p.VVm.ONE_TIME)i()(null!=P,"SKU must exist and be fetched."),i()(null!=x,"SKUPricePreview must exist."),e=await (0,l.XU)(P.applicationId,P.id,{expectedAmount:x.amount,expectedCurrency:x.currency,isGift:A,paymentSource:O,loadId:G,giftInfoOptions:F,orderId:B});else{i()(null!=v,"Missing subscriptionPlan"),i()(null!=V,"Missing invoicePreview");let t={amount:V.total,currency:V.currency},n=(0,_.l6)(R,V.checkoutContext?.available_plans),r=(0,_.$Q)((0,_.y8)(v.id,!1,!1,n));if(null!=L){let e=R.currency??V.currency,t=(0,_.Pg)(L,v.id,1,new Set(N));t=(0,_.qn)(t),r=(0,_.UC)(t,e.toLowerCase(),R.paymentSourceId)}if(A){let t=V.total,n=V.currency;e=await (0,l.XU)(h.tv,v.skuId,{expectedAmount:t,expectedCurrency:n,paymentSource:O,subscriptionPlanId:v.id,isGift:!0,loadId:G,giftInfoOptions:F,orderId:B})}else if(b&&null!=D&&null!=O&&null!=L){let n=R.currency??V.currency;e=p.AD1.has(O.type)?await (0,u.LD)(L,D,O,n,G):await (0,u.nV)(L,{paymentSource:O,currency:n},t,r,S,T,G)}else if(null!=L){let n=(0,_.Pg)(L,v.id,1,new Set(N)),i={paymentSource:O,currency:R.currency??V.currency};L.status===p.Dmq.PAUSED&&(i.status=p.Dmq.ACTIVE),L.isPausedAllowsResumeButNotUpdates||(i.items=n),e=await (0,u.nV)(L,i,t,r,S,T,G)}else e=await (0,o.B1)({planId:v.id,currency:R.currency??V.currency,paymentSource:O,trialId:C,metadata:M,referralCode:U,loadId:G,expectedInvoicePrice:t,expectedRenewalPrice:r})}if(e.redirectConfirmation)return void g(null!=e.redirectURL);t(f.h.COMPLETED),"subscription"in e?n=null!=e.subscription?c.A.createFromServer(e.subscription):null:"entitlements"in e&&(r=null!=e.entitlements?e.entitlements:void 0),"appliedUserDiscounts"in e&&(s=null!=e.appliedUserDiscounts&&e.appliedUserDiscounts.length>0?e.appliedUserDiscounts:void 0),w(n,r,s)}catch(e){t(f.h.FAIL),m(e),d.default.track(p.HAw.PAYMENT_FLOW_FAILED,{...I,payment_error_code:e?.code,payment_source_id:O?.id,payment_source_type:O?.type,duration_ms:Date.now()-y})}finally{E||r(!1)}}}