UNPKG

@arc-publishing/sdk-sales

Version:
40 lines 2.28 kB
import { __assign, __awaiter, __generator } from "tslib"; import { isAPIErrorResponse } from '@arc-publishing/sdk-subs-core/lib/utils/APIErrorResponse'; 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 enforceRecaptcha from './enforceRecaptcha'; export default function finalizePaymentUpdate(paymentID, paymentMethodID, token, options, recaptchaToken) { return __awaiter(this, void 0, void 0, function () { var _this = this; return __generator(this, function (_a) { return [2, enforceRecaptcha(recaptchaToken).then(function () { return __awaiter(_this, void 0, void 0, function () { var requestOpts; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, getOptions({ method: 'PUT', headers: headers, body: JSON.stringify(__assign(__assign({}, options), { token: token, 'recaptcha-token': recaptchaToken })) })]; case 1: requestOpts = _a.sent(); return [2, SingletonFetch("".concat(Sales.apiOrigin, "/sales/public/v1/paymentmethod/").concat(paymentID, "/provider/").concat(paymentMethodID, "/finalize"), requestOpts, 'finalizePaymentUpdate') .then(JSONResponseHandler) .then(function (json) { if (isAPIErrorResponse(json)) { throw json; } else { return json; } })]; } }); }); })]; }); }); } //# sourceMappingURL=finalizePaymentUpdate.js.map