@infrab4a/connect 5.2.0-beta.4 → 5.3.1-beta.1

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.
Files changed (36) hide show
  1. package/index.cjs.js +2 -510
  2. package/index.esm.js +3 -508
  3. package/package.json +1 -1
  4. package/src/domain/shopping/enums/index.d.ts +0 -2
  5. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +2 -10
  6. package/src/domain/shopping/models/checkout.d.ts +2 -0
  7. package/src/domain/shopping/models/payment-transaction.d.ts +2 -17
  8. package/src/domain/shopping/models/payment.d.ts +1 -2
  9. package/src/domain/shopping/types/card-info.type.d.ts +0 -1
  10. package/src/domain/shopping/types/index.d.ts +0 -1
  11. package/src/domain/shopping/types/pagarme-card.type.d.ts +3 -9
  12. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +3 -9
  13. package/src/domain/users/models/user-payment-method.d.ts +0 -2
  14. package/src/infra/pagarme/adapters/helpers/index.d.ts +0 -2
  15. package/src/infra/pagarme/adapters/index.d.ts +3 -2
  16. package/src/infra/pagarme/adapters/{v4/pagarme-bank-slip-payment-axios.adapter.d.ts → pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
  17. package/src/infra/pagarme/adapters/{v4/pagarme-card-payment-axios.adapter.d.ts → pagarme-card-payment-axios.adapter.d.ts} +6 -7
  18. package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +11 -0
  19. package/src/infra/pagarme/index.d.ts +0 -1
  20. package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +0 -24
  21. package/src/domain/shopping/enums/transaction-payment-methods.enum.d.ts +0 -5
  22. package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +0 -4
  23. package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +0 -12
  24. package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +0 -10
  25. package/src/infra/pagarme/adapters/v4/index.d.ts +0 -3
  26. package/src/infra/pagarme/adapters/v4/pagarme-pix-payment-axios.adapter.d.ts +0 -11
  27. package/src/infra/pagarme/adapters/v5/index.d.ts +0 -3
  28. package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +0 -11
  29. package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +0 -24
  30. package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +0 -10
  31. package/src/infra/pagarme/types/index.d.ts +0 -1
  32. package/src/infra/pagarme/types/v5/index.d.ts +0 -4
  33. package/src/infra/pagarme/types/v5/pagarmev5-customer.type.d.ts +0 -19
  34. package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +0 -89
  35. package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +0 -126
  36. package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +0 -11
package/index.esm.js CHANGED
@@ -48,33 +48,6 @@ 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
-
78
51
  var PaymentMethods;
79
52
  (function (PaymentMethods) {
80
53
  PaymentMethods["CARD"] = "card";
@@ -90,13 +63,6 @@ var PaymentProviders;
90
63
  PaymentProviders["GLAMPOINTS"] = "glampoints";
91
64
  })(PaymentProviders || (PaymentProviders = {}));
92
65
 
93
- var TransactionPaymentMethods;
94
- (function (TransactionPaymentMethods) {
95
- TransactionPaymentMethods["CARD"] = "credit_card";
96
- TransactionPaymentMethods["BANKSLIP"] = "boleto";
97
- TransactionPaymentMethods["PIX"] = "pix";
98
- })(TransactionPaymentMethods || (TransactionPaymentMethods = {}));
99
-
100
66
  class BasePaymentMethodFactory {
101
67
  constructor(methods) {
102
68
  this.methods = methods;
@@ -8595,201 +8561,6 @@ class PagarmePaymentOperationsHelper {
8595
8561
  }
8596
8562
  }
8597
8563
 
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' : 'Mens 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
-
8793
8564
  class PagarmeCardAxiosAdapter {
8794
8565
  constructor(credentials, paymentRepository, orderBlockedRepository) {
8795
8566
  this.credentials = credentials;
@@ -8846,9 +8617,8 @@ class PagarmeCardAxiosAdapter {
8846
8617
  });
8847
8618
  }
8848
8619
  }
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;
8620
+ async createCardHash(bu) {
8621
+ const key = bu === BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
8852
8622
  try {
8853
8623
  const { data } = await axios({
8854
8624
  method: 'GET',
@@ -9011,281 +8781,6 @@ class PagarmePixAxiosAdapter {
9011
8781
  }
9012
8782
  }
9013
8783
 
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
- if (error instanceof AxiosError) {
9048
- console.error('error data: ', JSON.stringify(error.response?.data));
9049
- }
9050
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
9051
- checkoutId: checkout.id,
9052
- userEmail: checkout.user.email,
9053
- info: error.response?.data,
9054
- });
9055
- }
9056
- }
9057
- async getBoletoTransaction(paymentId) {
9058
- try {
9059
- const { data } = await axios({
9060
- method: 'GET',
9061
- url: `${this.credentials.URL}/charges/${paymentId}`,
9062
- headers: {
9063
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9064
- 'Content-Type': 'application/json',
9065
- },
9066
- });
9067
- const payment = await this.paymentRepository.get({
9068
- id: data.id,
9069
- });
9070
- return payment.transaction;
9071
- }
9072
- catch (error) {
9073
- throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
9074
- paymentId,
9075
- info: error.response.data,
9076
- });
9077
- }
9078
- }
9079
- }
9080
-
9081
- class PagarmeV5CardAxiosAdapter {
9082
- constructor(credentials, paymentRepository, orderBlockedRepository) {
9083
- this.credentials = credentials;
9084
- this.paymentRepository = paymentRepository;
9085
- this.orderBlockedRepository = orderBlockedRepository;
9086
- }
9087
- async pay(checkout, card) {
9088
- try {
9089
- const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
9090
- console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
9091
- const { data } = await axios({
9092
- method: 'POST',
9093
- url: `${this.credentials.URL}/orders`,
9094
- headers: {
9095
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9096
- 'Content-Type': 'application/json',
9097
- },
9098
- data: payload,
9099
- });
9100
- console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
9101
- if (data.status == PagarMeV5OrderStatus.Falha ||
9102
- data.charges.at(0).status !== PagarMeV5OrderStatus.Pago ||
9103
- data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
9104
- await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
9105
- checkout,
9106
- card,
9107
- orderBlockedRepository: this.orderBlockedRepository,
9108
- });
9109
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
9110
- }
9111
- const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
9112
- return payment;
9113
- }
9114
- catch (error) {
9115
- if (error instanceof PaymentError) {
9116
- throw error;
9117
- }
9118
- if (error instanceof AxiosError) {
9119
- console.error('error data: ', JSON.stringify(error.response?.data));
9120
- }
9121
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
9122
- }
9123
- }
9124
- async addCard(card, customer) {
9125
- try {
9126
- const { id } = await this.createOrUpdateCustomer(customer);
9127
- const { data } = await axios({
9128
- method: 'POST',
9129
- url: `${this.credentials.URL}/customers/${id}/cards`,
9130
- headers: {
9131
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9132
- 'Content-Type': 'application/json',
9133
- },
9134
- data: {
9135
- number: card.number,
9136
- holder_name: card.name,
9137
- holder_document: card.cpf,
9138
- exp_month: card.expirationDate.split('/').at(0),
9139
- exp_year: card.expirationDate.split('/').at(1),
9140
- cvv: card.cvv,
9141
- billing_address: {
9142
- line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9143
- line_2: `${customer.billingAddress.extension}`,
9144
- zip_code: customer.billingAddress.zip,
9145
- city: customer.billingAddress.city,
9146
- state: customer.billingAddress.state,
9147
- country: 'BR',
9148
- },
9149
- },
9150
- });
9151
- return data;
9152
- }
9153
- catch (error) {
9154
- console.warn(JSON.stringify(error));
9155
- throw error;
9156
- }
9157
- }
9158
- async createCardHash(bu, shop) {
9159
- const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
9160
- const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
9161
- try {
9162
- const { data } = await axios({
9163
- method: 'GET',
9164
- headers: {
9165
- 'content-type': 'application/json',
9166
- },
9167
- url: `${this.credentials.URL}/transactions/card_hash_key`,
9168
- data: JSON.stringify({
9169
- api_key: key,
9170
- }),
9171
- });
9172
- return data;
9173
- }
9174
- catch (error) {
9175
- throw new BusinessError('Houve uma falha gerar o hash', {
9176
- info: error.response.data,
9177
- });
9178
- }
9179
- }
9180
- async getCardByToken(customerId, token) {
9181
- try {
9182
- const { data } = await axios({
9183
- method: 'GET',
9184
- url: `${this.credentials.URL}/cards/${token}`,
9185
- data: {
9186
- api_key: this.credentials.API_KEY,
9187
- },
9188
- });
9189
- return data;
9190
- }
9191
- catch (error) {
9192
- throw new BusinessError('Houve uma falha buscar o cartão com id: ' + token, {
9193
- info: error.response.data,
9194
- });
9195
- }
9196
- }
9197
- async createTransaction(info) {
9198
- return info;
9199
- }
9200
- async createOrUpdateCustomer(customer) {
9201
- try {
9202
- const { data } = await axios({
9203
- method: 'POST',
9204
- url: `${this.credentials.URL}/customers`,
9205
- headers: {
9206
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9207
- 'Content-Type': 'application/json',
9208
- },
9209
- data: {
9210
- name: customer.displayName,
9211
- email: customer.email,
9212
- document: customer.cpf,
9213
- type: 'individual',
9214
- document_type: 'CPF',
9215
- address: {
9216
- line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
9217
- line_2: `${customer.billingAddress.extension}`,
9218
- zip_code: customer.billingAddress.zip,
9219
- city: customer.billingAddress.city,
9220
- state: customer.billingAddress.state,
9221
- country: 'BR',
9222
- },
9223
- birthdate: format(new Date(customer.birthday), 'MM/dd/yyyy'),
9224
- phones: {
9225
- home_phone: {
9226
- country_code: '55',
9227
- number: customer.phone.slice(2),
9228
- area_code: customer.phone.slice(0, 2),
9229
- },
9230
- mobile_phone: {
9231
- country_code: '55',
9232
- number: customer.phone.slice(2),
9233
- area_code: customer.phone.slice(0, 2),
9234
- },
9235
- },
9236
- },
9237
- });
9238
- return data;
9239
- }
9240
- catch (error) {
9241
- console.warn(error);
9242
- throw error;
9243
- }
9244
- }
9245
- }
9246
-
9247
- class PagarmeV5PixAxiosAdapter {
9248
- constructor(credentials, paymentRepository) {
9249
- this.credentials = credentials;
9250
- this.paymentRepository = paymentRepository;
9251
- }
9252
- async pay(checkout) {
9253
- try {
9254
- const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
9255
- console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
9256
- const { data } = await axios({
9257
- method: 'POST',
9258
- url: `${this.credentials.URL}/orders`,
9259
- headers: {
9260
- Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9261
- 'Content-Type': 'application/json',
9262
- },
9263
- data: payload,
9264
- });
9265
- console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
9266
- if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
9267
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9268
- checkoutId: checkout.id,
9269
- userEmail: checkout.user.email,
9270
- info: data.charges.at(0).last_transaction?.gateway_response,
9271
- });
9272
- }
9273
- const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
9274
- return payment;
9275
- }
9276
- catch (error) {
9277
- if (error instanceof AxiosError) {
9278
- console.error('error data: ', JSON.stringify(error.response?.data));
9279
- }
9280
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9281
- checkoutId: checkout.id,
9282
- userEmail: checkout.user.email,
9283
- info: error.response?.data,
9284
- });
9285
- }
9286
- }
9287
- }
9288
-
9289
8784
  class VertexAxiosAdapter {
9290
8785
  constructor(config) {
9291
8786
  this.config = config;
@@ -9439,4 +8934,4 @@ class ProductsVertexSearch {
9439
8934
  }
9440
8935
  }
9441
8936
 
9442
- 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 };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.2.0-beta.4",
3
+ "version": "5.3.1-beta.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -2,7 +2,5 @@ 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';
6
5
  export * from './payment-methods.enum';
