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