@infrab4a/connect 5.5.2-beta.1 → 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 +262 -43
- package/index.esm.js +262 -44
- package/package.json +1 -1
- package/src/domain/shop-settings/models/shop-configs.d.ts +8 -2
- package/src/domain/shopping/models/order-blocked.d.ts +1 -0
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +1 -0
- package/src/errors/enum/error.enum.d.ts +2 -0
- package/src/errors/fraud-validation.error.d.ts +1 -1
- package/src/errors/not-found.error.d.ts +1 -0
- package/src/errors/payment.error.d.ts +1 -1
- package/src/infra/mercado-pago/adapters/mercado-pago-card-payment-axios.adapter.d.ts +1 -0
- package/src/infra/mercado-pago/helpers/index.d.ts +1 -0
- package/src/infra/mercado-pago/helpers/mercado-pago-errors.helper.d.ts +3 -0
- package/src/infra/pagarme/adapters/helpers/index.d.ts +1 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-blocked-order.helper.d.ts +6 -2
- package/src/infra/pagarme/adapters/helpers/pagarme-errors.helper.d.ts +3 -0
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
@@ -9373,6 +9376,47 @@ tslib.__decorate([
|
|
|
9373
9376
|
tslib.__metadata("design:returntype", Promise)
|
|
9374
9377
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
9375
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
|
+
|
|
9376
9420
|
class MercadoPagoRequestHelper {
|
|
9377
9421
|
static build(data) {
|
|
9378
9422
|
const { checkout, method, postback, card } = data;
|
|
@@ -9587,7 +9631,7 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
9587
9631
|
if (error instanceof axios.AxiosError) {
|
|
9588
9632
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9589
9633
|
}
|
|
9590
|
-
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, {
|
|
9591
9635
|
checkoutId: checkout.id,
|
|
9592
9636
|
userEmail: checkout.user.email,
|
|
9593
9637
|
info: error.response.data?.message || error.message?.toString(),
|
|
@@ -9609,16 +9653,7 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9609
9653
|
try {
|
|
9610
9654
|
const payload = await this.getPaymentPayload(checkout, card);
|
|
9611
9655
|
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9612
|
-
const
|
|
9613
|
-
method: 'POST',
|
|
9614
|
-
url: `${this.credentials.url}/v1/payments`,
|
|
9615
|
-
headers: {
|
|
9616
|
-
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9617
|
-
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9618
|
-
'Content-Type': 'application/json',
|
|
9619
|
-
},
|
|
9620
|
-
data: payload,
|
|
9621
|
-
});
|
|
9656
|
+
const data = await this.requestPayment(checkout, payload);
|
|
9622
9657
|
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
9623
9658
|
if (data.status == exports.MercadoPagoStatusEnum.rejected) {
|
|
9624
9659
|
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
@@ -9627,8 +9662,13 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9627
9662
|
type: 'Card',
|
|
9628
9663
|
limiteRange: 'day',
|
|
9629
9664
|
card,
|
|
9665
|
+
gatewayInfo: {
|
|
9666
|
+
status: data.status,
|
|
9667
|
+
statusDetail: data.status_detail,
|
|
9668
|
+
},
|
|
9630
9669
|
});
|
|
9631
|
-
|
|
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, {
|
|
9632
9672
|
checkoutId: checkout.id,
|
|
9633
9673
|
userEmail: checkout.user.email,
|
|
9634
9674
|
info: data,
|
|
@@ -9641,13 +9681,26 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9641
9681
|
if (error instanceof axios.AxiosError) {
|
|
9642
9682
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9643
9683
|
}
|
|
9644
|
-
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, {
|
|
9645
9685
|
checkoutId: checkout.id,
|
|
9646
9686
|
userEmail: checkout.user.email,
|
|
9647
9687
|
info: error.response.data?.message || error.message?.toString(),
|
|
9648
9688
|
});
|
|
9649
9689
|
}
|
|
9650
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
|
+
}
|
|
9651
9704
|
async getPaymentPayload(checkout, card) {
|
|
9652
9705
|
const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
|
|
9653
9706
|
const payload = MercadoPagoRequestHelper.build({
|
|
@@ -9749,7 +9802,7 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9749
9802
|
if (error instanceof axios.AxiosError) {
|
|
9750
9803
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9751
9804
|
}
|
|
9752
|
-
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, {
|
|
9753
9806
|
checkoutId: checkout.id,
|
|
9754
9807
|
userEmail: checkout.user.email,
|
|
9755
9808
|
info: error.response.data?.message || error.message?.toString(),
|
|
@@ -9820,7 +9873,7 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9820
9873
|
});
|
|
9821
9874
|
console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
|
|
9822
9875
|
if (result.data.status !== exports.PagarmePaymentStatus['Em processamento']) {
|
|
9823
|
-
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, {
|
|
9824
9877
|
checkoutId: checkout.id,
|
|
9825
9878
|
userEmail: checkout.user.email,
|
|
9826
9879
|
info: result.data,
|
|
@@ -9838,7 +9891,7 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9838
9891
|
return payment;
|
|
9839
9892
|
}
|
|
9840
9893
|
catch (error) {
|
|
9841
|
-
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, {
|
|
9842
9895
|
checkoutId: checkout.id,
|
|
9843
9896
|
userEmail: checkout.user.email,
|
|
9844
9897
|
info: error.response.data,
|
|
@@ -9890,24 +9943,25 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9890
9943
|
|
|
9891
9944
|
class PagarmeBlockedOrderHelper {
|
|
9892
9945
|
static async createBlockedOrderForUnauthorizedCard(params) {
|
|
9893
|
-
const { checkout, card, orderBlockedRepository } = params;
|
|
9946
|
+
const { checkout, card, orderBlockedRepository, gatewayInfo } = params;
|
|
9894
9947
|
await orderBlockedRepository.createBlockedOrderOrPayment({
|
|
9895
9948
|
checkout,
|
|
9896
9949
|
blockType: 'Card not authorized',
|
|
9897
9950
|
type: 'Card',
|
|
9898
9951
|
limiteRange: 'day',
|
|
9899
9952
|
card,
|
|
9953
|
+
gatewayInfo,
|
|
9900
9954
|
});
|
|
9901
9955
|
}
|
|
9902
|
-
static createPaymentError(checkout, resultData) {
|
|
9903
|
-
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, {
|
|
9904
9958
|
checkoutId: checkout.id,
|
|
9905
9959
|
userEmail: checkout.user.email,
|
|
9906
9960
|
info: resultData,
|
|
9907
9961
|
});
|
|
9908
9962
|
}
|
|
9909
|
-
static createGenericPaymentError(checkout, errorResponseData) {
|
|
9910
|
-
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, {
|
|
9911
9965
|
checkoutId: checkout.id,
|
|
9912
9966
|
userEmail: checkout.user.email,
|
|
9913
9967
|
info: errorResponseData,
|
|
@@ -9915,6 +9969,162 @@ class PagarmeBlockedOrderHelper {
|
|
|
9915
9969
|
}
|
|
9916
9970
|
}
|
|
9917
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
|
+
|
|
9918
10128
|
class PagarmePaymentFactoryHelper {
|
|
9919
10129
|
static async createSuccessfulPayment(params) {
|
|
9920
10130
|
const { checkout, resultData, paymentRepository } = params;
|
|
@@ -10170,7 +10380,7 @@ class PagarmeCardAxiosAdapter {
|
|
|
10170
10380
|
card,
|
|
10171
10381
|
orderBlockedRepository: this.orderBlockedRepository,
|
|
10172
10382
|
});
|
|
10173
|
-
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, result.data);
|
|
10383
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, exports.ErrorsCode.paymentError, result.data);
|
|
10174
10384
|
}
|
|
10175
10385
|
return PagarmePaymentFactoryHelper.createSuccessfulPayment({
|
|
10176
10386
|
checkout,
|
|
@@ -10182,7 +10392,7 @@ class PagarmeCardAxiosAdapter {
|
|
|
10182
10392
|
if (error instanceof PaymentError) {
|
|
10183
10393
|
throw error;
|
|
10184
10394
|
}
|
|
10185
|
-
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
10395
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, exports.ErrorsCode.paymentError, error.response?.data);
|
|
10186
10396
|
}
|
|
10187
10397
|
}
|
|
10188
10398
|
async addCard(card) {
|
|
@@ -10339,7 +10549,7 @@ class PagarmePixAxiosAdapter {
|
|
|
10339
10549
|
return payment;
|
|
10340
10550
|
}
|
|
10341
10551
|
catch (error) {
|
|
10342
|
-
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, {
|
|
10343
10553
|
checkoutId: checkout.id,
|
|
10344
10554
|
userEmail: checkout.user.email,
|
|
10345
10555
|
info: error.response?.data,
|
|
@@ -10394,7 +10604,7 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10394
10604
|
data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
|
|
10395
10605
|
(data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado &&
|
|
10396
10606
|
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus['Em processamento'])) {
|
|
10397
|
-
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, {
|
|
10398
10608
|
checkoutId: checkout.id,
|
|
10399
10609
|
userEmail: checkout.user.email,
|
|
10400
10610
|
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
@@ -10407,7 +10617,7 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10407
10617
|
if (error instanceof axios.AxiosError) {
|
|
10408
10618
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10409
10619
|
}
|
|
10410
|
-
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, {
|
|
10411
10621
|
checkoutId: checkout.id,
|
|
10412
10622
|
userEmail: checkout.user.email,
|
|
10413
10623
|
info: error.response?.data,
|
|
@@ -10458,15 +10668,21 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
10458
10668
|
data: payload,
|
|
10459
10669
|
});
|
|
10460
10670
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
10671
|
+
const charge = data.charges.at(0);
|
|
10461
10672
|
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
10462
|
-
|
|
10463
|
-
|
|
10673
|
+
charge.status !== exports.PagarMeV5OrderStatus.Pago ||
|
|
10674
|
+
charge.last_transaction.status !== exports.PagarMeV5PaymentStatus.Capturada) {
|
|
10464
10675
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
10465
10676
|
checkout,
|
|
10466
10677
|
card,
|
|
10467
10678
|
orderBlockedRepository: this.orderBlockedRepository,
|
|
10679
|
+
gatewayInfo: {
|
|
10680
|
+
status: charge.status,
|
|
10681
|
+
statusDetail: charge.last_transaction?.status,
|
|
10682
|
+
},
|
|
10468
10683
|
});
|
|
10469
|
-
|
|
10684
|
+
const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(charge.last_transaction.acquirer_return_code);
|
|
10685
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, errorCode, data);
|
|
10470
10686
|
}
|
|
10471
10687
|
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
|
|
10472
10688
|
return payment;
|
|
@@ -10478,7 +10694,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
10478
10694
|
if (error instanceof axios.AxiosError) {
|
|
10479
10695
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10480
10696
|
}
|
|
10481
|
-
|
|
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);
|
|
10482
10700
|
}
|
|
10483
10701
|
}
|
|
10484
10702
|
async addCard(card, customer) {
|
|
@@ -10624,7 +10842,7 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
10624
10842
|
});
|
|
10625
10843
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
10626
10844
|
if (data.status == exports.PagarMeV5OrderStatus.Falha || data.status == exports.PagarMeV5OrderStatus.Cancelado) {
|
|
10627
|
-
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, {
|
|
10628
10846
|
checkoutId: checkout.id,
|
|
10629
10847
|
userEmail: checkout.user.email,
|
|
10630
10848
|
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
@@ -10637,7 +10855,7 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
10637
10855
|
if (error instanceof axios.AxiosError) {
|
|
10638
10856
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10639
10857
|
}
|
|
10640
|
-
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, {
|
|
10641
10859
|
checkoutId: checkout.id,
|
|
10642
10860
|
userEmail: checkout.user.email,
|
|
10643
10861
|
info: error.response?.data,
|
|
@@ -11004,6 +11222,7 @@ exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
|
11004
11222
|
exports.Logger = Logger;
|
|
11005
11223
|
exports.MercadoPagoBankSlipAxiosAdapter = MercadoPagoBankSlipAxiosAdapter;
|
|
11006
11224
|
exports.MercadoPagoCardAxiosAdapter = MercadoPagoCardAxiosAdapter;
|
|
11225
|
+
exports.MercadoPagoErrorHelper = MercadoPagoErrorHelper;
|
|
11007
11226
|
exports.MercadoPagoPaymentMethodFactory = MercadoPagoPaymentMethodFactory;
|
|
11008
11227
|
exports.MercadoPagoPixAxiosAdapter = MercadoPagoPixAxiosAdapter;
|
|
11009
11228
|
exports.MercadoPagoRequestHelper = MercadoPagoRequestHelper;
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
@@ -9349,6 +9352,47 @@ __decorate([
|
|
|
9349
9352
|
__metadata("design:returntype", Promise)
|
|
9350
9353
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
9351
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
|
+
|
|
9352
9396
|
class MercadoPagoRequestHelper {
|
|
9353
9397
|
static build(data) {
|
|
9354
9398
|
const { checkout, method, postback, card } = data;
|
|
@@ -9563,7 +9607,7 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
9563
9607
|
if (error instanceof AxiosError) {
|
|
9564
9608
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9565
9609
|
}
|
|
9566
|
-
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, {
|
|
9567
9611
|
checkoutId: checkout.id,
|
|
9568
9612
|
userEmail: checkout.user.email,
|
|
9569
9613
|
info: error.response.data?.message || error.message?.toString(),
|
|
@@ -9585,16 +9629,7 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9585
9629
|
try {
|
|
9586
9630
|
const payload = await this.getPaymentPayload(checkout, card);
|
|
9587
9631
|
console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9588
|
-
const
|
|
9589
|
-
method: 'POST',
|
|
9590
|
-
url: `${this.credentials.url}/v1/payments`,
|
|
9591
|
-
headers: {
|
|
9592
|
-
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9593
|
-
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9594
|
-
'Content-Type': 'application/json',
|
|
9595
|
-
},
|
|
9596
|
-
data: payload,
|
|
9597
|
-
});
|
|
9632
|
+
const data = await this.requestPayment(checkout, payload);
|
|
9598
9633
|
console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
|
|
9599
9634
|
if (data.status == MercadoPagoStatusEnum.rejected) {
|
|
9600
9635
|
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
@@ -9603,8 +9638,13 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9603
9638
|
type: 'Card',
|
|
9604
9639
|
limiteRange: 'day',
|
|
9605
9640
|
card,
|
|
9641
|
+
gatewayInfo: {
|
|
9642
|
+
status: data.status,
|
|
9643
|
+
statusDetail: data.status_detail,
|
|
9644
|
+
},
|
|
9606
9645
|
});
|
|
9607
|
-
|
|
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, {
|
|
9608
9648
|
checkoutId: checkout.id,
|
|
9609
9649
|
userEmail: checkout.user.email,
|
|
9610
9650
|
info: data,
|
|
@@ -9617,13 +9657,26 @@ class MercadoPagoCardAxiosAdapter {
|
|
|
9617
9657
|
if (error instanceof AxiosError) {
|
|
9618
9658
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9619
9659
|
}
|
|
9620
|
-
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, {
|
|
9621
9661
|
checkoutId: checkout.id,
|
|
9622
9662
|
userEmail: checkout.user.email,
|
|
9623
9663
|
info: error.response.data?.message || error.message?.toString(),
|
|
9624
9664
|
});
|
|
9625
9665
|
}
|
|
9626
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
|
+
}
|
|
9627
9680
|
async getPaymentPayload(checkout, card) {
|
|
9628
9681
|
const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
|
|
9629
9682
|
const payload = MercadoPagoRequestHelper.build({
|
|
@@ -9725,7 +9778,7 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9725
9778
|
if (error instanceof AxiosError) {
|
|
9726
9779
|
console.warn(JSON.stringify(error.response.data.message));
|
|
9727
9780
|
}
|
|
9728
|
-
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, {
|
|
9729
9782
|
checkoutId: checkout.id,
|
|
9730
9783
|
userEmail: checkout.user.email,
|
|
9731
9784
|
info: error.response.data?.message || error.message?.toString(),
|
|
@@ -9796,7 +9849,7 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9796
9849
|
});
|
|
9797
9850
|
console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
|
|
9798
9851
|
if (result.data.status !== PagarmePaymentStatus['Em processamento']) {
|
|
9799
|
-
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, {
|
|
9800
9853
|
checkoutId: checkout.id,
|
|
9801
9854
|
userEmail: checkout.user.email,
|
|
9802
9855
|
info: result.data,
|
|
@@ -9814,7 +9867,7 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9814
9867
|
return payment;
|
|
9815
9868
|
}
|
|
9816
9869
|
catch (error) {
|
|
9817
|
-
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, {
|
|
9818
9871
|
checkoutId: checkout.id,
|
|
9819
9872
|
userEmail: checkout.user.email,
|
|
9820
9873
|
info: error.response.data,
|
|
@@ -9866,24 +9919,25 @@ class PagarmeBankSlipAxiosAdapter {
|
|
|
9866
9919
|
|
|
9867
9920
|
class PagarmeBlockedOrderHelper {
|
|
9868
9921
|
static async createBlockedOrderForUnauthorizedCard(params) {
|
|
9869
|
-
const { checkout, card, orderBlockedRepository } = params;
|
|
9922
|
+
const { checkout, card, orderBlockedRepository, gatewayInfo } = params;
|
|
9870
9923
|
await orderBlockedRepository.createBlockedOrderOrPayment({
|
|
9871
9924
|
checkout,
|
|
9872
9925
|
blockType: 'Card not authorized',
|
|
9873
9926
|
type: 'Card',
|
|
9874
9927
|
limiteRange: 'day',
|
|
9875
9928
|
card,
|
|
9929
|
+
gatewayInfo,
|
|
9876
9930
|
});
|
|
9877
9931
|
}
|
|
9878
|
-
static createPaymentError(checkout, resultData) {
|
|
9879
|
-
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, {
|
|
9880
9934
|
checkoutId: checkout.id,
|
|
9881
9935
|
userEmail: checkout.user.email,
|
|
9882
9936
|
info: resultData,
|
|
9883
9937
|
});
|
|
9884
9938
|
}
|
|
9885
|
-
static createGenericPaymentError(checkout, errorResponseData) {
|
|
9886
|
-
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, {
|
|
9887
9941
|
checkoutId: checkout.id,
|
|
9888
9942
|
userEmail: checkout.user.email,
|
|
9889
9943
|
info: errorResponseData,
|
|
@@ -9891,6 +9945,162 @@ class PagarmeBlockedOrderHelper {
|
|
|
9891
9945
|
}
|
|
9892
9946
|
}
|
|
9893
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
|
+
|
|
9894
10104
|
class PagarmePaymentFactoryHelper {
|
|
9895
10105
|
static async createSuccessfulPayment(params) {
|
|
9896
10106
|
const { checkout, resultData, paymentRepository } = params;
|
|
@@ -10146,7 +10356,7 @@ class PagarmeCardAxiosAdapter {
|
|
|
10146
10356
|
card,
|
|
10147
10357
|
orderBlockedRepository: this.orderBlockedRepository,
|
|
10148
10358
|
});
|
|
10149
|
-
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, result.data);
|
|
10359
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, ErrorsCode.paymentError, result.data);
|
|
10150
10360
|
}
|
|
10151
10361
|
return PagarmePaymentFactoryHelper.createSuccessfulPayment({
|
|
10152
10362
|
checkout,
|
|
@@ -10158,7 +10368,7 @@ class PagarmeCardAxiosAdapter {
|
|
|
10158
10368
|
if (error instanceof PaymentError) {
|
|
10159
10369
|
throw error;
|
|
10160
10370
|
}
|
|
10161
|
-
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
10371
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, ErrorsCode.paymentError, error.response?.data);
|
|
10162
10372
|
}
|
|
10163
10373
|
}
|
|
10164
10374
|
async addCard(card) {
|
|
@@ -10315,7 +10525,7 @@ class PagarmePixAxiosAdapter {
|
|
|
10315
10525
|
return payment;
|
|
10316
10526
|
}
|
|
10317
10527
|
catch (error) {
|
|
10318
|
-
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, {
|
|
10319
10529
|
checkoutId: checkout.id,
|
|
10320
10530
|
userEmail: checkout.user.email,
|
|
10321
10531
|
info: error.response?.data,
|
|
@@ -10370,7 +10580,7 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10370
10580
|
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
10371
10581
|
(data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado &&
|
|
10372
10582
|
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus['Em processamento'])) {
|
|
10373
|
-
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, {
|
|
10374
10584
|
checkoutId: checkout.id,
|
|
10375
10585
|
userEmail: checkout.user.email,
|
|
10376
10586
|
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
@@ -10383,7 +10593,7 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10383
10593
|
if (error instanceof AxiosError) {
|
|
10384
10594
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10385
10595
|
}
|
|
10386
|
-
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, {
|
|
10387
10597
|
checkoutId: checkout.id,
|
|
10388
10598
|
userEmail: checkout.user.email,
|
|
10389
10599
|
info: error.response?.data,
|
|
@@ -10434,15 +10644,21 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
10434
10644
|
data: payload,
|
|
10435
10645
|
});
|
|
10436
10646
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
10647
|
+
const charge = data.charges.at(0);
|
|
10437
10648
|
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
10438
|
-
|
|
10439
|
-
|
|
10649
|
+
charge.status !== PagarMeV5OrderStatus.Pago ||
|
|
10650
|
+
charge.last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
|
|
10440
10651
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
10441
10652
|
checkout,
|
|
10442
10653
|
card,
|
|
10443
10654
|
orderBlockedRepository: this.orderBlockedRepository,
|
|
10655
|
+
gatewayInfo: {
|
|
10656
|
+
status: charge.status,
|
|
10657
|
+
statusDetail: charge.last_transaction?.status,
|
|
10658
|
+
},
|
|
10444
10659
|
});
|
|
10445
|
-
|
|
10660
|
+
const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(charge.last_transaction.acquirer_return_code);
|
|
10661
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, errorCode, data);
|
|
10446
10662
|
}
|
|
10447
10663
|
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
10448
10664
|
return payment;
|
|
@@ -10454,7 +10670,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
10454
10670
|
if (error instanceof AxiosError) {
|
|
10455
10671
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10456
10672
|
}
|
|
10457
|
-
|
|
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);
|
|
10458
10676
|
}
|
|
10459
10677
|
}
|
|
10460
10678
|
async addCard(card, customer) {
|
|
@@ -10600,7 +10818,7 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
10600
10818
|
});
|
|
10601
10819
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
10602
10820
|
if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
|
|
10603
|
-
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, {
|
|
10604
10822
|
checkoutId: checkout.id,
|
|
10605
10823
|
userEmail: checkout.user.email,
|
|
10606
10824
|
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
@@ -10613,7 +10831,7 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
10613
10831
|
if (error instanceof AxiosError) {
|
|
10614
10832
|
console.error('error data: ', JSON.stringify(error.response?.data));
|
|
10615
10833
|
}
|
|
10616
|
-
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, {
|
|
10617
10835
|
checkoutId: checkout.id,
|
|
10618
10836
|
userEmail: checkout.user.email,
|
|
10619
10837
|
info: error.response?.data,
|
|
@@ -10775,4 +10993,4 @@ class ProductsVertexSearch {
|
|
|
10775
10993
|
}
|
|
10776
10994
|
}
|
|
10777
10995
|
|
|
10778
|
-
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, 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 };
|
|
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,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
|
|
4
|
+
errors?: ShopErrorMessages[];
|
|
5
|
+
antifraude?: {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
subscriber: {};
|
|
8
|
+
nonSubscriber: {};
|
|
9
|
+
};
|
|
10
|
+
sameDayNotAvaliable?: ShopSameDayNotAvailable;
|
|
5
11
|
static get identifiersFields(): GenericIdentifier[];
|
|
6
12
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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>;
|
|
@@ -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 {};
|