7
6
  export * from './payment-providers.enum';
8
- export * from './transaction-payment-methods.enum';
@@ -1,5 +1,3 @@
1
- import { Shops } from '../../catalog';
2
- import { User, UserAddress } from '../../users';
3
1
  import { BusinessUnitEnum } from '../enums';
4
2
  import { PaymentTransaction } from '../models';
5
3
  import { Checkout } from '../models/checkout';
@@ -8,14 +6,8 @@ import { CardInfo, PaymentCardInfo } from '../types';
8
6
  import { BaseCard } from '../types/base-card.type';
9
7
  export interface PaymentProviderCard<Card extends BaseCard = BaseCard> {
10
8
  pay(checkout: Checkout, card: PaymentCardInfo): Promise<Payment>;
11
- addCard?(card: CardInfo, customer: User & {
12
- billingAddress: Partial<UserAddress>;
13
- }): Promise<Card>;
9
+ addCard(card: CardInfo): Promise<Card>;
14
10
  getCardByToken(token: string): Promise<Card>;
15
- getCardByToken(customerId: string, token: string): Promise<Card>;
16
- createCardHash<T>(bu: BusinessUnitEnum, shop: Shops, card?: CardInfo): Promise<string | T>;
11
+ createCardHash<T>(bu: BusinessUnitEnum, card?: CardInfo): Promise<string | T>;
17
12
  createTransaction(info: any): Promise<PaymentTransaction>;
18
- createOrUpdateCustomer?(customer: User & {
19
- billingAddress: Partial<UserAddress>;
20
- }): any;
21
13
  }
