@infrab4a/connect 5.1.2-alpha.0 → 5.2.0-beta.0
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 +516 -2
- package/index.esm.js +514 -3
- package/package.json +1 -1
- package/src/domain/shopping/enums/index.d.ts +2 -0
- package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +24 -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 +10 -2
- package/src/domain/shopping/models/payment-transaction.d.ts +17 -2
- package/src/domain/shopping/models/payment.d.ts +2 -1
- package/src/domain/shopping/types/card-info.type.d.ts +1 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +4 -0
- package/src/domain/shopping/types/pagarme-credentials.type.d.ts +9 -3
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/pagarme/adapters/helpers/index.d.ts +2 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +12 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +10 -0
- package/src/infra/pagarme/adapters/index.d.ts +2 -3
- package/src/infra/pagarme/adapters/v4/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/{pagarme-bank-slip-payment-axios.adapter.d.ts → v4/pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
- package/src/infra/pagarme/adapters/{pagarme-card-payment-axios.adapter.d.ts → v4/pagarme-card-payment-axios.adapter.d.ts} +7 -6
- package/src/infra/pagarme/adapters/v4/pagarme-pix-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +24 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +10 -0
- package/src/infra/pagarme/index.d.ts +1 -0
- package/src/infra/pagarme/types/index.d.ts +1 -0
- package/src/infra/pagarme/types/v5/index.d.ts +4 -0
- package/src/infra/pagarme/types/v5/pagarmev5-customer.type.d.ts +19 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +89 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +126 -0
- package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +11 -0
- package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +0 -11
package/index.esm.js
CHANGED
|
@@ -48,6 +48,33 @@ var PagarmePaymentStatus;
|
|
|
48
48
|
PagarmePaymentStatus["Chargedback"] = "chargedback";
|
|
49
49
|
})(PagarmePaymentStatus || (PagarmePaymentStatus = {}));
|
|
50
50
|
|
|
51
|
+
var PagarMeV5PaymentStatus;
|
|
52
|
+
(function (PagarMeV5PaymentStatus) {
|
|
53
|
+
PagarMeV5PaymentStatus["Em processamento"] = "processing";
|
|
54
|
+
PagarMeV5PaymentStatus["Gerado"] = "generated";
|
|
55
|
+
PagarMeV5PaymentStatus["Visualizado"] = "viewed";
|
|
56
|
+
PagarMeV5PaymentStatus["Pago a menor"] = "underpaid";
|
|
57
|
+
PagarMeV5PaymentStatus["Pago a maior"] = "overpaid";
|
|
58
|
+
PagarMeV5PaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
59
|
+
PagarMeV5PaymentStatus["Pago"] = "paid";
|
|
60
|
+
PagarMeV5PaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
61
|
+
PagarMeV5PaymentStatus["Autorizada pendente de captura"] = "authorized_pending_capture";
|
|
62
|
+
PagarMeV5PaymentStatus["N\u00E3o autorizada"] = "not_authorized";
|
|
63
|
+
PagarMeV5PaymentStatus["Capturada"] = "captured";
|
|
64
|
+
PagarMeV5PaymentStatus["Aguardando captura"] = "waiting_capture";
|
|
65
|
+
PagarMeV5PaymentStatus["Com erro"] = "with_error";
|
|
66
|
+
PagarMeV5PaymentStatus["Estornado"] = "refunded";
|
|
67
|
+
PagarMeV5PaymentStatus["Cancelado"] = "voided";
|
|
68
|
+
PagarMeV5PaymentStatus["Falha"] = "failed";
|
|
69
|
+
})(PagarMeV5PaymentStatus || (PagarMeV5PaymentStatus = {}));
|
|
70
|
+
var PagarMeV5OrderStatus;
|
|
71
|
+
(function (PagarMeV5OrderStatus) {
|
|
72
|
+
PagarMeV5OrderStatus["Pendente"] = "pending";
|
|
73
|
+
PagarMeV5OrderStatus["Pago"] = "paid";
|
|
74
|
+
PagarMeV5OrderStatus["Cancelado"] = "canceled";
|
|
75
|
+
PagarMeV5OrderStatus["Falha"] = "failed";
|
|
76
|
+
})(PagarMeV5OrderStatus || (PagarMeV5OrderStatus = {}));
|
|
77
|
+
|
|
51
78
|
var PaymentMethods;
|
|
52
79
|
(function (PaymentMethods) {
|
|
53
80
|
PaymentMethods["CARD"] = "card";
|
|
@@ -63,6 +90,13 @@ var PaymentProviders;
|
|
|
63
90
|
PaymentProviders["GLAMPOINTS"] = "glampoints";
|
|
64
91
|
})(PaymentProviders || (PaymentProviders = {}));
|
|
65
92
|
|
|
93
|
+
var TransactionPaymentMethods;
|
|
94
|
+
(function (TransactionPaymentMethods) {
|
|
95
|
+
TransactionPaymentMethods["CARD"] = "credit_card";
|
|
96
|
+
TransactionPaymentMethods["BANKSLIP"] = "boleto";
|
|
97
|
+
TransactionPaymentMethods["PIX"] = "pix";
|
|
98
|
+
})(TransactionPaymentMethods || (TransactionPaymentMethods = {}));
|
|
99
|
+
|
|
66
100
|
class BasePaymentMethodFactory {
|
|
67
101
|
constructor(methods) {
|
|
68
102
|
this.methods = methods;
|
|
@@ -8561,6 +8595,201 @@ class PagarmePaymentOperationsHelper {
|
|
|
8561
8595
|
}
|
|
8562
8596
|
}
|
|
8563
8597
|
|
|
8598
|
+
class PagarMeV5RequestHelper {
|
|
8599
|
+
static build(checkout, method, card) {
|
|
8600
|
+
return {
|
|
8601
|
+
items: this.buildItems(checkout),
|
|
8602
|
+
customer: this.buildCustomer(checkout),
|
|
8603
|
+
shipping: this.buildShipping(checkout),
|
|
8604
|
+
payments: this.buildPayment(checkout, method, card),
|
|
8605
|
+
};
|
|
8606
|
+
}
|
|
8607
|
+
static buildItems(checkout) {
|
|
8608
|
+
return checkout.lineItems
|
|
8609
|
+
.filter((item) => !item.isGift)
|
|
8610
|
+
.map((item) => {
|
|
8611
|
+
return {
|
|
8612
|
+
amount: Math.floor(item.pricePaid * 100),
|
|
8613
|
+
description: item.name,
|
|
8614
|
+
quantity: item.quantity,
|
|
8615
|
+
code: item.EAN,
|
|
8616
|
+
};
|
|
8617
|
+
});
|
|
8618
|
+
}
|
|
8619
|
+
static buildCustomer(checkout) {
|
|
8620
|
+
return {
|
|
8621
|
+
name: checkout.user.displayName,
|
|
8622
|
+
email: checkout.user.email,
|
|
8623
|
+
type: 'individual',
|
|
8624
|
+
document: checkout.user.cpf,
|
|
8625
|
+
phones: {
|
|
8626
|
+
home_phone: {
|
|
8627
|
+
country_code: '55',
|
|
8628
|
+
number: checkout.user.phone.slice(2),
|
|
8629
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8630
|
+
},
|
|
8631
|
+
mobile_phone: {
|
|
8632
|
+
country_code: '55',
|
|
8633
|
+
number: checkout.user.phone.slice(2),
|
|
8634
|
+
area_code: checkout.user.phone.slice(0, 2),
|
|
8635
|
+
},
|
|
8636
|
+
},
|
|
8637
|
+
address: {
|
|
8638
|
+
line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
|
|
8639
|
+
line_2: `${checkout.billingAddress.extension}`,
|
|
8640
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8641
|
+
city: checkout.billingAddress.city,
|
|
8642
|
+
state: checkout.billingAddress.state,
|
|
8643
|
+
country: 'BR',
|
|
8644
|
+
},
|
|
8645
|
+
};
|
|
8646
|
+
}
|
|
8647
|
+
static buildShipping(checkout) {
|
|
8648
|
+
return {
|
|
8649
|
+
amount: Math.floor(checkout.shipping.ShippingPrice * 100),
|
|
8650
|
+
description: `${checkout.shipping.ShippingCompanyName} - ${checkout.shipping.description}`,
|
|
8651
|
+
recipient_name: checkout.shippingAddress.recipient,
|
|
8652
|
+
recipient_phone: checkout.user.phone,
|
|
8653
|
+
address: {
|
|
8654
|
+
line_1: `${checkout.shippingAddress.number}, ${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8655
|
+
line_2: `${checkout.shippingAddress.extension}`,
|
|
8656
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8657
|
+
city: checkout.shippingAddress.city,
|
|
8658
|
+
state: checkout.shippingAddress.state,
|
|
8659
|
+
country: 'BR',
|
|
8660
|
+
},
|
|
8661
|
+
};
|
|
8662
|
+
}
|
|
8663
|
+
static buildPayment(checkout, method, card) {
|
|
8664
|
+
return [
|
|
8665
|
+
{
|
|
8666
|
+
payment_method: method,
|
|
8667
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
8668
|
+
...(method === 'pix' && {
|
|
8669
|
+
pix: this.getPixOrder(),
|
|
8670
|
+
}),
|
|
8671
|
+
...(method === 'boleto' && {
|
|
8672
|
+
boleto: this.getBoletoOrder(),
|
|
8673
|
+
}),
|
|
8674
|
+
...(method === 'credit_card' && {
|
|
8675
|
+
credit_card: this.getCardOrder(checkout, card),
|
|
8676
|
+
}),
|
|
8677
|
+
},
|
|
8678
|
+
];
|
|
8679
|
+
}
|
|
8680
|
+
static getPixOrder() {
|
|
8681
|
+
return {
|
|
8682
|
+
expires_at: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
|
|
8683
|
+
};
|
|
8684
|
+
}
|
|
8685
|
+
static getBoletoOrder() {
|
|
8686
|
+
return {
|
|
8687
|
+
due_at: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
|
|
8688
|
+
instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
|
|
8689
|
+
type: 'DM',
|
|
8690
|
+
document_number: new Date().getTime().toString(),
|
|
8691
|
+
};
|
|
8692
|
+
}
|
|
8693
|
+
static getCardOrder(checkout, card) {
|
|
8694
|
+
return {
|
|
8695
|
+
installments: card.installments,
|
|
8696
|
+
statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : "Men's Market",
|
|
8697
|
+
card_id: card.cardId,
|
|
8698
|
+
card: {
|
|
8699
|
+
cvv: card.cardCvv,
|
|
8700
|
+
billing_address: {
|
|
8701
|
+
line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
|
|
8702
|
+
zip_code: checkout.billingAddress.zip,
|
|
8703
|
+
city: checkout.billingAddress.city,
|
|
8704
|
+
state: checkout.billingAddress.state,
|
|
8705
|
+
country: 'BR',
|
|
8706
|
+
},
|
|
8707
|
+
},
|
|
8708
|
+
};
|
|
8709
|
+
}
|
|
8710
|
+
}
|
|
8711
|
+
|
|
8712
|
+
class PagarMeV5ResponseHelper {
|
|
8713
|
+
static build(method, checkout, response) {
|
|
8714
|
+
return Payment.toInstance({
|
|
8715
|
+
createdAt: new Date(),
|
|
8716
|
+
updatedAt: new Date(),
|
|
8717
|
+
userId: checkout.user.id,
|
|
8718
|
+
checkoutId: checkout.id,
|
|
8719
|
+
totalPrice: checkout.totalPrice,
|
|
8720
|
+
paymentProvider: PaymentProviders.PAGARME,
|
|
8721
|
+
pagarMeOrderId: response.id,
|
|
8722
|
+
transaction: this.buildPaymentTransaction(method, response),
|
|
8723
|
+
});
|
|
8724
|
+
}
|
|
8725
|
+
static buildPaymentTransaction(method, response) {
|
|
8726
|
+
const charger = response.charges.at(0);
|
|
8727
|
+
const transaction = charger.last_transaction;
|
|
8728
|
+
return PaymentTransaction.toInstance({
|
|
8729
|
+
acquirer_name: 'pagar_me',
|
|
8730
|
+
amount: charger.amount,
|
|
8731
|
+
currency: charger.currency,
|
|
8732
|
+
gateway_id: charger.gateway_id,
|
|
8733
|
+
status: this.getPaymentStatus(transaction.status),
|
|
8734
|
+
payment_method: charger.payment_method,
|
|
8735
|
+
date_created: charger.created_at,
|
|
8736
|
+
date_updated: charger.updated_at,
|
|
8737
|
+
paid_amount: charger.paid_amount,
|
|
8738
|
+
paid_at: charger.paid_at,
|
|
8739
|
+
order_id: response.id,
|
|
8740
|
+
charger_id: charger.id,
|
|
8741
|
+
tid: charger.id,
|
|
8742
|
+
id: charger.id,
|
|
8743
|
+
...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(transaction)),
|
|
8744
|
+
...(method == TransactionPaymentMethods.PIX && this.getPixReponse(transaction)),
|
|
8745
|
+
...(method == TransactionPaymentMethods.CARD && this.getCardReponse(transaction)),
|
|
8746
|
+
});
|
|
8747
|
+
}
|
|
8748
|
+
static getPaymentStatus(status) {
|
|
8749
|
+
if (status == PagarMeV5PaymentStatus.Gerado)
|
|
8750
|
+
return PagarMeV5PaymentStatus['Aguardando pagamento'];
|
|
8751
|
+
if (status == PagarMeV5PaymentStatus.Capturada)
|
|
8752
|
+
return PagarMeV5PaymentStatus.Pago;
|
|
8753
|
+
return status;
|
|
8754
|
+
}
|
|
8755
|
+
static getBoletoReponse(transaction) {
|
|
8756
|
+
return {
|
|
8757
|
+
boleto_url: transaction.url?.toString(),
|
|
8758
|
+
boleto_barcode: transaction.barcode?.toString(),
|
|
8759
|
+
boleto_qr_code: transaction.qr_code?.toString(),
|
|
8760
|
+
boleto_expiration_date: transaction.due_at?.toString(),
|
|
8761
|
+
boleto_instructions: transaction.instructions?.toString(),
|
|
8762
|
+
boleto_nosso_numero: transaction.nosso_numero?.toString(),
|
|
8763
|
+
boleto_type: transaction.type?.toString(),
|
|
8764
|
+
boleto_document_number: transaction.document_number?.toString(),
|
|
8765
|
+
};
|
|
8766
|
+
}
|
|
8767
|
+
static getPixReponse(transaction) {
|
|
8768
|
+
return {
|
|
8769
|
+
pix_qr_code: transaction.qr_code?.toString(),
|
|
8770
|
+
pix_qr_code_url: transaction.qr_code_url?.toString(),
|
|
8771
|
+
pix_expiration_date: transaction.expires_at?.toString(),
|
|
8772
|
+
};
|
|
8773
|
+
}
|
|
8774
|
+
static getCardReponse(transaction) {
|
|
8775
|
+
return {
|
|
8776
|
+
soft_descriptor: transaction.statement_descriptor?.toString(),
|
|
8777
|
+
acquirer_name: transaction.acquirer_name?.toString(),
|
|
8778
|
+
acquirer_id: transaction.acquirer_tid?.toString(),
|
|
8779
|
+
acquirer_nsu: transaction.acquirer_nsu?.toString(),
|
|
8780
|
+
acquirer_auth_code: transaction.acquirer_auth_code?.toString(),
|
|
8781
|
+
acquirer_message: transaction.acquirer_message?.toString(),
|
|
8782
|
+
acquirer_return_code: transaction.acquirer_return_code?.toString(),
|
|
8783
|
+
installments: transaction.installments ?? null,
|
|
8784
|
+
card_holder_name: transaction.card?.holder_name?.toString(),
|
|
8785
|
+
card_last_digits: transaction.card?.last_four_digits?.toString(),
|
|
8786
|
+
card_first_digits: transaction.card?.first_six_digits?.toString(),
|
|
8787
|
+
card_brand: transaction.card?.brand?.toString(),
|
|
8788
|
+
card_id: transaction.card?.id?.toString(),
|
|
8789
|
+
};
|
|
8790
|
+
}
|
|
8791
|
+
}
|
|
8792
|
+
|
|
8564
8793
|
class PagarmeCardAxiosAdapter {
|
|
8565
8794
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
8566
8795
|
this.credentials = credentials;
|
|
@@ -8617,8 +8846,9 @@ class PagarmeCardAxiosAdapter {
|
|
|
8617
8846
|
});
|
|
8618
8847
|
}
|
|
8619
8848
|
}
|
|
8620
|
-
async createCardHash(bu) {
|
|
8621
|
-
const
|
|
8849
|
+
async createCardHash(bu, shop) {
|
|
8850
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
8851
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
8622
8852
|
try {
|
|
8623
8853
|
const { data } = await axios({
|
|
8624
8854
|
method: 'GET',
|
|
@@ -8781,6 +9011,287 @@ class PagarmePixAxiosAdapter {
|
|
|
8781
9011
|
}
|
|
8782
9012
|
}
|
|
8783
9013
|
|
|
9014
|
+
class PagarmeV5BankSlipAxiosAdapter {
|
|
9015
|
+
constructor(credentials, paymentRepository) {
|
|
9016
|
+
this.credentials = credentials;
|
|
9017
|
+
this.paymentRepository = paymentRepository;
|
|
9018
|
+
}
|
|
9019
|
+
async pay(checkout) {
|
|
9020
|
+
try {
|
|
9021
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
|
|
9022
|
+
console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
9023
|
+
const { data } = await axios({
|
|
9024
|
+
method: 'POST',
|
|
9025
|
+
url: `${this.credentials.URL}/orders`,
|
|
9026
|
+
headers: {
|
|
9027
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9028
|
+
'Content-Type': 'application/json',
|
|
9029
|
+
},
|
|
9030
|
+
data: payload,
|
|
9031
|
+
});
|
|
9032
|
+
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
9033
|
+
if (data.status === PagarMeV5OrderStatus.Falha ||
|
|
9034
|
+
data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
|
|
9035
|
+
(data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado &&
|
|
9036
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus['Em processamento'])) {
|
|
9037
|
+
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9038
|
+
checkoutId: checkout.id,
|
|
9039
|
+
userEmail: checkout.user.email,
|
|
9040
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9041
|
+
}));
|
|
9042
|
+
}
|
|
9043
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
|
|
9044
|
+
return payment;
|
|
9045
|
+
}
|
|
9046
|
+
catch (error) {
|
|
9047
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9048
|
+
if (error instanceof AxiosError) {
|
|
9049
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9050
|
+
}
|
|
9051
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
9052
|
+
checkoutId: checkout.id,
|
|
9053
|
+
userEmail: checkout.user.email,
|
|
9054
|
+
info: error.response?.data,
|
|
9055
|
+
});
|
|
9056
|
+
}
|
|
9057
|
+
}
|
|
9058
|
+
async getBoletoTransaction(paymentId) {
|
|
9059
|
+
try {
|
|
9060
|
+
const { data } = await axios({
|
|
9061
|
+
method: 'GET',
|
|
9062
|
+
url: `${this.credentials.URL}/charges/${paymentId}`,
|
|
9063
|
+
headers: {
|
|
9064
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9065
|
+
'Content-Type': 'application/json',
|
|
9066
|
+
},
|
|
9067
|
+
});
|
|
9068
|
+
const payment = await this.paymentRepository.get({
|
|
9069
|
+
id: data.id,
|
|
9070
|
+
});
|
|
9071
|
+
return payment.transaction;
|
|
9072
|
+
}
|
|
9073
|
+
catch (error) {
|
|
9074
|
+
throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
|
|
9075
|
+
paymentId,
|
|
9076
|
+
info: error.response.data,
|
|
9077
|
+
});
|
|
9078
|
+
}
|
|
9079
|
+
}
|
|
9080
|
+
}
|
|
9081
|
+
|
|
9082
|
+
class PagarmeV5CardAxiosAdapter {
|
|
9083
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
9084
|
+
this.credentials = credentials;
|
|
9085
|
+
this.paymentRepository = paymentRepository;
|
|
9086
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
9087
|
+
}
|
|
9088
|
+
async pay(checkout, card) {
|
|
9089
|
+
try {
|
|
9090
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
|
|
9091
|
+
console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9092
|
+
const { data } = await axios({
|
|
9093
|
+
method: 'POST',
|
|
9094
|
+
url: `${this.credentials.URL}/orders`,
|
|
9095
|
+
headers: {
|
|
9096
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9097
|
+
'Content-Type': 'application/json',
|
|
9098
|
+
},
|
|
9099
|
+
data: payload,
|
|
9100
|
+
});
|
|
9101
|
+
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9102
|
+
if (data.status == PagarMeV5OrderStatus.Falha ||
|
|
9103
|
+
data.charges.at(0).status !== PagarMeV5OrderStatus.Pago ||
|
|
9104
|
+
data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
|
|
9105
|
+
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9106
|
+
checkout,
|
|
9107
|
+
card,
|
|
9108
|
+
orderBlockedRepository: this.orderBlockedRepository,
|
|
9109
|
+
});
|
|
9110
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9111
|
+
}
|
|
9112
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
|
|
9113
|
+
return payment;
|
|
9114
|
+
}
|
|
9115
|
+
catch (error) {
|
|
9116
|
+
if (error instanceof PaymentError) {
|
|
9117
|
+
throw error;
|
|
9118
|
+
}
|
|
9119
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9120
|
+
if (error instanceof AxiosError) {
|
|
9121
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9122
|
+
}
|
|
9123
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9124
|
+
}
|
|
9125
|
+
}
|
|
9126
|
+
async addCard(card, customer) {
|
|
9127
|
+
try {
|
|
9128
|
+
const { id } = await this.createOrUpdateCustomer(customer);
|
|
9129
|
+
const { data } = await axios({
|
|
9130
|
+
method: 'POST',
|
|
9131
|
+
url: `${this.credentials.URL}/customers/${id}/cards`,
|
|
9132
|
+
headers: {
|
|
9133
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9134
|
+
'Content-Type': 'application/json',
|
|
9135
|
+
},
|
|
9136
|
+
data: {
|
|
9137
|
+
number: card.number,
|
|
9138
|
+
holder_name: card.name,
|
|
9139
|
+
holder_document: card.cpf,
|
|
9140
|
+
exp_month: card.expirationDate.split('/').at(0),
|
|
9141
|
+
exp_year: card.expirationDate.split('/').at(1),
|
|
9142
|
+
cvv: card.cvv,
|
|
9143
|
+
brand: card.flag,
|
|
9144
|
+
label: card.flag,
|
|
9145
|
+
billing_address: {
|
|
9146
|
+
line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
|
|
9147
|
+
line_2: `${customer.billingAddress.extension}`,
|
|
9148
|
+
zip_code: customer.billingAddress.zip,
|
|
9149
|
+
city: customer.billingAddress.city,
|
|
9150
|
+
state: customer.billingAddress.state,
|
|
9151
|
+
country: 'BR',
|
|
9152
|
+
},
|
|
9153
|
+
},
|
|
9154
|
+
});
|
|
9155
|
+
return data;
|
|
9156
|
+
}
|
|
9157
|
+
catch (error) {
|
|
9158
|
+
console.warn(error);
|
|
9159
|
+
throw error;
|
|
9160
|
+
}
|
|
9161
|
+
}
|
|
9162
|
+
async createCardHash(bu, shop) {
|
|
9163
|
+
const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
|
|
9164
|
+
const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
|
|
9165
|
+
try {
|
|
9166
|
+
const { data } = await axios({
|
|
9167
|
+
method: 'GET',
|
|
9168
|
+
headers: {
|
|
9169
|
+
'content-type': 'application/json',
|
|
9170
|
+
},
|
|
9171
|
+
url: `${this.credentials.URL}/transactions/card_hash_key`,
|
|
9172
|
+
data: JSON.stringify({
|
|
9173
|
+
api_key: key,
|
|
9174
|
+
}),
|
|
9175
|
+
});
|
|
9176
|
+
return data;
|
|
9177
|
+
}
|
|
9178
|
+
catch (error) {
|
|
9179
|
+
throw new BusinessError('Houve uma falha gerar o hash', {
|
|
9180
|
+
info: error.response.data,
|
|
9181
|
+
});
|
|
9182
|
+
}
|
|
9183
|
+
}
|
|
9184
|
+
async getCardByToken(customerId, token) {
|
|
9185
|
+
try {
|
|
9186
|
+
const { data } = await axios({
|
|
9187
|
+
method: 'GET',
|
|
9188
|
+
url: `${this.credentials.URL}/cards/${token}`,
|
|
9189
|
+
data: {
|
|
9190
|
+
api_key: this.credentials.API_KEY,
|
|
9191
|
+
},
|
|
9192
|
+
});
|
|
9193
|
+
return data;
|
|
9194
|
+
}
|
|
9195
|
+
catch (error) {
|
|
9196
|
+
throw new BusinessError('Houve uma falha buscar o cartão com id: ' + token, {
|
|
9197
|
+
info: error.response.data,
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
9200
|
+
}
|
|
9201
|
+
async createTransaction(info) {
|
|
9202
|
+
return info;
|
|
9203
|
+
}
|
|
9204
|
+
async createOrUpdateCustomer(customer) {
|
|
9205
|
+
try {
|
|
9206
|
+
const { data } = await axios({
|
|
9207
|
+
method: 'POST',
|
|
9208
|
+
url: `${this.credentials.URL}/customers`,
|
|
9209
|
+
headers: {
|
|
9210
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9211
|
+
'Content-Type': 'application/json',
|
|
9212
|
+
},
|
|
9213
|
+
data: {
|
|
9214
|
+
name: customer.displayName,
|
|
9215
|
+
email: customer.email,
|
|
9216
|
+
document: customer.cpf,
|
|
9217
|
+
type: 'individual',
|
|
9218
|
+
document_type: 'CPF',
|
|
9219
|
+
address: {
|
|
9220
|
+
line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
|
|
9221
|
+
line_2: `${customer.billingAddress.extension}`,
|
|
9222
|
+
zip_code: customer.billingAddress.zip,
|
|
9223
|
+
city: customer.billingAddress.city,
|
|
9224
|
+
state: customer.billingAddress.state,
|
|
9225
|
+
country: 'BR',
|
|
9226
|
+
},
|
|
9227
|
+
birthdate: format(customer.birthday, 'MM/dd/yyyy'),
|
|
9228
|
+
phones: {
|
|
9229
|
+
home_phone: {
|
|
9230
|
+
country_code: '55',
|
|
9231
|
+
number: customer.phone.slice(2),
|
|
9232
|
+
area_code: customer.phone.slice(0, 2),
|
|
9233
|
+
},
|
|
9234
|
+
mobile_phone: {
|
|
9235
|
+
country_code: '55',
|
|
9236
|
+
number: customer.phone.slice(2),
|
|
9237
|
+
area_code: customer.phone.slice(0, 2),
|
|
9238
|
+
},
|
|
9239
|
+
},
|
|
9240
|
+
},
|
|
9241
|
+
});
|
|
9242
|
+
return data;
|
|
9243
|
+
}
|
|
9244
|
+
catch (error) {
|
|
9245
|
+
console.warn(error);
|
|
9246
|
+
throw error;
|
|
9247
|
+
}
|
|
9248
|
+
}
|
|
9249
|
+
}
|
|
9250
|
+
|
|
9251
|
+
class PagarmeV5PixAxiosAdapter {
|
|
9252
|
+
constructor(credentials, paymentRepository) {
|
|
9253
|
+
this.credentials = credentials;
|
|
9254
|
+
this.paymentRepository = paymentRepository;
|
|
9255
|
+
}
|
|
9256
|
+
async pay(checkout) {
|
|
9257
|
+
try {
|
|
9258
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
9259
|
+
console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
|
|
9260
|
+
const { data } = await axios({
|
|
9261
|
+
method: 'POST',
|
|
9262
|
+
url: `${this.credentials.URL}/orders`,
|
|
9263
|
+
headers: {
|
|
9264
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9265
|
+
'Content-Type': 'application/json',
|
|
9266
|
+
},
|
|
9267
|
+
data: payload,
|
|
9268
|
+
});
|
|
9269
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9270
|
+
if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
|
|
9271
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9272
|
+
checkoutId: checkout.id,
|
|
9273
|
+
userEmail: checkout.user.email,
|
|
9274
|
+
info: data.charges.at(0).last_transaction?.gateway_response,
|
|
9275
|
+
});
|
|
9276
|
+
}
|
|
9277
|
+
const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
|
|
9278
|
+
return payment;
|
|
9279
|
+
}
|
|
9280
|
+
catch (error) {
|
|
9281
|
+
console.error('Full error: ', JSON.stringify(error));
|
|
9282
|
+
if (error instanceof AxiosError) {
|
|
9283
|
+
console.error('Error: ', error.message);
|
|
9284
|
+
console.error('Error response: ', error.response, 'error data: ', error.response?.data);
|
|
9285
|
+
}
|
|
9286
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9287
|
+
checkoutId: checkout.id,
|
|
9288
|
+
userEmail: checkout.user.email,
|
|
9289
|
+
info: error.response?.data,
|
|
9290
|
+
});
|
|
9291
|
+
}
|
|
9292
|
+
}
|
|
9293
|
+
}
|
|
9294
|
+
|
|
8784
9295
|
class VertexAxiosAdapter {
|
|
8785
9296
|
constructor(config) {
|
|
8786
9297
|
this.config = config;
|
|
@@ -8934,4 +9445,4 @@ class ProductsVertexSearch {
|
|
|
8934
9445
|
}
|
|
8935
9446
|
}
|
|
8936
9447
|
|
|
8937
|
-
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, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, 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 };
|
|
9448
|
+
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
|
@@ -2,5 +2,7 @@ export * from './antifraud-providers.enum';
|
|
|
2
2
|
export * from './business-unit.enum';
|
|
3
3
|
export * from './order-blocked.enum';
|
|
4
4
|
export * from './pagarme-payment-status.enum';
|
|
5
|
+
export * from './pagarme-v5-payment-status.enum';
|
|
5
6
|
export * from './payment-methods.enum';
|
|
6
7
|
export * from './payment-providers.enum';
|
|
8
|
+
export * from './transaction-payment-methods.enum';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum PagarMeV5PaymentStatus {
|
|
2
|
+
'Em processamento' = "processing",
|
|
3
|
+
'Gerado' = "generated",
|
|
4
|
+
'Visualizado' = "viewed",
|
|
5
|
+
'Pago a menor' = "underpaid",
|
|
6
|
+
'Pago a maior' = "overpaid",
|
|
7
|
+
'Aguardando pagamento' = "waiting_payment",
|
|
8
|
+
'Pago' = "paid",
|
|
9
|
+
'Aguardando estorno' = "pending_refund",
|
|
10
|
+
'Autorizada pendente de captura' = "authorized_pending_capture",
|
|
11
|
+
'Não autorizada' = "not_authorized",
|
|
12
|
+
'Capturada' = "captured",
|
|
13
|
+
'Aguardando captura' = "waiting_capture",
|
|
14
|
+
'Com erro' = "with_error",
|
|
15
|
+
'Estornado' = "refunded",
|
|
16
|
+
'Cancelado' = "voided",
|
|
17
|
+
'Falha' = "failed"
|
|
18
|
+
}
|
|
19
|
+
export declare enum PagarMeV5OrderStatus {
|
|
20
|
+
'Pendente' = "pending",
|
|
21
|
+
'Pago' = "paid",
|
|
22
|
+
'Cancelado' = "canceled",
|
|
23
|
+
'Falha' = "failed"
|
|
24
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Shops } from '../../catalog';
|
|
2
|
+
import { User, UserAddress } from '../../users';
|
|
1
3
|
import { BusinessUnitEnum } from '../enums';
|
|
2
4
|
import { PaymentTransaction } from '../models';
|
|
3
5
|
import { Checkout } from '../models/checkout';
|
|
@@ -6,8 +8,14 @@ import { CardInfo, PaymentCardInfo } from '../types';
|
|
|
6
8
|
import { BaseCard } from '../types/base-card.type';
|
|
7
9
|
export interface PaymentProviderCard<Card extends BaseCard = BaseCard> {
|
|
8
10
|
pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
|
|
9
|
-
addCard(card: CardInfo
|
|
11
|
+
addCard?(card: CardInfo, customer: User & {
|
|
12
|
+
billingAddress: Partial<UserAddress>;
|
|
13
|
+
}): Promise<Card>;
|
|
10
14
|
getCardByToken(token: string): Promise<Card>;
|
|
11
|
-
|
|
15
|
+
getCardByToken(customerId: string, token: string): Promise<Card>;
|
|
16
|
+
createCardHash<T>(bu: BusinessUnitEnum, shop: Shops, card?: CardInfo): Promise<string | T>;
|
|
12
17
|
createTransaction(info: any): Promise<PaymentTransaction>;
|
|
18
|
+
createOrUpdateCustomer?(customer: User & {
|
|
19
|
+
billingAddress: Partial<UserAddress>;
|
|
20
|
+
}): any;
|
|
13
21
|
}
|