Skip to content

Commit

Permalink
✨ Release 1.2.4
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joao-muniz-efi committed Sep 13, 2024
1 parent af29e37 commit 333465d
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 436 deletions.
149 changes: 59 additions & 90 deletions dist/cjs/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ var exports$1 = {
}
};
var description = "Module for integration with Efi Bank API";
var version = "1.2.2";
var version = "1.2.3";
var author = "Efi Bank - Consultoria Técnica | João Vitor Oliveira | João Lucas";
var license = "MIT";
var repository = "efipay/sdk-node-apis-efi";
Expand Down Expand Up @@ -692,14 +692,14 @@ class Endpoints {
}
} catch (error) {
if (this.options.pemKey && (this.options.cert_base64 === undefined || this.options.cert_base64 === false)) {
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}`;
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) {
throw `FALHA AO LER O CERTIFICADO, VERIFIQUE O CAMINHO INFORMADO: ${this.options.certificate}`;
console.error(`Falha ao ler o certificado, verifique o caminho informado: ${this.options.certificate}`);
}
if (this.options.pemKey && this.options.cert_base64 === true) {
throw `FALHA AO LER O CERTIFICADO OU A CHAVE, VERIFIQUE O CONTEÚDO INFORMADO DO CERTIFICADO E DA CHAVE`;
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) {
throw `FALHA AO LER O CERTIFICADO, VERIFIQUE O CONTEÚDO INFORMADO`;
console.error(`Falha ao ler o certificado, verifique o conteúdo informado`);
}
}
}
Expand Down Expand Up @@ -735,7 +735,18 @@ class Endpoints {
return res.data;
}).catch(error => {
if (this.authError) {
throw this.authError.response.data;
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:
Expand Down Expand Up @@ -886,7 +897,7 @@ class CobrancasMethods {
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
Expand Down Expand Up @@ -1025,7 +1036,7 @@ class CobrancasMethods {
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
Expand Down Expand Up @@ -1302,8 +1313,8 @@ class CobrancasMethods {
* begin_date: string,
* end_date: string,
* charge_type: 'billet' | 'card' | 'carnet' | 'subscription',
* status?: 'new' | 'waiting' | 'link' | 'paid' | 'unpaid' | 'canceled' | 'identified',
* date_of?: 'creation' | 'payment' | 'due',
* status?: 'new' | 'waiting' | 'link' | 'paid' | 'unpaid' | 'canceled' | 'identified' | 'settled'
* date_of?: 'creation' | 'payment' | 'expired',
* customer_document?: string,
* custom_id?: string,
* value?: number,
Expand All @@ -1315,104 +1326,59 @@ class CobrancasMethods {
* @returns {Promise<{
* code: number,
* data: Arrat<{
* charge_id: number,
* 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
* }
* customer: {
* phone_number: string | null,
* cnpj?: string,
* cpf?: string
* name?: string
* corporate_name?: string
* },
* payment?: {
* method: string,
* created_at: string,
* message: string | null,
* banking_billet?: {
* payment_method: string,
* paid_at: string | null,
* pix?: {
* qrcode: string,
* qrcode_image: string
* }
* banking_billet?: {
* barcode: string,
* pix?: {
* qrcode: string,
* qrcode_image: string
* },
* link: string,
* expire_at: 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,
* link: string,
* configurations: {
* days_to_write_off: number,
* interest_type?: 'monthly' | 'daily',
* interest?: number,
* fine?: number
* interest: number,
* fine: number
* }
* pdf: {
* charge: string
* },
* }
* },
* link?: {
* billet_discount: number | null,
* card_discount: number | null,
* conditional_discount_value: number | null,
* conditional_discount_type: string | null,
* conditional_discount_type: 'percentage' | 'currency' | null,
* conditional_discount_date: string | null,
* message: string | null,
* expire_at: string,
* request_delivery_address: boolean,
* payment_method: string,
* payment_method: 'banking_billet' | 'credit_card' | 'all',
* payment_url: string
* }
* }>
Expand Down Expand Up @@ -2091,7 +2057,7 @@ class CobrancasMethods {
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
Expand Down Expand Up @@ -2227,7 +2193,7 @@ class CobrancasMethods {
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
Expand Down Expand Up @@ -2436,7 +2402,7 @@ class CobrancasMethods {
* shippings?: Array<{
* name: string,
* value: number,
* payee_code: string
* payee_code?: string
* }>,
* metadata?: {
* custom_id?: string,
Expand Down Expand Up @@ -4905,7 +4871,9 @@ class OpenFinanceMethods extends PixMethods {
*
* @param { {
* nome?: string,
* organizacao?: boolean
* organizacao?: boolean,
* modalidade?: 'imediato' | 'recorrente' | 'agendado',
* tipoPessoa?: 'PJ' | 'PF'
* } } params
*
* @returns { Promise<{
Expand Down Expand Up @@ -5280,15 +5248,18 @@ class OpenFinanceMethods extends PixMethods {
* Para capturar uma falha utilize o `catch`, os campos disponíveis no objeto serão `nome` e `mensagem`.
*
* @param {{ identificadorPagamento: string }} params
* @param {{ valor: string }} body
* @param {Array<{
* endToEndId: string,
* valor: string
* }>} body
*
* @returns { Promise<{
* @returns { Promise<Array<{
* identificadorPagamento: string,
* endToEndId: string,
* valor: string,
* dataCriacao: string,
* status: string,
* }>}
* }>>}
*/
ofDevolutionRecurrencyPix(params, body) {}
}
Expand Down Expand Up @@ -5690,9 +5661,7 @@ class EfiPay extends AllMethods {
constructor(options) {
super();
if (options.pix_cert) {
console.warn('');
console.warn('O parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar');
console.warn('');
console.warn('⚠️ WARNING:\nO parâmetro "pix_cert" foi preterido, utilize "certificate" no lugar.');
options.certificate = options.pix_cert;
}
let methods = {};
Expand Down
Loading

0 comments on commit 333465d

Please sign in to comment.