@@ -22,5 +22,7 @@ export declare class Checkout extends BaseModel<Checkout> {
22
22
  billingAddress?: UserAddress;
23
23
  shipping?: ShippingMethod;
24
24
  coupon?: Coupon;
25
+ isChange?: boolean;
26
+ isReshipment?: boolean;
25
27
  static get identifiersFields(): GenericIdentifier[];
26
28
  }
@@ -1,14 +1,12 @@
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?: string;
4
+ id?: number;
5
5
  object?: string;
6
6
  status?: string;
7
- tid?: string;
8
- gateway_id?: string;
7
+ tid?: number;
9
8
  nsu?: number;
10
9
  amount: number;
11
- currency?: string;
12
10
  cost: number;
13
11
  installments?: number;
14
12
  referer: string;
@@ -28,12 +26,8 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
28
26
  refuse_reason?: string;
29
27
  status_reason?: string;
30
28
  acquirer_response_code?: string;
31
- acquirer_auth_code?: string;
32
- acquirer_return_code?: string;
33
29
  acquirer_name?: string;
34
- acquirer_message?: string;
35
30
  acquirer_id?: string;
36
- acquirer_nsu?: string;
37
31
  authorization_code?: string;
38
32
  soft_descriptor?: string;
39
33
  date_created?: string;
