moip-sdk-node-ts
Version:
Moip v2 API wrapper
28 lines (27 loc) • 1.37 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = __importDefault(require("../client/api"));
const endpoints_1 = require("../client/endpoints");
const getOne = (opts, _id) => api_1.default.get(opts, '/payments', _id);
const create = (opts, orderId, payment) => api_1.default.post(opts, `/orders/${orderId}/payments`, payment);
const preAuthorizationCapture = (opts, _id) => api_1.default.post(opts, `/payments/${_id}/capture`);
const preAuthorizationCancel = (opts, _id) => api_1.default.post(opts, `/payments/${_id}/void`);
const _authorize = (opts, _id, amount) => api_1.default.get(opts, null, null, {
customUrl: `${endpoints_1.endpoints.sandbox.v2.authorizePaymentSimulationUrl}?payment_id=${_id}&amount${amount}`,
});
const refund = (opts, _id, refund) => api_1.default.post(opts, `/payments/${_id}/refunds`, refund);
const getRefunds = (opts, _id) => api_1.default.get(opts, `/payments/${_id}/refunds`);
exports.default = {
getOne: getOne,
create: create,
preAuthorizationCapture: preAuthorizationCapture,
preAuthorizationCancel: preAuthorizationCancel,
_authorize: _authorize,
refunds: {
refund: refund,
getRefunds: getRefunds,
},
};