@infrab4a/connect 5.6.5-beta.0 → 5.6.5-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 +107 -76
- package/index.esm.js +107 -76
- package/package.json +1 -1
- package/src/domain/shopping/models/order.d.ts +8 -0
- package/src/infra/mercado-pago/adapters/mercado-pago-base-axios.d.ts +7 -3
- package/src/infra/mercado-pago/types/mercado-pago-response.type.d.ts +23 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-base-axios.d.ts +7 -3
- package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +115 -0
package/index.cjs.js
CHANGED
|
@@ -9877,36 +9877,92 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
9877
9877
|
}
|
|
9878
9878
|
}
|
|
9879
9879
|
|
|
9880
|
+
exports.MercadoPagoStatusDetailEnum = void 0;
|
|
9881
|
+
(function (MercadoPagoStatusDetailEnum) {
|
|
9882
|
+
MercadoPagoStatusDetailEnum["accredited"] = "accredited";
|
|
9883
|
+
MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
|
|
9884
|
+
MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
|
|
9885
|
+
MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
|
|
9886
|
+
MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
|
|
9887
|
+
MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
|
|
9888
|
+
MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
|
|
9889
|
+
MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
|
|
9890
|
+
MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
|
|
9891
|
+
MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
|
|
9892
|
+
MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
|
|
9893
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
|
|
9894
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
|
|
9895
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
|
|
9896
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
|
|
9897
|
+
MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
|
|
9898
|
+
MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
|
|
9899
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
|
|
9900
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
|
|
9901
|
+
MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
|
|
9902
|
+
MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
|
|
9903
|
+
MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
|
|
9904
|
+
MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
|
|
9905
|
+
MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
|
|
9906
|
+
MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
|
|
9907
|
+
MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
|
|
9908
|
+
MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
|
|
9909
|
+
MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
|
|
9910
|
+
MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
|
|
9911
|
+
MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
|
|
9912
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
|
|
9913
|
+
})(exports.MercadoPagoStatusDetailEnum || (exports.MercadoPagoStatusDetailEnum = {}));
|
|
9914
|
+
|
|
9915
|
+
exports.MercadoPagoStatusEnum = void 0;
|
|
9916
|
+
(function (MercadoPagoStatusEnum) {
|
|
9917
|
+
MercadoPagoStatusEnum["approved"] = "approved";
|
|
9918
|
+
MercadoPagoStatusEnum["authorized"] = "authorized";
|
|
9919
|
+
MercadoPagoStatusEnum["pending"] = "pending";
|
|
9920
|
+
MercadoPagoStatusEnum["in_process"] = "in_process";
|
|
9921
|
+
MercadoPagoStatusEnum["rejected"] = "rejected";
|
|
9922
|
+
MercadoPagoStatusEnum["cancelled"] = "cancelled";
|
|
9923
|
+
MercadoPagoStatusEnum["refunded"] = "refunded";
|
|
9924
|
+
MercadoPagoStatusEnum["charged_back"] = "charged_back";
|
|
9925
|
+
})(exports.MercadoPagoStatusEnum || (exports.MercadoPagoStatusEnum = {}));
|
|
9926
|
+
|
|
9880
9927
|
class MercadoPagoBaseAxiosAdapter {
|
|
9881
|
-
constructor(credentials) {
|
|
9928
|
+
constructor(credentials, paymentRepository) {
|
|
9882
9929
|
this.credentials = credentials;
|
|
9930
|
+
this.paymentRepository = paymentRepository;
|
|
9883
9931
|
}
|
|
9884
9932
|
async refund(order, amount) {
|
|
9885
9933
|
const { data } = await axios__default["default"]({
|
|
9886
9934
|
method: 'POST',
|
|
9887
|
-
url: `${this.credentials.url}/
|
|
9935
|
+
url: `${this.credentials.url}/payments/${order.payment.id}/refunds`,
|
|
9888
9936
|
headers: {
|
|
9889
|
-
'X-Idempotency-Key': `${order.
|
|
9937
|
+
'X-Idempotency-Key': `${order.payment.charger_id}-${new Date().getTime()}`,
|
|
9890
9938
|
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9891
9939
|
'Content-Type': 'application/json',
|
|
9892
9940
|
},
|
|
9893
9941
|
data: {
|
|
9894
|
-
|
|
9895
|
-
{
|
|
9896
|
-
id: order.id,
|
|
9897
|
-
amount,
|
|
9898
|
-
},
|
|
9899
|
-
],
|
|
9942
|
+
amount: +amount.toFixed(2),
|
|
9900
9943
|
},
|
|
9901
9944
|
});
|
|
9945
|
+
await this.paymentRepository.create({
|
|
9946
|
+
createdAt: new Date(),
|
|
9947
|
+
updatedAt: new Date(),
|
|
9948
|
+
userId: order.user.id,
|
|
9949
|
+
orderId: order.id,
|
|
9950
|
+
totalPrice: amount,
|
|
9951
|
+
paymentProvider: exports.PaymentProviders.MERCADOPAGO,
|
|
9952
|
+
mercadoPagoId: data.id,
|
|
9953
|
+
transaction: data,
|
|
9954
|
+
});
|
|
9902
9955
|
console.warn('[RESPONSE MERCADO PAGO REFUND]', JSON.stringify(data));
|
|
9903
|
-
return
|
|
9956
|
+
return {
|
|
9957
|
+
status: data.status,
|
|
9958
|
+
success: data.status === exports.MercadoPagoStatusEnum.approved ? true : false,
|
|
9959
|
+
};
|
|
9904
9960
|
}
|
|
9905
9961
|
}
|
|
9906
9962
|
|
|
9907
9963
|
class MercadoPagoCardAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
9908
9964
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
9909
|
-
super(credentials);
|
|
9965
|
+
super(credentials, paymentRepository);
|
|
9910
9966
|
this.credentials = credentials;
|
|
9911
9967
|
this.paymentRepository = paymentRepository;
|
|
9912
9968
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
@@ -10037,7 +10093,7 @@ class MercadoPagoCardAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
|
10037
10093
|
|
|
10038
10094
|
class MercadoPagoPixAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
10039
10095
|
constructor(credentials, paymentRepository) {
|
|
10040
|
-
super(credentials);
|
|
10096
|
+
super(credentials, paymentRepository);
|
|
10041
10097
|
this.credentials = credentials;
|
|
10042
10098
|
this.paymentRepository = paymentRepository;
|
|
10043
10099
|
}
|
|
@@ -10076,53 +10132,6 @@ class MercadoPagoPixAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
|
10076
10132
|
}
|
|
10077
10133
|
}
|
|
10078
10134
|
|
|
10079
|
-
exports.MercadoPagoStatusDetailEnum = void 0;
|
|
10080
|
-
(function (MercadoPagoStatusDetailEnum) {
|
|
10081
|
-
MercadoPagoStatusDetailEnum["accredited"] = "accredited";
|
|
10082
|
-
MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
|
|
10083
|
-
MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
|
|
10084
|
-
MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
|
|
10085
|
-
MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
|
|
10086
|
-
MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
|
|
10087
|
-
MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
|
|
10088
|
-
MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
|
|
10089
|
-
MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
|
|
10090
|
-
MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
|
|
10091
|
-
MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
|
|
10092
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
|
|
10093
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
|
|
10094
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
|
|
10095
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
|
|
10096
|
-
MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
|
|
10097
|
-
MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
|
|
10098
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
|
|
10099
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
|
|
10100
|
-
MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
|
|
10101
|
-
MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
|
|
10102
|
-
MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
|
|
10103
|
-
MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
|
|
10104
|
-
MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
|
|
10105
|
-
MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
|
|
10106
|
-
MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
|
|
10107
|
-
MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
|
|
10108
|
-
MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
|
|
10109
|
-
MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
|
|
10110
|
-
MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
|
|
10111
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
|
|
10112
|
-
})(exports.MercadoPagoStatusDetailEnum || (exports.MercadoPagoStatusDetailEnum = {}));
|
|
10113
|
-
|
|
10114
|
-
exports.MercadoPagoStatusEnum = void 0;
|
|
10115
|
-
(function (MercadoPagoStatusEnum) {
|
|
10116
|
-
MercadoPagoStatusEnum["approved"] = "approved";
|
|
10117
|
-
MercadoPagoStatusEnum["authorized"] = "authorized";
|
|
10118
|
-
MercadoPagoStatusEnum["pending"] = "pending";
|
|
10119
|
-
MercadoPagoStatusEnum["in_process"] = "in_process";
|
|
10120
|
-
MercadoPagoStatusEnum["rejected"] = "rejected";
|
|
10121
|
-
MercadoPagoStatusEnum["cancelled"] = "cancelled";
|
|
10122
|
-
MercadoPagoStatusEnum["refunded"] = "refunded";
|
|
10123
|
-
MercadoPagoStatusEnum["charged_back"] = "charged_back";
|
|
10124
|
-
})(exports.MercadoPagoStatusEnum || (exports.MercadoPagoStatusEnum = {}));
|
|
10125
|
-
|
|
10126
10135
|
class PagarmeBankSlipAxiosAdapter {
|
|
10127
10136
|
constructor(credentials, paymentRepository) {
|
|
10128
10137
|
this.credentials = credentials;
|
|
@@ -10913,30 +10922,52 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10913
10922
|
}
|
|
10914
10923
|
|
|
10915
10924
|
class PagarmeV5BaseAxiosAdapter {
|
|
10916
|
-
constructor(credentials) {
|
|
10925
|
+
constructor(credentials, paymentRepository) {
|
|
10917
10926
|
this.credentials = credentials;
|
|
10927
|
+
this.paymentRepository = paymentRepository;
|
|
10918
10928
|
}
|
|
10919
10929
|
async refund(order, amount) {
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10930
|
+
try {
|
|
10931
|
+
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
|
|
10932
|
+
const amountToSend = +amount.toFixed(2) * 100;
|
|
10933
|
+
console.warn('[PAGARME REFUND] Amount to send in cents', amountToSend);
|
|
10934
|
+
const { data } = await axios__default["default"]({
|
|
10935
|
+
method: 'DELETE',
|
|
10936
|
+
url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
|
|
10937
|
+
headers: {
|
|
10938
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
10939
|
+
'Content-Type': 'application/json',
|
|
10940
|
+
},
|
|
10941
|
+
data: {
|
|
10942
|
+
amount: amountToSend,
|
|
10943
|
+
},
|
|
10944
|
+
});
|
|
10945
|
+
console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
|
|
10946
|
+
await this.paymentRepository.create({
|
|
10947
|
+
createdAt: new Date(),
|
|
10948
|
+
updatedAt: new Date(),
|
|
10949
|
+
userId: order.user.id,
|
|
10950
|
+
orderId: order.id,
|
|
10951
|
+
totalPrice: amount,
|
|
10952
|
+
paymentProvider: exports.PaymentProviders.PAGARME,
|
|
10953
|
+
pagarMeOrderId: data.id,
|
|
10954
|
+
transaction: data,
|
|
10955
|
+
});
|
|
10956
|
+
return {
|
|
10957
|
+
status: data.status,
|
|
10958
|
+
success: data.status === exports.PagarMeV5OrderStatus.Pago ? true : false,
|
|
10959
|
+
};
|
|
10960
|
+
}
|
|
10961
|
+
catch (error) {
|
|
10962
|
+
console.error('Error during refund process for order', order.id, 'with error', error);
|
|
10963
|
+
throw error;
|
|
10964
|
+
}
|
|
10934
10965
|
}
|
|
10935
10966
|
}
|
|
10936
10967
|
|
|
10937
10968
|
class PagarmeV5CardAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
10938
10969
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
10939
|
-
super(credentials);
|
|
10970
|
+
super(credentials, paymentRepository);
|
|
10940
10971
|
this.credentials = credentials;
|
|
10941
10972
|
this.paymentRepository = paymentRepository;
|
|
10942
10973
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
@@ -11108,7 +11139,7 @@ class PagarmeV5CardAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
|
11108
11139
|
|
|
11109
11140
|
class PagarmeV5PixAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
11110
11141
|
constructor(credentials, paymentRepository) {
|
|
11111
|
-
super(credentials);
|
|
11142
|
+
super(credentials, paymentRepository);
|
|
11112
11143
|
this.credentials = credentials;
|
|
11113
11144
|
this.paymentRepository = paymentRepository;
|
|
11114
11145
|
}
|
package/index.esm.js
CHANGED
|
@@ -9853,36 +9853,92 @@ class MercadoPagoBankSlipAxiosAdapter {
|
|
|
9853
9853
|
}
|
|
9854
9854
|
}
|
|
9855
9855
|
|
|
9856
|
+
var MercadoPagoStatusDetailEnum;
|
|
9857
|
+
(function (MercadoPagoStatusDetailEnum) {
|
|
9858
|
+
MercadoPagoStatusDetailEnum["accredited"] = "accredited";
|
|
9859
|
+
MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
|
|
9860
|
+
MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
|
|
9861
|
+
MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
|
|
9862
|
+
MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
|
|
9863
|
+
MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
|
|
9864
|
+
MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
|
|
9865
|
+
MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
|
|
9866
|
+
MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
|
|
9867
|
+
MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
|
|
9868
|
+
MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
|
|
9869
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
|
|
9870
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
|
|
9871
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
|
|
9872
|
+
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
|
|
9873
|
+
MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
|
|
9874
|
+
MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
|
|
9875
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
|
|
9876
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
|
|
9877
|
+
MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
|
|
9878
|
+
MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
|
|
9879
|
+
MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
|
|
9880
|
+
MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
|
|
9881
|
+
MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
|
|
9882
|
+
MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
|
|
9883
|
+
MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
|
|
9884
|
+
MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
|
|
9885
|
+
MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
|
|
9886
|
+
MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
|
|
9887
|
+
MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
|
|
9888
|
+
MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
|
|
9889
|
+
})(MercadoPagoStatusDetailEnum || (MercadoPagoStatusDetailEnum = {}));
|
|
9890
|
+
|
|
9891
|
+
var MercadoPagoStatusEnum;
|
|
9892
|
+
(function (MercadoPagoStatusEnum) {
|
|
9893
|
+
MercadoPagoStatusEnum["approved"] = "approved";
|
|
9894
|
+
MercadoPagoStatusEnum["authorized"] = "authorized";
|
|
9895
|
+
MercadoPagoStatusEnum["pending"] = "pending";
|
|
9896
|
+
MercadoPagoStatusEnum["in_process"] = "in_process";
|
|
9897
|
+
MercadoPagoStatusEnum["rejected"] = "rejected";
|
|
9898
|
+
MercadoPagoStatusEnum["cancelled"] = "cancelled";
|
|
9899
|
+
MercadoPagoStatusEnum["refunded"] = "refunded";
|
|
9900
|
+
MercadoPagoStatusEnum["charged_back"] = "charged_back";
|
|
9901
|
+
})(MercadoPagoStatusEnum || (MercadoPagoStatusEnum = {}));
|
|
9902
|
+
|
|
9856
9903
|
class MercadoPagoBaseAxiosAdapter {
|
|
9857
|
-
constructor(credentials) {
|
|
9904
|
+
constructor(credentials, paymentRepository) {
|
|
9858
9905
|
this.credentials = credentials;
|
|
9906
|
+
this.paymentRepository = paymentRepository;
|
|
9859
9907
|
}
|
|
9860
9908
|
async refund(order, amount) {
|
|
9861
9909
|
const { data } = await axios({
|
|
9862
9910
|
method: 'POST',
|
|
9863
|
-
url: `${this.credentials.url}/
|
|
9911
|
+
url: `${this.credentials.url}/payments/${order.payment.id}/refunds`,
|
|
9864
9912
|
headers: {
|
|
9865
|
-
'X-Idempotency-Key': `${order.
|
|
9913
|
+
'X-Idempotency-Key': `${order.payment.charger_id}-${new Date().getTime()}`,
|
|
9866
9914
|
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9867
9915
|
'Content-Type': 'application/json',
|
|
9868
9916
|
},
|
|
9869
9917
|
data: {
|
|
9870
|
-
|
|
9871
|
-
{
|
|
9872
|
-
id: order.id,
|
|
9873
|
-
amount,
|
|
9874
|
-
},
|
|
9875
|
-
],
|
|
9918
|
+
amount: +amount.toFixed(2),
|
|
9876
9919
|
},
|
|
9877
9920
|
});
|
|
9921
|
+
await this.paymentRepository.create({
|
|
9922
|
+
createdAt: new Date(),
|
|
9923
|
+
updatedAt: new Date(),
|
|
9924
|
+
userId: order.user.id,
|
|
9925
|
+
orderId: order.id,
|
|
9926
|
+
totalPrice: amount,
|
|
9927
|
+
paymentProvider: PaymentProviders.MERCADOPAGO,
|
|
9928
|
+
mercadoPagoId: data.id,
|
|
9929
|
+
transaction: data,
|
|
9930
|
+
});
|
|
9878
9931
|
console.warn('[RESPONSE MERCADO PAGO REFUND]', JSON.stringify(data));
|
|
9879
|
-
return
|
|
9932
|
+
return {
|
|
9933
|
+
status: data.status,
|
|
9934
|
+
success: data.status === MercadoPagoStatusEnum.approved ? true : false,
|
|
9935
|
+
};
|
|
9880
9936
|
}
|
|
9881
9937
|
}
|
|
9882
9938
|
|
|
9883
9939
|
class MercadoPagoCardAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
9884
9940
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
9885
|
-
super(credentials);
|
|
9941
|
+
super(credentials, paymentRepository);
|
|
9886
9942
|
this.credentials = credentials;
|
|
9887
9943
|
this.paymentRepository = paymentRepository;
|
|
9888
9944
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
@@ -10013,7 +10069,7 @@ class MercadoPagoCardAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
|
10013
10069
|
|
|
10014
10070
|
class MercadoPagoPixAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
10015
10071
|
constructor(credentials, paymentRepository) {
|
|
10016
|
-
super(credentials);
|
|
10072
|
+
super(credentials, paymentRepository);
|
|
10017
10073
|
this.credentials = credentials;
|
|
10018
10074
|
this.paymentRepository = paymentRepository;
|
|
10019
10075
|
}
|
|
@@ -10052,53 +10108,6 @@ class MercadoPagoPixAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
|
|
|
10052
10108
|
}
|
|
10053
10109
|
}
|
|
10054
10110
|
|
|
10055
|
-
var MercadoPagoStatusDetailEnum;
|
|
10056
|
-
(function (MercadoPagoStatusDetailEnum) {
|
|
10057
|
-
MercadoPagoStatusDetailEnum["accredited"] = "accredited";
|
|
10058
|
-
MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
|
|
10059
|
-
MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
|
|
10060
|
-
MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
|
|
10061
|
-
MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
|
|
10062
|
-
MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
|
|
10063
|
-
MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
|
|
10064
|
-
MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
|
|
10065
|
-
MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
|
|
10066
|
-
MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
|
|
10067
|
-
MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
|
|
10068
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
|
|
10069
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
|
|
10070
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
|
|
10071
|
-
MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
|
|
10072
|
-
MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
|
|
10073
|
-
MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
|
|
10074
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
|
|
10075
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
|
|
10076
|
-
MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
|
|
10077
|
-
MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
|
|
10078
|
-
MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
|
|
10079
|
-
MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
|
|
10080
|
-
MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
|
|
10081
|
-
MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
|
|
10082
|
-
MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
|
|
10083
|
-
MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
|
|
10084
|
-
MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
|
|
10085
|
-
MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
|
|
10086
|
-
MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
|
|
10087
|
-
MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
|
|
10088
|
-
})(MercadoPagoStatusDetailEnum || (MercadoPagoStatusDetailEnum = {}));
|
|
10089
|
-
|
|
10090
|
-
var MercadoPagoStatusEnum;
|
|
10091
|
-
(function (MercadoPagoStatusEnum) {
|
|
10092
|
-
MercadoPagoStatusEnum["approved"] = "approved";
|
|
10093
|
-
MercadoPagoStatusEnum["authorized"] = "authorized";
|
|
10094
|
-
MercadoPagoStatusEnum["pending"] = "pending";
|
|
10095
|
-
MercadoPagoStatusEnum["in_process"] = "in_process";
|
|
10096
|
-
MercadoPagoStatusEnum["rejected"] = "rejected";
|
|
10097
|
-
MercadoPagoStatusEnum["cancelled"] = "cancelled";
|
|
10098
|
-
MercadoPagoStatusEnum["refunded"] = "refunded";
|
|
10099
|
-
MercadoPagoStatusEnum["charged_back"] = "charged_back";
|
|
10100
|
-
})(MercadoPagoStatusEnum || (MercadoPagoStatusEnum = {}));
|
|
10101
|
-
|
|
10102
10111
|
class PagarmeBankSlipAxiosAdapter {
|
|
10103
10112
|
constructor(credentials, paymentRepository) {
|
|
10104
10113
|
this.credentials = credentials;
|
|
@@ -10889,30 +10898,52 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
10889
10898
|
}
|
|
10890
10899
|
|
|
10891
10900
|
class PagarmeV5BaseAxiosAdapter {
|
|
10892
|
-
constructor(credentials) {
|
|
10901
|
+
constructor(credentials, paymentRepository) {
|
|
10893
10902
|
this.credentials = credentials;
|
|
10903
|
+
this.paymentRepository = paymentRepository;
|
|
10894
10904
|
}
|
|
10895
10905
|
async refund(order, amount) {
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10906
|
+
try {
|
|
10907
|
+
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
|
|
10908
|
+
const amountToSend = +amount.toFixed(2) * 100;
|
|
10909
|
+
console.warn('[PAGARME REFUND] Amount to send in cents', amountToSend);
|
|
10910
|
+
const { data } = await axios({
|
|
10911
|
+
method: 'DELETE',
|
|
10912
|
+
url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
|
|
10913
|
+
headers: {
|
|
10914
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
10915
|
+
'Content-Type': 'application/json',
|
|
10916
|
+
},
|
|
10917
|
+
data: {
|
|
10918
|
+
amount: amountToSend,
|
|
10919
|
+
},
|
|
10920
|
+
});
|
|
10921
|
+
console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
|
|
10922
|
+
await this.paymentRepository.create({
|
|
10923
|
+
createdAt: new Date(),
|
|
10924
|
+
updatedAt: new Date(),
|
|
10925
|
+
userId: order.user.id,
|
|
10926
|
+
orderId: order.id,
|
|
10927
|
+
totalPrice: amount,
|
|
10928
|
+
paymentProvider: PaymentProviders.PAGARME,
|
|
10929
|
+
pagarMeOrderId: data.id,
|
|
10930
|
+
transaction: data,
|
|
10931
|
+
});
|
|
10932
|
+
return {
|
|
10933
|
+
status: data.status,
|
|
10934
|
+
success: data.status === PagarMeV5OrderStatus.Pago ? true : false,
|
|
10935
|
+
};
|
|
10936
|
+
}
|
|
10937
|
+
catch (error) {
|
|
10938
|
+
console.error('Error during refund process for order', order.id, 'with error', error);
|
|
10939
|
+
throw error;
|
|
10940
|
+
}
|
|
10910
10941
|
}
|
|
10911
10942
|
}
|
|
10912
10943
|
|
|
10913
10944
|
class PagarmeV5CardAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
10914
10945
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
10915
|
-
super(credentials);
|
|
10946
|
+
super(credentials, paymentRepository);
|
|
10916
10947
|
this.credentials = credentials;
|
|
10917
10948
|
this.paymentRepository = paymentRepository;
|
|
10918
10949
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
@@ -11084,7 +11115,7 @@ class PagarmeV5CardAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
|
11084
11115
|
|
|
11085
11116
|
class PagarmeV5PixAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
|
|
11086
11117
|
constructor(credentials, paymentRepository) {
|
|
11087
|
-
super(credentials);
|
|
11118
|
+
super(credentials, paymentRepository);
|
|
11088
11119
|
this.credentials = credentials;
|
|
11089
11120
|
this.paymentRepository = paymentRepository;
|
|
11090
11121
|
}
|
package/package.json
CHANGED
|
@@ -22,4 +22,12 @@ export declare class Order extends Checkout {
|
|
|
22
22
|
plataform?: string;
|
|
23
23
|
origin?: string;
|
|
24
24
|
};
|
|
25
|
+
updatedBy?: {
|
|
26
|
+
id?: string;
|
|
27
|
+
name: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
origin: string;
|
|
30
|
+
updatedAt: Date;
|
|
31
|
+
};
|
|
32
|
+
reshipmentCancellationReason?: string;
|
|
25
33
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { MercadoPagoCredentials, Order } from '../../../domain';
|
|
1
|
+
import { MercadoPagoCredentials, Order, PaymentRepository } from '../../../domain';
|
|
2
2
|
export declare class MercadoPagoBaseAxiosAdapter {
|
|
3
3
|
protected credentials: MercadoPagoCredentials;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
protected paymentRepository: PaymentRepository;
|
|
5
|
+
constructor(credentials: MercadoPagoCredentials, paymentRepository: PaymentRepository);
|
|
6
|
+
refund(order: Order, amount: number): Promise<{
|
|
7
|
+
status: string;
|
|
8
|
+
success: boolean;
|
|
9
|
+
}>;
|
|
6
10
|
}
|
|
@@ -186,3 +186,26 @@ export type MercadoPagoResponse = {
|
|
|
186
186
|
accounts_info?: any;
|
|
187
187
|
tags?: any;
|
|
188
188
|
};
|
|
189
|
+
export type MercadoPagoRefundResponse = {
|
|
190
|
+
id: number;
|
|
191
|
+
payment_id: number;
|
|
192
|
+
amount: number;
|
|
193
|
+
metadata: Array<Record<string, unknown>>;
|
|
194
|
+
source: Array<{
|
|
195
|
+
name: {
|
|
196
|
+
en: string;
|
|
197
|
+
pt: string;
|
|
198
|
+
es: string;
|
|
199
|
+
};
|
|
200
|
+
id: string;
|
|
201
|
+
type: string;
|
|
202
|
+
}>;
|
|
203
|
+
date_created: string;
|
|
204
|
+
unique_sequence_number: string | null;
|
|
205
|
+
refund_mode: string;
|
|
206
|
+
adjustment_amount: number;
|
|
207
|
+
status: MercadoPagoStatus;
|
|
208
|
+
reason: string | null;
|
|
209
|
+
label: Array<Record<string, unknown>>;
|
|
210
|
+
partition_details: Array<Record<string, unknown>>;
|
|
211
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Order, PagarmeCredentialsV5 } from '../../../../domain';
|
|
1
|
+
import { Order, PagarmeCredentialsV5, PaymentRepository } from '../../../../domain';
|
|
2
2
|
export declare class PagarmeV5BaseAxiosAdapter {
|
|
3
3
|
protected credentials: PagarmeCredentialsV5;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
protected paymentRepository: PaymentRepository;
|
|
5
|
+
constructor(credentials: PagarmeCredentialsV5, paymentRepository: PaymentRepository);
|
|
6
|
+
refund(order: Order, amount: number): Promise<{
|
|
7
|
+
status: string;
|
|
8
|
+
success: boolean;
|
|
9
|
+
}>;
|
|
6
10
|
}
|
|
@@ -124,3 +124,118 @@ export type PagarMeV5Transaction = {
|
|
|
124
124
|
created_at: string;
|
|
125
125
|
updated_at: string;
|
|
126
126
|
};
|
|
127
|
+
export type PagarMeV5RefundResponse = {
|
|
128
|
+
id: string;
|
|
129
|
+
code: string;
|
|
130
|
+
gateway_id: string;
|
|
131
|
+
amount: number;
|
|
132
|
+
paid_amount: number;
|
|
133
|
+
canceled_amount: number;
|
|
134
|
+
status: PagarMeV5OrderStatus;
|
|
135
|
+
currency: string;
|
|
136
|
+
payment_method: string;
|
|
137
|
+
paid_at: string;
|
|
138
|
+
canceled_at: string;
|
|
139
|
+
created_at: string;
|
|
140
|
+
updated_at: string;
|
|
141
|
+
order: {
|
|
142
|
+
id: string;
|
|
143
|
+
code: string;
|
|
144
|
+
amount: number;
|
|
145
|
+
closed: boolean;
|
|
146
|
+
created_at: string;
|
|
147
|
+
updated_at: string;
|
|
148
|
+
closed_at: string;
|
|
149
|
+
currency: string;
|
|
150
|
+
status: PagarMeV5OrderStatus;
|
|
151
|
+
customer_id: string;
|
|
152
|
+
};
|
|
153
|
+
customer: {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
email: string;
|
|
157
|
+
code: string;
|
|
158
|
+
document: string;
|
|
159
|
+
document_type: string;
|
|
160
|
+
type: string;
|
|
161
|
+
delinquent: boolean;
|
|
162
|
+
address: {
|
|
163
|
+
id: string;
|
|
164
|
+
line_1: string;
|
|
165
|
+
line_2: string;
|
|
166
|
+
zip_code: string;
|
|
167
|
+
city: string;
|
|
168
|
+
state: string;
|
|
169
|
+
country: string;
|
|
170
|
+
status: string;
|
|
171
|
+
created_at: string;
|
|
172
|
+
updated_at: string;
|
|
173
|
+
};
|
|
174
|
+
created_at: string;
|
|
175
|
+
updated_at: string;
|
|
176
|
+
birthdate: string;
|
|
177
|
+
phones: {
|
|
178
|
+
home_phone: {
|
|
179
|
+
country_code: string;
|
|
180
|
+
number: string;
|
|
181
|
+
area_code: string;
|
|
182
|
+
};
|
|
183
|
+
mobile_phone: {
|
|
184
|
+
country_code: string;
|
|
185
|
+
number: string;
|
|
186
|
+
area_code: string;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
last_transaction: {
|
|
191
|
+
brand_id: string;
|
|
192
|
+
id: string;
|
|
193
|
+
transaction_type: string;
|
|
194
|
+
gateway_id: string;
|
|
195
|
+
amount: number;
|
|
196
|
+
status: PagarMeV5PaymentStatus;
|
|
197
|
+
success: boolean;
|
|
198
|
+
installments: number;
|
|
199
|
+
statement_descriptor: string;
|
|
200
|
+
acquirer_name: string;
|
|
201
|
+
acquirer_tid: string;
|
|
202
|
+
acquirer_nsu: string;
|
|
203
|
+
acquirer_auth_code: string;
|
|
204
|
+
acquirer_message: string;
|
|
205
|
+
acquirer_return_code: string;
|
|
206
|
+
operation_type: string;
|
|
207
|
+
card: {
|
|
208
|
+
id: string;
|
|
209
|
+
first_six_digits: string;
|
|
210
|
+
last_four_digits: string;
|
|
211
|
+
brand: string;
|
|
212
|
+
holder_name: string;
|
|
213
|
+
holder_document: string;
|
|
214
|
+
exp_month: number;
|
|
215
|
+
exp_year: number;
|
|
216
|
+
status: string;
|
|
217
|
+
type: string;
|
|
218
|
+
created_at: string;
|
|
219
|
+
updated_at: string;
|
|
220
|
+
billing_address: {
|
|
221
|
+
zip_code: string;
|
|
222
|
+
city: string;
|
|
223
|
+
state: string;
|
|
224
|
+
country: string;
|
|
225
|
+
line_1: string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
funding_source: string;
|
|
229
|
+
created_at: string;
|
|
230
|
+
updated_at: string;
|
|
231
|
+
gateway_response: {
|
|
232
|
+
code: string;
|
|
233
|
+
};
|
|
234
|
+
antifraud_response: {
|
|
235
|
+
status: string;
|
|
236
|
+
score: string;
|
|
237
|
+
provider_name: string;
|
|
238
|
+
};
|
|
239
|
+
metadata: Record<string, unknown>;
|
|
240
|
+
};
|
|
241
|
+
};
|