@@ -42,7 +36,6 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
42
36
  paid_amount?: number;
43
37
  paid_at?: string;
44
38
  refunded_amount?: number;
45
- card_id?: string;
46
39
  card_holder_name?: string;
47
40
  card_last_digits?: string;
48
41
  card_first_digits?: string;
@@ -55,14 +48,8 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
55
48
  capture_method?: string;
56
49
  antifraud_score?: string;
57
50
  boleto_url?: string;
58
- boleto_line?: string;
59
51
  boleto_barcode?: string;
60
- boleto_qr_code?: string;
61
52
  boleto_expiration_date?: string;
62
- boleto_instructions?: string;
63
- boleto_nosso_numero?: string;
64
- boleto_type?: string;
65
- boleto_document_number?: string;
66
53
  subscription_id?: string;
67
54
  split_rules?: string;
68
55
  antifraud_metadata?: any;
@@ -72,11 +59,9 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
72
59
  fraudCovered?: boolean;
73
60
  fraud_reimbursed?: string;
74
61
  order_id?: string;
75
- charger_id?: string;
76
62
  risk_level?: string;
77
63
  receipt_url?: string;
78
64
  private_label?: string;
79
65
  pix_qr_code?: string;
80
- pix_qr_code_url?: string;
81
66
  pix_expiration_date?: string;
82
67
  }