@infrab4a/connect 5.1.0-beta.5 → 5.1.0-beta.7
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 +50 -55
- package/index.esm.js +51 -56
- package/package.json +1 -1
- package/src/domain/shopping/enums/index.d.ts +1 -0
- package/src/domain/shopping/enums/transaction-payment-methods.enum.d.ts +5 -0
- package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +2 -1
- package/src/domain/shopping/models/payment-transaction.d.ts +2 -2
- package/src/domain/shopping/types/pagarme-credentials.type.d.ts +9 -3
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +1 -1
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +2 -2
- package/src/infra/pagarme/adapters/v4/pagarme-card-payment-axios.adapter.d.ts +2 -1
- package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +2 -1
- package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +6 -6
package/index.cjs.js
CHANGED
|
@@ -115,6 +115,13 @@ exports.PaymentProviders = void 0;
|
|
|
115
115
|
PaymentProviders["GLAMPOINTS"] = "glampoints";
|
|
116
116
|
})(exports.PaymentProviders || (exports.PaymentProviders = {}));
|
|
117
117
|
|
|
118
|
+
exports.TransactionPaymentMethods = void 0;
|
|
119
|
+
(function (TransactionPaymentMethods) {
|
|
120
|
+
TransactionPaymentMethods["CARD"] = "credit_card";
|
|
121
|
+
TransactionPaymentMethods["BANKSLIP"] = "boleto";
|
|
122
|
+
TransactionPaymentMethods["PIX"] = "pix";
|
|
123
|
+
})(exports.TransactionPaymentMethods || (exports.TransactionPaymentMethods = {}));
|
|
124
|
+
|
|
118
125
|
class BasePaymentMethodFactory {
|
|
119
126
|
constructor(methods) {
|
|
120
127
|
this.methods = methods;
|
|
@@ -8588,12 +8595,12 @@ class PagarmePaymentOperationsHelper {
|
|
|
8588
8595
|
}
|
|
8589
8596
|
|
|
8590
8597
|
class PagarMeV5RequestHelper {
|
|
8591
|
-
static build(checkout,
|
|
8598
|
+
static build(checkout, method, card) {
|
|
8592
8599
|
return {
|
|
8593
8600
|
items: this.buildItems(checkout),
|
|
8594
8601
|
customer: this.buildCustomer(checkout),
|
|
8595
8602
|
shipping: this.buildShipping(checkout),
|
|
8596
|
-
payments: this.buildPayment(checkout,
|
|
8603
|
+
payments: this.buildPayment(checkout, method, card),
|
|
8597
8604
|
};
|
|
8598
8605
|
}
|
|
8599
8606
|
static buildItems(checkout) {
|
|
@@ -8652,18 +8659,18 @@ class PagarMeV5RequestHelper {
|
|
|
8652
8659
|
},
|
|
8653
8660
|
};
|
|
8654
8661
|
}
|
|
8655
|
-
static buildPayment(checkout,
|
|
8662
|
+
static buildPayment(checkout, method, card) {
|
|
8656
8663
|
return [
|
|
8657
8664
|
{
|
|
8658
|
-
payment_method:
|
|
8665
|
+
payment_method: method,
|
|
8659
8666
|
amount: Math.floor(checkout.totalPrice * 100),
|
|
8660
|
-
...(
|
|
8667
|
+
...(method === 'pix' && {
|
|
8661
8668
|
pix: this.getPixOrder(),
|
|
8662
8669
|
}),
|
|
8663
|
-
...(
|
|
8670
|
+
...(method === 'boleto' && {
|
|
8664
8671
|
boleto: this.getBoletoOrder(),
|
|
8665
8672
|
}),
|
|
8666
|
-
...(
|
|
8673
|
+
...(method === 'credit_card' && {
|
|
8667
8674
|
credit_card: this.getCardOrder(checkout, card),
|
|
8668
8675
|
}),
|
|
8669
8676
|
},
|
|
@@ -8695,7 +8702,7 @@ class PagarMeV5RequestHelper {
|
|
|
8695
8702
|
}
|
|
8696
8703
|
|
|
8697
8704
|
class PagarMeV5ResponseHelper {
|
|
8698
|
-
static build(checkout, response) {
|
|
8705
|
+
static build(method, checkout, response) {
|
|
8699
8706
|
return Payment.toInstance({
|
|
8700
8707
|
createdAt: new Date(),
|
|
8701
8708
|
updatedAt: new Date(),
|
|
@@ -8704,10 +8711,10 @@ class PagarMeV5ResponseHelper {
|
|
|
8704
8711
|
totalPrice: checkout.totalPrice,
|
|
8705
8712
|
paymentProvider: exports.PaymentProviders.PAGARME,
|
|
8706
8713
|
pagarMeOrderId: response.id,
|
|
8707
|
-
transaction: this.buildPaymentTransaction(response),
|
|
8714
|
+
transaction: this.buildPaymentTransaction(method, response),
|
|
8708
8715
|
});
|
|
8709
8716
|
}
|
|
8710
|
-
static buildPaymentTransaction(response) {
|
|
8717
|
+
static buildPaymentTransaction(method, response) {
|
|
8711
8718
|
const charger = response.charges.at(0);
|
|
8712
8719
|
const transaction = charger.last_transaction;
|
|
8713
8720
|
return PaymentTransaction.toInstance({
|
|
@@ -8722,11 +8729,11 @@ class PagarMeV5ResponseHelper {
|
|
|
8722
8729
|
paid_amount: charger.paid_amount,
|
|
8723
8730
|
paid_at: charger.paid_at,
|
|
8724
8731
|
order_id: response.id,
|
|
8725
|
-
tid:
|
|
8726
|
-
id:
|
|
8727
|
-
...this.getBoletoReponse(transaction),
|
|
8728
|
-
...this.getPixReponse(transaction),
|
|
8729
|
-
...this.getCardReponse(transaction),
|
|
8732
|
+
tid: transaction.id,
|
|
8733
|
+
id: transaction.id,
|
|
8734
|
+
...(method == exports.TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(transaction)),
|
|
8735
|
+
...(method == exports.TransactionPaymentMethods.PIX && this.getPixReponse(transaction)),
|
|
8736
|
+
...(method == exports.TransactionPaymentMethods.CARD && this.getCardReponse(transaction)),
|
|
8730
8737
|
});
|
|
8731
8738
|
}
|
|
8732
8739
|
static getBoletoReponse(transaction) {
|
|
@@ -8823,8 +8830,9 @@ class PagarmeCardAxiosAdapter {
|
|
|
8823
8830
|
});
|
|
8824
8831
|
}
|
|
8825
8832
|
}
|
|
8826
|
-
async createCardHash(bu) {
|
|
8827
|
-
const
|
|
8833
|
+
async createCardHash(bu, shop) {
|
|
8834
|
+
const credentials = shop && shop == exports.Shops.MENSMARKET ? this.credentials[exports.Shops.MENSMARKET] : this.credentials[exports.Shops.GLAMSHOP];
|
|
8835
|
+
const key = bu === exports.BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
8828
8836
|
try {
|
|
8829
8837
|
const { data } = await axios__default["default"]({
|
|
8830
8838
|
method: 'GET',
|
|
@@ -9005,8 +9013,9 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9005
9013
|
data: payload,
|
|
9006
9014
|
});
|
|
9007
9015
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9008
|
-
if (data.
|
|
9009
|
-
data.charges.at(0).status
|
|
9016
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9017
|
+
data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
|
|
9018
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado) {
|
|
9010
9019
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9011
9020
|
// checkoutId: checkout.id,
|
|
9012
9021
|
// userEmail: checkout.user.email,
|
|
@@ -9043,22 +9052,21 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9043
9052
|
data: payload,
|
|
9044
9053
|
});
|
|
9045
9054
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9046
|
-
if (data.
|
|
9047
|
-
data.charges.at(0).status
|
|
9055
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9056
|
+
data.charges.at(0).status === exports.PagarMeV5OrderStatus.Falha ||
|
|
9057
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Gerado) {
|
|
9048
9058
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9049
9059
|
checkoutId: checkout.id,
|
|
9050
9060
|
userEmail: checkout.user.email,
|
|
9051
|
-
info: data,
|
|
9061
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9052
9062
|
}));
|
|
9053
9063
|
}
|
|
9054
|
-
const
|
|
9055
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9064
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(exports.TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
9056
9065
|
return payment;
|
|
9057
9066
|
}
|
|
9058
9067
|
catch (error) {
|
|
9059
9068
|
console.error('Full error: ', JSON.stringify(error));
|
|
9060
9069
|
if (error instanceof axios.AxiosError) {
|
|
9061
|
-
console.error('Error: ', error.message);
|
|
9062
9070
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9063
9071
|
}
|
|
9064
9072
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
@@ -9112,8 +9120,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9112
9120
|
data: payload,
|
|
9113
9121
|
});
|
|
9114
9122
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9115
|
-
if (data.
|
|
9116
|
-
data.charges.at(0).status !== exports.PagarMeV5PaymentStatus.
|
|
9123
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha ||
|
|
9124
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Pago ||
|
|
9125
|
+
data.charges.at(0).last_transaction.status !== exports.PagarMeV5PaymentStatus.Capturada) {
|
|
9117
9126
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9118
9127
|
checkout,
|
|
9119
9128
|
card,
|
|
@@ -9121,8 +9130,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9121
9130
|
});
|
|
9122
9131
|
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9123
9132
|
}
|
|
9124
|
-
const
|
|
9125
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9133
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
|
|
9126
9134
|
return payment;
|
|
9127
9135
|
}
|
|
9128
9136
|
catch (error) {
|
|
@@ -9131,7 +9139,6 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9131
9139
|
}
|
|
9132
9140
|
console.error('Full error: ', JSON.stringify(error));
|
|
9133
9141
|
if (error instanceof axios.AxiosError) {
|
|
9134
|
-
console.error('Error: ', error.message);
|
|
9135
9142
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9136
9143
|
}
|
|
9137
9144
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
@@ -9178,8 +9185,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9178
9185
|
});
|
|
9179
9186
|
}
|
|
9180
9187
|
}
|
|
9181
|
-
async createCardHash(bu) {
|
|
9182
|
-
const
|
|
9188
|
+
async createCardHash(bu, shop) {
|
|
9189
|
+
const credentials = shop && shop == exports.Shops.MENSMARKET ? this.credentials[exports.Shops.MENSMARKET] : this.credentials[exports.Shops.GLAMSHOP];
|
|
9190
|
+
const key = bu === exports.BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
9183
9191
|
try {
|
|
9184
9192
|
const { data } = await axios__default["default"]({
|
|
9185
9193
|
method: 'GET',
|
|
@@ -9202,7 +9210,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9202
9210
|
async getCardByToken(id) {
|
|
9203
9211
|
try {
|
|
9204
9212
|
const { data } = await axios__default["default"]({
|
|
9205
|
-
method: '
|
|
9213
|
+
method: 'GET',
|
|
9206
9214
|
url: `${this.credentials.URL}/cards/${id}`,
|
|
9207
9215
|
data: {
|
|
9208
9216
|
api_key: this.credentials.API_KEY,
|
|
@@ -9217,26 +9225,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9217
9225
|
}
|
|
9218
9226
|
}
|
|
9219
9227
|
async createTransaction(info) {
|
|
9220
|
-
|
|
9221
|
-
const { data } = await axios__default["default"]({
|
|
9222
|
-
method: 'POST',
|
|
9223
|
-
url: `${this.credentials.URL}/transactions`,
|
|
9224
|
-
headers: {
|
|
9225
|
-
Authorization: 'Basic ' + Buffer.from(this.credentials.API_KEY).toString('base64'),
|
|
9226
|
-
'Content-Type': 'application/json',
|
|
9227
|
-
},
|
|
9228
|
-
data: {
|
|
9229
|
-
...info,
|
|
9230
|
-
api_key: this.credentials.API_KEY,
|
|
9231
|
-
},
|
|
9232
|
-
});
|
|
9233
|
-
return data;
|
|
9234
|
-
}
|
|
9235
|
-
catch (error) {
|
|
9236
|
-
throw new BusinessError('Houve uma falha ao criar a transação', {
|
|
9237
|
-
info: error.response.data,
|
|
9238
|
-
});
|
|
9239
|
-
}
|
|
9228
|
+
return;
|
|
9240
9229
|
}
|
|
9241
9230
|
}
|
|
9242
9231
|
|
|
@@ -9289,8 +9278,14 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9289
9278
|
data: payload,
|
|
9290
9279
|
});
|
|
9291
9280
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9292
|
-
|
|
9293
|
-
|
|
9281
|
+
if (data.status == exports.PagarMeV5OrderStatus.Falha || data.status == exports.PagarMeV5OrderStatus.Cancelado) {
|
|
9282
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9283
|
+
checkoutId: checkout.id,
|
|
9284
|
+
userEmail: checkout.user.email,
|
|
9285
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9286
|
+
});
|
|
9287
|
+
}
|
|
9288
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(exports.TransactionPaymentMethods.PIX, checkout, data));
|
|
9294
9289
|
return payment;
|
|
9295
9290
|
}
|
|
9296
9291
|
catch (error) {
|
package/index.esm.js
CHANGED
|
@@ -90,6 +90,13 @@ var PaymentProviders;
|
|
|
90
90
|
PaymentProviders["GLAMPOINTS"] = "glampoints";
|
|
91
91
|
})(PaymentProviders || (PaymentProviders = {}));
|
|
92
92
|
|
|
93
|
+
var TransactionPaymentMethods;
|
|
94
|
+
(function (TransactionPaymentMethods) {
|
|
95
|
+
TransactionPaymentMethods["CARD"] = "credit_card";
|
|
96
|
+
TransactionPaymentMethods["BANKSLIP"] = "boleto";
|
|
97
|
+
TransactionPaymentMethods["PIX"] = "pix";
|
|
98
|
+
})(TransactionPaymentMethods || (TransactionPaymentMethods = {}));
|
|
99
|
+
|
|
93
100
|
class BasePaymentMethodFactory {
|
|
94
101
|
constructor(methods) {
|
|
95
102
|
this.methods = methods;
|
|
@@ -8563,12 +8570,12 @@ class PagarmePaymentOperationsHelper {
|
|
|
8563
8570
|
}
|
|
8564
8571
|
|
|
8565
8572
|
class PagarMeV5RequestHelper {
|
|
8566
|
-
static build(checkout,
|
|
8573
|
+
static build(checkout, method, card) {
|
|
8567
8574
|
return {
|
|
8568
8575
|
items: this.buildItems(checkout),
|
|
8569
8576
|
customer: this.buildCustomer(checkout),
|
|
8570
8577
|
shipping: this.buildShipping(checkout),
|
|
8571
|
-
payments: this.buildPayment(checkout,
|
|
8578
|
+
payments: this.buildPayment(checkout, method, card),
|
|
8572
8579
|
};
|
|
8573
8580
|
}
|
|
8574
8581
|
static buildItems(checkout) {
|
|
@@ -8627,18 +8634,18 @@ class PagarMeV5RequestHelper {
|
|
|
8627
8634
|
},
|
|
8628
8635
|
};
|
|
8629
8636
|
}
|
|
8630
|
-
static buildPayment(checkout,
|
|
8637
|
+
static buildPayment(checkout, method, card) {
|
|
8631
8638
|
return [
|
|
8632
8639
|
{
|
|
8633
|
-
payment_method:
|
|
8640
|
+
payment_method: method,
|
|
8634
8641
|
amount: Math.floor(checkout.totalPrice * 100),
|
|
8635
|
-
...(
|
|
8642
|
+
...(method === 'pix' && {
|
|
8636
8643
|
pix: this.getPixOrder(),
|
|
8637
8644
|
}),
|
|
8638
|
-
...(
|
|
8645
|
+
...(method === 'boleto' && {
|
|
8639
8646
|
boleto: this.getBoletoOrder(),
|
|
8640
8647
|
}),
|
|
8641
|
-
...(
|
|
8648
|
+
...(method === 'credit_card' && {
|
|
8642
8649
|
credit_card: this.getCardOrder(checkout, card),
|
|
8643
8650
|
}),
|
|
8644
8651
|
},
|
|
@@ -8670,7 +8677,7 @@ class PagarMeV5RequestHelper {
|
|
|
8670
8677
|
}
|
|
8671
8678
|
|
|
8672
8679
|
class PagarMeV5ResponseHelper {
|
|
8673
|
-
static build(checkout, response) {
|
|
8680
|
+
static build(method, checkout, response) {
|
|
8674
8681
|
return Payment.toInstance({
|
|
8675
8682
|
createdAt: new Date(),
|
|
8676
8683
|
updatedAt: new Date(),
|
|
@@ -8679,10 +8686,10 @@ class PagarMeV5ResponseHelper {
|
|
|
8679
8686
|
totalPrice: checkout.totalPrice,
|
|
8680
8687
|
paymentProvider: PaymentProviders.PAGARME,
|
|
8681
8688
|
pagarMeOrderId: response.id,
|
|
8682
|
-
transaction: this.buildPaymentTransaction(response),
|
|
8689
|
+
transaction: this.buildPaymentTransaction(method, response),
|
|
8683
8690
|
});
|
|
8684
8691
|
}
|
|
8685
|
-
static buildPaymentTransaction(response) {
|
|
8692
|
+
static buildPaymentTransaction(method, response) {
|
|
8686
8693
|
const charger = response.charges.at(0);
|
|
8687
8694
|
const transaction = charger.last_transaction;
|
|
8688
8695
|
return PaymentTransaction.toInstance({
|
|
@@ -8697,11 +8704,11 @@ class PagarMeV5ResponseHelper {
|
|
|
8697
8704
|
paid_amount: charger.paid_amount,
|
|
8698
8705
|
paid_at: charger.paid_at,
|
|
8699
8706
|
order_id: response.id,
|
|
8700
|
-
tid:
|
|
8701
|
-
id:
|
|
8702
|
-
...this.getBoletoReponse(transaction),
|
|
8703
|
-
...this.getPixReponse(transaction),
|
|
8704
|
-
...this.getCardReponse(transaction),
|
|
8707
|
+
tid: transaction.id,
|
|
8708
|
+
id: transaction.id,
|
|
8709
|
+
...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(transaction)),
|
|
8710
|
+
...(method == TransactionPaymentMethods.PIX && this.getPixReponse(transaction)),
|
|
8711
|
+
...(method == TransactionPaymentMethods.CARD && this.getCardReponse(transaction)),
|
|
8705
8712
|
});
|
|
8706
8713
|
}
|
|
8707
8714
|
static getBoletoReponse(transaction) {
|
|
@@ -8798,8 +8805,9 @@ class PagarmeCardAxiosAdapter {
|
|
|
8798
8805
|
});
|
|
8799
8806
|
}
|
|
8800
8807
|
}
|
|
8801
|
-
async createCardHash(bu) {
|
|
8802
|
-
const
|
|
8808
|
+
async createCardHash(bu, shop) {
|
|
8809
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
8810
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
8803
8811
|
try {
|
|
8804
8812
|
const { data } = await axios({
|
|
8805
8813
|
method: 'GET',
|
|
@@ -8980,8 +8988,9 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
8980
8988
|
data: payload,
|
|
8981
8989
|
});
|
|
8982
8990
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8983
|
-
if (data.
|
|
8984
|
-
data.charges.at(0).status
|
|
8991
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
8992
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
8993
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado) {
|
|
8985
8994
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8986
8995
|
// checkoutId: checkout.id,
|
|
8987
8996
|
// userEmail: checkout.user.email,
|
|
@@ -9018,22 +9027,21 @@ class PagarmeV5BankSlipAxiosAdapter {
|
|
|
9018
9027
|
data: payload,
|
|
9019
9028
|
});
|
|
9020
9029
|
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9021
|
-
if (data.
|
|
9022
|
-
data.charges.at(0).status
|
|
9030
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9031
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
9032
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado) {
|
|
9023
9033
|
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9024
9034
|
checkoutId: checkout.id,
|
|
9025
9035
|
userEmail: checkout.user.email,
|
|
9026
|
-
info: data,
|
|
9036
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9027
9037
|
}));
|
|
9028
9038
|
}
|
|
9029
|
-
const
|
|
9030
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9039
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
9031
9040
|
return payment;
|
|
9032
9041
|
}
|
|
9033
9042
|
catch (error) {
|
|
9034
9043
|
console.error('Full error: ', JSON.stringify(error));
|
|
9035
9044
|
if (error instanceof AxiosError) {
|
|
9036
|
-
console.error('Error: ', error.message);
|
|
9037
9045
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9038
9046
|
}
|
|
9039
9047
|
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
@@ -9087,8 +9095,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9087
9095
|
data: payload,
|
|
9088
9096
|
});
|
|
9089
9097
|
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9090
|
-
if (data.
|
|
9091
|
-
data.charges.at(0).status !== PagarMeV5PaymentStatus.
|
|
9098
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9099
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Pago ||
|
|
9100
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
|
|
9092
9101
|
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9093
9102
|
checkout,
|
|
9094
9103
|
card,
|
|
@@ -9096,8 +9105,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9096
9105
|
});
|
|
9097
9106
|
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9098
9107
|
}
|
|
9099
|
-
const
|
|
9100
|
-
const payment = await this.paymentRepository.create(paymentData);
|
|
9108
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
9101
9109
|
return payment;
|
|
9102
9110
|
}
|
|
9103
9111
|
catch (error) {
|
|
@@ -9106,7 +9114,6 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9106
9114
|
}
|
|
9107
9115
|
console.error('Full error: ', JSON.stringify(error));
|
|
9108
9116
|
if (error instanceof AxiosError) {
|
|
9109
|
-
console.error('Error: ', error.message);
|
|
9110
9117
|
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9111
9118
|
}
|
|
9112
9119
|
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
@@ -9153,8 +9160,9 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9153
9160
|
});
|
|
9154
9161
|
}
|
|
9155
9162
|
}
|
|
9156
|
-
async createCardHash(bu) {
|
|
9157
|
-
const
|
|
9163
|
+
async createCardHash(bu, shop) {
|
|
9164
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
9165
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
9158
9166
|
try {
|
|
9159
9167
|
const { data } = await axios({
|
|
9160
9168
|
method: 'GET',
|
|
@@ -9177,7 +9185,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9177
9185
|
async getCardByToken(id) {
|
|
9178
9186
|
try {
|
|
9179
9187
|
const { data } = await axios({
|
|
9180
|
-
method: '
|
|
9188
|
+
method: 'GET',
|
|
9181
9189
|
url: `${this.credentials.URL}/cards/${id}`,
|
|
9182
9190
|
data: {
|
|
9183
9191
|
api_key: this.credentials.API_KEY,
|
|
@@ -9192,26 +9200,7 @@ class PagarmeV5CardAxiosAdapter {
|
|
|
9192
9200
|
}
|
|
9193
9201
|
}
|
|
9194
9202
|
async createTransaction(info) {
|
|
9195
|
-
|
|
9196
|
-
const { data } = await axios({
|
|
9197
|
-
method: 'POST',
|
|
9198
|
-
url: `${this.credentials.URL}/transactions`,
|
|
9199
|
-
headers: {
|
|
9200
|
-
Authorization: 'Basic ' + Buffer.from(this.credentials.API_KEY).toString('base64'),
|
|
9201
|
-
'Content-Type': 'application/json',
|
|
9202
|
-
},
|
|
9203
|
-
data: {
|
|
9204
|
-
...info,
|
|
9205
|
-
api_key: this.credentials.API_KEY,
|
|
9206
|
-
},
|
|
9207
|
-
});
|
|
9208
|
-
return data;
|
|
9209
|
-
}
|
|
9210
|
-
catch (error) {
|
|
9211
|
-
throw new BusinessError('Houve uma falha ao criar a transação', {
|
|
9212
|
-
info: error.response.data,
|
|
9213
|
-
});
|
|
9214
|
-
}
|
|
9203
|
+
return;
|
|
9215
9204
|
}
|
|
9216
9205
|
}
|
|
9217
9206
|
|
|
@@ -9264,8 +9253,14 @@ class PagarmeV5PixAxiosAdapter {
|
|
|
9264
9253
|
data: payload,
|
|
9265
9254
|
});
|
|
9266
9255
|
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9267
|
-
|
|
9268
|
-
|
|
9256
|
+
if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
|
|
9257
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9258
|
+
checkoutId: checkout.id,
|
|
9259
|
+
userEmail: checkout.user.email,
|
|
9260
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9261
|
+
});
|
|
9262
|
+
}
|
|
9263
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
|
|
9269
9264
|
return payment;
|
|
9270
9265
|
}
|
|
9271
9266
|
catch (error) {
|
|
@@ -9436,4 +9431,4 @@ class ProductsVertexSearch {
|
|
|
9436
9431
|
}
|
|
9437
9432
|
}
|
|
9438
9433
|
|
|
9439
|
-
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, 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, 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, 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 };
|
|
9434
|
+
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, 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, 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 };
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Shops } from '../../catalog';
|
|
1
2
|
import { BusinessUnitEnum } from '../enums';
|
|
2
3
|
import { PaymentTransaction } from '../models';
|
|
3
4
|
import { Checkout } from '../models/checkout';
|
|
@@ -8,6 +9,6 @@ export interface PaymentProviderCard<Card extends BaseCard = BaseCard> {
|
|
|
8
9
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
9
10
|
addCard(card: CardInfo): Promise<Card>;
|
|
10
11
|
getCardByToken(token: string): Promise<Card>;
|
|
11
|
-
createCardHash<T>(bu: BusinessUnitEnum, card?: CardInfo): Promise<string | T>;
|
|
12
|
+
createCardHash<T>(bu: BusinessUnitEnum, shop: Shops, card?: CardInfo): Promise<string | T>;
|
|
12
13
|
createTransaction(info: any): Promise<PaymentTransaction>;
|
|
13
14
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseModel } from '../../generic/model/base.model';
|
|
2
2
|
import { PaymentBilling, PaymentCard, PaymentCustomer, PaymentItem, PaymentShipping } from './types';
|
|
3
3
|
export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
|
|
4
|
-
id?:
|
|
4
|
+
id?: string;
|
|
5
5
|
object?: string;
|
|
6
6
|
status?: string;
|
|
7
|
-
tid?:
|
|
7
|
+
tid?: string;
|
|
8
8
|
gateway_id?: string;
|
|
9
9
|
nsu?: number;
|
|
10
10
|
amount: number;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export type PagarmeCredentials = {
|
|
2
2
|
URL: string;
|
|
3
|
-
URL_POSTBACK
|
|
3
|
+
URL_POSTBACK?: string;
|
|
4
4
|
API_KEY: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Glamshop: {
|
|
6
|
+
SUBSCRIPTION_API_KEY: string;
|
|
7
|
+
SHOP_API_KEY: string;
|
|
8
|
+
};
|
|
9
|
+
mensmarket: {
|
|
10
|
+
SUBSCRIPTION_API_KEY: string;
|
|
11
|
+
SHOP_API_KEY: string;
|
|
12
|
+
};
|
|
7
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checkout, PaymentCardInfo } from '../../../../domain';
|
|
2
2
|
import { PagarMeV5RequestPayload } from '../../types';
|
|
3
3
|
export declare class PagarMeV5RequestHelper {
|
|
4
|
-
static build(checkout: Checkout,
|
|
4
|
+
static build(checkout: Checkout, method: 'pix' | 'boleto' | 'credit_card', card?: PaymentCardInfo): PagarMeV5RequestPayload;
|
|
5
5
|
private static buildItems;
|
|
6
6
|
private static buildCustomer;
|
|
7
7
|
private static buildShipping;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Checkout, Payment } from '../../../../domain';
|
|
1
|
+
import { Checkout, Payment, TransactionPaymentMethods } from '../../../../domain';
|
|
2
2
|
import { PagarMeV5Response } from '../../types';
|
|
3
3
|
export declare class PagarMeV5ResponseHelper {
|
|
4
|
-
static build(checkout: Checkout, response: PagarMeV5Response): Payment;
|
|
4
|
+
static build(method: TransactionPaymentMethods, checkout: Checkout, response: PagarMeV5Response): Payment;
|
|
5
5
|
private static buildPaymentTransaction;
|
|
6
6
|
private static getBoletoReponse;
|
|
7
7
|
private static getPixReponse;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Shops } from '../../../../domain/catalog';
|
|
1
2
|
import { BusinessUnitEnum } from '../../../../domain/shopping/enums';
|
|
2
3
|
import { PaymentProviderCard } from '../../../../domain/shopping/interfaces';
|
|
3
4
|
import { Checkout, Payment, PaymentTransaction } from '../../../../domain/shopping/models';
|
|
@@ -10,7 +11,7 @@ export declare class PagarmeCardAxiosAdapter implements PaymentProviderCard<Paga
|
|
|
10
11
|
constructor(credentials: PagarmeCredentials, paymentRepository: PaymentRepository, orderBlockedRepository: OrderBlockedRepository);
|
|
11
12
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
12
13
|
addCard(card: CardInfo): Promise<PagarMeCard>;
|
|
13
|
-
createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum): Promise<PagarMeCardManualHash>;
|
|
14
|
+
createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum, shop?: Shops): Promise<PagarMeCardManualHash>;
|
|
14
15
|
getCardByToken(id: string): Promise<PagarMeCard>;
|
|
15
16
|
createTransaction(info: any): Promise<PaymentTransaction>;
|
|
16
17
|
private createCardPayment;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Shops } from '../../../../domain';
|
|
1
2
|
import { BusinessUnitEnum } from '../../../../domain/shopping/enums';
|
|
2
3
|
import { PaymentProviderCard } from '../../../../domain/shopping/interfaces';
|
|
3
4
|
import { Checkout, Payment, PaymentTransaction } from '../../../../domain/shopping/models';
|
|
@@ -10,7 +11,7 @@ export declare class PagarmeV5CardAxiosAdapter implements PaymentProviderCard<Pa
|
|
|
10
11
|
constructor(credentials: PagarmeCredentials, paymentRepository: PaymentRepository, orderBlockedRepository: OrderBlockedRepository);
|
|
11
12
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
12
13
|
addCard(card: CardInfo): Promise<PagarMeCard>;
|
|
13
|
-
createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum): Promise<PagarMeCardManualHash>;
|
|
14
|
+
createCardHash<PagarMeCardManualHash>(bu: BusinessUnitEnum, shop?: Shops): Promise<PagarMeCardManualHash>;
|
|
14
15
|
getCardByToken(id: string): Promise<PagarMeCard>;
|
|
15
16
|
createTransaction(info: any): Promise<PaymentTransaction>;
|
|
16
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PagarMeV5OrderStatus
|
|
1
|
+
import { PagarMeV5OrderStatus } from '../../../../domain';
|
|
2
2
|
export type PagarMeV5Response = {
|
|
3
3
|
id: string;
|
|
4
4
|
code: string;
|
|
@@ -41,7 +41,7 @@ export type PagarMeV5Charger = {
|
|
|
41
41
|
code: string;
|
|
42
42
|
gateway_id: string;
|
|
43
43
|
amount: number;
|
|
44
|
-
status:
|
|
44
|
+
status: PagarMeV5OrderStatus;
|
|
45
45
|
currency: string;
|
|
46
46
|
payment_method: string;
|
|
47
47
|
paid_amount: number;
|
|
@@ -103,7 +103,7 @@ export type PagarMeV5Transaction = {
|
|
|
103
103
|
type: string;
|
|
104
104
|
created_at: string;
|
|
105
105
|
updated_at: string;
|
|
106
|
-
billing_address
|
|
106
|
+
billing_address?: {
|
|
107
107
|
zip_code: string;
|
|
108
108
|
city: string;
|
|
109
109
|
state: string;
|
|
@@ -112,10 +112,10 @@ export type PagarMeV5Transaction = {
|
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
114
|
gateway_response?: {
|
|
115
|
-
code:
|
|
116
|
-
errors
|
|
115
|
+
code: string;
|
|
116
|
+
errors?: [
|
|
117
117
|
{
|
|
118
|
-
message
|
|
118
|
+
message?: string;
|
|
119
119
|
}
|
|
120
120
|
];
|
|
121
121
|
};
|