UNPKG

@vtex/payment-provider-sdk

Version:
75 lines (74 loc) 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRoutes = void 0; const api_1 = require("@vtex/api"); const co_body_1 = require("co-body"); const getRoutes = (Connector) => { return { paymentMethods: api_1.method({ GET: [ async function getPaymentMethods(ctx, next) { const connector = new Connector(ctx); ctx.body = connector.paymentMethods(); ctx.status = 200; await next(); }, ], }), manifest: api_1.method({ GET: [ async function getManifest(ctx, next) { const connector = new Connector(ctx); ctx.body = connector.manifest(); ctx.status = 200; await next(); }, ], }), authorizations: api_1.method({ POST: [ async function postAuthorizations(ctx, next) { const connector = new Connector(ctx); const reqBody = await co_body_1.json(ctx.req); ctx.body = await connector.payments(reqBody); ctx.status = 200; await next(); }, ], }), settlements: api_1.method({ POST: [ async function postSettlements(ctx, next) { const connector = new Connector(ctx); const reqBody = await co_body_1.json(ctx.req); ctx.body = await connector.paymentSettlements(reqBody); ctx.status = 200; await next(); }, ], }), refunds: api_1.method({ POST: [ async function postRefunds(ctx, next) { const connector = new Connector(ctx); const reqBody = await co_body_1.json(ctx.req); ctx.body = await connector.paymentRefunds(reqBody); ctx.status = 200; await next(); }, ], }), cancellations: api_1.method({ POST: [ async function postCancellations(ctx, next) { const connector = new Connector(ctx); const reqBody = ctx.state.body; ctx.body = await connector.paymentCancellations(reqBody); ctx.status = 200; await next(); }, ], }), }; }; exports.getRoutes = getRoutes;