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