@infrab4a/connect 5.4.0-beta.20 → 5.4.0-beta.22
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 +115 -15
- package/index.esm.js +114 -16
- package/package.json +1 -1
- package/src/domain/shopping/enums/index.d.ts +1 -0
- package/src/domain/shopping/enums/order-payment-status.enum.d.ts +10 -0
- package/src/domain/shopping/factories/index.d.ts +1 -0
- package/src/domain/shopping/factories/mercado-pago-payment-method.factory.d.ts +2 -1
- package/src/infra/mercado-pago/adapters/index.d.ts +1 -0
- package/src/infra/mercado-pago/adapters/mercado-pago-boleto-payment-axios.adapter.d.ts +8 -0
- package/src/infra/mercado-pago/helpers/mercado-pago-request.helper.d.ts +32 -16
- package/src/infra/mercado-pago/helpers/mercado-pago-response.helper.d.ts +2 -0
- package/src/infra/mercado-pago/types/mercado-pago-response.type.d.ts +8 -0
package/index.cjs.js
CHANGED
|
@@ -62,6 +62,18 @@ exports.OrderBlockedType = void 0;
|
|
|
62
62
|
OrderBlockedType["Boleto"] = "Boleto";
|
|
63
63
|
})(exports.OrderBlockedType || (exports.OrderBlockedType = {}));
|
|
64
64
|
|
|
65
|
+
exports.OrderPaymentStatus = void 0;
|
|
66
|
+
(function (OrderPaymentStatus) {
|
|
67
|
+
OrderPaymentStatus["Em processamento"] = "processing";
|
|
68
|
+
OrderPaymentStatus["Autorizada"] = "authorized";
|
|
69
|
+
OrderPaymentStatus["Pago"] = "paid";
|
|
70
|
+
OrderPaymentStatus["Estornada"] = "refunded";
|
|
71
|
+
OrderPaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
72
|
+
OrderPaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
73
|
+
OrderPaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
|
|
74
|
+
OrderPaymentStatus["Chargedback"] = "chargedback";
|
|
75
|
+
})(exports.OrderPaymentStatus || (exports.OrderPaymentStatus = {}));
|
|
76
|
+
|
|
65
77
|
exports.PagarmePaymentStatus = void 0;
|
|
66
78
|
(function (PagarmePaymentStatus) {
|
|
67
79
|
PagarmePaymentStatus["Em processamento"] = "processing";
|
|
@@ -148,6 +160,9 @@ class AntifraudProviderFactory {
|
|
|
148
160
|
class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
149
161
|
}
|
|
150
162
|
|
|
163
|
+
class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
164
|
+
}
|
|
165
|
+
|
|
151
166
|
class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
|
|
152
167
|
}
|
|
153
168
|
|
|
@@ -8773,10 +8788,11 @@ class MercadoPagoRequestHelper {
|
|
|
8773
8788
|
statement_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
|
|
8774
8789
|
additional_info: {
|
|
8775
8790
|
items: this.buildItems(checkout),
|
|
8776
|
-
payer: this.buildFullPayer(checkout),
|
|
8791
|
+
...(method === 'credit_card' && { payer: this.buildFullPayer(checkout) }),
|
|
8777
8792
|
},
|
|
8778
8793
|
...(method === 'credit_card' && this.buildCardPayment(card)),
|
|
8779
8794
|
...(method === 'pix' && this.buildPixPayment()),
|
|
8795
|
+
...(method === 'boleto' && this.buildBoletoPayment(checkout)),
|
|
8780
8796
|
};
|
|
8781
8797
|
}
|
|
8782
8798
|
static buildItems(checkout) {
|
|
@@ -8817,6 +8833,9 @@ class MercadoPagoRequestHelper {
|
|
|
8817
8833
|
zip_code: checkout.shippingAddress.zip,
|
|
8818
8834
|
street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8819
8835
|
street_number: checkout.shippingAddress.number,
|
|
8836
|
+
neighborhood: checkout.shippingAddress.district,
|
|
8837
|
+
city: checkout.shippingAddress.city,
|
|
8838
|
+
federal_unit: checkout.shippingAddress.state,
|
|
8820
8839
|
},
|
|
8821
8840
|
};
|
|
8822
8841
|
}
|
|
@@ -8832,6 +8851,33 @@ class MercadoPagoRequestHelper {
|
|
|
8832
8851
|
date_of_expiration: dateFns.format(dateFns.addDays(new Date(), 1), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
|
|
8833
8852
|
};
|
|
8834
8853
|
}
|
|
8854
|
+
static buildBoletoPayment(checkout) {
|
|
8855
|
+
return {
|
|
8856
|
+
payment_method_id: 'bolbradesco',
|
|
8857
|
+
date_of_expiration: dateFns.format(dateFns.addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
|
|
8858
|
+
payer: {
|
|
8859
|
+
first_name: checkout.user.firstName,
|
|
8860
|
+
last_name: checkout.user.lastName,
|
|
8861
|
+
email: checkout.user.email,
|
|
8862
|
+
identification: {
|
|
8863
|
+
type: 'CPF',
|
|
8864
|
+
number: checkout.user.cpf.replace(/\D/g, ''),
|
|
8865
|
+
},
|
|
8866
|
+
phone: {
|
|
8867
|
+
area_code: checkout.user.phone.substring(0, 2),
|
|
8868
|
+
number: checkout.user.phone.substring(2),
|
|
8869
|
+
},
|
|
8870
|
+
address: {
|
|
8871
|
+
zip_code: checkout.shippingAddress.zip.replace(/\D/g, ''),
|
|
8872
|
+
street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8873
|
+
street_number: checkout.shippingAddress.number,
|
|
8874
|
+
neighborhood: checkout.shippingAddress.district,
|
|
8875
|
+
city: checkout.shippingAddress.city,
|
|
8876
|
+
federal_unit: checkout.shippingAddress.state,
|
|
8877
|
+
},
|
|
8878
|
+
},
|
|
8879
|
+
};
|
|
8880
|
+
}
|
|
8835
8881
|
}
|
|
8836
8882
|
|
|
8837
8883
|
class MercadoPagoResponseHelper {
|
|
@@ -8852,7 +8898,7 @@ class MercadoPagoResponseHelper {
|
|
|
8852
8898
|
id: response.id.toString(),
|
|
8853
8899
|
acquirer_name: exports.PaymentProviders.MERCADOPAGO,
|
|
8854
8900
|
amount: response.transaction_amount,
|
|
8855
|
-
status: response.status,
|
|
8901
|
+
status: this.statusMapping(response.status),
|
|
8856
8902
|
status_reason: response.status_detail?.toString(),
|
|
8857
8903
|
payment_method: method,
|
|
8858
8904
|
currency: response.currency_id?.toString(),
|
|
@@ -8861,20 +8907,18 @@ class MercadoPagoResponseHelper {
|
|
|
8861
8907
|
charger_id: response.charges_details?.at(0)?.id?.toString() ?? null,
|
|
8862
8908
|
...(method == exports.TransactionPaymentMethods.PIX && this.getPixReponse(response)),
|
|
8863
8909
|
...(method == exports.TransactionPaymentMethods.CARD && this.getCardReponse(response)),
|
|
8910
|
+
...(method == exports.TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(response)),
|
|
8864
8911
|
});
|
|
8865
8912
|
}
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
// boleto_document_number: transaction.document_number?.toString(),
|
|
8876
|
-
// }
|
|
8877
|
-
// }
|
|
8913
|
+
static getBoletoReponse(response) {
|
|
8914
|
+
return {
|
|
8915
|
+
boleto_url: response.transaction_details?.external_resource_url?.toString(),
|
|
8916
|
+
boleto_barcode: response.transaction_details?.barcode?.content?.toString(),
|
|
8917
|
+
boleto_line: response.transaction_details?.digitable_line?.toString(),
|
|
8918
|
+
boleto_expiration_date: response.date_of_expiration?.toString(),
|
|
8919
|
+
boleto_document_number: response.transaction_details?.verification_code?.toString(),
|
|
8920
|
+
};
|
|
8921
|
+
}
|
|
8878
8922
|
static getPixReponse(response) {
|
|
8879
8923
|
return {
|
|
8880
8924
|
pix_qr_code: response.point_of_interaction?.transaction_data?.qr_code,
|
|
@@ -8894,7 +8938,61 @@ class MercadoPagoResponseHelper {
|
|
|
8894
8938
|
card_expiration_year: response.card?.expiration_year?.toString(),
|
|
8895
8939
|
capture_method: response.payment_type_id?.toString(),
|
|
8896
8940
|
authorization_code: response.authorization_code?.toString(),
|
|
8941
|
+
paid_amount: this.statusMapping(response.status) == 'paid' ? response.transaction_details?.total_paid_amount : null,
|
|
8942
|
+
paid_at: this.statusMapping(response.status) == 'paid' ? response.date_approved : null,
|
|
8943
|
+
};
|
|
8944
|
+
}
|
|
8945
|
+
static statusMapping(status) {
|
|
8946
|
+
const statusMap = {
|
|
8947
|
+
approved: 'paid',
|
|
8948
|
+
pending: 'waiting_payment',
|
|
8949
|
+
in_process: 'processing',
|
|
8950
|
+
rejected: 'refused',
|
|
8951
|
+
cancelled: 'refused',
|
|
8952
|
+
refunded: 'refunded',
|
|
8953
|
+
charged_back: 'chargedback',
|
|
8897
8954
|
};
|
|
8955
|
+
return statusMap[status] || status;
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
|
|
8959
|
+
class MercadoPagoBankSlipAxiosAdapter {
|
|
8960
|
+
constructor(credentials, paymentRepository) {
|
|
8961
|
+
this.credentials = credentials;
|
|
8962
|
+
this.paymentRepository = paymentRepository;
|
|
8963
|
+
}
|
|
8964
|
+
async pay(checkout) {
|
|
8965
|
+
try {
|
|
8966
|
+
const payload = MercadoPagoRequestHelper.build({
|
|
8967
|
+
checkout,
|
|
8968
|
+
method: 'boleto',
|
|
8969
|
+
postback: this.credentials.postback,
|
|
8970
|
+
});
|
|
8971
|
+
console.warn('[MERCADO PAGO BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
8972
|
+
const { data } = await axios__default["default"]({
|
|
8973
|
+
method: 'POST',
|
|
8974
|
+
url: `${this.credentials.url}/v1/payments`,
|
|
8975
|
+
headers: {
|
|
8976
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
8977
|
+
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
8978
|
+
'Content-Type': 'application/json',
|
|
8979
|
+
},
|
|
8980
|
+
data: payload,
|
|
8981
|
+
});
|
|
8982
|
+
console.warn('[MERCADO PAGO RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8983
|
+
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
8984
|
+
return payment;
|
|
8985
|
+
}
|
|
8986
|
+
catch (error) {
|
|
8987
|
+
if (error instanceof axios.AxiosError) {
|
|
8988
|
+
console.warn(error.response);
|
|
8989
|
+
console.warn(error.response.data);
|
|
8990
|
+
console.warn(error.response.data.cause);
|
|
8991
|
+
}
|
|
8992
|
+
}
|
|
8993
|
+
}
|
|
8994
|
+
getBoletoTransaction(paymentId) {
|
|
8995
|
+
throw new Error('Method not implemented.');
|
|
8898
8996
|
}
|
|
8899
8997
|
}
|
|
8900
8998
|
|
|
@@ -9024,7 +9122,7 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9024
9122
|
method: 'POST',
|
|
9025
9123
|
url: `${this.credentials.url}/v1/payments`,
|
|
9026
9124
|
headers: {
|
|
9027
|
-
'X-Idempotency-Key': checkout.id
|
|
9125
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9028
9126
|
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9029
9127
|
'Content-Type': 'application/json',
|
|
9030
9128
|
},
|
|
@@ -10237,7 +10335,9 @@ exports.Log = Log;
|
|
|
10237
10335
|
exports.LogDocument = LogDocument;
|
|
10238
10336
|
exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
10239
10337
|
exports.Logger = Logger;
|
|
10338
|
+
exports.MercadoPagoBankSlipAxiosAdapter = MercadoPagoBankSlipAxiosAdapter;
|
|
10240
10339
|
exports.MercadoPagoCardAxiosAdapter = MercadoPagoCardAxiosAdapter;
|
|
10340
|
+
exports.MercadoPagoPaymentMethodFactory = MercadoPagoPaymentMethodFactory;
|
|
10241
10341
|
exports.MercadoPagoPixAxiosAdapter = MercadoPagoPixAxiosAdapter;
|
|
10242
10342
|
exports.MercadoPagoRequestHelper = MercadoPagoRequestHelper;
|
|
10243
10343
|
exports.MercadoPagoResponseHelper = MercadoPagoResponseHelper;
|
package/index.esm.js
CHANGED
|
@@ -38,6 +38,18 @@ var OrderBlockedType;
|
|
|
38
38
|
OrderBlockedType["Boleto"] = "Boleto";
|
|
39
39
|
})(OrderBlockedType || (OrderBlockedType = {}));
|
|
40
40
|
|
|
41
|
+
var OrderPaymentStatus;
|
|
42
|
+
(function (OrderPaymentStatus) {
|
|
43
|
+
OrderPaymentStatus["Em processamento"] = "processing";
|
|
44
|
+
OrderPaymentStatus["Autorizada"] = "authorized";
|
|
45
|
+
OrderPaymentStatus["Pago"] = "paid";
|
|
46
|
+
OrderPaymentStatus["Estornada"] = "refunded";
|
|
47
|
+
OrderPaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
48
|
+
OrderPaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
49
|
+
OrderPaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
|
|
50
|
+
OrderPaymentStatus["Chargedback"] = "chargedback";
|
|
51
|
+
})(OrderPaymentStatus || (OrderPaymentStatus = {}));
|
|
52
|
+
|
|
41
53
|
var PagarmePaymentStatus;
|
|
42
54
|
(function (PagarmePaymentStatus) {
|
|
43
55
|
PagarmePaymentStatus["Em processamento"] = "processing";
|
|
@@ -124,6 +136,9 @@ class AntifraudProviderFactory {
|
|
|
124
136
|
class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
125
137
|
}
|
|
126
138
|
|
|
139
|
+
class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
140
|
+
}
|
|
141
|
+
|
|
127
142
|
class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
|
|
128
143
|
}
|
|
129
144
|
|
|
@@ -8749,10 +8764,11 @@ class MercadoPagoRequestHelper {
|
|
|
8749
8764
|
statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
|
|
8750
8765
|
additional_info: {
|
|
8751
8766
|
items: this.buildItems(checkout),
|
|
8752
|
-
payer: this.buildFullPayer(checkout),
|
|
8767
|
+
...(method === 'credit_card' && { payer: this.buildFullPayer(checkout) }),
|
|
8753
8768
|
},
|
|
8754
8769
|
...(method === 'credit_card' && this.buildCardPayment(card)),
|
|
8755
8770
|
...(method === 'pix' && this.buildPixPayment()),
|
|
8771
|
+
...(method === 'boleto' && this.buildBoletoPayment(checkout)),
|
|
8756
8772
|
};
|
|
8757
8773
|
}
|
|
8758
8774
|
static buildItems(checkout) {
|
|
@@ -8793,6 +8809,9 @@ class MercadoPagoRequestHelper {
|
|
|
8793
8809
|
zip_code: checkout.shippingAddress.zip,
|
|
8794
8810
|
street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8795
8811
|
street_number: checkout.shippingAddress.number,
|
|
8812
|
+
neighborhood: checkout.shippingAddress.district,
|
|
8813
|
+
city: checkout.shippingAddress.city,
|
|
8814
|
+
federal_unit: checkout.shippingAddress.state,
|
|
8796
8815
|
},
|
|
8797
8816
|
};
|
|
8798
8817
|
}
|
|
@@ -8808,6 +8827,33 @@ class MercadoPagoRequestHelper {
|
|
|
8808
8827
|
date_of_expiration: format(addDays(new Date(), 1), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
|
|
8809
8828
|
};
|
|
8810
8829
|
}
|
|
8830
|
+
static buildBoletoPayment(checkout) {
|
|
8831
|
+
return {
|
|
8832
|
+
payment_method_id: 'bolbradesco',
|
|
8833
|
+
date_of_expiration: format(addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
|
|
8834
|
+
payer: {
|
|
8835
|
+
first_name: checkout.user.firstName,
|
|
8836
|
+
last_name: checkout.user.lastName,
|
|
8837
|
+
email: checkout.user.email,
|
|
8838
|
+
identification: {
|
|
8839
|
+
type: 'CPF',
|
|
8840
|
+
number: checkout.user.cpf.replace(/\D/g, ''),
|
|
8841
|
+
},
|
|
8842
|
+
phone: {
|
|
8843
|
+
area_code: checkout.user.phone.substring(0, 2),
|
|
8844
|
+
number: checkout.user.phone.substring(2),
|
|
8845
|
+
},
|
|
8846
|
+
address: {
|
|
8847
|
+
zip_code: checkout.shippingAddress.zip.replace(/\D/g, ''),
|
|
8848
|
+
street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8849
|
+
street_number: checkout.shippingAddress.number,
|
|
8850
|
+
neighborhood: checkout.shippingAddress.district,
|
|
8851
|
+
city: checkout.shippingAddress.city,
|
|
8852
|
+
federal_unit: checkout.shippingAddress.state,
|
|
8853
|
+
},
|
|
8854
|
+
},
|
|
8855
|
+
};
|
|
8856
|
+
}
|
|
8811
8857
|
}
|
|
8812
8858
|
|
|
8813
8859
|
class MercadoPagoResponseHelper {
|
|
@@ -8828,7 +8874,7 @@ class MercadoPagoResponseHelper {
|
|
|
8828
8874
|
id: response.id.toString(),
|
|
8829
8875
|
acquirer_name: PaymentProviders.MERCADOPAGO,
|
|
8830
8876
|
amount: response.transaction_amount,
|
|
8831
|
-
status: response.status,
|
|
8877
|
+
status: this.statusMapping(response.status),
|
|
8832
8878
|
status_reason: response.status_detail?.toString(),
|
|
8833
8879
|
payment_method: method,
|
|
8834
8880
|
currency: response.currency_id?.toString(),
|
|
@@ -8837,20 +8883,18 @@ class MercadoPagoResponseHelper {
|
|
|
8837
8883
|
charger_id: response.charges_details?.at(0)?.id?.toString() ?? null,
|
|
8838
8884
|
...(method == TransactionPaymentMethods.PIX && this.getPixReponse(response)),
|
|
8839
8885
|
...(method == TransactionPaymentMethods.CARD && this.getCardReponse(response)),
|
|
8886
|
+
...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(response)),
|
|
8840
8887
|
});
|
|
8841
8888
|
}
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
// boleto_document_number: transaction.document_number?.toString(),
|
|
8852
|
-
// }
|
|
8853
|
-
// }
|
|
8889
|
+
static getBoletoReponse(response) {
|
|
8890
|
+
return {
|
|
8891
|
+
boleto_url: response.transaction_details?.external_resource_url?.toString(),
|
|
8892
|
+
boleto_barcode: response.transaction_details?.barcode?.content?.toString(),
|
|
8893
|
+
boleto_line: response.transaction_details?.digitable_line?.toString(),
|
|
8894
|
+
boleto_expiration_date: response.date_of_expiration?.toString(),
|
|
8895
|
+
boleto_document_number: response.transaction_details?.verification_code?.toString(),
|
|
8896
|
+
};
|
|
8897
|
+
}
|
|
8854
8898
|
static getPixReponse(response) {
|
|
8855
8899
|
return {
|
|
8856
8900
|
pix_qr_code: response.point_of_interaction?.transaction_data?.qr_code,
|
|
@@ -8870,7 +8914,61 @@ class MercadoPagoResponseHelper {
|
|
|
8870
8914
|
card_expiration_year: response.card?.expiration_year?.toString(),
|
|
8871
8915
|
capture_method: response.payment_type_id?.toString(),
|
|
8872
8916
|
authorization_code: response.authorization_code?.toString(),
|
|
8917
|
+
paid_amount: this.statusMapping(response.status) == 'paid' ? response.transaction_details?.total_paid_amount : null,
|
|
8918
|
+
paid_at: this.statusMapping(response.status) == 'paid' ? response.date_approved : null,
|
|
8919
|
+
};
|
|
8920
|
+
}
|
|
8921
|
+
static statusMapping(status) {
|
|
8922
|
+
const statusMap = {
|
|
8923
|
+
approved: 'paid',
|
|
8924
|
+
pending: 'waiting_payment',
|
|
8925
|
+
in_process: 'processing',
|
|
8926
|
+
rejected: 'refused',
|
|
8927
|
+
cancelled: 'refused',
|
|
8928
|
+
refunded: 'refunded',
|
|
8929
|
+
charged_back: 'chargedback',
|
|
8873
8930
|
};
|
|
8931
|
+
return statusMap[status] || status;
|
|
8932
|
+
}
|
|
8933
|
+
}
|
|
8934
|
+
|
|
8935
|
+
class MercadoPagoBankSlipAxiosAdapter {
|
|
8936
|
+
constructor(credentials, paymentRepository) {
|
|
8937
|
+
this.credentials = credentials;
|
|
8938
|
+
this.paymentRepository = paymentRepository;
|
|
8939
|
+
}
|
|
8940
|
+
async pay(checkout) {
|
|
8941
|
+
try {
|
|
8942
|
+
const payload = MercadoPagoRequestHelper.build({
|
|
8943
|
+
checkout,
|
|
8944
|
+
method: 'boleto',
|
|
8945
|
+
postback: this.credentials.postback,
|
|
8946
|
+
});
|
|
8947
|
+
console.warn('[MERCADO PAGO BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
8948
|
+
const { data } = await axios({
|
|
8949
|
+
method: 'POST',
|
|
8950
|
+
url: `${this.credentials.url}/v1/payments`,
|
|
8951
|
+
headers: {
|
|
8952
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
8953
|
+
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
8954
|
+
'Content-Type': 'application/json',
|
|
8955
|
+
},
|
|
8956
|
+
data: payload,
|
|
8957
|
+
});
|
|
8958
|
+
console.warn('[MERCADO PAGO RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8959
|
+
const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
8960
|
+
return payment;
|
|
8961
|
+
}
|
|
8962
|
+
catch (error) {
|
|
8963
|
+
if (error instanceof AxiosError) {
|
|
8964
|
+
console.warn(error.response);
|
|
8965
|
+
console.warn(error.response.data);
|
|
8966
|
+
console.warn(error.response.data.cause);
|
|
8967
|
+
}
|
|
8968
|
+
}
|
|
8969
|
+
}
|
|
8970
|
+
getBoletoTransaction(paymentId) {
|
|
8971
|
+
throw new Error('Method not implemented.');
|
|
8874
8972
|
}
|
|
8875
8973
|
}
|
|
8876
8974
|
|
|
@@ -9000,7 +9098,7 @@ class MercadoPagoPixAxiosAdapter {
|
|
|
9000
9098
|
method: 'POST',
|
|
9001
9099
|
url: `${this.credentials.url}/v1/payments`,
|
|
9002
9100
|
headers: {
|
|
9003
|
-
'X-Idempotency-Key': checkout.id
|
|
9101
|
+
'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
|
|
9004
9102
|
Authorization: `Bearer ${this.credentials.api_key}`,
|
|
9005
9103
|
'Content-Type': 'application/json',
|
|
9006
9104
|
},
|
|
@@ -10014,4 +10112,4 @@ class ProductsVertexSearch {
|
|
|
10014
10112
|
}
|
|
10015
10113
|
}
|
|
10016
10114
|
|
|
10017
|
-
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, 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, MercadoPagoCardAxiosAdapter, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, 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, 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 };
|
|
10115
|
+
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, 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, 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, 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, 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,7 @@
|
|
|
1
1
|
export * from './antifraud-providers.enum';
|
|
2
2
|
export * from './business-unit.enum';
|
|
3
3
|
export * from './order-blocked.enum';
|
|
4
|
+
export * from './order-payment-status.enum';
|
|
4
5
|
export * from './pagarme-payment-status.enum';
|
|
5
6
|
export * from './pagarme-v5-payment-status.enum';
|
|
6
7
|
export * from './payment-methods.enum';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum OrderPaymentStatus {
|
|
2
|
+
'Em processamento' = "processing",
|
|
3
|
+
'Autorizada' = "authorized",
|
|
4
|
+
'Pago' = "paid",
|
|
5
|
+
'Estornada' = "refunded",
|
|
6
|
+
'Aguardando pagamento' = "waiting_payment",
|
|
7
|
+
'Aguardando estorno' = "pending_refund",
|
|
8
|
+
'Recusada/Não autorizada' = "refused",
|
|
9
|
+
'Chargedback' = "chargedback"
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './adyen-payment-method.factory';
|
|
2
2
|
export * from './antifraud-provider.factory';
|
|
3
3
|
export * from './glampoints-payment-method.factory';
|
|
4
|
+
export * from './mercado-pago-payment-method.factory';
|
|
4
5
|
export * from './pagarme-payment-method.factory';
|
|
5
6
|
export * from './payment-provider.factory';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { PaymentProviderCard } from '../interfaces';
|
|
1
|
+
import { PaymentProviderCard, PaymentProviderPix } from '../interfaces';
|
|
2
2
|
import { MercadoPagoCard } from '../types';
|
|
3
3
|
import { BasePaymentMethodFactory } from './base-payment-method.factory';
|
|
4
4
|
type MercadoPagoPaymentFactoryMethods = {
|
|
5
5
|
card?: PaymentProviderCard<MercadoPagoCard>;
|
|
6
|
+
pix?: PaymentProviderPix;
|
|
6
7
|
};
|
|
7
8
|
export declare class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory<MercadoPagoPaymentFactoryMethods> {
|
|
8
9
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Checkout, MercadoPagoCredentials, Payment, PaymentProviderBankSlip, PaymentRepository, PaymentTransaction } from '../../../domain';
|
|
2
|
+
export declare class MercadoPagoBankSlipAxiosAdapter implements PaymentProviderBankSlip {
|
|
3
|
+
private credentials;
|
|
4
|
+
private paymentRepository;
|
|
5
|
+
constructor(credentials: MercadoPagoCredentials, paymentRepository: PaymentRepository);
|
|
6
|
+
pay(checkout: Checkout): Promise<Payment>;
|
|
7
|
+
getBoletoTransaction(paymentId: number): Promise<PaymentTransaction>;
|
|
8
|
+
}
|
|
@@ -8,13 +8,6 @@ export declare class MercadoPagoRequestHelper {
|
|
|
8
8
|
}): {
|
|
9
9
|
payment_method_id: string;
|
|
10
10
|
date_of_expiration: string;
|
|
11
|
-
installments: any;
|
|
12
|
-
token: any;
|
|
13
|
-
transaction_amount: number;
|
|
14
|
-
notification_url: string;
|
|
15
|
-
metadata: {
|
|
16
|
-
checkoutId: string;
|
|
17
|
-
};
|
|
18
11
|
payer: {
|
|
19
12
|
first_name: string;
|
|
20
13
|
last_name: string;
|
|
@@ -23,18 +16,28 @@ export declare class MercadoPagoRequestHelper {
|
|
|
23
16
|
type: string;
|
|
24
17
|
number: string;
|
|
25
18
|
};
|
|
19
|
+
phone: {
|
|
20
|
+
area_code: string;
|
|
21
|
+
number: string;
|
|
22
|
+
};
|
|
23
|
+
address: {
|
|
24
|
+
zip_code: string;
|
|
25
|
+
street_name: string;
|
|
26
|
+
street_number: string;
|
|
27
|
+
neighborhood: string;
|
|
28
|
+
city: string;
|
|
29
|
+
federal_unit: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
installments: any;
|
|
33
|
+
token: any;
|
|
34
|
+
transaction_amount: number;
|
|
35
|
+
notification_url: string;
|
|
36
|
+
metadata: {
|
|
37
|
+
checkoutId: string;
|
|
26
38
|
};
|
|
27
39
|
statement_descriptor: string;
|
|
28
40
|
additional_info: {
|
|
29
|
-
items: {
|
|
30
|
-
id: string;
|
|
31
|
-
title: string;
|
|
32
|
-
description: string;
|
|
33
|
-
picture_url: string;
|
|
34
|
-
category_id: string;
|
|
35
|
-
quantity: number;
|
|
36
|
-
unit_price: number;
|
|
37
|
-
}[];
|
|
38
41
|
payer: {
|
|
39
42
|
first_name: string;
|
|
40
43
|
last_name: string;
|
|
@@ -46,8 +49,20 @@ export declare class MercadoPagoRequestHelper {
|
|
|
46
49
|
zip_code: string;
|
|
47
50
|
street_name: string;
|
|
48
51
|
street_number: string;
|
|
52
|
+
neighborhood: string;
|
|
53
|
+
city: string;
|
|
54
|
+
federal_unit: string;
|
|
49
55
|
};
|
|
50
56
|
};
|
|
57
|
+
items: {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
picture_url: string;
|
|
62
|
+
category_id: string;
|
|
63
|
+
quantity: number;
|
|
64
|
+
unit_price: number;
|
|
65
|
+
}[];
|
|
51
66
|
};
|
|
52
67
|
};
|
|
53
68
|
private static buildItems;
|
|
@@ -55,4 +70,5 @@ export declare class MercadoPagoRequestHelper {
|
|
|
55
70
|
private static buildFullPayer;
|
|
56
71
|
private static buildCardPayment;
|
|
57
72
|
private static buildPixPayment;
|
|
73
|
+
private static buildBoletoPayment;
|
|
58
74
|
}
|
|
@@ -3,6 +3,8 @@ import { MercadoPagoResponse } from '../types';
|
|
|
3
3
|
export declare class MercadoPagoResponseHelper {
|
|
4
4
|
static build(method: TransactionPaymentMethods, checkout: Checkout, response: MercadoPagoResponse): Payment;
|
|
5
5
|
private static buildPaymentTransaction;
|
|
6
|
+
private static getBoletoReponse;
|
|
6
7
|
private static getPixReponse;
|
|
7
8
|
private static getCardReponse;
|
|
9
|
+
private static statusMapping;
|
|
8
10
|
}
|
|
@@ -102,6 +102,9 @@ export type MercadoPagoResponse = {
|
|
|
102
102
|
financing_group?: any;
|
|
103
103
|
deduction_schema?: string;
|
|
104
104
|
installments?: number;
|
|
105
|
+
barcode?: {
|
|
106
|
+
content?: string;
|
|
107
|
+
};
|
|
105
108
|
transaction_details?: {
|
|
106
109
|
payment_method_reference_id?: any;
|
|
107
110
|
acquirer_reference?: any;
|
|
@@ -112,6 +115,11 @@ export type MercadoPagoResponse = {
|
|
|
112
115
|
installment_amount?: number;
|
|
113
116
|
financial_institution?: any;
|
|
114
117
|
payable_deferral_period?: any;
|
|
118
|
+
digitable_line?: string;
|
|
119
|
+
barcode?: {
|
|
120
|
+
content?: string;
|
|
121
|
+
};
|
|
122
|
+
verification_code?: string;
|
|
115
123
|
};
|
|
116
124
|
fee_details?: any[];
|
|
117
125
|
charges_details?: [
|