UNPKG

@arc-publishing/sdk-sales

Version:
35 lines 1.68 kB
import { __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 { isInitializedPayment } from './order'; export default function initializePayment(orderNumber, paymentMethodID, options) { return __awaiter(this, void 0, void 0, function () { var url, fetchOptions; return __generator(this, function (_a) { switch (_a.label) { case 0: url = "".concat(Sales.apiOrigin, "/sales/public/v1/checkout/order/").concat(orderNumber, "/payment/").concat(paymentMethodID); if (options && options.applePayValidationUrl) { url = url + "?validationURL=".concat(options.applePayValidationUrl); } return [4, getOptions({ method: 'GET', headers: headers, options: options })]; case 1: fetchOptions = _a.sent(); return [2, SingletonFetch(url, fetchOptions, 'initializePayment') .then(JSONResponseHandler) .then(function (json) { if (isInitializedPayment(json)) { return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=initializePayment.js.map