@infrab4a/connect 5.5.2-beta.0 → 5.5.2-beta.2

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
@@ -1731,18 +1731,20 @@ exports.ErrorsCode = void 0;
1731
1731
  ErrorsCode["invalidCheckoutError"] = "invalid-checkout";
1732
1732
  ErrorsCode["stockLimit"] = "stock-limit";
1733
1733
  ErrorsCode["stockOut"] = "stock-out";
1734
+ ErrorsCode["notFound"] = "not-found";
1734
1735
  ErrorsCode["fraudPreventionInternal"] = "fraud-prevention-internal";
1735
1736
  ErrorsCode["fraudPreventionExternal"] = "fraud-prevention-external";
1736
1737
  ErrorsCode["invalidCardError"] = "invalid-card-error";
1737
1738
  ErrorsCode["insuficientFundsError"] = "insuficient-funds-error";
1739
+ ErrorsCode["paymentNotAuthorizedError"] = "payment-not-authorized-error";
1738
1740
  ErrorsCode["paymentError"] = "payment-error";
1739
1741
  })(exports.ErrorsCode || (exports.ErrorsCode = {}));
1740
1742
 
1741
1743
  class FraudValidationError extends tsCustomError.CustomError {
1742
- constructor(message, additionalData) {
1744
+ constructor(message, type, additionalData) {
1743
1745
  super(message);
1744
1746
  this.additionalData = additionalData;
1745
- this.type = 'antifraud';
1747
+ this.type = type;
1746
1748
  }
1747
1749
  }
1748
1750
 
@@ -1755,14 +1757,15 @@ class InvalidArgumentError extends tsCustomError.CustomError {
1755
1757
  class NotFoundError extends tsCustomError.CustomError {
1756
1758
  constructor(message) {
1757
1759
  super(message);
1760
+ this.type = exports.ErrorsCode.notFound;
1758
1761
  }
1759
1762
  }
1760
1763
 
1761
1764
  class PaymentError extends tsCustomError.CustomError {
1762
- constructor(message, additionalData) {
1765
+ constructor(message, type, additionalData) {
1763
1766
  super(message);
1764
1767
  this.additionalData = additionalData;
1765
- this.type = 'payment';
1768
+ this.type = type;
1766
1769
  }
1767
1770
  }
1768
1771
 
@@ -1777,14 +1780,14 @@ class RequiredArgumentError extends tsCustomError.CustomError {
1777
1780
  class StockLimitError extends BusinessError {
1778
1781
  constructor(message, additionalData) {
1779
1782
  super(message, additionalData);
1780
- this.type = 'stock-limit';
1783
+ this.type = exports.ErrorsCode.stockLimit;
1781
1784
  }
1782
1785
  }
1783
1786
 
1784
1787
  class StockOutError extends BusinessError {
1785
1788
  constructor(message, additionalData) {
1786
1789
  super(message, additionalData);
1787
- this.type = 'stock-out';
1790
+ this.type = exports.ErrorsCode.stockOut;
1788
1791
  }
1789
1792
  }
1790
1793
 
@@ -1801,7 +1804,7 @@ class AntifraudBankSlipService {
1801
1804
  type: 'Boleto',
1802
1805
  limiteRange: 'day',
1803
1806
  });
1804
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
1807
+ throw new FraudValidationError('Boleto não autorizado para cliente não assinante', exports.ErrorsCode.fraudPreventionInternal, {
1805
1808
  checkoutId: checkout.id,
1806
1809
  userEmail: checkout.user.email,
1807
1810
  info: {
@@ -1870,7 +1873,7 @@ class AntifraudCardService {
1870
1873
  async validateBlockedOrderAttempts(checkout, card) {
1871
1874
  const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
1872
1875
  if (!isValid) {
1873
- throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, {
1876
+ throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, exports.ErrorsCode.fraudPreventionInternal, {
1874
1877
  checkoutId: checkout.id,
1875
1878
  userEmail: checkout.user.email,
1876
1879
  info: {
@@ -1884,7 +1887,7 @@ class AntifraudCardService {
1884
1887
  async validateDayAndWeekOrderLimits(checkout, card) {
1885
1888
  const isValid = await this.verifyDayAndWeekOrders(checkout, card);
1886
1889
  if (!isValid) {
1887
- throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', {
1890
+ throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', exports.ErrorsCode.fraudPreventionInternal, {
1888
1891
  checkoutId: checkout.id,
1889
1892
  userEmail: checkout.user.email,
1890
1893
  info: {
@@ -2403,14 +2406,14 @@ class AdyenBlockedOrderHelper {
2403
2406
  limiteRange: 'day',
2404
2407
  card: params.card,
2405
2408
  });
2406
- 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', {
2409
+ 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', exports.ErrorsCode.paymentError, {
2407
2410
  checkoutId: params.checkout.id,
2408
2411
  userEmail: params.checkout.user.email,
2409
2412
  info: params.adyenResponse,
2410
2413
  });
2411
2414
  }
2412
2415
  static createPaymentError(checkout, errorInfo) {
2413
- return 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', {
2416
+ return 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', exports.ErrorsCode.paymentError, {
2414
2417
  checkoutId: checkout.id,
2415
2418
  userEmail: checkout.user.email,
2416
2419
  info: errorInfo,
@@ -5171,6 +5174,18 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
5171
5174
  }
5172
5175
  }
5173
5176
 
5177
+ class ShopConfigsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5178
+ constructor({ firestore, interceptors, cache, }) {
5179
+ super({
5180
+ firestore,
5181
+ collectionName: 'shopConfigs',
5182
+ model: ShopConfigs,
5183
+ interceptors,
5184
+ cache,
5185
+ });
5186
+ }
5187
+ }
5188
+
5174
5189
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5175
5190
  constructor({ firestore, interceptors, cache, }) {
5176
5191
  super({
@@ -9361,6 +9376,47 @@ tslib.__decorate([
9361
9376
  tslib.__metadata("design:returntype", Promise)
9362
9377
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9363
9378
 
9379
+ class MercadoPagoErrorHelper {
9380
+ static getErrorTypeFromResponse(errorCode) {
9381
+ switch (errorCode) {
9382
+ case 'bad_filled_card_data':
9383
+ case 'invalid_card_token':
9384
+ case 'card_disabled':
9385
+ case 'cc_rejected_card_disabled':
9386
+ case 'cc_rejected_bad_filled_card_number':
9387
+ case 'cc_rejected_bad_filled_date':
9388
+ case 'cc_rejected_bad_filled_other':
9389
+ case 'cc_rejected_bad_filled_security_code':
9390
+ return exports.ErrorsCode.invalidCardError;
9391
+ case 'high_risk':
9392
+ case 'rejected_high_risk':
9393
+ case 'cc_rejected_blacklist':
9394
+ case 'cc_rejected_call_for_authorize':
9395
+ case 'cc_rejected_high_risk':
9396
+ return exports.ErrorsCode.fraudPreventionExternal;
9397
+ case 'rejected_by_issuer':
9398
+ case 'rejected_by_bank':
9399
+ case 'cc_rejected_max_attempts':
9400
+ case 'required_call_for_authorize':
9401
+ case 'max_attempts_exceeded':
9402
+ return exports.ErrorsCode.paymentNotAuthorizedError;
9403
+ case 'insufficient_amount':
9404
+ case 'amount_limit_exceeded':
9405
+ case 'cc_rejected_insufficient_amount':
9406
+ return exports.ErrorsCode.insuficientFundsError;
9407
+ case 'processing_error':
9408
+ return exports.ErrorsCode.paymentError;
9409
+ case 'invalid_installments':
9410
+ case 'cc_rejected_invalid_installments':
9411
+ case 'cc_rejected_other_reason':
9412
+ case 'rejected_insufficient_data':
9413
+ return exports.ErrorsCode.businessError;
9414
+ default:
9415
+ return exports.ErrorsCode.paymentError;
9416
+ }
9417
+ }
9418
+ }
9419
+
9364
9420
  class MercadoPagoRequestHelper {
9365
9421
  static build(data) {
9366
9422
  const { checkout, method, postback, card } = data;
@@ -9575,7 +9631,7 @@ class MercadoPagoBankSlipAxiosAdapter {
9575
9631
  if (error instanceof axios.AxiosError) {
9576
9632
  console.warn(JSON.stringify(error.response.data.message));
9577
9633
  }
9578
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9634
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', exports.ErrorsCode.paymentError, {
9579
9635
  checkoutId: checkout.id,
9580
9636
  userEmail: checkout.user.email,
9581
9637
  info: error.response.data?.message || error.message?.toString(),
@@ -9597,16 +9653,7 @@ class MercadoPagoCardAxiosAdapter {
9597
9653
  try {
9598
9654
  const payload = await this.getPaymentPayload(checkout, card);
9599
9655
  console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
9600
- const { data } = await axios__default["default"]({
9601
- method: 'POST',
9602
- url: `${this.credentials.url}/v1/payments`,
9603
- headers: {
9604
- 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9605
- Authorization: `Bearer ${this.credentials.api_key}`,
9606
- 'Content-Type': 'application/json',
9607
- },
9608
- data: payload,
9609
- });
9656
+ const data = await this.requestPayment(checkout, payload);
9610
9657
  console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
9611
9658
  if (data.status == exports.MercadoPagoStatusEnum.rejected) {
9612
9659
  await this.orderBlockedRepository.createBlockedOrderOrPayment({
@@ -9615,8 +9662,13 @@ class MercadoPagoCardAxiosAdapter {
9615
9662
  type: 'Card',
9616
9663
  limiteRange: 'day',
9617
9664
  card,
9665
+ gatewayInfo: {
9666
+ status: data.status,
9667
+ statusDetail: data.status_detail,
9668
+ },
9618
9669
  });
9619
- 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', {
9670
+ const errorCode = MercadoPagoErrorHelper.getErrorTypeFromResponse(data.status_detail);
9671
+ 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', errorCode, {
9620
9672
  checkoutId: checkout.id,
9621
9673
  userEmail: checkout.user.email,
9622
9674
  info: data,
@@ -9629,13 +9681,26 @@ class MercadoPagoCardAxiosAdapter {
9629
9681
  if (error instanceof axios.AxiosError) {
9630
9682
  console.warn(JSON.stringify(error.response.data.message));
9631
9683
  }
9632
- 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', {
9684
+ 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', exports.ErrorsCode.paymentError, {
9633
9685
  checkoutId: checkout.id,
9634
9686
  userEmail: checkout.user.email,
9635
9687
  info: error.response.data?.message || error.message?.toString(),
9636
9688
  });
9637
9689
  }
9638
9690
  }
9691
+ async requestPayment(checkout, payload) {
9692
+ const { data } = await axios__default["default"]({
9693
+ method: 'POST',
9694
+ url: `${this.credentials.url}/v1/payments`,
9695
+ headers: {
9696
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9697
+ Authorization: `Bearer ${this.credentials.api_key}`,
9698
+ 'Content-Type': 'application/json',
9699
+ },
9700
+ data: payload,
9701
+ });
9702
+ return data;
9703
+ }
9639
9704
  async getPaymentPayload(checkout, card) {
9640
9705
  const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
9641
9706
  const payload = MercadoPagoRequestHelper.build({
@@ -9737,7 +9802,7 @@ class MercadoPagoPixAxiosAdapter {
9737
9802
  if (error instanceof axios.AxiosError) {
9738
9803
  console.warn(JSON.stringify(error.response.data.message));
9739
9804
  }
9740
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9805
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', exports.ErrorsCode.paymentError, {
9741
9806
  checkoutId: checkout.id,
9742
9807
  userEmail: checkout.user.email,
9743
9808
  info: error.response.data?.message || error.message?.toString(),
@@ -9808,7 +9873,7 @@ class PagarmeBankSlipAxiosAdapter {
9808
9873
  });
9809
9874
  console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
9810
9875
  if (result.data.status !== exports.PagarmePaymentStatus['Em processamento']) {
9811
- return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9876
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', exports.ErrorsCode.paymentError, {
9812
9877
  checkoutId: checkout.id,
9813
9878
  userEmail: checkout.user.email,
9814
9879
  info: result.data,
@@ -9826,7 +9891,7 @@ class PagarmeBankSlipAxiosAdapter {
9826
9891
  return payment;
9827
9892
  }
9828
9893
  catch (error) {
9829
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9894
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', exports.ErrorsCode.paymentError, {
9830
9895
  checkoutId: checkout.id,
9831
9896
  userEmail: checkout.user.email,
9832
9897
  info: error.response.data,
@@ -9878,24 +9943,25 @@ class PagarmeBankSlipAxiosAdapter {
9878
9943
 
9879
9944
  class PagarmeBlockedOrderHelper {
9880
9945
  static async createBlockedOrderForUnauthorizedCard(params) {
9881
- const { checkout, card, orderBlockedRepository } = params;
9946
+ const { checkout, card, orderBlockedRepository, gatewayInfo } = params;
9882
9947
  await orderBlockedRepository.createBlockedOrderOrPayment({
9883
9948
  checkout,
9884
9949
  blockType: 'Card not authorized',
9885
9950
  type: 'Card',
9886
9951
  limiteRange: 'day',
9887
9952
  card,
9953
+ gatewayInfo,
9888
9954
  });
9889
9955
  }
9890
- static createPaymentError(checkout, resultData) {
9891
- return 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', {
9956
+ static createPaymentError(checkout, errorType, resultData) {
9957
+ return 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', errorType, {
9892
9958
  checkoutId: checkout.id,
9893
9959
  userEmail: checkout.user.email,
9894
9960
  info: resultData,
9895
9961
  });
9896
9962
  }
9897
- static createGenericPaymentError(checkout, errorResponseData) {
9898
- return 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', {
9963
+ static createGenericPaymentError(checkout, errorType, errorResponseData) {
9964
+ return 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', errorType, {
9899
9965
  checkoutId: checkout.id,
9900
9966
  userEmail: checkout.user.email,
9901
9967
  info: errorResponseData,
@@ -9903,6 +9969,162 @@ class PagarmeBlockedOrderHelper {
9903
9969
  }
9904
9970
  }
9905
9971
 
9972
+ /* eslint-disable complexity */
9973
+ class PagarMeErrorHelper {
9974
+ static getErrorTypeFromResponse(errorCode) {
9975
+ switch (errorCode) {
9976
+ // Cartão inválido, vencido, bloqueado
9977
+ case '1000':
9978
+ case '1001':
9979
+ case '1011':
9980
+ case '1025':
9981
+ case '1032':
9982
+ case '1045':
9983
+ case '1068':
9984
+ case '1069':
9985
+ case '1070':
9986
+ case '2001':
9987
+ case '2004':
9988
+ return exports.ErrorsCode.invalidCardError;
9989
+ // Suspeita de fraude, prevenção do banco
9990
+ case '1002':
9991
+ case '1004':
9992
+ case '1019':
9993
+ case '2002':
9994
+ case '2005':
9995
+ case '2007':
9996
+ case '2008':
9997
+ case '2009':
9998
+ case '2010':
9999
+ return exports.ErrorsCode.fraudPreventionExternal;
10000
+ // Recusado pelo banco/emissor
10001
+ case '1007':
10002
+ case '1008':
10003
+ case '2000':
10004
+ case '5093':
10005
+ return exports.ErrorsCode.paymentNotAuthorizedError;
10006
+ // Saldo/limite insuficiente ou excedido
10007
+ case '1016':
10008
+ case '1021':
10009
+ case '1023':
10010
+ case '2011':
10011
+ case '2012':
10012
+ case '5051':
10013
+ case '5087':
10014
+ return exports.ErrorsCode.insuficientFundsError;
10015
+ // Valor solicitado inválido
10016
+ case '5016':
10017
+ case '5092':
10018
+ return exports.ErrorsCode.paymentError;
10019
+ // Código de segurança inválido ou não enviado
10020
+ case '5025':
10021
+ case '9124':
10022
+ return exports.ErrorsCode.paymentError;
10023
+ // Dados obrigatórios ausentes
10024
+ case '1044':
10025
+ case '5034':
10026
+ case '5047':
10027
+ case '5061':
10028
+ return exports.ErrorsCode.paymentError;
10029
+ // Erros internos ou genéricos
10030
+ case '5000':
10031
+ case '5001':
10032
+ case '5003':
10033
+ case '5004':
10034
+ case '5006':
10035
+ case '5008':
10036
+ case '5009':
10037
+ case '5010':
10038
+ case '5011':
10039
+ case '5012':
10040
+ case '5013':
10041
+ case '5014':
10042
+ case '5015':
10043
+ case '5017':
10044
+ case '5018':
10045
+ case '5019':
10046
+ case '5020':
10047
+ case '5021':
10048
+ case '5022':
10049
+ case '5023':
10050
+ case '5024':
10051
+ case '5026':
10052
+ case '5027':
10053
+ case '5028':
10054
+ case '5029':
10055
+ case '5030':
10056
+ case '5031':
10057
+ case '5032':
10058
+ case '5033':
10059
+ case '5035':
10060
+ case '5036':
10061
+ case '5037':
10062
+ case '5038':
10063
+ case '5039':
10064
+ case '5040':
10065
+ case '5041':
10066
+ case '5042':
10067
+ case '5043':
10068
+ case '5044':
10069
+ case '5045':
10070
+ case '5049':
10071
+ case '5050':
10072
+ case '5052':
10073
+ case '5053':
10074
+ case '5054':
10075
+ case '5055':
10076
+ case '5056':
10077
+ case '5057':
10078
+ case '5058':
10079
+ case '5059':
10080
+ case '5060':
10081
+ case '5062':
10082
+ case '5063':
10083
+ case '5064':
10084
+ case '5065':
10085
+ case '5066':
10086
+ case '5067':
10087
+ case '5068':
10088
+ case '5069':
10089
+ case '5070':
10090
+ case '5071':
10091
+ case '5072':
10092
+ case '5073':
10093
+ case '5074':
10094
+ case '5075':
10095
+ case '5076':
10096
+ case '5077':
10097
+ case '5078':
10098
+ case '5079':
10099
+ case '5080':
10100
+ case '5081':
10101
+ case '5082':
10102
+ case '5083':
10103
+ case '5084':
10104
+ case '5085':
10105
+ case '5089':
10106
+ case '5090':
10107
+ case '5095':
10108
+ case '5096':
10109
+ case '5097':
10110
+ return exports.ErrorsCode.paymentError;
10111
+ // Banco/emissor inválido ou não operante
10112
+ case '1049':
10113
+ case '1050':
10114
+ return exports.ErrorsCode.paymentError;
10115
+ // Transação não suportada para o banco/emissor
10116
+ case '1061':
10117
+ return exports.ErrorsCode.paymentError;
10118
+ case '5094':
10119
+ case '1010':
10120
+ case '1046':
10121
+ return exports.ErrorsCode.businessError;
10122
+ default:
10123
+ return exports.ErrorsCode.paymentError;
10124
+ }
10125
+ }
10126
+ }
10127
+
9906
10128
  class PagarmePaymentFactoryHelper {
9907
10129
  static async createSuccessfulPayment(params) {
9908
10130
  const { checkout, resultData, paymentRepository } = params;
@@ -10158,7 +10380,7 @@ class PagarmeCardAxiosAdapter {
10158
10380
  card,
10159
10381
  orderBlockedRepository: this.orderBlockedRepository,
10160
10382
  });
10161
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, result.data);
10383
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, exports.ErrorsCode.paymentError, result.data);
10162
10384
  }
10163
10385
  return PagarmePaymentFactoryHelper.createSuccessfulPayment({
10164
10386
  checkout,
@@ -10170,7 +10392,7 @@ class PagarmeCardAxiosAdapter {
10170
10392
  if (error instanceof PaymentError) {
10171
10393
  throw error;
10172
10394
  }
10173
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
10395
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, exports.ErrorsCode.paymentError, error.response?.data);
10174
10396
  }
10175
10397
  }
10176
10398
  async addCard(card) {
@@ -10327,7 +10549,7 @@ class PagarmePixAxiosAdapter {
10327
10549
  return payment;
10328
10550
  }
10329
10551
  catch (error) {
10330
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10552
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', exports.ErrorsCode.paymentError, {
10331
10553
  checkoutId: checkout.id,
10332
10554
  userEmail: checkout.user.email,
10333
10555
  info: error.response?.data,
@@ -10382,7 +10604,7 @@ class PagarmeV5BankSlipAxiosAdapter {
10382
10604
  data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
10383
10605
  (data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado &&
10384
10606
  data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus['Em processamento'])) {
10385
- return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10607
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', exports.ErrorsCode.paymentError, {
10386
10608
  checkoutId: checkout.id,
10387
10609
  userEmail: checkout.user.email,
10388
10610
  info: data.charges.at(0).last_transaction?.gateway_response,
@@ -10395,7 +10617,7 @@ class PagarmeV5BankSlipAxiosAdapter {
10395
10617
  if (error instanceof axios.AxiosError) {
10396
10618
  console.error('error data: ', JSON.stringify(error.response?.data));
10397
10619
  }
10398
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10620
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', exports.ErrorsCode.paymentError, {
10399
10621
  checkoutId: checkout.id,
10400
10622
  userEmail: checkout.user.email,
10401
10623
  info: error.response?.data,
@@ -10446,15 +10668,21 @@ class PagarmeV5CardAxiosAdapter {
10446
10668
  data: payload,
10447
10669
  });
10448
10670
  console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
10671
+ const charge = data.charges.at(0);
10449
10672
  if (data.status == exports.PagarMeV5OrderStatus.Falha ||
10450
- data.charges.at(0).status !== exports.PagarMeV5OrderStatus.Pago ||
10451
- data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Capturada) {
10673
+ charge.status !== exports.PagarMeV5OrderStatus.Pago ||
10674
+ charge.last_transaction.status !== exports.PagarMeV5PaymentStatus.Capturada) {
10452
10675
  await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
10453
10676
  checkout,
10454
10677
  card,
10455
10678
  orderBlockedRepository: this.orderBlockedRepository,
10679
+ gatewayInfo: {
10680
+ status: charge.status,
10681
+ statusDetail: charge.last_transaction?.status,
10682
+ },
10456
10683
  });
10457
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
10684
+ const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(charge.last_transaction.acquirer_return_code);
10685
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, errorCode, data);
10458
10686
  }
10459
10687
  const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
10460
10688
  return payment;
@@ -10466,7 +10694,9 @@ class PagarmeV5CardAxiosAdapter {
10466
10694
  if (error instanceof axios.AxiosError) {
10467
10695
  console.error('error data: ', JSON.stringify(error.response?.data));
10468
10696
  }
10469
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
10697
+ const returnCode = error.response?.data?.charges?.at(0)?.last_transaction?.acquirer_return_code;
10698
+ const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(returnCode);
10699
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, errorCode, error.response?.data);
10470
10700
  }
10471
10701
  }
10472
10702
  async addCard(card, customer) {
@@ -10612,7 +10842,7 @@ class PagarmeV5PixAxiosAdapter {
10612
10842
  });
10613
10843
  console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
10614
10844
  if (data.status == exports.PagarMeV5OrderStatus.Falha || data.status == exports.PagarMeV5OrderStatus.Cancelado) {
10615
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10845
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', exports.ErrorsCode.paymentError, {
10616
10846
  checkoutId: checkout.id,
10617
10847
  userEmail: checkout.user.email,
10618
10848
  info: data.charges.at(0).last_transaction?.gateway_response,
@@ -10625,7 +10855,7 @@ class PagarmeV5PixAxiosAdapter {
10625
10855
  if (error instanceof axios.AxiosError) {
10626
10856
  console.error('error data: ', JSON.stringify(error.response?.data));
10627
10857
  }
10628
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10858
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', exports.ErrorsCode.paymentError, {
10629
10859
  checkoutId: checkout.id,
10630
10860
  userEmail: checkout.user.email,
10631
10861
  info: error.response?.data,
@@ -10992,6 +11222,7 @@ exports.LogFirestoreRepository = LogFirestoreRepository;
10992
11222
  exports.Logger = Logger;
10993
11223
  exports.MercadoPagoBankSlipAxiosAdapter = MercadoPagoBankSlipAxiosAdapter;
10994
11224
  exports.MercadoPagoCardAxiosAdapter = MercadoPagoCardAxiosAdapter;
11225
+ exports.MercadoPagoErrorHelper = MercadoPagoErrorHelper;
10995
11226
  exports.MercadoPagoPaymentMethodFactory = MercadoPagoPaymentMethodFactory;
10996
11227
  exports.MercadoPagoPixAxiosAdapter = MercadoPagoPixAxiosAdapter;
10997
11228
  exports.MercadoPagoRequestHelper = MercadoPagoRequestHelper;
@@ -11041,6 +11272,7 @@ exports.Sequence = Sequence;
11041
11272
  exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
11042
11273
  exports.ShippingMethod = ShippingMethod;
11043
11274
  exports.ShopConfigs = ShopConfigs;
11275
+ exports.ShopConfigsFirestoreRepository = ShopConfigsFirestoreRepository;
11044
11276
  exports.ShopMenu = ShopMenu;
11045
11277
  exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;
11046
11278
  exports.ShopSettings = ShopSettings;
package/index.esm.js CHANGED
@@ -1707,18 +1707,20 @@ var ErrorsCode;
1707
1707
  ErrorsCode["invalidCheckoutError"] = "invalid-checkout";
1708
1708
  ErrorsCode["stockLimit"] = "stock-limit";
1709
1709
  ErrorsCode["stockOut"] = "stock-out";
1710
+ ErrorsCode["notFound"] = "not-found";
1710
1711
  ErrorsCode["fraudPreventionInternal"] = "fraud-prevention-internal";
1711
1712
  ErrorsCode["fraudPreventionExternal"] = "fraud-prevention-external";
1712
1713
  ErrorsCode["invalidCardError"] = "invalid-card-error";
1713
1714
  ErrorsCode["insuficientFundsError"] = "insuficient-funds-error";
1715
+ ErrorsCode["paymentNotAuthorizedError"] = "payment-not-authorized-error";
1714
1716
  ErrorsCode["paymentError"] = "payment-error";
1715
1717
  })(ErrorsCode || (ErrorsCode = {}));
1716
1718
 
1717
1719
  class FraudValidationError extends CustomError {
1718
- constructor(message, additionalData) {
1720
+ constructor(message, type, additionalData) {
1719
1721
  super(message);
1720
1722
  this.additionalData = additionalData;
1721
- this.type = 'antifraud';
1723
+ this.type = type;
1722
1724
  }
1723
1725
  }
1724
1726
 
@@ -1731,14 +1733,15 @@ class InvalidArgumentError extends CustomError {
1731
1733
  class NotFoundError extends CustomError {
1732
1734
  constructor(message) {
1733
1735
  super(message);
1736
+ this.type = ErrorsCode.notFound;
1734
1737
  }
1735
1738
  }
1736
1739
 
1737
1740
  class PaymentError extends CustomError {
1738
- constructor(message, additionalData) {
1741
+ constructor(message, type, additionalData) {
1739
1742
  super(message);
1740
1743
  this.additionalData = additionalData;
1741
- this.type = 'payment';
1744
+ this.type = type;
1742
1745
  }
1743
1746
  }
1744
1747
 
@@ -1753,14 +1756,14 @@ class RequiredArgumentError extends CustomError {
1753
1756
  class StockLimitError extends BusinessError {
1754
1757
  constructor(message, additionalData) {
1755
1758
  super(message, additionalData);
1756
- this.type = 'stock-limit';
1759
+ this.type = ErrorsCode.stockLimit;
1757
1760
  }
1758
1761
  }
1759
1762
 
1760
1763
  class StockOutError extends BusinessError {
1761
1764
  constructor(message, additionalData) {
1762
1765
  super(message, additionalData);
1763
- this.type = 'stock-out';
1766
+ this.type = ErrorsCode.stockOut;
1764
1767
  }
1765
1768
  }
1766
1769
 
@@ -1777,7 +1780,7 @@ class AntifraudBankSlipService {
1777
1780
  type: 'Boleto',
1778
1781
  limiteRange: 'day',
1779
1782
  });
1780
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
1783
+ throw new FraudValidationError('Boleto não autorizado para cliente não assinante', ErrorsCode.fraudPreventionInternal, {
1781
1784
  checkoutId: checkout.id,
1782
1785
  userEmail: checkout.user.email,
1783
1786
  info: {
@@ -1846,7 +1849,7 @@ class AntifraudCardService {
1846
1849
  async validateBlockedOrderAttempts(checkout, card) {
1847
1850
  const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
1848
1851
  if (!isValid) {
1849
- throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, {
1852
+ throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, ErrorsCode.fraudPreventionInternal, {
1850
1853
  checkoutId: checkout.id,
1851
1854
  userEmail: checkout.user.email,
1852
1855
  info: {
@@ -1860,7 +1863,7 @@ class AntifraudCardService {
1860
1863
  async validateDayAndWeekOrderLimits(checkout, card) {
1861
1864
  const isValid = await this.verifyDayAndWeekOrders(checkout, card);
1862
1865
  if (!isValid) {
1863
- throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', {
1866
+ throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', ErrorsCode.fraudPreventionInternal, {
1864
1867
  checkoutId: checkout.id,
1865
1868
  userEmail: checkout.user.email,
1866
1869
  info: {
@@ -2379,14 +2382,14 @@ class AdyenBlockedOrderHelper {
2379
2382
  limiteRange: 'day',
2380
2383
  card: params.card,
2381
2384
  });
2382
- 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', {
2385
+ 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', ErrorsCode.paymentError, {
2383
2386
  checkoutId: params.checkout.id,
2384
2387
  userEmail: params.checkout.user.email,
2385
2388
  info: params.adyenResponse,
2386
2389
  });
2387
2390
  }
2388
2391
  static createPaymentError(checkout, errorInfo) {
2389
- return 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', {
2392
+ return 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', ErrorsCode.paymentError, {
2390
2393
  checkoutId: checkout.id,
2391
2394
  userEmail: checkout.user.email,
2392
2395
  info: errorInfo,
@@ -5147,6 +5150,18 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
5147
5150
  }
5148
5151
  }
5149
5152
 
5153
+ class ShopConfigsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5154
+ constructor({ firestore, interceptors, cache, }) {
5155
+ super({
5156
+ firestore,
5157
+ collectionName: 'shopConfigs',
5158
+ model: ShopConfigs,
5159
+ interceptors,
5160
+ cache,
5161
+ });
5162
+ }
5163
+ }
5164
+
5150
5165
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5151
5166
  constructor({ firestore, interceptors, cache, }) {
5152
5167
  super({
@@ -9337,6 +9352,47 @@ __decorate([
9337
9352
  __metadata("design:returntype", Promise)
9338
9353
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9339
9354
 
9355
+ class MercadoPagoErrorHelper {
9356
+ static getErrorTypeFromResponse(errorCode) {
9357
+ switch (errorCode) {
9358
+ case 'bad_filled_card_data':
9359
+ case 'invalid_card_token':
9360
+ case 'card_disabled':
9361
+ case 'cc_rejected_card_disabled':
9362
+ case 'cc_rejected_bad_filled_card_number':
9363
+ case 'cc_rejected_bad_filled_date':
9364
+ case 'cc_rejected_bad_filled_other':
9365
+ case 'cc_rejected_bad_filled_security_code':
9366
+ return ErrorsCode.invalidCardError;
9367
+ case 'high_risk':
9368
+ case 'rejected_high_risk':
9369
+ case 'cc_rejected_blacklist':
9370
+ case 'cc_rejected_call_for_authorize':
9371
+ case 'cc_rejected_high_risk':
9372
+ return ErrorsCode.fraudPreventionExternal;
9373
+ case 'rejected_by_issuer':
9374
+ case 'rejected_by_bank':
9375
+ case 'cc_rejected_max_attempts':
9376
+ case 'required_call_for_authorize':
9377
+ case 'max_attempts_exceeded':
9378
+ return ErrorsCode.paymentNotAuthorizedError;
9379
+ case 'insufficient_amount':
9380
+ case 'amount_limit_exceeded':
9381
+ case 'cc_rejected_insufficient_amount':
9382
+ return ErrorsCode.insuficientFundsError;
9383
+ case 'processing_error':
9384
+ return ErrorsCode.paymentError;
9385
+ case 'invalid_installments':
9386
+ case 'cc_rejected_invalid_installments':
9387
+ case 'cc_rejected_other_reason':
9388
+ case 'rejected_insufficient_data':
9389
+ return ErrorsCode.businessError;
9390
+ default:
9391
+ return ErrorsCode.paymentError;
9392
+ }
9393
+ }
9394
+ }
9395
+
9340
9396
  class MercadoPagoRequestHelper {
9341
9397
  static build(data) {
9342
9398
  const { checkout, method, postback, card } = data;
@@ -9551,7 +9607,7 @@ class MercadoPagoBankSlipAxiosAdapter {
9551
9607
  if (error instanceof AxiosError) {
9552
9608
  console.warn(JSON.stringify(error.response.data.message));
9553
9609
  }
9554
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9610
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
9555
9611
  checkoutId: checkout.id,
9556
9612
  userEmail: checkout.user.email,
9557
9613
  info: error.response.data?.message || error.message?.toString(),
@@ -9573,16 +9629,7 @@ class MercadoPagoCardAxiosAdapter {
9573
9629
  try {
9574
9630
  const payload = await this.getPaymentPayload(checkout, card);
9575
9631
  console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
9576
- const { data } = await axios({
9577
- method: 'POST',
9578
- url: `${this.credentials.url}/v1/payments`,
9579
- headers: {
9580
- 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9581
- Authorization: `Bearer ${this.credentials.api_key}`,
9582
- 'Content-Type': 'application/json',
9583
- },
9584
- data: payload,
9585
- });
9632
+ const data = await this.requestPayment(checkout, payload);
9586
9633
  console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
9587
9634
  if (data.status == MercadoPagoStatusEnum.rejected) {
9588
9635
  await this.orderBlockedRepository.createBlockedOrderOrPayment({
@@ -9591,8 +9638,13 @@ class MercadoPagoCardAxiosAdapter {
9591
9638
  type: 'Card',
9592
9639
  limiteRange: 'day',
9593
9640
  card,
9641
+ gatewayInfo: {
9642
+ status: data.status,
9643
+ statusDetail: data.status_detail,
9644
+ },
9594
9645
  });
9595
- 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', {
9646
+ const errorCode = MercadoPagoErrorHelper.getErrorTypeFromResponse(data.status_detail);
9647
+ 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', errorCode, {
9596
9648
  checkoutId: checkout.id,
9597
9649
  userEmail: checkout.user.email,
9598
9650
  info: data,
@@ -9605,13 +9657,26 @@ class MercadoPagoCardAxiosAdapter {
9605
9657
  if (error instanceof AxiosError) {
9606
9658
  console.warn(JSON.stringify(error.response.data.message));
9607
9659
  }
9608
- 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', {
9660
+ 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', ErrorsCode.paymentError, {
9609
9661
  checkoutId: checkout.id,
9610
9662
  userEmail: checkout.user.email,
9611
9663
  info: error.response.data?.message || error.message?.toString(),
9612
9664
  });
9613
9665
  }
9614
9666
  }
9667
+ async requestPayment(checkout, payload) {
9668
+ const { data } = await axios({
9669
+ method: 'POST',
9670
+ url: `${this.credentials.url}/v1/payments`,
9671
+ headers: {
9672
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9673
+ Authorization: `Bearer ${this.credentials.api_key}`,
9674
+ 'Content-Type': 'application/json',
9675
+ },
9676
+ data: payload,
9677
+ });
9678
+ return data;
9679
+ }
9615
9680
  async getPaymentPayload(checkout, card) {
9616
9681
  const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
9617
9682
  const payload = MercadoPagoRequestHelper.build({
@@ -9713,7 +9778,7 @@ class MercadoPagoPixAxiosAdapter {
9713
9778
  if (error instanceof AxiosError) {
9714
9779
  console.warn(JSON.stringify(error.response.data.message));
9715
9780
  }
9716
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9781
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
9717
9782
  checkoutId: checkout.id,
9718
9783
  userEmail: checkout.user.email,
9719
9784
  info: error.response.data?.message || error.message?.toString(),
@@ -9784,7 +9849,7 @@ class PagarmeBankSlipAxiosAdapter {
9784
9849
  });
9785
9850
  console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
9786
9851
  if (result.data.status !== PagarmePaymentStatus['Em processamento']) {
9787
- return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9852
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
9788
9853
  checkoutId: checkout.id,
9789
9854
  userEmail: checkout.user.email,
9790
9855
  info: result.data,
@@ -9802,7 +9867,7 @@ class PagarmeBankSlipAxiosAdapter {
9802
9867
  return payment;
9803
9868
  }
9804
9869
  catch (error) {
9805
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9870
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
9806
9871
  checkoutId: checkout.id,
9807
9872
  userEmail: checkout.user.email,
9808
9873
  info: error.response.data,
@@ -9854,24 +9919,25 @@ class PagarmeBankSlipAxiosAdapter {
9854
9919
 
9855
9920
  class PagarmeBlockedOrderHelper {
9856
9921
  static async createBlockedOrderForUnauthorizedCard(params) {
9857
- const { checkout, card, orderBlockedRepository } = params;
9922
+ const { checkout, card, orderBlockedRepository, gatewayInfo } = params;
9858
9923
  await orderBlockedRepository.createBlockedOrderOrPayment({
9859
9924
  checkout,
9860
9925
  blockType: 'Card not authorized',
9861
9926
  type: 'Card',
9862
9927
  limiteRange: 'day',
9863
9928
  card,
9929
+ gatewayInfo,
9864
9930
  });
9865
9931
  }
9866
- static createPaymentError(checkout, resultData) {
9867
- return 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', {
9932
+ static createPaymentError(checkout, errorType, resultData) {
9933
+ return 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', errorType, {
9868
9934
  checkoutId: checkout.id,
9869
9935
  userEmail: checkout.user.email,
9870
9936
  info: resultData,
9871
9937
  });
9872
9938
  }
9873
- static createGenericPaymentError(checkout, errorResponseData) {
9874
- return 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', {
9939
+ static createGenericPaymentError(checkout, errorType, errorResponseData) {
9940
+ return 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', errorType, {
9875
9941
  checkoutId: checkout.id,
9876
9942
  userEmail: checkout.user.email,
9877
9943
  info: errorResponseData,
@@ -9879,6 +9945,162 @@ class PagarmeBlockedOrderHelper {
9879
9945
  }
9880
9946
  }
9881
9947
 
9948
+ /* eslint-disable complexity */
9949
+ class PagarMeErrorHelper {
9950
+ static getErrorTypeFromResponse(errorCode) {
9951
+ switch (errorCode) {
9952
+ // Cartão inválido, vencido, bloqueado
9953
+ case '1000':
9954
+ case '1001':
9955
+ case '1011':
9956
+ case '1025':
9957
+ case '1032':
9958
+ case '1045':
9959
+ case '1068':
9960
+ case '1069':
9961
+ case '1070':
9962
+ case '2001':
9963
+ case '2004':
9964
+ return ErrorsCode.invalidCardError;
9965
+ // Suspeita de fraude, prevenção do banco
9966
+ case '1002':
9967
+ case '1004':
9968
+ case '1019':
9969
+ case '2002':
9970
+ case '2005':
9971
+ case '2007':
9972
+ case '2008':
9973
+ case '2009':
9974
+ case '2010':
9975
+ return ErrorsCode.fraudPreventionExternal;
9976
+ // Recusado pelo banco/emissor
9977
+ case '1007':
9978
+ case '1008':
9979
+ case '2000':
9980
+ case '5093':
9981
+ return ErrorsCode.paymentNotAuthorizedError;
9982
+ // Saldo/limite insuficiente ou excedido
9983
+ case '1016':
9984
+ case '1021':
9985
+ case '1023':
9986
+ case '2011':
9987
+ case '2012':
9988
+ case '5051':
9989
+ case '5087':
9990
+ return ErrorsCode.insuficientFundsError;
9991
+ // Valor solicitado inválido
9992
+ case '5016':
9993
+ case '5092':
9994
+ return ErrorsCode.paymentError;
9995
+ // Código de segurança inválido ou não enviado
9996
+ case '5025':
9997
+ case '9124':
9998
+ return ErrorsCode.paymentError;
9999
+ // Dados obrigatórios ausentes
10000
+ case '1044':
10001
+ case '5034':
10002
+ case '5047':
10003
+ case '5061':
10004
+ return ErrorsCode.paymentError;
10005
+ // Erros internos ou genéricos
10006
+ case '5000':
10007
+ case '5001':
10008
+ case '5003':
10009
+ case '5004':
10010
+ case '5006':
10011
+ case '5008':
10012
+ case '5009':
10013
+ case '5010':
10014
+ case '5011':
10015
+ case '5012':
10016
+ case '5013':
10017
+ case '5014':
10018
+ case '5015':
10019
+ case '5017':
10020
+ case '5018':
10021
+ case '5019':
10022
+ case '5020':
10023
+ case '5021':
10024
+ case '5022':
10025
+ case '5023':
10026
+ case '5024':
10027
+ case '5026':
10028
+ case '5027':
10029
+ case '5028':
10030
+ case '5029':
10031
+ case '5030':
10032
+ case '5031':
10033
+ case '5032':
10034
+ case '5033':
10035
+ case '5035':
10036
+ case '5036':
10037
+ case '5037':
10038
+ case '5038':
10039
+ case '5039':
10040
+ case '5040':
10041
+ case '5041':
10042
+ case '5042':
10043
+ case '5043':
10044
+ case '5044':
10045
+ case '5045':
10046
+ case '5049':
10047
+ case '5050':
10048
+ case '5052':
10049
+ case '5053':
10050
+ case '5054':
10051
+ case '5055':
10052
+ case '5056':
10053
+ case '5057':
10054
+ case '5058':
10055
+ case '5059':
10056
+ case '5060':
10057
+ case '5062':
10058
+ case '5063':
10059
+ case '5064':
10060
+ case '5065':
10061
+ case '5066':
10062
+ case '5067':
10063
+ case '5068':
10064
+ case '5069':
10065
+ case '5070':
10066
+ case '5071':
10067
+ case '5072':
10068
+ case '5073':
10069
+ case '5074':
10070
+ case '5075':
10071
+ case '5076':
10072
+ case '5077':
10073
+ case '5078':
10074
+ case '5079':
10075
+ case '5080':
10076
+ case '5081':
10077
+ case '5082':
10078
+ case '5083':
10079
+ case '5084':
10080
+ case '5085':
10081
+ case '5089':
10082
+ case '5090':
10083
+ case '5095':
10084
+ case '5096':
10085
+ case '5097':
10086
+ return ErrorsCode.paymentError;
10087
+ // Banco/emissor inválido ou não operante
10088
+ case '1049':
10089
+ case '1050':
10090
+ return ErrorsCode.paymentError;
10091
+ // Transação não suportada para o banco/emissor
10092
+ case '1061':
10093
+ return ErrorsCode.paymentError;
10094
+ case '5094':
10095
+ case '1010':
10096
+ case '1046':
10097
+ return ErrorsCode.businessError;
10098
+ default:
10099
+ return ErrorsCode.paymentError;
10100
+ }
10101
+ }
10102
+ }
10103
+
9882
10104
  class PagarmePaymentFactoryHelper {
9883
10105
  static async createSuccessfulPayment(params) {
9884
10106
  const { checkout, resultData, paymentRepository } = params;
@@ -10134,7 +10356,7 @@ class PagarmeCardAxiosAdapter {
10134
10356
  card,
10135
10357
  orderBlockedRepository: this.orderBlockedRepository,
10136
10358
  });
10137
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, result.data);
10359
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, ErrorsCode.paymentError, result.data);
10138
10360
  }
10139
10361
  return PagarmePaymentFactoryHelper.createSuccessfulPayment({
10140
10362
  checkout,
@@ -10146,7 +10368,7 @@ class PagarmeCardAxiosAdapter {
10146
10368
  if (error instanceof PaymentError) {
10147
10369
  throw error;
10148
10370
  }
10149
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
10371
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, ErrorsCode.paymentError, error.response?.data);
10150
10372
  }
10151
10373
  }
10152
10374
  async addCard(card) {
@@ -10303,7 +10525,7 @@ class PagarmePixAxiosAdapter {
10303
10525
  return payment;
10304
10526
  }
10305
10527
  catch (error) {
10306
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10528
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
10307
10529
  checkoutId: checkout.id,
10308
10530
  userEmail: checkout.user.email,
10309
10531
  info: error.response?.data,
@@ -10358,7 +10580,7 @@ class PagarmeV5BankSlipAxiosAdapter {
10358
10580
  data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
10359
10581
  (data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado &&
10360
10582
  data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus['Em processamento'])) {
10361
- return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10583
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
10362
10584
  checkoutId: checkout.id,
10363
10585
  userEmail: checkout.user.email,
10364
10586
  info: data.charges.at(0).last_transaction?.gateway_response,
@@ -10371,7 +10593,7 @@ class PagarmeV5BankSlipAxiosAdapter {
10371
10593
  if (error instanceof AxiosError) {
10372
10594
  console.error('error data: ', JSON.stringify(error.response?.data));
10373
10595
  }
10374
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10596
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
10375
10597
  checkoutId: checkout.id,
10376
10598
  userEmail: checkout.user.email,
10377
10599
  info: error.response?.data,
@@ -10422,15 +10644,21 @@ class PagarmeV5CardAxiosAdapter {
10422
10644
  data: payload,
10423
10645
  });
10424
10646
  console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
10647
+ const charge = data.charges.at(0);
10425
10648
  if (data.status == PagarMeV5OrderStatus.Falha ||
10426
- data.charges.at(0).status !== PagarMeV5OrderStatus.Pago ||
10427
- data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
10649
+ charge.status !== PagarMeV5OrderStatus.Pago ||
10650
+ charge.last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
10428
10651
  await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
10429
10652
  checkout,
10430
10653
  card,
10431
10654
  orderBlockedRepository: this.orderBlockedRepository,
10655
+ gatewayInfo: {
10656
+ status: charge.status,
10657
+ statusDetail: charge.last_transaction?.status,
10658
+ },
10432
10659
  });
10433
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
10660
+ const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(charge.last_transaction.acquirer_return_code);
10661
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, errorCode, data);
10434
10662
  }
10435
10663
  const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
10436
10664
  return payment;
@@ -10442,7 +10670,9 @@ class PagarmeV5CardAxiosAdapter {
10442
10670
  if (error instanceof AxiosError) {
10443
10671
  console.error('error data: ', JSON.stringify(error.response?.data));
10444
10672
  }
10445
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
10673
+ const returnCode = error.response?.data?.charges?.at(0)?.last_transaction?.acquirer_return_code;
10674
+ const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(returnCode);
10675
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, errorCode, error.response?.data);
10446
10676
  }
10447
10677
  }
10448
10678
  async addCard(card, customer) {
@@ -10588,7 +10818,7 @@ class PagarmeV5PixAxiosAdapter {
10588
10818
  });
10589
10819
  console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
10590
10820
  if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
10591
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10821
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
10592
10822
  checkoutId: checkout.id,
10593
10823
  userEmail: checkout.user.email,
10594
10824
  info: data.charges.at(0).last_transaction?.gateway_response,
@@ -10601,7 +10831,7 @@ class PagarmeV5PixAxiosAdapter {
10601
10831
  if (error instanceof AxiosError) {
10602
10832
  console.error('error data: ', JSON.stringify(error.response?.data));
10603
10833
  }
10604
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
10834
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
10605
10835
  checkoutId: checkout.id,
10606
10836
  userEmail: checkout.user.email,
10607
10837
  info: error.response?.data,
@@ -10763,4 +10993,4 @@ class ProductsVertexSearch {
10763
10993
  }
10764
10994
  }
10765
10995
 
10766
- export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandCategory, BrandCategoryFirestoreRepository, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, ErrorsCode, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopConfigs, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
10996
+ export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandCategory, BrandCategoryFirestoreRepository, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, ErrorsCode, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoErrorHelper, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopConfigs, ShopConfigsFirestoreRepository, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.2-beta.0",
3
+ "version": "5.5.2-beta.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -1,6 +1,12 @@
1
1
  import { BaseModel, GenericIdentifier } from '../../generic/model';
2
- import { ShopErrorMessages } from './types';
2
+ import { ShopErrorMessages, ShopSameDayNotAvailable } from './types';
3
3
  export declare class ShopConfigs extends BaseModel<ShopConfigs> {
4
- errors: ShopErrorMessages[];
4
+ errors?: ShopErrorMessages[];
5
+ antifraude?: {
6
+ enabled: boolean;
7
+ subscriber: {};
8
+ nonSubscriber: {};
9
+ };
10
+ sameDayNotAvaliable?: ShopSameDayNotAvailable;
5
11
  static get identifiersFields(): GenericIdentifier[];
6
12
  }
@@ -19,6 +19,7 @@ export declare class OrderBlocked extends BaseModel<OrderBlocked> {
19
19
  type: OrderBlockedType;
20
20
  card?: any;
21
21
  checkout: Checkout;
22
+ gatewayInfo?: any;
22
23
  date: Date;
23
24
  static get identifiersFields(): GenericIdentifier[];
24
25
  }
@@ -7,6 +7,7 @@ type CreateBlockedOrderParams = {
7
7
  type: string;
8
8
  limiteRange: string;
9
9
  card?: PaymentCardInfo;
10
+ gatewayInfo?: any;
10
11
  };
11
12
  export interface OrderBlockedRepository extends CrudRepository<OrderBlocked> {
12
13
  createBlockedOrderOrPayment(params: CreateBlockedOrderParams): Promise<OrderBlocked>;
@@ -4,9 +4,11 @@ export declare enum ErrorsCode {
4
4
  invalidCheckoutError = "invalid-checkout",
5
5
  stockLimit = "stock-limit",
6
6
  stockOut = "stock-out",
7
+ notFound = "not-found",
7
8
  fraudPreventionInternal = "fraud-prevention-internal",
8
9
  fraudPreventionExternal = "fraud-prevention-external",
9
10
  invalidCardError = "invalid-card-error",
10
11
  insuficientFundsError = "insuficient-funds-error",
12
+ paymentNotAuthorizedError = "payment-not-authorized-error",
11
13
  paymentError = "payment-error"
12
14
  }
@@ -3,5 +3,5 @@ import { checkoutAdditionalDataError } from './types';
3
3
  export declare class FraudValidationError extends CustomError {
4
4
  additionalData?: checkoutAdditionalDataError;
5
5
  type: string;
6
- constructor(message: string, additionalData?: checkoutAdditionalDataError);
6
+ constructor(message: string, type: string, additionalData?: checkoutAdditionalDataError);
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { CustomError } from 'ts-custom-error';
2
2
  export declare class NotFoundError extends CustomError {
3
+ type: string;
3
4
  constructor(message: string);
4
5
  }
@@ -3,5 +3,5 @@ import { checkoutAdditionalDataError } from './types';
3
3
  export declare class PaymentError extends CustomError {
4
4
  additionalData?: checkoutAdditionalDataError;
5
5
  type: string;
6
- constructor(message: string, additionalData?: checkoutAdditionalDataError);
6
+ constructor(message: string, type: string, additionalData?: checkoutAdditionalDataError);
7
7
  }
@@ -1,3 +1,4 @@
1
1
  export * from './home-firestore.repository';
2
+ export * from './shop-configs-firestore.repository';
2
3
  export * from './shop-menu-firestore.repository';
3
4
  export * from './shop-settings-firestore.repository';
@@ -6,6 +6,7 @@ export declare class MercadoPagoCardAxiosAdapter implements PaymentProviderCard<
6
6
  private orderBlockedRepository;
7
7
  constructor(credentials: MercadoPagoCredentials, paymentRepository: PaymentRepository, orderBlockedRepository: OrderBlockedRepository);
8
8
  pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
9
+ requestPayment(checkout: Checkout, payload: any): Promise<MercadoPagoResponse>;
9
10
  private getPaymentPayload;
10
11
  addCard?(card: CardInfo, customer: User & {
11
12
  billingAddress: Partial<UserAddress>;
@@ -1,2 +1,3 @@
1
+ export * from './mercado-pago-errors.helper';
1
2
  export * from './mercado-pago-request.helper';
2
3
  export * from './mercado-pago-response.helper';
@@ -0,0 +1,3 @@
1
+ export declare class MercadoPagoErrorHelper {
2
+ static getErrorTypeFromResponse(errorCode: string): string;
3
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './pagarme-blocked-order.helper';
2
+ export * from './pagarme-errors.helper';
2
3
  export * from './pagarme-payment-factory.helper';
3
4
  export * from './pagarme-payment-operations.helper';
4
5
  export * from './pagarme-v5-request.helper';
@@ -5,10 +5,14 @@ interface BlockedOrderParams {
5
5
  checkout: Checkout;
6
6
  card: PaymentCardInfo;
7
7
  orderBlockedRepository: OrderBlockedRepository;
8
+ gatewayInfo?: {
9
+ status: string;
10
+ statusDetail: string;
11
+ };
8
12
  }
9
13
  export declare class PagarmeBlockedOrderHelper {
10
14
  static createBlockedOrderForUnauthorizedCard(params: BlockedOrderParams): Promise<void>;
11
- static createPaymentError(checkout: Checkout, resultData: any): PaymentError;
12
- static createGenericPaymentError(checkout: Checkout, errorResponseData: any): PaymentError;
15
+ static createPaymentError(checkout: Checkout, errorType: string, resultData: any): PaymentError;
16
+ static createGenericPaymentError(checkout: Checkout, errorType: string, errorResponseData: any): PaymentError;
13
17
  }
14
18
  export {};
@@ -0,0 +1,3 @@
1
+ export declare class PagarMeErrorHelper {
2
+ static getErrorTypeFromResponse(errorCode: string): string;
3
+ }