Skip to content

Commit 333465d

Browse files
✨ Release 1.2.4
Correção no retorno de alguns endpoints Falhas devido a credenciais atribuidas incorretamente agora são apresentadas de forma amigável, sendo mais fácil o entendimento para o integrador
1 parent af29e37 commit 333465d

File tree

10 files changed

+262
-436
lines changed

10 files changed

+262
-436
lines changed

dist/cjs/index.cjs

Lines changed: 59 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ var exports$1 = {
579579
}
580580
};
581581
var description = "Module for integration with Efi Bank API";
582-
var version = "1.2.2";
582+
var version = "1.2.3";
583583
var author = "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas";
584584
var license = "MIT";
585585
var repository = "efipay/sdk-node-apis-efi";
@@ -692,14 +692,14 @@ class Endpoints {
692692
}
693693
} catch (error) {
694694
if (this.options.pemKey && (this.options.cert_base64 === undefined || this.options.cert_base64 === false)) {
695-
throw `FALHA AO LER O CERTIFICADO OU A CHAVE, VERIFIQUE O CAMINHO INFORMADO:\n CAMINHO DO CERTIFICADO: ${this.options.certificate} \n CAMINHO DA CHAVE: ${this.options.pemKey}`;
695+
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}`);
696696
} else if (this.options.cert_base64 === undefined || this.options.cert_base64 === false) {
697-
throw `FALHA AO LER O CERTIFICADO, VERIFIQUE O CAMINHO INFORMADO: ${this.options.certificate}`;
697+
console.error(`Falha ao ler o certificado, verifique o caminho informado: ${this.options.certificate}`);
698698
}
699699
if (this.options.pemKey && this.options.cert_base64 === true) {
700-
throw `FALHA AO LER O CERTIFICADO OU A CHAVE, VERIFIQUE O CONTEÚDO INFORMADO DO CERTIFICADO E DA CHAVE`;
700+
console.error(`Falha ao ler o certificado ou a chave, verifique o conteúdo informado do certificado e da chave`);
701701
} else if (this.options.cert_base64 === true) {
702-
throw `FALHA AO LER O CERTIFICADO, VERIFIQUE O CONTEÚDO INFORMADO`;
702+
console.error(`Falha ao ler o certificado, verifique o conteúdo informado`);
703703
}
704704
}
705705
}
@@ -735,7 +735,18 @@ class Endpoints {
735735
return res.data;
736736
}).catch(error => {
737737
if (this.authError) {
738-
throw this.authError.response.data;
738+
const error = this.authError?.response?.data || this.authError?.cause || this.authError;
739+
switch (error.message) {
740+
case 'socket hang up':
741+
throw 'Verifique o atributo sandbox e certificate, e garanta que eles estejam corretamente atribuidos para o ambiente desejado';
742+
case 'header too long':
743+
throw 'Verifique se o certificado foi enviado no formato correto';
744+
case 'wrong tag':
745+
case 'error:0909006C:PEM routines:get_name:no start line':
746+
throw 'Foi enviando um certificado .pem porém não foi enviado o atributo pemKey corretamente, tente enviar o mesmo valor para ambos';
747+
default:
748+
throw error;
749+
}
739750
} else {
740751
switch (this.baseUrl) {
741752
case this.constants.APIS.DEFAULT.URL.PRODUCTION:
@@ -886,7 +897,7 @@ class CobrancasMethods {
886897
* shippings?: Array<{
887898
* name: string,
888899
* value: number,
889-
* payee_code: string
900+
* payee_code?: string
890901
* }>,
891902
* metadata?: {
892903
* custom_id?: string,
@@ -1025,7 +1036,7 @@ class CobrancasMethods {
10251036
* shippings?: Array<{
10261037
* name: string,
10271038
* value: number,
1028-
* payee_code: string
1039+
* payee_code?: string
10291040
* }>,
10301041
* metadata?: {
10311042
* custom_id?: string,
@@ -1302,8 +1313,8 @@ class CobrancasMethods {
13021313
* begin_date: string,
13031314
* end_date: string,
13041315
* charge_type: 'billet' | 'card' | 'carnet' | 'subscription',
1305-
* status?: 'new' | 'waiting' | 'link' | 'paid' | 'unpaid' | 'canceled' | 'identified',
1306-
* date_of?: 'creation' | 'payment' | 'due',
1316+
* status?: 'new' | 'waiting' | 'link' | 'paid' | 'unpaid' | 'canceled' | 'identified' | 'settled'
1317+
* date_of?: 'creation' | 'payment' | 'expired',
13071318
* customer_document?: string,
13081319
* custom_id?: string,
13091320
* value?: number,
@@ -1315,104 +1326,59 @@ class CobrancasMethods {
13151326
* @returns {Promise<{
13161327
* code: number,
13171328
* data: Arrat<{
1318-
* charge_id: number,
1329+
* id: number,
13191330
* total: number,
13201331
* status: string,
1321-
* reason?: string,
13221332
* custom_id: string | null,
13231333
* created_at: string,
1324-
* notification_url: string | null,
1325-
* items: Array<{
1326-
* name: string,
1327-
* value: number,
1328-
* amount: number
1329-
* }>,
1330-
* shippings?: Array<{
1331-
* name: string,
1332-
* value: number,
1333-
* payee_code: string
1334-
* }>,
1335-
* history: Array<{
1336-
* message: string,
1337-
* created_at: string
1338-
* }>,
1339-
* customer?: {
1340-
* name: string | null,
1341-
* cpf: string | null,
1342-
* birth?: string,
1343-
* email?: string,
1344-
* phone_number?: string,
1345-
* address?: {
1346-
* street: string,
1347-
* number: string,
1348-
* complement: string | null,
1349-
* neighborhood: string,
1350-
* city: string,
1351-
* state: string,
1352-
* zipcode: string
1353-
* }
1334+
* customer: {
1335+
* phone_number: string | null,
1336+
* cnpj?: string,
1337+
* cpf?: string
1338+
* name?: string
1339+
* corporate_name?: string
13541340
* },
13551341
* payment?: {
1356-
* method: string,
1357-
* created_at: string,
1358-
* message: string | null,
1359-
* banking_billet?: {
1342+
* payment_method: string,
1343+
* paid_at: string | null,
1344+
* pix?: {
1345+
* qrcode: string,
1346+
* qrcode_image: string
1347+
* }
1348+
* banking_billet?: {
13601349
* barcode: string,
1361-
* pix?: {
1362-
* qrcode: string,
1363-
* qrcode_image: string
1364-
* },
13651350
* link: string,
1351+
* expire_at: string
13661352
* pdf: {
13671353
* charge: string
1368-
* },
1369-
* expire_at: string
1370-
* },
1371-
* credit_card?: {
1372-
* mask: string,
1373-
* installments: number,
1374-
* installment_value: number,
1375-
* address: {
1376-
* street: string,
1377-
* number: string,
1378-
* complement: string | null,
1379-
* neighborhood: string,
1380-
* city: string,
1381-
* state: string,
1382-
* zipcode: string
13831354
* }
13841355
* },
13851356
* carnet?: {
13861357
* parcel: number,
13871358
* barcode: string,
1388-
* pix?: {
1389-
* qrcode: string,
1390-
* qrcode_image: string
1391-
* },
1392-
* url: string,
1393-
* parcel_link: string,
1394-
* pdf: {
1395-
* charge: string
1396-
* },
13971359
* expire_at: string,
1398-
* configurations?: {
1399-
* days_to_write_off?: number,
1360+
* link: string,
1361+
* configurations: {
1362+
* days_to_write_off: number,
14001363
* interest_type?: 'monthly' | 'daily',
1401-
* interest?: number,
1402-
* fine?: number
1364+
* interest: number,
1365+
* fine: number
14031366
* }
1367+
* pdf: {
1368+
* charge: string
1369+
* },
14041370
* }
14051371
* },
14061372
* link?: {
14071373
* billet_discount: number | null,
14081374
* card_discount: number | null,
14091375
* conditional_discount_value: number | null,
1410-
* conditional_discount_type: string | null,
1376+
* conditional_discount_type: 'percentage' | 'currency' | null,
14111377
* conditional_discount_date: string | null,
14121378
* message: string | null,
14131379
* expire_at: string,
14141380
* request_delivery_address: boolean,
1415-
* payment_method: string,
1381+
* payment_method: 'banking_billet' | 'credit_card' | 'all',
14161382
* payment_url: string
14171383
* }
14181384
* }>
@@ -2091,7 +2057,7 @@ class CobrancasMethods {
20912057
* shippings?: Array<{
20922058
* name: string,
20932059
* value: number,
2094-
* payee_code: string
2060+
* payee_code?: string
20952061
* }>,
20962062
* metadata?: {
20972063
* custom_id?: string,
@@ -2227,7 +2193,7 @@ class CobrancasMethods {
22272193
* shippings?: Array<{
22282194
* name: string,
22292195
* value: number,
2230-
* payee_code: string
2196+
* payee_code?: string
22312197
* }>,
22322198
* metadata?: {
22332199
* custom_id?: string,
@@ -2436,7 +2402,7 @@ class CobrancasMethods {
24362402
* shippings?: Array<{
24372403
* name: string,
24382404
* value: number,
2439-
* payee_code: string
2405+
* payee_code?: string
24402406
* }>,
24412407
* metadata?: {
24422408
* custom_id?: string,
@@ -4905,7 +4871,9 @@ class OpenFinanceMethods extends PixMethods {
49054871
*
49064872
* @param { {
49074873
* nome?: string,
4908-
* organizacao?: boolean
4874+
* organizacao?: boolean,
4875+
* modalidade?: 'imediato' | 'recorrente' | 'agendado',
4876+
* tipoPessoa?: 'PJ' | 'PF'
49094877
* } } params
49104878
*
49114879
* @returns { Promise<{
@@ -5280,15 +5248,18 @@ class OpenFinanceMethods extends PixMethods {
52805248
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `nome` e `mensagem`.
52815249
*
52825250
* @param {{ identificadorPagamento: string }} params
5283-
* @param {{ valor: string }} body
5251+
* @param {Array<{
5252+
* endToEndId: string,
5253+
* valor: string
5254+
* }>} body
52845255
*
5285-
* @returns { Promise<{
5256+
* @returns { Promise<Array<{
52865257
* identificadorPagamento: string,
52875258
* endToEndId: string,
52885259
* valor: string,
52895260
* dataCriacao: string,
52905261
* status: string,
5291-
* }>}
5262+
* }>>}
52925263
*/
52935264
ofDevolutionRecurrencyPix(params, body) {}
52945265
}
@@ -5690,9 +5661,7 @@ class EfiPay extends AllMethods {
56905661
constructor(options) {
56915662
super();
56925663
if (options.pix_cert) {
5693-
console.warn('');
5694-
console.warn('O parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar');
5695-
console.warn('');
5664+
console.warn('⚠️ WARNING:\nO parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar.');
56965665
options.certificate = options.pix_cert;
56975666
}
56985667
let methods = {};

0 commit comments

Comments
 (0)