@infrab4a/connect 5.4.0-beta.23 → 5.4.0-beta.24

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,9 +8984,7 @@ 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
  }
8992
8989
  }
8993
8990
  }
@@ -9003,41 +9000,48 @@ class MercadoPagoCardAxiosAdapter {
9003
9000
  this.orderBlockedRepository = orderBlockedRepository;
9004
9001
  }
9005
9002
  async pay(checkout, card) {
9006
- const payload = MercadoPagoRequestHelper.build({
9007
- checkout,
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({
9003
+ try {
9004
+ const payload = MercadoPagoRequestHelper.build({
9027
9005
  checkout,
9028
- blockType: 'Card not authorized',
9029
- type: 'Card',
9030
- limiteRange: 'day',
9006
+ method: 'credit_card',
9007
+ postback: this.credentials.postback,
9031
9008
  card,
9032
9009
  });
9033
- 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', {
9034
- checkoutId: checkout.id,
9035
- userEmail: checkout.user.email,
9036
- info: data,
9010
+ console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
9011
+ const { data } = await axios__default["default"]({
9012
+ method: 'POST',
9013
+ url: `${this.credentials.url}/v1/payments`,
9014
+ headers: {
9015
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9016
+ Authorization: `Bearer ${this.credentials.api_key}`,
9017
+ 'Content-Type': 'application/json',
9018
+ },
9019
+ data: payload,
9037
9020
  });
9021
+ console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
9022
+ if ((data.status !== 'approved' && data.status_detail !== exports.MercadoPagoStatusDetailEnum.accredited) ||
9023
+ data.status !== 'authorized') {
9024
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
9025
+ checkout,
9026
+ blockType: 'Card not authorized',
9027
+ type: 'Card',
9028
+ limiteRange: 'day',
9029
+ card,
9030
+ });
9031
+ 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', {
9032
+ checkoutId: checkout.id,
9033
+ userEmail: checkout.user.email,
9034
+ info: data,
9035
+ });
9036
+ }
9037
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
9038
+ return payment;
9039
+ }
9040
+ catch (error) {
9041
+ if (error instanceof axios.AxiosError) {
9042
+ console.warn(JSON.stringify(error.response.data.cause));
9043
+ }
9038
9044
  }
9039
- const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
9040
- return payment;
9041
9045
  }
9042
9046
  async addCard(card, customer) {
9043
9047
  const { data } = await axios__default["default"]({
@@ -9135,9 +9139,7 @@ class MercadoPagoPixAxiosAdapter {
9135
9139
  }
9136
9140
  catch (error) {
9137
9141
  if (error instanceof axios.AxiosError) {
9138
- console.warn(error.response);
9139
- console.warn(error.response.data);
9140
- console.warn(error.response.data.cause);
9142
+ console.warn(JSON.stringify(error.response.data.cause));
9141
9143
  }
9142
9144
  }
9143
9145
  }
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,9 +8960,7 @@ 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
  }
8968
8965
  }
8969
8966
  }
@@ -8979,41 +8976,48 @@ class MercadoPagoCardAxiosAdapter {
8979
8976
  this.orderBlockedRepository = orderBlockedRepository;
8980
8977
  }
8981
8978
  async pay(checkout, card) {
8982
- const payload = MercadoPagoRequestHelper.build({
8983
- checkout,
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({
8979
+ try {
8980
+ const payload = MercadoPagoRequestHelper.build({
9003
8981
  checkout,
9004
- blockType: 'Card not authorized',
9005
- type: 'Card',
9006
- limiteRange: 'day',
8982
+ method: 'credit_card',
8983
+ postback: this.credentials.postback,
9007
8984
  card,
9008
8985
  });
9009
- 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', {
9010
- checkoutId: checkout.id,
9011
- userEmail: checkout.user.email,
9012
- info: data,
8986
+ console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
8987
+ const { data } = await axios({
8988
+ method: 'POST',
8989
+ url: `${this.credentials.url}/v1/payments`,
8990
+ headers: {
8991
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
8992
+ Authorization: `Bearer ${this.credentials.api_key}`,
8993
+ 'Content-Type': 'application/json',
8994
+ },
8995
+ data: payload,
9013
8996
  });
8997
+ console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
8998
+ if ((data.status !== 'approved' && data.status_detail !== MercadoPagoStatusDetailEnum.accredited) ||
8999
+ data.status !== 'authorized') {
9000
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
9001
+ checkout,
9002
+ blockType: 'Card not authorized',
9003
+ type: 'Card',
9004
+ limiteRange: 'day',
9005
+ card,
9006
+ });
9007
+ 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', {
9008
+ checkoutId: checkout.id,
9009
+ userEmail: checkout.user.email,
9010
+ info: data,
9011
+ });
9012
+ }
9013
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
9014
+ return payment;
9015
+ }
9016
+ catch (error) {
9017
+ if (error instanceof AxiosError) {
9018
+ console.warn(JSON.stringify(error.response.data.cause));
9019
+ }
9014
9020
  }
9015
- const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
9016
- return payment;
9017
9021
  }
9018
9022
  async addCard(card, customer) {
9019
9023
  const { data } = await axios({
@@ -9111,9 +9115,7 @@ class MercadoPagoPixAxiosAdapter {
9111
9115
  }
9112
9116
  catch (error) {
9113
9117
  if (error instanceof AxiosError) {
9114
- console.warn(error.response);
9115
- console.warn(error.response.data);
9116
- console.warn(error.response.data.cause);
9118
+ console.warn(JSON.stringify(error.response.data.cause));
9117
9119
  }
9118
9120
  }
9119
9121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.4.0-beta.23",
3
+ "version": "5.4.0-beta.24",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -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;