UNPKG

@arc-publishing/sdk-sales

Version:
39 lines 1.89 kB
import { __assign, __awaiter, __generator } from "tslib"; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { headers } from './constants'; import { getOptions } from './utils'; import SingletonFetch from '../serviceHelpers/SingletonFetch'; import Sales from './sales'; import { isOrderResponse } from './order'; export default function finalizePayment3ds(orderNumber, paymentMethodID, token, options, spreedlySuccess) { return __awaiter(this, void 0, void 0, function () { var body, opts; return __generator(this, function (_a) { switch (_a.label) { case 0: body = spreedlySuccess ? JSON.stringify(__assign(__assign({}, options), { token: token, SPREEDLY_SUCCEEDED: true })) : JSON.stringify(__assign(__assign({}, options), { token: token })); return [4, getOptions({ method: 'PUT', headers: headers, body: body })]; case 1: opts = _a.sent(); return [2, SingletonFetch("".concat(Sales.apiOrigin, "/sales/public/v1/checkout/3ds/order/").concat(orderNumber, "/payment/").concat(paymentMethodID), opts, 'finalize3DS') .then(JSONResponseHandler) .then(function (json) { if (isOrderResponse(json)) { Sales.currentOrder = json; return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=finalizePayment3ds.js.map