UNPKG

@vtex/payment-provider

Version:
73 lines (72 loc) 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Payments = void 0; const api_1 = require("@vtex/api"); const routes = { inbound: (transactionId, paymentId, action) => `${routes.payment(transactionId, paymentId)}/inbound-request/${action}`, payment: (transactionId, paymentId) => `/transactions/${transactionId}/payments/${paymentId}`, }; class Payments extends api_1.ExternalClient { constructor(context, options) { var _a; super(`http://${context.account}.vtexpayments.com.br/payment-provider`, context, { ...(options !== null && options !== void 0 ? options : {}), headers: { ...((_a = options === null || options === void 0 ? void 0 : options.headers) !== null && _a !== void 0 ? _a : {}), 'X-Vtex-Use-Https': 'true', }, }); this.context = context; this.retry = (url, tracingConfig) => { const metric = 'gateway-retry'; return this.http.post(url, undefined, { metric, tracing: { requestSpanNameSuffix: metric, ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing, }, }); }; this.callback = (url, callback, tracingConfig) => { const metric = 'gateway-callback'; return this.http.post(url, callback, { metric, tracing: { requestSpanNameSuffix: metric, ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing, }, }); }; this.createToken = (url, payload, tracingConfig) => { const metric = 'gateway-secure-proxy-tokens'; return this.http.post(url, payload, { metric, tracing: { requestSpanNameSuffix: metric, ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing, }, }); }; this.getTokens = (url, tracingConfig) => { const metric = 'gateway-secure-proxy-tokens'; return this.http.get(url, { metric, tracing: { requestSpanNameSuffix: metric, ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing, }, }); }; this.inbound = (transactionId, paymentId, action, payload, tracingConfig) => { const metric = 'gateway-inbound-request'; return this.http.post(routes.inbound(transactionId, paymentId, action), payload, { metric, tracing: { requestSpanNameSuffix: metric, ...tracingConfig === null || tracingConfig === void 0 ? void 0 : tracingConfig.tracing, }, }); }; } } exports.Payments = Payments;