Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
}).expectCalls();
window.xprops.createOrder = mockAsyncProp(expect('createOrder', async () => {
return ZalgoPromise.try(() => {
return orderID;
});
}));
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
}).expectCalls();
window.xprops.createOrder = mockAsyncProp(expect('createOrder', async () => {
return ZalgoPromise.try(() => {
return orderID;
});
}));
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
return await wrapPromise(async ({ expect }) => {
const orderID = 'XXXXXXXXXX';
const payerID = 'YYYYYYYYYY';
window.xprops.intent = INTENT.AUTHORIZE;
const gqlMock = getGraphQLApiMock({
data: {
data: {
checkoutSession: {
cart: {
intent: INTENT.AUTHORIZE,
amounts: {
total: {
currencyCode: 'USD'
}
}
}
}
}
}
}).expectCalls();
window.xprops.createOrder = mockAsyncProp(expect('createOrder', async () => {
return ZalgoPromise.try(() => {
return orderID;
});
}));
const authorize = memoize(() => {
if (intent !== INTENT.AUTHORIZE) {
throw new Error(`Use ${ SDK_QUERY_KEYS.INTENT }=${ INTENT.AUTHORIZE } to use client-side authorize`);
}
return authorizeOrder(orderID, { facilitatorAccessToken, buyerAccessToken, partnerAttributionID, forceRestAPI })
.finally(get.reset)
.finally(authorize.reset)
.catch(handleProcessorError);
});
const authorize = memoize(() => {
if (intent !== INTENT.AUTHORIZE) {
throw new Error(`Use ${ SDK_QUERY_KEYS.INTENT }=${ INTENT.AUTHORIZE } to use client-side authorize`);
}
return authorizeOrder(orderID, { facilitatorAccessToken, buyerAccessToken, partnerAttributionID, forceRestAPI })
.finally(get.reset)
.finally(authorize.reset)
.catch(handleProcessorError);
});