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