@infrab4a/connect 5.4.0-beta.23 → 5.4.0-beta.25
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
|
@@ -8788,7 +8788,6 @@ class MercadoPagoRequestHelper {
|
|
|
8788
8788
|
statement_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
|
|
8789
8789
|
additional_info: {
|
|
8790
8790
|
items: this.buildItems(checkout),
|
|
8791
|
-
...(method === 'credit_card' && { payer: this.buildFullPayer(checkout) }),
|
|
8792
8791
|
},
|
|
8793
8792
|
...(method === 'credit_card' && this.buildCardPayment(card)),
|
|
8794
8793
|
...(method === 'pix' && this.buildPixPayment()),
|
|
@@ -8985,10 +8984,9 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
8985
8984
|
}
|
|
8986
8985
|
catch (error) {
|
|
8987
8986
|
if (error instanceof axios.AxiosError) {
|
|
8988
|
-
console.warn(error.response);
|
|
8989
|
-
console.warn(error.response.data);
|
|
8990
|
-
console.warn(error.response.data.cause);
|
|
8987
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
8991
8988
|
}
|
|
8989
|
+
throw error;
|
|
8992
8990
|
}
|
|
8993
8991
|
}
|
|
8994
8992
|
getBoletoTransaction(paymentId) {
|
|
@@ -9003,41 +9001,49 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9003
9001
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
9004
9002
|
}
|
|
9005
9003
|
async pay(checkout, card) {
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
method: 'credit_card',
|
|
9009
|
-
postback: this.credentials.postback,
|
|
9010
|
-
card,
|
|
9011
|
-
});
|
|
9012
|
-
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9013
|
-
const { data } = await axios__default["default"]({
|
|
9014
|
-
method: 'POST',
|
|
9015
|
-
url: `${this.credentials.url}/v1/payments`,
|
|
9016
|
-
headers: {
|
|
9017
|
-
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9018
|
-
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9019
|
-
'Content-Type': 'application/json',
|
|
9020
|
-
},
|
|
9021
|
-
data: payload,
|
|
9022
|
-
});
|
|
9023
|
-
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
9024
|
-
if ((data.status !== 'approved' && data.status_detail !== exports.MercadoPagoStatusDetailEnum.accredited) ||
|
|
9025
|
-
data.status !== 'authorized') {
|
|
9026
|
-
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
9004
|
+
try {
|
|
9005
|
+
const payload = MercadoPagoRequestHelper.build({
|
|
9027
9006
|
checkout,
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
limiteRange: 'day',
|
|
9007
|
+
method: 'credit_card',
|
|
9008
|
+
postback: this.credentials.postback,
|
|
9031
9009
|
card,
|
|
9032
9010
|
});
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9011
|
+
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9012
|
+
const { data } = await axios__default["default"]({
|
|
9013
|
+
method: 'POST',
|
|
9014
|
+
url: `${this.credentials.url}/v1/payments`,
|
|
9015
|
+
headers: {
|
|
9016
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9017
|
+
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9018
|
+
'Content-Type': 'application/json',
|
|
9019
|
+
},
|
|
9020
|
+
data: payload,
|
|
9037
9021
|
});
|
|
9022
|
+
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
9023
|
+
if ((data.status !== 'approved' && data.status_detail !== exports.MercadoPagoStatusDetailEnum.accredited) ||
|
|
9024
|
+
data.status !== 'authorized') {
|
|
9025
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
9026
|
+
checkout,
|
|
9027
|
+
blockType: 'Card not authorized',
|
|
9028
|
+
type: 'Card',
|
|
9029
|
+
limiteRange: 'day',
|
|
9030
|
+
card,
|
|
9031
|
+
});
|
|
9032
|
+
throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
|
|
9033
|
+
checkoutId: checkout.id,
|
|
9034
|
+
userEmail: checkout.user.email,
|
|
9035
|
+
info: data,
|
|
9036
|
+
});
|
|
9037
|
+
}
|
|
9038
|
+
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
|
|
9039
|
+
return payment;
|
|
9040
|
+
}
|
|
9041
|
+
catch (error) {
|
|
9042
|
+
if (error instanceof axios.AxiosError) {
|
|
9043
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
9044
|
+
}
|
|
9045
|
+
throw error;
|
|
9038
9046
|
}
|
|
9039
|
-
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
|
|
9040
|
-
return payment;
|
|
9041
9047
|
}
|
|
9042
9048
|
async addCard(card, customer) {
|
|
9043
9049
|
const { data } = await axios__default["default"]({
|
|
@@ -9135,10 +9141,9 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9135
9141
|
}
|
|
9136
9142
|
catch (error) {
|
|
9137
9143
|
if (error instanceof axios.AxiosError) {
|
|
9138
|
-
console.warn(error.response);
|
|
9139
|
-
console.warn(error.response.data);
|
|
9140
|
-
console.warn(error.response.data.cause);
|
|
9144
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
9141
9145
|
}
|
|
9146
|
+
throw error;
|
|
9142
9147
|
}
|
|
9143
9148
|
}
|
|
9144
9149
|
}
|
package/index.esm.js
CHANGED
|
@@ -8764,7 +8764,6 @@ class MercadoPagoRequestHelper {
|
|
|
8764
8764
|
statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
|
|
8765
8765
|
additional_info: {
|
|
8766
8766
|
items: this.buildItems(checkout),
|
|
8767
|
-
...(method === 'credit_card' && { payer: this.buildFullPayer(checkout) }),
|
|
8768
8767
|
},
|
|
8769
8768
|
...(method === 'credit_card' && this.buildCardPayment(card)),
|
|
8770
8769
|
...(method === 'pix' && this.buildPixPayment()),
|
|
@@ -8961,10 +8960,9 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
8961
8960
|
}
|
|
8962
8961
|
catch (error) {
|
|
8963
8962
|
if (error instanceof AxiosError) {
|
|
8964
|
-
console.warn(error.response);
|
|
8965
|
-
console.warn(error.response.data);
|
|
8966
|
-
console.warn(error.response.data.cause);
|
|
8963
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
8967
8964
|
}
|
|
8965
|
+
throw error;
|
|
8968
8966
|
}
|
|
8969
8967
|
}
|
|
8970
8968
|
getBoletoTransaction(paymentId) {
|
|
@@ -8979,41 +8977,49 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
8979
8977
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
8980
8978
|
}
|
|
8981
8979
|
async pay(checkout, card) {
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
method: 'credit_card',
|
|
8985
|
-
postback: this.credentials.postback,
|
|
8986
|
-
card,
|
|
8987
|
-
});
|
|
8988
|
-
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
8989
|
-
const { data } = await axios({
|
|
8990
|
-
method: 'POST',
|
|
8991
|
-
url: `${this.credentials.url}/v1/payments`,
|
|
8992
|
-
headers: {
|
|
8993
|
-
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
8994
|
-
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
8995
|
-
'Content-Type': 'application/json',
|
|
8996
|
-
},
|
|
8997
|
-
data: payload,
|
|
8998
|
-
});
|
|
8999
|
-
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
9000
|
-
if ((data.status !== 'approved' && data.status_detail !== MercadoPagoStatusDetailEnum.accredited) ||
|
|
9001
|
-
data.status !== 'authorized') {
|
|
9002
|
-
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
8980
|
+
try {
|
|
8981
|
+
const payload = MercadoPagoRequestHelper.build({
|
|
9003
8982
|
checkout,
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
limiteRange: 'day',
|
|
8983
|
+
method: 'credit_card',
|
|
8984
|
+
postback: this.credentials.postback,
|
|
9007
8985
|
card,
|
|
9008
8986
|
});
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
|
|
8987
|
+
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
8988
|
+
const { data } = await axios({
|
|
8989
|
+
method: 'POST',
|
|
8990
|
+
url: `${this.credentials.url}/v1/payments`,
|
|
8991
|
+
headers: {
|
|
8992
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
8993
|
+
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
8994
|
+
'Content-Type': 'application/json',
|
|
8995
|
+
},
|
|
8996
|
+
data: payload,
|
|
9013
8997
|
});
|
|
8998
|
+
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
8999
|
+
if ((data.status !== 'approved' && data.status_detail !== MercadoPagoStatusDetailEnum.accredited) ||
|
|
9000
|
+
data.status !== 'authorized') {
|
|
9001
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
9002
|
+
checkout,
|
|
9003
|
+
blockType: 'Card not authorized',
|
|
9004
|
+
type: 'Card',
|
|
9005
|
+
limiteRange: 'day',
|
|
9006
|
+
card,
|
|
9007
|
+
});
|
|
9008
|
+
throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
|
|
9009
|
+
checkoutId: checkout.id,
|
|
9010
|
+
userEmail: checkout.user.email,
|
|
9011
|
+
info: data,
|
|
9012
|
+
});
|
|
9013
|
+
}
|
|
9014
|
+
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
9015
|
+
return payment;
|
|
9016
|
+
}
|
|
9017
|
+
catch (error) {
|
|
9018
|
+
if (error instanceof AxiosError) {
|
|
9019
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
9020
|
+
}
|
|
9021
|
+
throw error;
|
|
9014
9022
|
}
|
|
9015
|
-
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
9016
|
-
return payment;
|
|
9017
9023
|
}
|
|
9018
9024
|
async addCard(card, customer) {
|
|
9019
9025
|
const { data } = await axios({
|
|
@@ -9111,10 +9117,9 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9111
9117
|
}
|
|
9112
9118
|
catch (error) {
|
|
9113
9119
|
if (error instanceof AxiosError) {
|
|
9114
|
-
console.warn(error.response);
|
|
9115
|
-
console.warn(error.response.data);
|
|
9116
|
-
console.warn(error.response.data.cause);
|
|
9120
|
+
console.warn(JSON.stringify(error.response.data.cause));
|
|
9117
9121
|
}
|
|
9122
|
+
throw error;
|
|
9118
9123
|
}
|
|
9119
9124
|
}
|
|
9120
9125
|
}
|
package/package.json
CHANGED
|
@@ -38,22 +38,6 @@ export declare class MercadoPagoRequestHelper {
|
|
|
38
38
|
};
|
|
39
39
|
statement_descriptor: string;
|
|
40
40
|
additional_info: {
|
|
41
|
-
payer: {
|
|
42
|
-
first_name: string;
|
|
43
|
-
last_name: string;
|
|
44
|
-
phone: {
|
|
45
|
-
area_code: string;
|
|
46
|
-
number: string;
|
|
47
|
-
};
|
|
48
|
-
address: {
|
|
49
|
-
zip_code: string;
|
|
50
|
-
street_name: string;
|
|
51
|
-
street_number: string;
|
|
52
|
-
neighborhood: string;
|
|
53
|
-
city: string;
|
|
54
|
-
federal_unit: string;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
41
|
items: {
|
|
58
42
|
id: string;
|
|
59
43
|
title: string;
|