@infrab4a/connect 5.0.0 → 5.1.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.
Files changed (28) hide show
  1. package/index.cjs.js +447 -0
  2. package/index.esm.js +445 -1
  3. package/package.json +1 -1
  4. package/src/domain/shopping/enums/index.d.ts +1 -0
  5. package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +24 -0
  6. package/src/domain/shopping/models/payment-transaction.d.ts +14 -0
  7. package/src/domain/shopping/models/payment.d.ts +1 -0
  8. package/src/domain/shopping/types/index.d.ts +1 -0
  9. package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +4 -0
  10. package/src/infra/pagarme/adapters/helpers/index.d.ts +2 -0
  11. package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +12 -0
  12. package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +9 -0
  13. package/src/infra/pagarme/adapters/index.d.ts +2 -3
  14. package/src/infra/pagarme/adapters/v4/index.d.ts +3 -0
  15. package/src/infra/pagarme/adapters/{pagarme-bank-slip-payment-axios.adapter.d.ts → v4/pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
  16. package/src/infra/pagarme/adapters/{pagarme-card-payment-axios.adapter.d.ts → v4/pagarme-card-payment-axios.adapter.d.ts} +5 -5
  17. package/src/infra/pagarme/adapters/v4/pagarme-pix-payment-axios.adapter.d.ts +11 -0
  18. package/src/infra/pagarme/adapters/v5/index.d.ts +3 -0
  19. package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +11 -0
  20. package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +16 -0
  21. package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +10 -0
  22. package/src/infra/pagarme/index.d.ts +1 -0
  23. package/src/infra/pagarme/types/index.d.ts +1 -0
  24. package/src/infra/pagarme/types/v5/index.d.ts +3 -0
  25. package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +85 -0
  26. package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +126 -0
  27. package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +11 -0
  28. 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";
@@ -8535,6 +8562,178 @@ class PagarmePaymentOperationsHelper {
8535
8562
  }
8536
8563
  }
8537
8564
 
