sdk-node-apis-efi
Version:
Module for integration with Efi Bank API
1,773 lines (1,748 loc) • 158 kB
JavaScript
import fs from 'fs';
import https from 'https';
import axios from 'axios';
import randomstring from 'randomstring';
var constants = {
APIS: {
DEFAULT: {
URL: {
PRODUCTION: 'https://cobrancas.api.efipay.com.br/v1',
SANDBOX: 'https://cobrancas-h.api.efipay.com.br/v1'
},
ENDPOINTS: {
authorize: {
route: '/authorize',
method: 'post'
},
sendSubscriptionLinkEmail: {
route: '/charge/:id/subscription/resend',
method: 'post'
},
oneStepSubscription: {
route: '/plan/:id/subscription/one-step',
method: 'post'
},
settleCarnet: {
route: '/carnet/:id/settle',
method: 'put'
},
oneStepSubscriptionLink: {
route: '/plan/:id/subscription/one-step/link',
method: 'post'
},
sendLinkEmail: {
route: '/charge/:id/link/resend',
method: 'post'
},
createOneStepLink: {
route: '/charge/one-step/link',
method: 'post'
},
createCharge: {
route: '/charge',
method: 'post'
},
detailCharge: {
route: '/charge/:id',
method: 'get'
},
updateChargeMetadata: {
route: '/charge/:id/metadata',
method: 'put'
},
updateBillet: {
route: '/charge/:id/billet',
method: 'put'
},
definePayMethod: {
route: '/charge/:id/pay',
method: 'post'
},
cancelCharge: {
route: '/charge/:id/cancel',
method: 'put'
},
createCarnet: {
route: '/carnet',
method: 'post'
},
detailCarnet: {
route: '/carnet/:id',
method: 'get'
},
updateCarnetParcel: {
route: '/carnet/:id/parcel/:parcel',
method: 'put'
},
updateCarnetParcels: {
route: '/carnet/:id/parcels',
method: 'put'
},
updateCarnetMetadata: {
route: '/carnet/:id/metadata',
method: 'put'
},
getNotification: {
route: '/notification/:token',
method: 'get'
},
listPlans: {
route: '/plans',
method: 'get'
},
createPlan: {
route: '/plan',
method: 'post'
},
deletePlan: {
route: '/plan/:id',
method: 'delete'
},
createSubscription: {
route: '/plan/:id/subscription',
method: 'post'
},
createOneStepSubscription: {
route: '/plan/:id/subscription/one-step',
method: 'post'
},
createOneStepSubscriptionLink: {
route: '/plan/:id/subscription/one-step/link',
method: 'post'
},
detailSubscription: {
route: '/subscription/:id',
method: 'get'
},
defineSubscriptionPayMethod: {
route: '/subscription/:id/pay',
method: 'post'
},
cancelSubscription: {
route: '/subscription/:id/cancel',
method: 'put'
},
updateSubscriptionMetadata: {
route: '/subscription/:id/metadata',
method: 'put'
},
getInstallments: {
route: '/installments',
method: 'get'
},
sendBilletEmail: {
route: '/charge/:id/billet/resend',
method: 'post'
},
createChargeHistory: {
route: '/charge/:id/history',
method: 'post'
},
sendCarnetEmail: {
route: '/carnet/:id/resend',
method: 'post'
},
sendCarnetParcelEmail: {
route: '/carnet/:id/parcel/:parcel/resend',
method: 'post'
},
createCarnetHistory: {
route: '/carnet/:id/history',
method: 'post'
},
cancelCarnet: {
route: '/carnet/:id/cancel',
method: 'put'
},
cancelCarnetParcel: {
route: '/carnet/:id/parcel/:parcel/cancel',
method: 'put'
},
linkCharge: {
route: '/charge/:id/link',
method: 'post'
},
defineLinkPayMethod: {
route: '/charge/:id/link',
method: 'post'
},
updateChargeLink: {
route: '/charge/:id/link',
method: 'put'
},
updatePlan: {
route: '/plan/:id',
method: 'put'
},
updateSubscription: {
route: '/subscription/:id',
method: 'put'
},
createSubscriptionHistory: {
route: '/subscription/:id/history',
method: 'post'
},
defineBalanceSheetBillet: {
route: '/charge/:id/balance-sheet',
method: 'post'
},
settleCharge: {
route: '/charge/:id/settle',
method: 'put'
},
settleCarnetParcel: {
route: '/carnet/:id/parcel/:parcel/settle',
method: 'put'
},
createOneStepCharge: {
route: '/charge/one-step',
method: 'post'
},
cardPaymentRetry: {
route: '/charge/:id/retry',
method: 'post'
},
refundCard: {
route: '/charge/card/:id/refund',
method: 'post'
},
listCharges: {
route: '/charges',
method: 'get'
}
}
},
PIX: {
URL: {
PRODUCTION: 'https://pix.api.efipay.com.br',
SANDBOX: 'https://pix-h.api.efipay.com.br'
},
ENDPOINTS: {
authorize: {
route: '/oauth/token',
method: 'post'
},
pixCreateDueCharge: {
route: '/v2/cobv/:txid',
method: 'put'
},
pixUpdateDueCharge: {
route: '/v2/cobv/:txid',
method: 'patch'
},
pixDetailDueCharge: {
route: '/v2/cobv/:txid',
method: 'get'
},
pixListDueCharges: {
route: '/v2/cobv/',
method: 'get'
},
createReport: {
route: '/v2/gn/relatorios/extrato-conciliacao',
method: 'post'
},
detailReport: {
route: '/v2/gn/relatorios/:id',
method: 'get'
},
pixCreateCharge: {
route: '/v2/cob/:txid',
method: 'put'
},
pixUpdateCharge: {
route: '/v2/cob/:txid',
method: 'patch'
},
pixCreateImmediateCharge: {
route: '/v2/cob',
method: 'post'
},
pixDetailCharge: {
route: '/v2/cob/:txid',
method: 'get'
},
pixListCharges: {
route: '/v2/cob',
method: 'get'
},
pixDetailReceived: {
route: '/v2/pix/:e2eId',
method: 'get'
},
pixReceivedList: {
route: '/v2/pix',
method: 'get'
},
pixSend: {
route: '/v3/gn/pix/:idEnvio',
method: 'put'
},
pixSendDetail: {
route: '/v2/gn/pix/enviados/:e2eid',
method: 'get'
},
pixSendList: {
route: '/v2/gn/pix/enviados',
method: 'get'
},
pixDevolution: {
route: '/v2/pix/:e2eId/devolucao/:id',
method: 'put'
},
pixDetailDevolution: {
route: '/v2/pix/:e2eId/devolucao/:id',
method: 'get'
},
pixConfigWebhook: {
route: '/v2/webhook/:chave',
method: 'put'
},
pixDetailWebhook: {
route: '/v2/webhook/:chave',
method: 'get'
},
pixListWebhook: {
route: '/v2/webhook',
method: 'get'
},
pixDeleteWebhook: {
route: '/v2/webhook/:chave',
method: 'delete'
},
pixCreateLocation: {
route: '/v2/loc',
method: 'post'
},
pixLocationList: {
route: '/v2/loc',
method: 'get'
},
pixDetailLocation: {
route: '/v2/loc/:id',
method: 'get'
},
pixGenerateQRCode: {
route: '/v2/loc/:id/qrcode',
method: 'get'
},
pixUnlinkTxidLocation: {
route: '/v2/loc/:id/txid',
method: 'delete'
},
pixCreateEvp: {
route: '/v2/gn/evp',
method: 'post'
},
pixListEvp: {
route: '/v2/gn/evp',
method: 'get'
},
pixDeleteEvp: {
route: '/v2/gn/evp/:chave',
method: 'delete'
},
getAccountBalance: {
route: '/v2/gn/saldo',
method: 'get'
},
updateAccountConfig: {
route: '/v2/gn/config',
method: 'put'
},
listAccountConfig: {
route: '/v2/gn/config',
method: 'get'
},
pixSplitDetailCharge: {
route: '/v2/gn/split/cob/:txid',
method: 'get'
},
pixSplitLinkCharge: {
route: '/v2/gn/split/cob/:txid/vinculo/:splitConfigId',
method: 'put'
},
pixSplitUnlinkCharge: {
route: '/v2/gn/split/cob/:txid/vinculo/:splitConfigId',
method: 'delete'
},
pixSplitDetailDueCharge: {
route: '/v2/gn/split/cobv/:txid',
method: 'get'
},
pixSplitLinkDueCharge: {
route: '/v2/gn/split/cobv/:txid/vinculo/:splitConfigId',
method: 'put'
},
pixSplitUnlinkDueCharge: {
route: '/v2/gn/split/cobv/:txid/vinculo/:splitConfigId',
method: 'delete'
},
pixSplitConfig: {
route: '/v2/gn/split/config',
method: 'post'
},
pixSplitConfigId: {
route: '/v2/gn/split/config/:id',
method: 'put'
},
pixSplitDetailConfig: {
route: '/v2/gn/split/config/:id',
method: 'get'
},
pixSendDetailId: {
route: '/v2/gn/pix/enviados/id-envio/:idEnvio',
method: 'get'
},
pixCreateDueChargeBatch: {
route: '/v2/lotecobv/:id',
method: 'put'
},
pixUpdateDueChargeBatch: {
route: '/v2/lotecobv/:id',
method: 'patch'
},
pixDetailDueChargeBatch: {
route: '/v2/lotecobv/:id',
method: 'get'
},
pixListDueChargeBatch: {
route: '/v2/lotecobv',
method: 'get'
},
medDefense: {
route: '/v2/gn/infracoes/:idInfracao/defesa',
method: 'post'
},
medList: {
route: '/v2/gn/infracoes',
method: 'get'
},
pixQrCodeDetail: {
route: '/v2/gn/qrcodes/detalhar',
method: 'post'
},
pixQrCodePay: {
route: '/v2/gn/pix/:idEnvio/qrcode',
method: 'put'
},
pixResendWebhook: {
route: '/v2/gn/webhook/reenviar',
method: 'post'
}
}
},
OPENFINANCE: {
URL: {
PRODUCTION: 'https://openfinance.api.efipay.com.br/v1',
SANDBOX: 'https://openfinance-h.api.efipay.com.br/v1'
},
ENDPOINTS: {
authorize: {
route: '/oauth/token',
method: 'post'
},
ofListParticipants: {
route: '/participantes/',
method: 'GET'
},
ofStartPixPayment: {
route: '/pagamentos/pix',
method: 'POST'
},
ofListPixPayment: {
route: '/pagamentos/pix',
method: 'GET'
},
ofConfigUpdate: {
route: '/config',
method: 'PUT'
},
ofConfigDetail: {
route: '/config',
method: 'GET'
},
ofDevolutionPix: {
route: '/pagamentos/pix/:identificadorPagamento/devolver',
method: 'post'
},
ofCancelSchedulePix: {
route: '/pagamentos-agendados/pix/:identificadorPagamento/cancelar',
method: 'patch'
},
ofListSchedulePixPayment: {
route: '/pagamentos-agendados/pix',
method: 'get'
},
ofStartSchedulePixPayment: {
route: '/pagamentos-agendados/pix',
method: 'post'
},
ofDevolutionSchedulePix: {
route: '/pagamentos-agendados/pix/:identificadorPagamento/devolver',
method: 'post'
},
ofStartRecurrencyPixPayment: {
route: '/pagamentos-recorrentes/pix',
method: 'post'
},
ofListRecurrencyPixPayment: {
route: '/pagamentos-recorrentes/pix',
method: 'get'
},
ofCancelRecurrencyPix: {
route: '/pagamentos-recorrentes/pix/:identificadorPagamento/cancelar',
method: 'patch'
},
ofDevolutionRecurrencyPix: {
route: '/pagamentos-recorrentes/pix/:identificadorPagamento/devolver',
method: 'post'
},
ofReplaceRecurrencyPixParcel: {
route: '/pagamentos-recorrentes/pix/:identificadorPagamento/substituir/:endToEndId',
method: 'patch'
}
}
},
PAGAMENTOS: {
URL: {
PRODUCTION: 'https://pagarcontas.api.efipay.com.br/v1',
SANDBOX: 'https://pagarcontas-h.api.efipay.com.br/v1'
},
ENDPOINTS: {
authorize: {
route: '/oauth/token',
method: 'post'
},
payDetailBarCode: {
route: '/codBarras/:codBarras',
method: 'GET'
},
payRequestBarCode: {
route: '/codBarras/:codBarras',
method: 'POST'
},
payDetailPayment: {
route: '/:idPagamento',
method: 'GET'
},
payListPayments: {
route: '/resumo',
method: 'GET'
}
}
},
CONTAS: {
URL: {
PRODUCTION: 'https://abrircontas.api.efipay.com.br/v1',
SANDBOX: 'https://abrircontas-h.api.efipay.com.br/v1'
},
ENDPOINTS: {
authorize: {
route: '/oauth/token',
method: 'post'
},
createAccount: {
route: '/conta-simplificada',
method: 'post'
},
getAccountCertificate: {
route: '/conta-simplificada/:identificador/certificado',
method: 'post'
},
getAccountCredentials: {
route: '/conta-simplificada/:identificador/credenciais',
method: 'get'
},
accountConfigWebhook: {
route: '/webhook',
method: 'post'
},
accountDeleteWebhook: {
route: '/webhook/:identificadorWebhook',
method: 'delete'
},
accountDetailWebhook: {
route: '/webhook/:identificadorWebhook',
method: 'get'
},
accountListWebhook: {
route: '/webhooks',
method: 'get'
}
}
},
EXTRATOS: {
URL: {
PRODUCTION: 'https://extratos.api.efipay.com.br/v1',
SANDBOX: 'https://extratos-h.api.efipay.com.br/v1'
},
ENDPOINTS: {
authorize: {
route: '/oauth/token',
method: 'post'
},
listStatementFiles: {
route: '/extrato-cnab/arquivos',
method: 'get'
},
getStatementFile: {
route: '/extrato-cnab/download/:nome_arquivo',
method: 'get'
},
listStatementRecurrences: {
route: '/extrato-cnab/agendamentos',
method: 'get'
},
createStatementRecurrency: {
route: '/extrato-cnab/agendar',
method: 'post'
},
updateStatementRecurrency: {
route: '/extrato-cnab/agendar/:identificador',
method: 'patch'
},
createSftpKey: {
route: '/extrato-cnab/gerar-chaves',
method: 'post'
}
}
}
}
};
var name = "sdk-node-apis-efi";
var main = "dist/cjs/index.cjs";
var types = "dist/types/index.d.ts";
var exports = {
".": {
require: "./dist/cjs/index.cjs",
"import": "./dist/cjs/index.cjs",
types: "./dist/types/index.d.ts"
}
};
var description = "Module for integration with Efi Bank API";
var version = "1.2.18";
var author = "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas";
var license = "MIT";
var repository = "efipay/sdk-node-apis-efi";
var homepage = "https://github.com/efipay/sdk-node-apis-efi";
var keywords = [
"efi",
"efi pay",
"efi bank",
"pagamentos",
"payment",
"sdk",
"integração",
"integration",
"api",
"bank slip",
"boleto bancario",
"credit card",
"cartao de credito",
"pix",
"Open Finance"
];
var dependencies = {
axios: "^1.2.2",
randomstring: "^1.2.2"
};
var scripts = {
start: "node app.js",
build: "rollup -c && tsc --project tsconfig.json",
test: "./node_modules/.bin/jest",
"test-cov": "./node_modules/.bin/jest --coverage"
};
var devDependencies = {
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.5",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-json": "^6.1.0",
prettier: "^3.0.3",
rollup: "^2.52.3",
typescript: "^4.3.5",
undici: "^6.19.2"
};
var sdkPackage = {
name: name,
main: main,
types: types,
exports: exports,
description: description,
version: version,
author: author,
license: license,
repository: repository,
homepage: homepage,
keywords: keywords,
dependencies: dependencies,
scripts: scripts,
devDependencies: devDependencies
};
// @ts-nocheck
class Endpoints {
constructor(options, constants) {
this.options = options;
this.auth = null;
this.constants = constants;
this.authError = null;
this.axiosInstance = axios.create();
}
run(name, params, body) {
let endpoint;
if (this.constants.APIS.DEFAULT.ENDPOINTS.hasOwnProperty(name)) {
endpoint = this.constants.APIS.DEFAULT.ENDPOINTS[name];
this.baseUrl = this.options.sandbox ? this.constants.APIS.DEFAULT.URL.SANDBOX : this.constants.APIS.DEFAULT.URL.PRODUCTION;
this.authRoute = this.constants.APIS.DEFAULT.ENDPOINTS.authorize;
} else {
Object.keys(this.constants.APIS).forEach(key => {
if (this.constants.APIS[key].ENDPOINTS.hasOwnProperty(name)) {
endpoint = this.constants.APIS[key].ENDPOINTS[name];
this.baseUrl = this.options.sandbox ? this.constants.APIS[key].URL.SANDBOX : this.constants.APIS[key].URL.PRODUCTION;
this.authRoute = this.constants.APIS[key].ENDPOINTS.authorize;
return;
}
});
try {
if (this.options.cert_base64 === undefined || this.options.cert_base64 === false) {
if (this.options.pemKey) {
this.agent = new https.Agent({
cert: fs.readFileSync(this.options.certificate),
key: fs.readFileSync(this.options.pemKey),
passphrase: ''
});
} else {
this.agent = new https.Agent({
pfx: fs.readFileSync(this.options.certificate),
passphrase: ''
});
}
} else if (this.options.cert_base64 === true) {
if (this.options.pemKey) {
this.agent = new https.Agent({
cert: Buffer.from(this.options.certificate, 'base64'),
key: Buffer.from(this.options.pemKey, 'base64'),
passphrase: ''
});
} else {
this.agent = new https.Agent({
pfx: Buffer.from(this.options.certificate, 'base64'),
passphrase: ''
});
}
}
} catch (error) {
if (this.options.pemKey && (this.options.cert_base64 === undefined || this.options.cert_base64 === false)) {
console.error(`Falha ao ler o certificado ou a chave, verifique o caminho informado:\nCaminho do certificado: ${this.options.certificate}\nCaminho da chave: ${this.options.pemKey}`);
} else if (this.options.cert_base64 === undefined || this.options.cert_base64 === false) {
console.error(`Falha ao ler o certificado, verifique o caminho informado: ${this.options.certificate}`);
}
if (this.options.pemKey && this.options.cert_base64 === true) {
console.error(`Falha ao ler o certificado ou a chave, verifique o conteúdo informado do certificado e da chave`);
} else if (this.options.cert_base64 === true) {
console.error(`Falha ao ler o certificado, verifique o conteúdo informado`);
}
}
}
this.params = params;
return this.req(endpoint, body);
}
async req(endpoint, body) {
let req = await this.createRequest(endpoint, body);
// Request interceptor
this.axiosInstance.interceptors.request.use(async config => {
if (!this.auth || this.isExpired()) {
this.authError = await this.authenticate();
}
config.headers = {
Authorization: `Bearer ${this.auth.access_token}`,
'x-skip-mtls-checking': !this.options.validateMtls
};
if (this.options.partner_token) {
config.headers['partner-token'] = this.options.partner_token;
}
if (this.baseUrl == this.constants.APIS.OPENFINANCE.URL.PRODUCTION || this.baseUrl == this.constants.APIS.OPENFINANCE.URL.SANDBOX) {
config.headers['x-idempotency-key'] = randomstring.generate({
length: 72,
charset: 'alphanumeric'
});
}
return config;
}, error => {
Promise.reject(error);
});
return this.axiosInstance(req).then(res => {
return res.data;
}).catch(error => {
if (this.authError) {
const error = this.authError?.response?.data || this.authError?.cause || this.authError;
switch (error.message) {
case 'socket hang up':
throw 'Verifique o atributo sandbox e certificate, e garanta que eles estejam corretamente atribuidos para o ambiente desejado';
case 'header too long':
throw 'Verifique se o certificado foi enviado no formato correto';
case 'wrong tag':
case 'error:0909006C:PEM routines:get_name:no start line':
throw 'Foi enviando um certificado .pem porém não foi enviado o atributo pemKey corretamente, tente enviar o mesmo valor para ambos';
default:
throw error;
}
} else {
switch (this.baseUrl) {
case this.constants.APIS.DEFAULT.URL.PRODUCTION:
case this.constants.APIS.DEFAULT.URL.SANDBOX:
throw error.response.data;
case this.constants.APIS.PIX.URL.PRODUCTION:
case this.constants.APIS.PIX.URL.SANDBOX:
throw error.response.data;
case this.constants.APIS.OPENFINANCE.URL.PRODUCTION:
case this.constants.APIS.OPENFINANCE.URL.SANDBOX:
throw error.response.data;
case this.constants.APIS.PAGAMENTOS.URL.PRODUCTION:
case this.constants.APIS.PAGAMENTOS.URL.SANDBOX:
throw error.response.data;
case this.constants.APIS.CONTAS.URL.PRODUCTION:
case this.constants.APIS.CONTAS.URL.SANDBOX:
throw error.response.data;
default:
throw error.response.data;
}
}
});
}
isExpired() {
if (!this.options.cache) {
return true;
}
let current_time = new Date().getTime() / 1000;
if (current_time > this.auth.authDate + this.auth.expires_in) {
return true;
}
return false;
}
async authenticate() {
let authParams = {
method: 'POST',
url: this.baseUrl + this.authRoute.route,
headers: {
'api-sdk': 'efi-node-' + sdkPackage.version
},
data: {
grant_type: 'client_credentials'
}
};
if (this.constants.APIS.DEFAULT.URL.PRODUCTION == this.baseUrl || this.constants.APIS.DEFAULT.URL.SANDBOX == this.baseUrl) {
authParams.auth = {
username: this.options.client_id,
password: this.options.client_secret
};
} else {
let token = Buffer.from(this.options.client_id + ':' + this.options.client_secret).toString('base64');
authParams.headers['Authorization'] = 'Basic ' + token;
authParams.headers['Content-Type'] = 'application/json';
authParams.httpsAgent = this.agent;
}
return axios(authParams).then(res => {
this.auth = res.data;
this.auth.authDate = new Date().getTime() / 1000;
}).catch(error => {
return error;
});
}
async createRequest(endpoint, body) {
let {
route,
method
} = endpoint;
let regex = /\:(\w+)/g;
let query = '';
let placeholders = route.match(regex) || [];
let params = {};
for (let prop in this.params) {
params[prop] = this.params[prop];
}
let getVariables = function () {
return placeholders.map(function (item) {
return item.replace(':', '');
});
};
let updateRoute = function () {
let variables = getVariables();
variables.forEach(function (value, index) {
if (params[value]) {
route = route.replace(placeholders[index], params[value]);
delete params[value];
}
});
};
let getQueryString = function () {
let keys = Object.keys(params);
let initial = keys.length >= 1 ? '?' : '';
return keys.reduce(function (previous, current, index, array) {
let next = index === array.length - 1 ? '' : '&';
return [previous, current, '=', params[current], next].join('');
}, initial);
};
updateRoute();
query = getQueryString();
let headers = new Object();
if (endpoint.route === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.route && endpoint.method === this.constants.APIS.PIX.ENDPOINTS.pixConfigWebhook.method) {
this.options.validateMtls = this.options.validateMtls || this.options.validate_mtls;
headers['x-skip-mtls-checking'] = !this.options.validateMtls;
}
if (this.options.partner_token) {
headers['partner-token'] = this.options.partner_token;
}
if (this.baseUrl == this.constants.APIS.OPENFINANCE.URL.PRODUCTION || this.baseUrl == this.constants.APIS.OPENFINANCE.URL.SANDBOX) {
headers['x-idempotency-key'] = randomstring.generate({
length: 72,
charset: 'alphanumeric'
});
}
let req = {
method,
url: String([this.baseUrl, route, query].join('')),
headers,
data: body
};
if (this.baseUrl != this.constants.APIS.DEFAULT.URL.PRODUCTION && this.baseUrl != this.constants.APIS.DEFAULT.URL.SANDBOX) {
req['httpsAgent'] = this.agent;
}
return req;
}
}
// @ts-nocheck
class ExtratosMethods {
/**
* **GET /v1/extrato-cnab/arquivos**
*
* Consultar arquivos gerados
*
* Este endpoint é utilizado para consultar os arquivos CNAB gerados e associados a uma conta específica.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @returns { Promise <{
* Array<{
* data_geracao: string,
* nome: string
* }>
* }>}
*/
listStatementFiles() {}
/**
* **GET /v1/extrato-cnab/download/:nome_arquivo**
*
* Solicitar Download do extrato
*
* Este endpoint é utilizado para Endpoint para solicitar download do extrato.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @param { { nome_arquivo: string } } params
*
* @returns { Promise<string> }
*/
getStatementFile(params) {}
/**
* **GET /v1/extrato-cnab/agendamentos**
*
* Consultar recorrências cadastradas
*
* Este endpoint é utilizado para consultar os agendamentos de recorrências cadastradas em uma conta específica.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @returns { Promise<{
* Array<{
* status: string,
* periodicidade: string,
* envia_email: boolean,
* comprimir_arquivos: boolean,
* data_criacao: string
* }>
* }>}
*
*/
listStatementRecurrences() {}
/**
* **POST /v1/extrato-cnab/agendar**
*
* Criar recorrência
*
* Este endpoint é utilizado para criar uma nova recorrência.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @param { {} } params
* @param { {
* periodicidade: string,
* enviar_email: boolean,
* comprimir_arquivos: boolean
* } } body
*
* @returns { Promise<void> }
*/
createStatementRecurrency(params, body) {}
/**
* **PATCH /v1/extrato-cnab/agendar/:identificador**
*
* Revisar recorrência
*
* Este endpoint é utilizado para atualizar ou modificar uma recorrência existente a partir do identificador.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @param { { identificador: string } } params
* @param {{
* periodicidade: string,
* status: string,
* envia_email: boolean,
* comprimir_arquivos: boolean,
* }} body
*
* @returns { Promise<void> }
*/
updateStatementRecurrency(params, body) {}
/**
* **POST /v1/extrato-cnab/gerar-chaves**
*
* Gerar chave
*
* Este endpoint é utilizado para gerar uma chave associada a uma conta específica.
*
* Para capturar uma falha utilize o `catch`, o campo disponível será `mensagem`.
*
* @returns { Promise<{
* privateKey: string
* }>}
*/
createSftpKey() {}
}
// @ts-nocheck
class CobrancasMethods extends ExtratosMethods {
/**
* **POST /v1/charge/one-step**
*
* Criação de transação em One Step (Um passo)
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* Obs: Para Pessoa Jurídica não serão obrigatórios o nome e CPF, apenas os demais dados do cliente contidos em juridical_person
*
* Obs: Caso utilize o campo configurations interest, se optar por utilizar apenas o valor, o tipo será considerado como "daily"
*
* @param { {} } params
* @param { {
* items: Array<{
* name: string,
* value: number,
* amount: number,
* marketplace?: {
* mode?: string,
* repasses: Array<{
* payee_code: string,
* percentage?: number,
* fixed?: number
* }>
* }
* }>,
* shippings?: Array<{
* name: string,
* value: number,
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
* notification_url?: string
* },
* payment: {
* banking_billet?: {
* customer: {
* name?: string,
* cpf?: string,
* email?: string,
* phone_number?: string,
* birth?: string,
* address?: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* juridical_person?: {
* corporate_name: string,
* cnpj: string
* }
* },
* expire_at: string,
* discount?: {
* type: 'percentage' | 'currency',
* value: number
* },
* conditional_discount?: {
* type: 'percentage' | 'currency',
* value: number,
* until_date: string
* },
* configurations?: {
* days_to_write_off?: number,
* fine?: number,
* interest?: {
* value: number,
* type: 'monthly' | 'daily'
* } | number
* },
* message?: string
* },
* credit_card?: {
* customer: {
* name: string,
* cpf: string,
* email: string,
* phone_number?: string,
* birth?: string,
* address?: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* juridical_person?: {
* corporate_name: string,
* cnpj: string
* }
* },
* installments: number,
* discount?: {
* type: 'percentage' | 'currency',
* value: number
* },
* billing_address?: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* payment_token: string,
* message?: string
* }
* }
* } } body
*
* @returns {Promise<{
* code: number,
* data: {
* charge_id: number,
* total: number,
* status: string,
* barcode?: string,
* pix?: {
* qrcode: string,
* qrcode_image: string
* }
* link?: string,
* billet_link?: string,
* pdf?: {
* charge: string
* },
* expire_at?: string,
* installments?: number,
* installment_value?: number,
* refusal?: {
* reason: string,
* retry: boolean
* }
* payment: string,
* }
* }>}
*/
createOneStepCharge(params, body) {}
/**
* **POST /v1/charge**
*
* Criar transação
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { {} } params
* @param { {
* items: Array<{
* name: string,
* value: number,
* amount: number,
* marketplace?: {
* payee_code: string,
* percentage?: number
* }
* }>,
* shippings?: Array<{
* name: string,
* value: number,
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
* notification_url?: string
* }
* } } body
*
* @returns {Promise<{
* code: number,
* data: {
* charge_id: number,
* total: number,
* status: string,
* custom_id: string | null,
* created_at: string,
* }
* }>}
*/
createCharge(params, body) {}
/**
* **POST /v1/charge/:id/pay**
*
* Associar à forma de pagamento
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* Obs: Para Pessoa Jurídica não serão obrigatórios o nome e CPF, apenas os demais dados do cliente contidos em juridical_person
*
* Obs: Caso utilize o campo configurations interest, se optar por utilizar apenas o valor, o tipo será considerado como "daily"
*
* @param { { id: number } } params
* @param { {
* payment: {
* banking_billet?: {
* customer: {
* name?: string,
* cpf?: string,
* email: string,
* phone_number?: string,
* birth?: string,
* address: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* juridical_person?: {
* corporate_name: string,
* cnpj: string
* }
* },
* expire_at: string,
* discount?: {
* type: 'percentage' | 'currency',
* value: number
* },
* conditional_discount?: {
* type: 'percentage' | 'currency',
* value: number,
* until_date: string
* },
* configurations?: {
* days_to_write_off?: number,
* fine?: number,
* interest?: {
* value: number,
* type: 'monthly' | 'daily'
* } | number
* },
* message?: string
* },
* credit_card?: {
* customer: {
* name?: string,
* cpf?: string,
* email: string,
* phone_number?: string,
* birth?: string,
* address: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* juridical_person?: {
* corporate_name: string,
* cnpj: string
* }
* },
* installments: number,
* discount?: {
* type: 'percentage' | 'currency',
* value: number
* },
* billing_address: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement?: string,
* state: string
* },
* payment_token: string,
* message?: string
* }
* }
* } } body
*
* @returns {Promise<{
* code: number,
* data: {
* charge_id: number,
* total: number,
* status: string,
* reason?: string | null,
* payment: string
* barcode: string,
* pix?: {
* qrcode: string,
* qrcode_image: string
* },
* link?: string,
* pdf?: {
* charge: string
* },
* expire_at?: string,
* configurations?: {
* days_to_write_off: number,
* interest_type?: 'monthly'| 'daily',
* interest?: number,
* fine?: number
* }
* installments?: number,
* installment_value?: number
* }
* }>}
*/
definePayMethod(params, body) {}
/**
* **GET /v1/charge/:id**
*
* Retornar informações de transação existente
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
*
* @returns {Promise<{
* code: number,
* data: {
* charge_id: number,
* total: number,
* status: string,
* reason?: string,
* custom_id: string | null,
* created_at: string,
* notification_url: string | null,
* items: Array<{
* name: string,
* value: number,
* amount: number
* }>,
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* }>,
* history: Array<{
* message: string,
* created_at: string
* }>,
* customer?: {
* name: string | null,
* cpf: string | null,
* birth?: string,
* email?: string,
* phone_number?: string,
* address?: {
* street: string,
* number: string,
* complement: string | null,
* neighborhood: string,
* city: string,
* state: string,
* zipcode: string
* }
* },
* payment?: {
* method: string,
* created_at: string,
* message: string | null,
* banking_billet?: {
* barcode: string,
* pix?: {
* qrcode: string,
* qrcode_image: string
* },
* link: string,
* pdf: {
* charge: string
* },
* expire_at: string
* },
* credit_card?: {
* mask: string,
* installments: number,
* installment_value: number,
* address: {
* street: string,
* number: string,
* complement: string | null,
* neighborhood: string,
* city: string,
* state: string,
* zipcode: string
* }
* },
* carnet?: {
* parcel: number,
* barcode: string,
* pix?: {
* qrcode: string,
* qrcode_image: string
* },
* url: string,
* parcel_link: string,
* pdf: {
* charge: string
* },
* expire_at: string,
* configurations?: {
* days_to_write_off?: number,
* interest_type?: 'monthly' | 'daily',
* interest?: number,
* fine?: number
* }
* }
* },
* link?: {
* billet_discount: number | null,
* card_discount: number | null,
* conditional_discount_value: number | null,
* conditional_discount_type: string | null,
* conditional_discount_date: string | null,
* message: string | null,
* expire_at: string,
* request_delivery_address: boolean,
* payment_method: string,
* payment_url: string
* }
* }
* }>}
*/
detailCharge(params) {}
/**
* **GET /v1/charges**
*
* Retornar lista de cobranças
*
* Este endpoint possui filtros para afunilar os resultados da busca, tais como CPF/CNPJ e status.
* Dentre todos os filtros disponíveis, os filtros charge_type, begin_date e end_date são obrigatórios e representam o tipo da transação e o intervalo de datas em que as cobranças consultadas devem estar compreendidas.
*
* @param {{
* begin_date: string,
* end_date: string,
* charge_type: 'billet' | 'card' | 'carnet' | 'subscription',
* status?: 'new' | 'waiting' | 'link' | 'paid' | 'unpaid' | 'canceled' | 'identified' | 'settled'
* date_of?: 'creation' | 'payment' | 'expired',
* customer_document?: string,
* custom_id?: string,
* value?: number,
* limit?: number,
* page?: number,
* offset?: number
* }} params
*
* @returns {Promise<{
* code: number,
* data: Array<{
* id: number,
* total: number,
* status: string,
* custom_id: string | null,
* created_at: string,
* customer: {
* phone_number: string | null,
* cnpj?: string,
* cpf?: string
* name?: string
* corporate_name?: string
* },
* payment?: {
* payment_method: string,
* paid_at: string | null,
* pix?: {
* qrcode: string,
* qrcode_image: string
* }
* banking_billet?: {
* barcode: string,
* link: string,
* expire_at: string
* pdf: {
* charge: string
* }
* },
* carnet?: {
* parcel: number,
* barcode: string,
* expire_at: string,
* link: string,
* configurations: {
* days_to_write_off: number,
* interest_type?: 'monthly' | 'daily',
* interest: number,
* fine: number
* }
* pdf: {
* charge: string
* },
* }
* },
* link?: {
* billet_discount: number | null,
* card_discount: number | null,
* conditional_discount_value: number | null,
* conditional_discount_type: 'percentage' | 'currency' | null,
* conditional_discount_date: string | null,
* message: string | null,
* expire_at: string,
* request_delivery_address: boolean,
* payment_method: 'banking_billet' | 'credit_card' | 'all',
* payment_url: string
* }
* }>
* >}
*/
listCharges(params) {}
/**
* **PUT /v1/charge/:id/metadata**
*
* Incluir "notification_url" e "custom_id" em uma transação existente
*
* - O atributo `resend` diz se será realizado o reenvio da notificação após a alteração ser aplicada.
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
* @param { {
* notification_url?: string,
* custom_id?: string,
* resend?: boolean
* } } body
*
* @returns {Promise<{
* code: number,
* }>}
*/
updateChargeMetadata(params, body) {}
/**
* **PUT /v1/charge/:id/billet**
*
* Altera a data de vencimento de uma transação existente.
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* Obs: A nova data de vencimento deve ser pelo menos maior que a data atual.
*
* @param { { id: number } } params
* @param { { expire_at: string }} body
*
* @returns {Promise<{
* code: number,
* }>}
*/
updateBillet(params, body) {}
/**
* **PUT /v1/charge/:id/cancel**
*
* Cancela uma transação existente
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
*
* @returns {Promise<{
* code: number,
* }>}
*/
cancelCharge(params) {}
/**
* **POST /v1/charge/:id/billet/resend**
*
* Reenvio do boleto bancário para o email desejado
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
* @param { { email: string }} body
*
* @returns {Promise<{
* code: number,
* }>}
*/
sendBilletEmail(params, body) {}
/**
* **POST /v1/charge/:id/history**
*
* Acrescentar descrição ao histórico de uma transação
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
* @param { { description: string }} body
*
* @returns {Promise<{
* code: number,
* }>}
*/
createChargeHistory(params, body) {}
/**
* **POST /v1/charge/:id/balance-sheet**
*
* Define que a transação será do tipo boleto balancete.
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
* @param { {
* title: string,
* body: Array<{
* header: string,
* tables: Array<{
* rows: Array<Array<{
* align: string,
* color: string,
* style: string,
* text: string,
* colspan: number
* }>>
* }>
* }>
* } } body
*
* @returns {Promise<{
* code: number,
* }>}
*/
defineBalanceSheetBillet(params, body) {}
/**
* **PUT /v1/charge/:id/settle**
*
* Marcar como pago (baixa manual) uma determinada transação
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
*
* @returns {Promise<{
* code: number,
* }>}
*/
settleCharge(params) {}
/**
* **POST /v1/charge/:id/retry**
*
* Retentativa de pagamento via cartão de crédito
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* Obs: Para Pessoa Jurídica não serão obrigatórios o nome e CPF, apenas os demais dados do cliente contidos em juridical_person
*
* @param { { id: number } } params
* @param { {
* payment: {
* credit_card: {
* customer: {
* name?: string,
* cpf?: string,
* email: string,
* birth: string,
* phone_number?: string,
* juridical_person?: {
* corporate_name: string,
* cnpj: string
* }
* },
* billing_address: {
* street: string,
* number: string,
* neighborhood: string,
* zipcode: string,
* city: string,
* complement: string,
* state: string
* },
* payment_token: string
* }
* }
* } } body
*
* @returns {Promise<{
* code: number,
* data: {
* installments: number,
* installment_value: number,
* charge_id: number,
* status: string,
* total: number,
* payment: string
* }
* }>}
*/
cardPaymentRetry(params, body) {}
/**
* **POST /v1/charge/card/:id/refund**
*
* Estorno de pagamento via cartão de crédito
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { { id: number } } params
* @param { { amount?: number } } body
*
* @returns {Promise<{
* code: number,
* message: string,
* }>}
*/
refundCard(params, body) {}
/**
* **GET /v1/installments**
*
* Listar parcelas de acordo com a bandeira do cartão
*
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `code`, `error` e `error_description`.
*
* @param { {
* total: number,
* brand: 'visa' | 'mastercard' | 'amex' | 'elo' | 'hipercard'
* } } params
*
* @returns {Promise<{
* code: number,
* data: {
* rate: number,
* name: string,
* installments: Array<{
* installment: number,
* has_interest: bo