mercadopago
Version:
Mercadopago SDK for Node.js
82 lines (81 loc) • 3.46 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdvancedPayment = void 0;
/**
* AdvancedPayment (marketplace split-payments) client for the MercadoPago API.
*
* Enables marketplace integrations to collect a single payment and distribute
* the funds among multiple sellers (disbursements). Supports two-step flows
* (authorise → capture) and individual disbursement release-date control.
*
* @module advancedPayment
*/
const create_1 = __importDefault(require("./create"));
const get_1 = __importDefault(require("./get"));
const search_1 = __importDefault(require("./search"));
const update_1 = __importDefault(require("./update"));
const cancel_1 = __importDefault(require("./cancel"));
const capture_1 = __importDefault(require("./capture"));
const updateReleaseDate_1 = __importDefault(require("./updateReleaseDate"));
/**
* Client facade for MercadoPago advanced (split) payment operations.
*/
class AdvancedPayment {
constructor(mercadoPagoConfig) {
this.config = mercadoPagoConfig;
}
/**
* Create a new advanced (split) payment distributed among multiple sellers.
*/
create({ body, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, create_1.default)({ body, config: this.config });
}
/**
* Retrieve an advanced payment by its ID.
*/
get({ id, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, get_1.default)({ id, config: this.config });
}
/**
* Search advanced payments with optional filters and pagination.
*/
search(advancedPaymentSearchOptions = {}) {
const { options, requestOptions } = advancedPaymentSearchOptions;
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, search_1.default)({ options, config: this.config });
}
/**
* Update an existing advanced payment with arbitrary fields.
*/
update({ id, body, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, update_1.default)({ id, body, config: this.config });
}
/**
* Cancel a pending advanced payment by setting its status to `cancelled`.
*/
cancel({ id, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, cancel_1.default)({ id, config: this.config });
}
/**
* Capture a previously authorised advanced payment.
*/
capture({ id, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, capture_1.default)({ id, config: this.config });
}
/**
* Change the money release date for all disbursements of an advanced payment.
*/
updateReleaseDate({ id, releaseDate, requestOptions }) {
this.config.options = Object.assign(Object.assign({}, this.config.options), requestOptions);
return (0, updateReleaseDate_1.default)({ id, releaseDate, config: this.config });
}
}
exports.AdvancedPayment = AdvancedPayment;