8565
+ class PagarMeV5RequestHelper {
8566
+ static build(checkout, type, card) {
8567
+ return {
8568
+ items: this.buildItems(checkout),
8569
+ customer: this.buildCustomer(checkout),
8570
+ shipping: this.buildShipping(checkout),
8571
+ payments: this.buildPayment(checkout, type, card),
8572
+ };
8573
+ }
8574
+ static buildItems(checkout) {
8575
+ return checkout.lineItems.map((item) => {
8576
+ return {
8577
+ amount: Math.floor(item.pricePaid * 100),
8578
+ description: item.name,
8579
+ quantity: item.quantity,
8580
+ };
8581
+ });
8582
+ }
8583
+ static buildCustomer(checkout) {
8584
+ return {
8585
+ name: checkout.user.displayName,
8586
+ email: checkout.user.email,
8587
+ type: 'individual',
8588
+ document: checkout.user.cpf,
8589
+ phones: {
8590
+ mobile_phone: {
8591
+ country_code: '55',
8592
+ number: checkout.user.phone.slice(2),
8593
+ area_code: checkout.user.phone.slice(0, 1),
8594
+ },
8595
+ },
8596
+ address: {
8597
+ line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
8598
+ line_2: `${checkout.billingAddress.extension}`,
8599
+ zip_code: checkout.shippingAddress.zip,
8600
+ city: checkout.billingAddress.city,
8601
+ state: checkout.billingAddress.state,
8602
+ country: checkout.billingAddress.country,
8603
+ },
8604
+ };
8605
+ }
8606
+ static buildShipping(checkout) {
8607
+ return {
8608
+ amount: checkout.shipping.ShippingPrice,
8609
+ description: '',
8610
+ recipient_name: checkout.shippingAddress.recipient,
8611
+ recipient_phone: checkout.user.phone,
8612
+ address: {
8613
+ line_1: `${checkout.shippingAddress.number}, ${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
8614
+ line_2: `${checkout.shippingAddress.extension}`,
8615
+ zip_code: checkout.shippingAddress.zip,
8616
+ city: checkout.shippingAddress.city,
8617
+ state: checkout.shippingAddress.state,
8618
+ country: checkout.shippingAddress.country,
8619
+ },
8620
+ };
8621
+ }
8622
+ static buildPayment(checkout, type, card) {
8623
+ return [
8624
+ {
8625
+ payment_method: type,
8626
+ amount: Math.floor(checkout.totalPrice * 100),
8627
+ ...(type === 'pix' && {
8628
+ pix: this.getPixOrder(),
8629
+ }),
8630
+ ...(type === 'boleto' && {
8631
+ boleto: this.getBoletoOrder(),
8632
+ }),
8633
+ ...(type === 'credit_card' && {
8634
+ credit_card: this.getCardOrder(checkout, card),
8635
+ }),
8636
+ },
8637
+ ];
8638
+ }
8639
+ static getPixOrder() {
8640
+ return {
8641
+ expires_at: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
8642
+ };
8643
+ }
8644
+ static getBoletoOrder() {
8645
+ return {
8646
+ due_at: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
8647
+ instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
8648
+ type: 'DM',
8649
+ document_number: new Date().getTime().toString(),
8650
+ };
8651
+ }
8652
+ static getCardOrder(checkout, card) {
8653
+ return {
8654
+ installments: card.installments,
8655
+ statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : "Men's Market",
8656
+ card_id: card.cardId,
8657
+ card: {
8658
+ cvv: card.cardCvv,
8659
+ },
8660
+ };
8661
+ }
8662
+ }
8663
+
8664
+ class PagarMeV5ResponseHelper {
8665
+ static build(checkout, response) {
8666
+ return Payment.toInstance({
8667
+ createdAt: new Date(),
8668
+ updatedAt: new Date(),
8669
+ userId: checkout.user.id,
8670
+ checkoutId: checkout.id,
8671
+ totalPrice: checkout.totalPrice,
8672
+ paymentProvider: PaymentProviders.PAGARME,
8673
+ pagarMeOrderId: response.id,
8674
+ transaction: this.buildPaymentTransaction(response),
8675
+ });
8676
+ }
8677
+ static buildPaymentTransaction(response) {
8678
+ const charger = response.charges.at(0);
8679
+ const transaction = charger.last_transaction;
8680
+ return PaymentTransaction.toInstance({
8681
+ acquirer_name: 'pagar_me',
8682
+ amount: charger.amount,
8683
+ currency: charger.currency,
8684
+ gateway_id: charger.gateway_id,
8685
+ status: charger.status,
8686
+ payment_method: charger.payment_method,
8687
+ date_created: charger.created_at,
8688
+ date_updated: charger.updated_at,
8689
+ paid_amount: charger.paid_amount,
8690
+ paid_at: charger.paid_at,
8691
+ order_id: response.id,
8692
+ tid: +transaction.id,
8693
+ id: +transaction.id,
8694
+ ...this.getBoletoReponse(transaction),
8695
+ ...this.getPixReponse(transaction),
8696
+ ...this.getCardReponse(transaction),
8697
+ });
8698
+ }
8699
+ static getBoletoReponse(transaction) {
8700
+ return {
8701
+ boleto_url: transaction.url?.toString(),
8702
+ boleto_barcode: transaction.barcode?.toString(),
8703
+ boleto_qr_code: transaction.qr_code?.toString(),
8704
+ boleto_expiration_date: transaction.due_at?.toString(),
8705
+ boleto_instructions: transaction.instructions?.toString(),
8706
+ boleto_nosso_numero: transaction.nosso_numero?.toString(),
8707
+ boleto_type: transaction.type?.toString(),
8708
+ boleto_document_number: transaction.document_number?.toString(),
8709
+ };
8710
+ }
8711
+ static getPixReponse(transaction) {
8712
+ return {
8713
+ pix_qr_code: transaction.qr_code?.toString(),
8714
+ pix_qr_code_url: transaction.qr_code_url?.toString(),
8715
+ pix_expiration_date: transaction.expires_at?.toString(),
8716
+ };
8717
+ }
8718
+ static getCardReponse(transaction) {
8719
+ return {
8720
+ soft_descriptor: transaction.statement_descriptor?.toString(),
8721
+ acquirer_name: transaction.acquirer_name?.toString(),
8722
+ acquirer_id: transaction.acquirer_tid?.toString(),
8723
+ acquirer_nsu: transaction.acquirer_nsu?.toString(),
8724
+ acquirer_auth_code: transaction.acquirer_auth_code?.toString(),
8725
+ acquirer_message: transaction.acquirer_message?.toString(),
8726
+ acquirer_return_code: transaction.acquirer_return_code?.toString(),
8727
+ installments: transaction.installments ?? null,
8728
+ card_holder_name: transaction.card.holder_name?.toString(),
8729
+ card_last_digits: transaction.card.last_four_digits?.toString(),
8730
+ card_first_digits: transaction.card.first_six_digits?.toString(),
8731
+ card_brand: transaction.card.brand?.toString(),
8732
+ card_id: transaction.card.id?.toString(),
8733
+ };
8734
+ }
8735
+ }
8736
+
8538
8737
  class PagarmeCardAxiosAdapter {
8539
8738
  constructor(credentials, paymentRepository, orderBlockedRepository) {
8540
8739
  this.credentials = credentials;
@@ -8755,6 +8954,251 @@ class PagarmePixAxiosAdapter {
8755
8954
  }
8756
8955
  }
8757
8956
 
8957
+ /* eslint-disable no-console */
8958
+ class PagarmeV5BankSlipAxiosAdapter {
8959
+ constructor(credentials, paymentRepository) {
8960
+ this.credentials = credentials;
8961
+ this.paymentRepository = paymentRepository;
8962
+ }
8963
+ async pay(checkout) {
8964
+ try {
8965
+ const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
8966
+ console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
8967
+ const { data } = await axios({
8968
+ method: 'POST',
8969
+ url: `${this.credentials.URL}/orders`,
8970
+ headers: {
8971
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
8972
+ 'Content-Type': 'application/json',
8973
+ },
8974
+ data: payload,
8975
+ });
8976
+ console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
8977
+ if (data.charges.at(0).status !== PagarMeV5OrderStatus['Em processamento'] ||
8978
+ data.charges.at(0).status !== PagarMeV5PaymentStatus['Falha']) {
8979
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
8980
+ checkoutId: checkout.id,
8981
+ userEmail: checkout.user.email,
8982
+ info: data,
8983
+ }));
8984
+ }
8985
+ const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
8986
+ const payment = await this.paymentRepository.create(paymentData);
8987
+ return payment;
8988
+ }
8989
+ catch (error) {
8990
+ console.log(error.response?.data?.errors);
8991
+ console.log(error.response?.data?.request);
8992
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
8993
+ checkoutId: checkout.id,
8994
+ userEmail: checkout.user.email,
8995
+ info: error.response.data,
8996
+ });
8997
+ }
8998
+ }
8999
+ async getBoletoTransaction(paymentId) {
9000
+ try {
9001
+ const { data } = await axios({
9002
+ method: 'GET',
9003
+ url: `${this.credentials.URL}/charges/${paymentId}`,
9004
+ headers: {
9005
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9006
+ 'Content-Type': 'application/json',
9007
+ },
9008
+ });
9009
+ const payment = await this.paymentRepository.get({
9010
+ id: +data.id,
9011
+ });
9012
+ return payment.transaction;
9013
+ }
9014
+ catch (error) {
9015
+ throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
9016
+ paymentId,
9017
+ info: error.response.data,
9018
+ });
9019
+ }
9020
+ }
9021
+ }
9022
+
9023
+ class PagarmeV5CardAxiosAdapter {
9024
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
9025
+ this.credentials = credentials;
9026
+ this.paymentRepository = paymentRepository;
9027
+ this.orderBlockedRepository = orderBlockedRepository;
9028
+ }
9029
+ async pay(checkout, card) {
9030
+ try {
9031
+ const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
9032
+ console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
9033
+ const { data } = await axios({
9034
+ method: 'POST',
9035
+ url: `${this.credentials.URL}/orders`,
9036
+ headers: {
9037
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9038
+ 'Content-Type': 'application/json',
9039
+ },
9040
+ data: payload,
9041
+ });
9042
+ console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
9043
+ if (data.charges.at(0).status !== PagarMeV5PaymentStatus.Pago ||
9044
+ data.charges.at(0).status !== PagarMeV5PaymentStatus.Capturada) {
9045
+ await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
9046
+ checkout,
9047
+ card,
9048
+ orderBlockedRepository: this.orderBlockedRepository,
9049
+ });
9050
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
9051
+ }
9052
+ const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
9053
+ const payment = await this.paymentRepository.create(paymentData);
9054
+ return payment;
9055
+ }
9056
+ catch (error) {
9057
+ if (error instanceof PaymentError) {
9058
+ throw error;
9059
+ }
9060
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
9061
+ }
9062
+ }
9063
+ // Dúvidas: preciso criar um cliente? como faz na mens?
9064
+ async addCard(card) {
9065
+ try {
9066
+ const { data } = await axios({
9067
+ method: 'POST',
9068
+ url: `${this.credentials.URL}/cards`,
9069
+ data: {
9070
+ api_key: this.credentials.API_KEY,
9071
+ card_number: card.number,
9072
+ card_expiration_date: card.expirationDate.replace('/', ''),
9073
+ card_holder_name: card.name,
9074
+ card_cvv: card.cvv,
9075
+ // number: '4000000000000010',
9076
+ // holder_name: 'Tony Stark',
9077
+ // holder_document: '93095135270',
9078
+ // exp_month: 1,
9079
+ // exp_year: 30,
9080
+ // cvv: '351',
9081
+ // brand: 'Mastercard',
9082
+ // label: 'Sua bandeira',
9083
+ // billing_address: {
9084
+ // line_1: '375, Av. General Osorio, Centro',
9085
+ // line_2: '7º Andar',
9086
+ // zip_code: '220000111',
9087
+ // city: 'Rio de Janeiro',
9088
+ // state: 'RJ',
9089
+ // country: 'BR',
9090
+ // },
9091
+ // options: {
9092
+ // verify_card: true,
9093
+ // },
9094
+ },
9095
+ });
9096
+ return data;
9097
+ }
9098
+ catch (error) {
9099
+ throw new BusinessError('Houve uma falha adicionar o cartão', {
9100
+ info: error.response.data,
9101
+ });
9102
+ }
9103
+ }
9104
+ async createCardHash(bu) {
9105
+ const key = bu === BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
9106
+ try {
9107
+ const { data } = await axios({
9108
+ method: 'GET',
9109
+ headers: {
9110
+ 'content-type': 'application/json',
9111
+ },
9112
+ url: `${this.credentials.URL}/transactions/card_hash_key`,
9113
+ data: JSON.stringify({
9114
+ api_key: key,
9115
+ }),
9116
+ });
9117
+ return data;
9118
+ }
9119
+ catch (error) {
9120
+ throw new BusinessError('Houve uma falha gerar o hash', {
9121
+ info: error.response.data,
9122
+ });
9123
+ }
9124
+ }
9125
+ async getCardByToken(id) {
9126
+ try {
9127
+ const { data } = await axios({
9128
+ method: 'POST',
9129
+ url: `${this.credentials.URL}/cards/${id}`,
9130
+ data: {
9131
+ api_key: this.credentials.API_KEY,
9132
+ },
9133
+ });
9134
+ return data;
9135
+ }
9136
+ catch (error) {
9137
+ throw new BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
9138
+ info: error.response.data,
9139
+ });
9140
+ }
9141
+ }
9142
+ async createTransaction(info) {
9143
+ try {
9144
+ const { data } = await axios({
9145
+ method: 'POST',
9146
+ url: `${this.credentials.URL}/transactions`,
9147
+ headers: {
9148
+ Authorization: 'Basic ' + Buffer.from(this.credentials.API_KEY).toString('base64'),
9149
+ 'Content-Type': 'application/json',
9150
+ },
9151
+ data: {
9152
+ ...info,
9153
+ api_key: this.credentials.API_KEY,
9154
+ },
9155
+ });
9156
+ return data;
9157
+ }
9158
+ catch (error) {
9159
+ throw new BusinessError('Houve uma falha ao criar a transação', {
9160
+ info: error.response.data,
9161
+ });
9162
+ }
9163
+ }
9164
+ }
9165
+
9166
+ /* eslint-disable no-console */
9167
+ class PagarmeV5PixAxiosAdapter {
9168
+ constructor(credentials, paymentRepository) {
9169
+ this.credentials = credentials;
9170
+ this.paymentRepository = paymentRepository;
9171
+ }
9172
+ async pay(checkout) {
9173
+ try {
9174
+ const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
9175
+ console.warn('[PAGARME PIX DATA TO SEND]', payload);
9176
+ const { data } = await axios({
9177
+ method: 'POST',
9178
+ url: `${this.credentials.URL}/orders`,
9179
+ headers: {
9180
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
9181
+ 'Content-Type': 'application/json',
9182
+ },
9183
+ data: payload,
9184
+ });
9185
+ console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
9186
+ const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
9187
+ const payment = await this.paymentRepository.create(paymentData);
9188
+ return payment;
9189
+ }
9190
+ catch (error) {
9191
+ console.log(error.response?.data?.errors);
9192
+ console.log(error.response?.data?.request);
9193
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9194
+ checkoutId: checkout.id,
9195
+ userEmail: checkout.user.email,
9196
+ info: error.response?.data,
9197
+ });
9198
+ }
9199
+ }
9200
+ }
9201
+
8758
9202
  class VertexAxiosAdapter {
8759
9203
  constructor(config) {
8760
9204
  this.config = config;
@@ -8908,4 +9352,4 @@ class ProductsVertexSearch {
8908
9352
  }
8909
9353
  }
8910
9354
 
8911
- 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 };
9355
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.0.0",
3
+ "version": "5.1.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -2,5 +2,6 @@ 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';
@@ -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
+ }
@@ -5,8 +5,10 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
5
5
  object?: string;
6
6
  status?: string;
7
7
  tid?: number;
8
+ gateway_id?: string;
8
9
  nsu?: number;
9
10
  amount: number;
11
+ currency?: string;
10
12
  cost: number;
11
13
  installments?: number;
12
14
  referer: string;
@@ -26,8 +28,12 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
26
28
  refuse_reason?: string;
27
29
  status_reason?: string;
28
30
  acquirer_response_code?: string;
31
+ acquirer_auth_code?: string;
32
+ acquirer_return_code?: string;
29
33
  acquirer_name?: string;
34
+ acquirer_message?: string;
30
35
  acquirer_id?: string;
36
+ acquirer_nsu?: string;
31
37
  authorization_code?: string;
32
38
  soft_descriptor?: string;
33
39
  date_created?: string;
@@ -36,6 +42,7 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
36
42
  paid_amount?: number;
37
43
  paid_at?: string;
38
44
  refunded_amount?: number;
45
+ card_id?: string;
39
46
  card_holder_name?: string;
40
47
  card_last_digits?: string;
41
48
  card_first_digits?: string;
@@ -48,8 +55,14 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
48
55
  capture_method?: string;
49
56
  antifraud_score?: string;
50
57
  boleto_url?: string;
58
+ boleto_line?: string;
51
59
  boleto_barcode?: string;
60
+ boleto_qr_code?: string;
52
61
  boleto_expiration_date?: string;
62
+ boleto_instructions?: string;
63
+ boleto_nosso_numero?: string;
64
+ boleto_type?: string;
65
+ boleto_document_number?: string;
53
66
  subscription_id?: string;
54
67
  split_rules?: string;
55
68
  antifraud_metadata?: any;
@@ -63,5 +76,6 @@ export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
63
76
  receipt_url?: string;
64
77
  private_label?: string;
65
78
  pix_qr_code?: string;
79
+ pix_qr_code_url?: string;
66
80
  pix_expiration_date?: string;
67
81
  }
@@ -5,6 +5,7 @@ export declare class Payment extends BaseModel<Payment> {
5
5
  id: number;
6
6
  checkoutId: string;
7
7
  orderId?: string;
8
+ pagarMeOrderId?: string;
8
9
  totalPrice: number;
9
10
  userId: string;
10
11
  paymentProvider: PaymentProvider;
@@ -8,6 +8,7 @@ export * from './checkout-stock-validation.type';
8
8
  export * from './glam-credentials.type';
9
9
  export * from './order-tracking-events.type';
10
10
  export * from './pagarme-card.type';
11
+ export * from './pagarme-credentials-v5.type';
11
12
  export * from './pagarme-credentials.type';
12
13
  export * from './payment-card-info.type';
13
14
  export * from './payment-method.type';
@@ -0,0 +1,4 @@
1
+ export type PagarmeCredentialsV5 = {
2
+ URL: string;
3
+ API_KEY: string;
4
+ };
@@ -1,3 +1,5 @@
1
1
  export * from './pagarme-blocked-order.helper';
2
2
  export * from './pagarme-payment-factory.helper';
3
3
  export * from './pagarme-payment-operations.helper';
4
+ export * from './pagarme-v5-request.helper';
5
+ export * from './pagarme-v5-response.helper';
@@ -0,0 +1,12 @@
1
+ import { Checkout, PaymentCardInfo } from '../../../../domain';
2
+ import { PagarMeV5RequestPayload } from '../../types';
3
+ export declare class PagarMeV5RequestHelper {
4
+ static build(checkout: Checkout, type: 'pix' | 'boleto' | 'credit_card', card?: PaymentCardInfo): PagarMeV5RequestPayload;
5
+ private static buildItems;
6
+ private static buildCustomer;
7
+ private static buildShipping;
8
+ private static buildPayment;
9
+ private static getPixOrder;
10
+ private static getBoletoOrder;
11
+ private static getCardOrder;
12
+ }
@@ -0,0 +1,9 @@
1
+ import { Checkout, Payment } from '../../../../domain';
2
+ import { PagarMeV5Response } from '../../types';
3
+ export declare class PagarMeV5ResponseHelper {
4
+ static build(checkout: Checkout, response: PagarMeV5Response): Payment;
5
+ private static buildPaymentTransaction;
6
+ private static getBoletoReponse;
7
+ private static getPixReponse;
8
+ private static getCardReponse;
9
+ }
@@ -1,3 +1,2 @@
1
- export * from './pagarme-bank-slip-payment-axios.adapter';
2
- export * from './pagarme-card-payment-axios.adapter';
3
- export * from './pagarme-pix-payment-axios.adapter';
1
+ export * from './v4';
2
+ export * from './v5';
@@ -0,0 +1,3 @@
1
+ export * from './pagarme-bank-slip-payment-axios.adapter';
2
+ export * from './pagarme-card-payment-axios.adapter';
3
+ export * from './pagarme-pix-payment-axios.adapter';
@@ -1,7 +1,7 @@
1
- import { PaymentProviderBankSlip } from '../../../domain/shopping/interfaces';
2
- import { Checkout, Payment, PaymentTransaction } from '../../../domain/shopping/models';
3
- import { PaymentRepository } from '../../../domain/shopping/repositories';
4
- import { PagarmeCredentials } from '../../../domain/shopping/types';
1
+ import { PaymentProviderBankSlip } from '../../../../domain/shopping/interfaces';
2
+ import { Checkout, Payment, PaymentTransaction } from '../../../../domain/shopping/models';
3
+ import { PaymentRepository } from '../../../../domain/shopping/repositories';
4
+ import { PagarmeCredentials } from '../../../../domain/shopping/types';
5
5
  export declare class PagarmeBankSlipAxiosAdapter implements PaymentProviderBankSlip {
6
6
  private credentials;
7
7
  private paymentRepository;