@infrab4a/connect 5.1.0-beta.4 → 5.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js
CHANGED
|
@@ -8615,6 +8615,11 @@ class PagarMeV5RequestHelper {
|
|
|
8615
8615
|
type: 'individual',
|
|
8616
8616
|
document: checkout.user.cpf,
|
|
8617
8617
|
phones: {
|
|
8618
|
+
home_phone: {
|
|
8619
|
+
country_code: '55',
|
|
8620
|
+
number: checkout.user.phone.slice(2),
|
|
8621
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8622
|
+
},
|
|
8618
8623
|
mobile_phone: {
|
|
8619
8624
|
country_code: '55',
|
|
8620
8625
|
number: checkout.user.phone.slice(2),
|
|
@@ -8753,11 +8758,11 @@ class PagarMeV5ResponseHelper {
|
|
|
8753
8758
|
acquirer_message: transaction.acquirer_message?.toString(),
|
|
8754
8759
|
acquirer_return_code: transaction.acquirer_return_code?.toString(),
|
|
8755
8760
|
installments: transaction.installments ?? null,
|
|
8756
|
-
card_holder_name: transaction.card
|
|
8757
|
-
card_last_digits: transaction.card
|
|
8758
|
-
card_first_digits: transaction.card
|
|
8759
|
-
card_brand: transaction.card
|
|
8760
|
-
card_id: transaction.card
|
|
8761
|
+
card_holder_name: transaction.card?.holder_name?.toString(),
|
|
8762
|
+
card_last_digits: transaction.card?.last_four_digits?.toString(),
|
|
8763
|
+
card_first_digits: transaction.card?.first_six_digits?.toString(),
|
|
8764
|
+
card_brand: transaction.card?.brand?.toString(),
|
|
8765
|
+
card_id: transaction.card?.id?.toString(),
|
|
8761
8766
|
};
|
|
8762
8767
|
}
|
|
8763
8768
|
}
|
|
@@ -9000,8 +9005,9 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9000
9005
|
data: payload,
|
|
9001
9006
|
});
|
|
9002
9007
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9003
|
-
if (data.
|
|
9004
|
-
data.charges.at(0).status
|
|
9008
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9009
|
+
data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
|
|
9010
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado) {
|
|
9005
9011
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9006
9012
|
// checkoutId: checkout.id,
|
|
9007
9013
|
// userEmail: checkout.user.email,
|
|
@@ -9038,22 +9044,21 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9038
9044
|
data: payload,
|
|
9039
9045
|
});
|
|
9040
9046
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9041
|
-
if (data.
|
|
9042
|
-
data.charges.at(0).status
|
|
9047
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9048
|
+
data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
|
|
9049
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado) {
|
|
9043
9050
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9044
9051
|
checkoutId: checkout.id,
|
|
9045
9052
|
userEmail: checkout.user.email,
|
|
9046
|
-
info: data,
|
|
9053
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9047
9054
|
}));
|
|
9048
9055
|
}
|
|
9049
|
-
const
|
|
9050
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9056
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9051
9057
|
return payment;
|
|
9052
9058
|
}
|
|
9053
9059
|
catch (error) {
|
|
9054
|
-
console.error('Full error: ', error);
|
|
9060
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9055
9061
|
if (error instanceof axios.AxiosError) {
|
|
9056
|
-
console.error('Error: ', error.message);
|
|
9057
9062
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9058
9063
|
}
|
|
9059
9064
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
@@ -9107,8 +9112,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9107
9112
|
data: payload,
|
|
9108
9113
|
});
|
|
9109
9114
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9110
|
-
if (data.
|
|
9111
|
-
data.charges.at(0).status !== exports.PagarMeV5PaymentStatus.
|
|
9115
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9116
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Pago ||
|
|
9117
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Capturada) {
|
|
9112
9118
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9113
9119
|
checkout,
|
|
9114
9120
|
card,
|
|
@@ -9116,17 +9122,15 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9116
9122
|
});
|
|
9117
9123
|
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9118
9124
|
}
|
|
9119
|
-
const
|
|
9120
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9125
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9121
9126
|
return payment;
|
|
9122
9127
|
}
|
|
9123
9128
|
catch (error) {
|
|
9124
9129
|
if (error instanceof PaymentError) {
|
|
9125
9130
|
throw error;
|
|
9126
9131
|
}
|
|
9127
|
-
console.error('Full error: ', error);
|
|
9132
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9128
9133
|
if (error instanceof axios.AxiosError) {
|
|
9129
|
-
console.error('Error: ', error.message);
|
|
9130
9134
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9131
9135
|
}
|
|
9132
9136
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
@@ -9284,12 +9288,18 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9284
9288
|
data: payload,
|
|
9285
9289
|
});
|
|
9286
9290
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9287
|
-
|
|
9288
|
-
|
|
9291
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha || data.status == exports.PagarMeV5OrderStatus.Cancelado) {
|
|
9292
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9293
|
+
checkoutId: checkout.id,
|
|
9294
|
+
userEmail: checkout.user.email,
|
|
9295
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9296
|
+
});
|
|
9297
|
+
}
|
|
9298
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9289
9299
|
return payment;
|
|
9290
9300
|
}
|
|
9291
9301
|
catch (error) {
|
|
9292
|
-
console.error('Full error: ', error);
|
|
9302
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9293
9303
|
if (error instanceof axios.AxiosError) {
|
|
9294
9304
|
console.error('Error: ', error.message);
|
|
9295
9305
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
package/index.esm.js
CHANGED
|
@@ -8590,6 +8590,11 @@ class PagarMeV5RequestHelper {
|
|
|
8590
8590
|
type: 'individual',
|
|
8591
8591
|
document: checkout.user.cpf,
|
|
8592
8592
|
phones: {
|
|
8593
|
+
home_phone: {
|
|
8594
|
+
country_code: '55',
|
|
8595
|
+
number: checkout.user.phone.slice(2),
|
|
8596
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8597
|
+
},
|
|
8593
8598
|
mobile_phone: {
|
|
8594
8599
|
country_code: '55',
|
|
8595
8600
|
number: checkout.user.phone.slice(2),
|
|
@@ -8728,11 +8733,11 @@ class PagarMeV5ResponseHelper {
|
|
|
8728
8733
|
acquirer_message: transaction.acquirer_message?.toString(),
|
|
8729
8734
|
acquirer_return_code: transaction.acquirer_return_code?.toString(),
|
|
8730
8735
|
installments: transaction.installments ?? null,
|
|
8731
|
-
card_holder_name: transaction.card
|
|
8732
|
-
card_last_digits: transaction.card
|
|
8733
|
-
card_first_digits: transaction.card
|
|
8734
|
-
card_brand: transaction.card
|
|
8735
|
-
card_id: transaction.card
|
|
8736
|
+
card_holder_name: transaction.card?.holder_name?.toString(),
|
|
8737
|
+
card_last_digits: transaction.card?.last_four_digits?.toString(),
|
|
8738
|
+
card_first_digits: transaction.card?.first_six_digits?.toString(),
|
|
8739
|
+
card_brand: transaction.card?.brand?.toString(),
|
|
8740
|
+
card_id: transaction.card?.id?.toString(),
|
|
8736
8741
|
};
|
|
8737
8742
|
}
|
|
8738
8743
|
}
|
|
@@ -8975,8 +8980,9 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
8975
8980
|
data: payload,
|
|
8976
8981
|
});
|
|
8977
8982
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8978
|
-
if (data.
|
|
8979
|
-
data.charges.at(0).status
|
|
8983
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
8984
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
8985
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado) {
|
|
8980
8986
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8981
8987
|
// checkoutId: checkout.id,
|
|
8982
8988
|
// userEmail: checkout.user.email,
|
|
@@ -9013,22 +9019,21 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9013
9019
|
data: payload,
|
|
9014
9020
|
});
|
|
9015
9021
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9016
|
-
if (data.
|
|
9017
|
-
data.charges.at(0).status
|
|
9022
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9023
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
9024
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado) {
|
|
9018
9025
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9019
9026
|
checkoutId: checkout.id,
|
|
9020
9027
|
userEmail: checkout.user.email,
|
|
9021
|
-
info: data,
|
|
9028
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9022
9029
|
}));
|
|
9023
9030
|
}
|
|
9024
|
-
const
|
|
9025
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9031
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9026
9032
|
return payment;
|
|
9027
9033
|
}
|
|
9028
9034
|
catch (error) {
|
|
9029
|
-
console.error('Full error: ', error);
|
|
9035
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9030
9036
|
if (error instanceof AxiosError) {
|
|
9031
|
-
console.error('Error: ', error.message);
|
|
9032
9037
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9033
9038
|
}
|
|
9034
9039
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
@@ -9082,8 +9087,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9082
9087
|
data: payload,
|
|
9083
9088
|
});
|
|
9084
9089
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9085
|
-
if (data.
|
|
9086
|
-
data.charges.at(0).status !== PagarMeV5PaymentStatus.
|
|
9090
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9091
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Pago ||
|
|
9092
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
|
|
9087
9093
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9088
9094
|
checkout,
|
|
9089
9095
|
card,
|
|
@@ -9091,17 +9097,15 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9091
9097
|
});
|
|
9092
9098
|
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9093
9099
|
}
|
|
9094
|
-
const
|
|
9095
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9100
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9096
9101
|
return payment;
|
|
9097
9102
|
}
|
|
9098
9103
|
catch (error) {
|
|
9099
9104
|
if (error instanceof PaymentError) {
|
|
9100
9105
|
throw error;
|
|
9101
9106
|
}
|
|
9102
|
-
console.error('Full error: ', error);
|
|
9107
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9103
9108
|
if (error instanceof AxiosError) {
|
|
9104
|
-
console.error('Error: ', error.message);
|
|
9105
9109
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9106
9110
|
}
|
|
9107
9111
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
@@ -9259,12 +9263,18 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9259
9263
|
data: payload,
|
|
9260
9264
|
});
|
|
9261
9265
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9262
|
-
|
|
9263
|
-
|
|
9266
|
+
if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
|
|
9267
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9268
|
+
checkoutId: checkout.id,
|
|
9269
|
+
userEmail: checkout.user.email,
|
|
9270
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9271
|
+
});
|
|
9272
|
+
}
|
|
9273
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(checkout, data));
|
|
9264
9274
|
return payment;
|
|
9265
9275
|
}
|
|
9266
9276
|
catch (error) {
|
|
9267
|
-
console.error('Full error: ', error);
|
|
9277
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9268
9278
|
if (error instanceof AxiosError) {
|
|
9269
9279
|
console.error('Error: ', error.message);
|
|
9270
9280
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PagarMeV5OrderStatus
|
|
1
|
+
import { PagarMeV5OrderStatus } from '../../../../domain';
|
|
2
2
|
export type PagarMeV5Response = {
|
|
3
3
|
id: string;
|
|
4
4
|
code: string;
|
|
@@ -41,7 +41,7 @@ export type PagarMeV5Charger = {
|
|
|
41
41
|
code: string;
|
|
42
42
|
gateway_id: string;
|
|
43
43
|
amount: number;
|
|
44
|
-
status:
|
|
44
|
+
status: PagarMeV5OrderStatus;
|
|
45
45
|
currency: string;
|
|
46
46
|
payment_method: string;
|
|
47
47
|
paid_amount: number;
|
|
@@ -103,7 +103,7 @@ export type PagarMeV5Transaction = {
|
|
|
103
103
|
type: string;
|
|
104
104
|
created_at: string;
|
|
105
105
|
updated_at: string;
|
|
106
|
-
billing_address
|
|
106
|
+
billing_address?: {
|
|
107
107
|
zip_code: string;
|
|
108
108
|
city: string;
|
|
109
109
|
state: string;
|
|
@@ -112,10 +112,10 @@ export type PagarMeV5Transaction = {
|
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
gateway_response?: {
|
|
115
|
-
code:
|
|
116
|
-
errors
|
|
115
|
+
code: string;
|
|
116
|
+
errors?: [
|
|
117
117
|
{
|
|
118
|
-
message
|
|
118
|
+
message?: string;
|
|
119
119
|
}
|
|
120
120
|
];
|
|
121
121
|
};
|