Build 576754stable
Module 624210
1,105 characters · in 8b3ffd4b288ba291.js, 331bf8185c686a13.jsDependencies
Source Raw
function(r,t,e){e.d(t,{Nl:()=>s,fS:()=>a,iY:()=>i});var n=e(636537),o=e(26279),l=e(652215);async function a(r){let{skuId:t,paymentSourceId:e,paymentGateway:a,loadId:i,testMode:s}=r,u={};null!=e&&(u.payment_source_id=e),null!=a&&(u.payment_gateway=a);let d={order_line_items:[{sku_id:t,quantity:1,purchase_type:o.BM.ONE_TIME}],billing_facet:u};s&&(d.application_facet={test_mode:!0});let c=(await n.Bo.post({url:l.Rsh.ORDER_CREATE,body:d,context:null!=i&&""!==i?{load_id:i}:void 0,rejectWithError:!0})).body;if(null==c||null==c.id||""===c.id)throw Error("Invalid order response");return c}async function i(r){let{orderId:t,updates:e,expectedRevision:o}=r,a={};"paymentSourceId"in e&&(a.billing_facet={payment_source_id:e.paymentSourceId}),null!=o&&(a.expected_revision=o);let i=(await n.Bo.patch({url:l.Rsh.ORDER_UPDATE(t),body:a,rejectWithError:!0})).body;if(null==i||null==i.id||""===i.id)throw Error("Invalid order response");return i}async function s(r){let t=await n.Bo.post({url:l.Rsh.ORDER_DISCARD(r),rejectWithError:!1});if(null==t.body)throw Error("Invalid discard order response");return t.body}}