@infrab4a/connect 4.20.0-beta.8 → 4.20.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 (79) hide show
  1. package/index.cjs.js +76 -861
  2. package/index.esm.js +79 -838
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/product-base.d.ts +2 -0
  5. package/src/domain/catalog/models/variant.d.ts +2 -0
  6. package/src/domain/general/models/index.d.ts +0 -1
  7. package/src/domain/general/repositories/index.d.ts +0 -1
  8. package/src/domain/shopping/index.d.ts +0 -4
  9. package/src/domain/shopping/models/index.d.ts +0 -1
  10. package/src/domain/shopping/models/order-blocked.d.ts +6 -4
  11. package/src/domain/shopping/models/order.d.ts +2 -2
  12. package/src/domain/shopping/models/payment.d.ts +63 -10
  13. package/src/domain/shopping/models/types/index.d.ts +4 -4
  14. package/src/domain/shopping/types/index.d.ts +0 -8
  15. package/src/errors/index.d.ts +2 -8
  16. package/src/infra/elasticsearch/indexes/products-index.d.ts +2 -0
  17. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  18. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -1
  19. package/src/infra/firebase/firestore/repositories/shopping/{order-blocked-firestore.repository.d.ts → order-blocked-firestore.repository.ts.d.ts} +2 -2
  20. package/src/infra/index.d.ts +0 -2
  21. package/src/utils/index.d.ts +2 -2
  22. package/src/domain/general/models/sequences.d.ts +0 -9
  23. package/src/domain/general/repositories/sequences.repository.d.ts +0 -4
  24. package/src/domain/shopping/enums/antifraud-providers.enum.d.ts +0 -6
  25. package/src/domain/shopping/enums/business-unit.enum.d.ts +0 -4
  26. package/src/domain/shopping/enums/index.d.ts +0 -6
  27. package/src/domain/shopping/enums/order-blocked.enum.d.ts +0 -5
  28. package/src/domain/shopping/enums/pagarme-payment-status.enum.d.ts +0 -10
  29. package/src/domain/shopping/enums/payment-methods.enum.d.ts +0 -6
  30. package/src/domain/shopping/enums/payment-providers.enum.d.ts +0 -5
  31. package/src/domain/shopping/factories/adyen-payment-method.factory.d.ts +0 -9
  32. package/src/domain/shopping/factories/antifraud-provider.factory.d.ts +0 -15
  33. package/src/domain/shopping/factories/base-payment-method.factory.d.ts +0 -7
  34. package/src/domain/shopping/factories/glampoints-payment-method.factory.d.ts +0 -8
  35. package/src/domain/shopping/factories/index.d.ts +0 -5
  36. package/src/domain/shopping/factories/pagarme-payment-method.factory.d.ts +0 -11
  37. package/src/domain/shopping/factories/payment-provider.factory.d.ts +0 -15
  38. package/src/domain/shopping/interfaces/antifraud-method-factory.interface.d.ts +0 -11
  39. package/src/domain/shopping/interfaces/antifraud-provider.interface.d.ts +0 -5
  40. package/src/domain/shopping/interfaces/index.d.ts +0 -7
  41. package/src/domain/shopping/interfaces/payment-method-factory.interface.d.ts +0 -14
  42. package/src/domain/shopping/interfaces/payment-provider-bank-slip.interface.d.ts +0 -7
  43. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +0 -13
  44. package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +0 -5
  45. package/src/domain/shopping/interfaces/payment-provider-pix.interface.d.ts +0 -5
  46. package/src/domain/shopping/models/payment-transaction.d.ts +0 -67
  47. package/src/domain/shopping/services/antifraud-bankslip.service.d.ts +0 -9
  48. package/src/domain/shopping/services/antifraud-card.service.d.ts +0 -18
  49. package/src/domain/shopping/services/antifraud-glampoints.service.d.ts +0 -6
  50. package/src/domain/shopping/services/antifraud-pix.service.d.ts +0 -6
  51. package/src/domain/shopping/services/glampoints-payment.service.d.ts +0 -8
  52. package/src/domain/shopping/services/index.d.ts +0 -5
  53. package/src/domain/shopping/types/adyen-card.type.d.ts +0 -3
  54. package/src/domain/shopping/types/adyen-credentials.type.d.ts +0 -6
  55. package/src/domain/shopping/types/antifraud-provider.type.d.ts +0 -2
  56. package/src/domain/shopping/types/base-card.type.d.ts +0 -2
  57. package/src/domain/shopping/types/card-info.type.d.ts +0 -8
  58. package/src/domain/shopping/types/pagarme-card-manual-hash.type.d.ts +0 -6
  59. package/src/domain/shopping/types/pagarme-card.type.d.ts +0 -16
  60. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +0 -7
  61. package/src/domain/shopping/types/payment-method.type.d.ts +0 -2
  62. package/src/domain/shopping/types/payment-provider.type.d.ts +0 -2
  63. package/src/errors/business.error.d.ts +0 -7
  64. package/src/errors/fraud-validation.error.d.ts +0 -7
  65. package/src/errors/payment.error.d.ts +0 -7
  66. package/src/errors/stock-limit.error.d.ts +0 -5
  67. package/src/errors/stock-out.error.d.ts +0 -5
  68. package/src/errors/types/checkout-additional-data-erro.type.d.ts +0 -6
  69. package/src/errors/types/index.d.ts +0 -2
  70. package/src/errors/types/pagarme-erros.type.d.ts +0 -9
  71. package/src/infra/adyen/adapters/adyen-card-payment-axios.adapter.d.ts +0 -17
  72. package/src/infra/adyen/adapters/index.d.ts +0 -1
  73. package/src/infra/adyen/index.d.ts +0 -1
  74. package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +0 -7
  75. package/src/infra/pagarme/adapters/index.d.ts +0 -3
  76. package/src/infra/pagarme/adapters/pagarme-bank-slip-payment-axios.adapter.d.ts +0 -12
  77. package/src/infra/pagarme/adapters/pagarme-card-payment-axios.adapter.d.ts +0 -17
  78. package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +0 -11
  79. package/src/infra/pagarme/index.d.ts +0 -1
package/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'reflect-metadata';
2
2
  import { __decorate, __metadata, __values, __spreadArray, __read, __extends, __rest } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type, Expose } from 'class-transformer';
4
- import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
5
- export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
4
+ import { parseISO } from 'date-fns';
5
+ export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
6
  import { isNil, isArray, first, last, flatten, compact, get, isString, each, unset, isObject, set, isNumber, chunk, isEmpty, isDate, isBoolean, isInteger, isNaN as isNaN$1, sortBy, omit } from 'lodash';
7
7
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
8
8
  import { debug } from 'debug';
@@ -13,90 +13,6 @@ import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc
13
13
  import { ref, uploadBytes } from 'firebase/storage';
14
14
  import { mutation, query as query$1 } from 'gql-query-builder';
15
15
 
16
- var AntifraudProviders;
17
- (function (AntifraudProviders) {
18
- AntifraudProviders["BANKSLIP"] = "bankSlip";
19
- AntifraudProviders["CARD"] = "card";
20
- AntifraudProviders["PIX"] = "pix";
21
- AntifraudProviders["POINTS"] = "glampoints";
22
- })(AntifraudProviders || (AntifraudProviders = {}));
23
-
24
- var BusinessUnitEnum;
25
- (function (BusinessUnitEnum) {
26
- BusinessUnitEnum[BusinessUnitEnum["SUBSCRIPTION"] = 1] = "SUBSCRIPTION";
27
- BusinessUnitEnum[BusinessUnitEnum["SHOP"] = 2] = "SHOP";
28
- })(BusinessUnitEnum || (BusinessUnitEnum = {}));
29
-
30
- var OrderBlockedType;
31
- (function (OrderBlockedType) {
32
- OrderBlockedType["Checkout"] = "Checkout";
33
- OrderBlockedType["Card"] = "Card";
34
- OrderBlockedType["Boleto"] = "Boleto";
35
- })(OrderBlockedType || (OrderBlockedType = {}));
36
-
37
- var PagarmePaymentStatus;
38
- (function (PagarmePaymentStatus) {
39
- PagarmePaymentStatus["Em processamento"] = "processing";
40
- PagarmePaymentStatus["Autorizada"] = "authorized";
41
- PagarmePaymentStatus["Pago"] = "paid";
42
- PagarmePaymentStatus["Estornada"] = "refunded";
43
- PagarmePaymentStatus["Aguardando pagamento"] = "waiting_payment";
44
- PagarmePaymentStatus["Aguardando estorno"] = "pending_refund";
45
- PagarmePaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
46
- PagarmePaymentStatus["Chargedback"] = "chargedback";
47
- })(PagarmePaymentStatus || (PagarmePaymentStatus = {}));
48
-
49
- var PaymentMethods;
50
- (function (PaymentMethods) {
51
- PaymentMethods["CARD"] = "card";
52
- PaymentMethods["BANKSLIP"] = "bankSlip";
53
- PaymentMethods["PIX"] = "pix";
54
- PaymentMethods["POINTS"] = "glampoints";
55
- })(PaymentMethods || (PaymentMethods = {}));
56
-
57
- var PaymentProviders;
58
- (function (PaymentProviders) {
59
- PaymentProviders["PAGARME"] = "pagarMe";
60
- PaymentProviders["ADYEN"] = "adyen";
61
- PaymentProviders["GLAMPOINTS"] = "glampoints";
62
- })(PaymentProviders || (PaymentProviders = {}));
63
-
64
- class BasePaymentMethodFactory {
65
- constructor(methods) {
66
- this.methods = methods;
67
- }
68
- build(method) {
69
- return this.methods[method];
70
- }
71
- }
72
-
73
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
74
- }
75
-
76
- class AntifraudProviderFactory {
77
- constructor(antifraudProviders) {
78
- this.antifraudProviders = antifraudProviders;
79
- }
80
- build(provider) {
81
- return this.antifraudProviders[provider];
82
- }
83
- }
84
-
85
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
86
- }
87
-
88
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
89
- }
90
-
91
- class PaymentProviderFactory {
92
- constructor(paymentProviders) {
93
- this.paymentProviders = paymentProviders;
94
- }
95
- build(provider) {
96
- return this.paymentProviders[provider];
97
- }
98
- }
99
-
100
16
  class BaseModel {
101
17
  get identifier() {
102
18
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
@@ -643,182 +559,175 @@ var Status;
643
559
  Status["CANCELLED"] = "Cancelado";
644
560
  })(Status || (Status = {}));
645
561
 
646
- class PaymentTransaction extends BaseModel {
562
+ class Payment extends BaseModel {
563
+ static get identifiersFields() {
564
+ return ['id'];
565
+ }
647
566
  }
648
567
  __decorate([
649
568
  Expose({ name: 'refuse_reason' }),
650
569
  __metadata("design:type", String)
651
- ], PaymentTransaction.prototype, "refuseReason", void 0);
570
+ ], Payment.prototype, "refuseReason", void 0);
652
571
  __decorate([
653
572
  Expose({ name: 'status_reason' }),
654
573
  __metadata("design:type", String)
655
- ], PaymentTransaction.prototype, "statusReason", void 0);
574
+ ], Payment.prototype, "statusReason", void 0);
656
575
  __decorate([
657
576
  Expose({ name: 'acquirer_response_code' }),
658
577
  __metadata("design:type", String)
659
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
578
+ ], Payment.prototype, "acquirerResponseCode", void 0);
660
579
  __decorate([
661
580
  Expose({ name: 'acquirer_name' }),
662
581
  __metadata("design:type", String)
663
- ], PaymentTransaction.prototype, "acquirerName", void 0);
582
+ ], Payment.prototype, "acquirerName", void 0);
664
583
  __decorate([
665
584
  Expose({ name: 'acquirer_id' }),
666
585
  __metadata("design:type", String)
667
- ], PaymentTransaction.prototype, "acquirerId", void 0);
586
+ ], Payment.prototype, "acquirerId", void 0);
668
587
  __decorate([
669
588
  Expose({ name: 'authorization_code' }),
670
589
  __metadata("design:type", String)
671
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
590
+ ], Payment.prototype, "authorizationCode", void 0);
672
591
  __decorate([
673
592
  Expose({ name: 'soft_descriptor' }),
674
593
  __metadata("design:type", String)
675
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
594
+ ], Payment.prototype, "softDescriptor", void 0);
676
595
  __decorate([
677
596
  Expose({ name: 'date_created' }),
678
597
  __metadata("design:type", String)
679
- ], PaymentTransaction.prototype, "dateCreated", void 0);
598
+ ], Payment.prototype, "dateCreated", void 0);
680
599
  __decorate([
681
600
  Expose({ name: 'date_updated' }),
682
601
  __metadata("design:type", String)
683
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
602
+ ], Payment.prototype, "dateUpdated", void 0);
684
603
  __decorate([
685
604
  Expose({ name: 'authorized_amount' }),
686
605
  __metadata("design:type", Number)
687
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
606
+ ], Payment.prototype, "authorizedAmount", void 0);
688
607
  __decorate([
689
608
  Expose({ name: 'paid_amount' }),
690
609
  __metadata("design:type", Number)
691
- ], PaymentTransaction.prototype, "paidAmount", void 0);
610
+ ], Payment.prototype, "paidAmount", void 0);
692
611
  __decorate([
693
612
  Expose({ name: 'paid_at' }),
694
613
  __metadata("design:type", String)
695
- ], PaymentTransaction.prototype, "paidAt", void 0);
614
+ ], Payment.prototype, "paidAt", void 0);
696
615
  __decorate([
697
616
  Expose({ name: 'refunded_amount' }),
698
617
  __metadata("design:type", Number)
699
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
618
+ ], Payment.prototype, "refundedAmount", void 0);
700
619
  __decorate([
701
620
  Expose({ name: 'card_holder_name' }),
702
621
  __metadata("design:type", String)
703
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
622
+ ], Payment.prototype, "cardHolderName", void 0);
704
623
  __decorate([
705
624
  Expose({ name: 'card_last_digits' }),
706
625
  __metadata("design:type", String)
707
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
626
+ ], Payment.prototype, "cardLastDigits", void 0);
708
627
  __decorate([
709
628
  Expose({ name: 'card_first_digits' }),
710
629
  __metadata("design:type", String)
711
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
630
+ ], Payment.prototype, "cardFirstDigits", void 0);
712
631
  __decorate([
713
632
  Expose({ name: 'card_brand' }),
714
633
  __metadata("design:type", String)
715
- ], PaymentTransaction.prototype, "cardBrand", void 0);
634
+ ], Payment.prototype, "cardBrand", void 0);
716
635
  __decorate([
717
636
  Expose({ name: 'card_pin_mode' }),
718
637
  __metadata("design:type", String)
719
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
638
+ ], Payment.prototype, "cardPinMode", void 0);
720
639
  __decorate([
721
640
  Expose({ name: 'card_magstripe_fallback' }),
722
641
  __metadata("design:type", Boolean)
723
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
642
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
724
643
  __decorate([
725
644
  Expose({ name: 'cvm_pin' }),
726
645
  __metadata("design:type", Boolean)
727
- ], PaymentTransaction.prototype, "cvmPin", void 0);
646
+ ], Payment.prototype, "cvmPin", void 0);
728
647
  __decorate([
729
648
  Expose({ name: 'postback_url' }),
730
649
  __metadata("design:type", String)
731
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
650
+ ], Payment.prototype, "postbackUrl", void 0);
732
651
  __decorate([
733
652
  Expose({ name: 'payment_method' }),
734
653
  __metadata("design:type", String)
735
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
654
+ ], Payment.prototype, "paymentMethod", void 0);
736
655
  __decorate([
737
656
  Expose({ name: 'capture_method' }),
738
657
  __metadata("design:type", String)
739
- ], PaymentTransaction.prototype, "captureMethod", void 0);
658
+ ], Payment.prototype, "captureMethod", void 0);
740
659
  __decorate([
741
660
  Expose({ name: 'antifraud_score' }),
742
661
  __metadata("design:type", String)
743
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
662
+ ], Payment.prototype, "antifraudScore", void 0);
744
663
  __decorate([
745
664
  Expose({ name: 'boleto_url' }),
746
665
  __metadata("design:type", String)
747
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
666
+ ], Payment.prototype, "boletoUrl", void 0);
748
667
  __decorate([
749
668
  Expose({ name: 'boleto_barcode' }),
750
669
  __metadata("design:type", String)
751
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
670
+ ], Payment.prototype, "boletoBarcode", void 0);
752
671
  __decorate([
753
672
  Expose({ name: 'boleto_expiration_date' }),
754
673
  __metadata("design:type", String)
755
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
674
+ ], Payment.prototype, "boletoExpirationDate", void 0);
756
675
  __decorate([
757
676
  Expose({ name: 'subscription_id' }),
758
677
  __metadata("design:type", String)
759
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
678
+ ], Payment.prototype, "subscriptionId", void 0);
760
679
  __decorate([
761
680
  Expose({ name: 'split_rules' }),
762
681
  __metadata("design:type", String)
763
- ], PaymentTransaction.prototype, "splitRules", void 0);
682
+ ], Payment.prototype, "splitRules", void 0);
764
683
  __decorate([
765
684
  Expose({ name: 'antifraud_metadata' }),
766
685
  __metadata("design:type", Object)
767
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
686
+ ], Payment.prototype, "antifraudMetadata", void 0);
768
687
  __decorate([
769
688
  Expose({ name: 'reference_key' }),
770
689
  __metadata("design:type", String)
771
- ], PaymentTransaction.prototype, "referenceKey", void 0);
690
+ ], Payment.prototype, "referenceKey", void 0);
772
691
  __decorate([
773
692
  Expose({ name: 'local_transaction_id' }),
774
693
  __metadata("design:type", String)
775
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
694
+ ], Payment.prototype, "localTransactionId", void 0);
776
695
  __decorate([
777
696
  Expose({ name: 'local_time' }),
778
697
  __metadata("design:type", String)
779
- ], PaymentTransaction.prototype, "localTime", void 0);
698
+ ], Payment.prototype, "localTime", void 0);
780
699
  __decorate([
781
700
  Expose({ name: 'fraud_covered' }),
782
701
  __metadata("design:type", Boolean)
783
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
702
+ ], Payment.prototype, "fraudCovered", void 0);
784
703
  __decorate([
785
704
  Expose({ name: 'fraud_reimbursed' }),
786
705
  __metadata("design:type", String)
787
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
706
+ ], Payment.prototype, "fraudReimbursed", void 0);
788
707
  __decorate([
789
708
  Expose({ name: 'order_id' }),
790
709
  __metadata("design:type", String)
791
- ], PaymentTransaction.prototype, "orderId", void 0);
710
+ ], Payment.prototype, "orderId", void 0);
792
711
  __decorate([
793
712
  Expose({ name: 'risk_level' }),
794
713
  __metadata("design:type", String)
795
- ], PaymentTransaction.prototype, "riskLevel", void 0);
714
+ ], Payment.prototype, "riskLevel", void 0);
796
715
  __decorate([
797
716
  Expose({ name: 'receipt_url' }),
798
717
  __metadata("design:type", String)
799
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
718
+ ], Payment.prototype, "receiptUrl", void 0);
800
719
  __decorate([
801
720
  Expose({ name: 'private_label' }),
802
721
  __metadata("design:type", String)
803
- ], PaymentTransaction.prototype, "privateLabel", void 0);
722
+ ], Payment.prototype, "privateLabel", void 0);
804
723
  __decorate([
805
724
  Expose({ name: 'pix_qr_code' }),
806
725
  __metadata("design:type", String)
807
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
726
+ ], Payment.prototype, "pixQrCode", void 0);
808
727
  __decorate([
809
728
  Expose({ name: 'pix_expiration_date' }),
810
729
  __metadata("design:type", String)
811
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
812
-
813
- class Payment extends BaseModel {
814
- static get identifiersFields() {
815
- return ['id'];
816
- }
817
- }
818
- __decorate([
819
- Type(() => PaymentTransaction),
820
- __metadata("design:type", PaymentTransaction)
821
- ], Payment.prototype, "transaction", void 0);
730
+ ], Payment.prototype, "pixExpirationDate", void 0);
822
731
 
823
732
  class SubscriptionPayment extends BaseModel {
824
733
  static get identifiersFields() {
@@ -2320,8 +2229,8 @@ var OrderStatus;
2320
2229
  class Order extends Checkout {
2321
2230
  }
2322
2231
  __decorate([
2323
- Type(() => PaymentTransaction),
2324
- __metadata("design:type", PaymentTransaction)
2232
+ Type(() => Payment),
2233
+ __metadata("design:type", Payment)
2325
2234
  ], Order.prototype, "payment", void 0);
2326
2235
 
2327
2236
  class OrderBlocked extends BaseModel {
@@ -2352,308 +2261,6 @@ __decorate([
2352
2261
  __metadata("design:type", Coupon)
2353
2262
  ], CheckoutSubscription.prototype, "coupon", void 0);
2354
2263
 
2355
- class BusinessError extends CustomError {
2356
- constructor(message, additionalData, type = '') {
2357
- super(message);
2358
- this.additionalData = additionalData;
2359
- this.type = type;
2360
- }
2361
- }
2362
-
2363
- class DuplicatedResultsError extends CustomError {
2364
- constructor(message) {
2365
- super(message);
2366
- }
2367
- }
2368
-
2369
- class FraudValidationError extends CustomError {
2370
- constructor(message, additionalData) {
2371
- super(message);
2372
- this.additionalData = additionalData;
2373
- this.type = 'antifraud';
2374
- }
2375
- }
2376
-
2377
- class InvalidArgumentError extends CustomError {
2378
- constructor(message) {
2379
- super(message);
2380
- }
2381
- }
2382
-
2383
- class NotFoundError extends CustomError {
2384
- constructor(message) {
2385
- super(message);
2386
- }
2387
- }
2388
-
2389
- class PaymentError extends CustomError {
2390
- constructor(message, additionalData) {
2391
- super(message);
2392
- this.additionalData = additionalData;
2393
- this.type = 'payment';
2394
- }
2395
- }
2396
-
2397
- class RequiredArgumentError extends CustomError {
2398
- constructor(args) {
2399
- super(`Required arguments: ${args.join(', ')}`);
2400
- this.args = args;
2401
- this.arguments = args;
2402
- }
2403
- }
2404
-
2405
- class StockLimitError extends BusinessError {
2406
- constructor(message, additionalData) {
2407
- super(message, additionalData);
2408
- this.type = 'stock-limit';
2409
- }
2410
- }
2411
-
2412
- class StockOutError extends BusinessError {
2413
- constructor(message, additionalData) {
2414
- super(message, additionalData);
2415
- this.type = 'stock-out';
2416
- }
2417
- }
2418
-
2419
- class AntifraudBankSlipService {
2420
- constructor(orderBlockedRepository) {
2421
- this.orderBlockedRepository = orderBlockedRepository;
2422
- this.MAX_ORDER_VALUE = 5000;
2423
- }
2424
- async validate(checkout) {
2425
- var _a, _b;
2426
- if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2427
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2428
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
2429
- checkoutId: checkout.id,
2430
- userEmail: checkout.user.email,
2431
- info: {
2432
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2433
- subtotal: checkout.subTotalPrice,
2434
- total: checkout.totalPrice,
2435
- },
2436
- });
2437
- }
2438
- return true;
2439
- }
2440
- }
2441
-
2442
- class AntifraudCardService {
2443
- constructor(orderRepository, orderBlockedRepository) {
2444
- this.orderRepository = orderRepository;
2445
- this.orderBlockedRepository = orderBlockedRepository;
2446
- this.LIMIT_ORDERS_DAY = 2;
2447
- this.LIMIT_ORDERS_WEEK = 7;
2448
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2449
- }
2450
- async validate(checkout, card) {
2451
- var _a, _b;
2452
- if (!(await this.verifyBlockedOrderAttempts(checkout, card)))
2453
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
2454
- checkoutId: checkout.id,
2455
- userEmail: checkout.user.email,
2456
- info: {
2457
- isSubscriber: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber,
2458
- subtotal: checkout.subTotalPrice,
2459
- total: checkout.totalPrice,
2460
- },
2461
- });
2462
- if (!(await this.verifyDayAndWeekOrders(checkout, card)))
2463
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
2464
- checkoutId: checkout.id,
2465
- userEmail: checkout.user.email,
2466
- info: {
2467
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2468
- subtotal: checkout.subTotalPrice,
2469
- total: checkout.totalPrice,
2470
- },
2471
- });
2472
- return true;
2473
- }
2474
- async verifyBlockedOrderAttempts(checkout, card) {
2475
- var _a, _b, _c, _d;
2476
- const day = `${format(new Date(), 'yyyy-MM-DD')}T00:00:00`;
2477
- const endOfDay = `${format(new Date(), 'yyyy-MM-DD')}T23:59:59`;
2478
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2479
- .find({
2480
- filters: {
2481
- customer: { cpf: { operator: Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2482
- date: [
2483
- { operator: Where.GTE, value: new Date(day) },
2484
- { operator: Where.LTE, value: new Date(endOfDay) },
2485
- ],
2486
- },
2487
- })
2488
- .then((data) => data.data);
2489
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2490
- .find({
2491
- filters: {
2492
- customer: { email: { operator: Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2493
- date: [
2494
- { operator: Where.GTE, value: new Date(day) },
2495
- { operator: Where.LTE, value: new Date(endOfDay) },
2496
- ],
2497
- },
2498
- })
2499
- .then((data) => data.data);
2500
- const ordersBlockedWithCep = await this.orderBlockedRepository
2501
- .find({
2502
- filters: {
2503
- customer: { shippingAddress: { zip: { operator: Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2504
- date: [
2505
- { operator: Where.GTE, value: new Date(day) },
2506
- { operator: Where.LTE, value: new Date(endOfDay) },
2507
- ],
2508
- },
2509
- })
2510
- .then((data) => data.data);
2511
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2512
- .find({
2513
- filters: {
2514
- customer: { phoneNumber: { operator: Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2515
- date: [
2516
- { operator: Where.GTE, value: new Date(day) },
2517
- { operator: Where.LTE, value: new Date(endOfDay) },
2518
- ],
2519
- },
2520
- })
2521
- .then((data) => data.data);
2522
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2523
- var _a;
2524
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2525
- });
2526
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2527
- var _a, _b;
2528
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) && e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email);
2529
- });
2530
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2531
- var _a, _b, _c, _d, _e, _f;
2532
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2533
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2534
- ((_d = (_c = e.customer.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip) === null || _d === void 0 ? void 0 : _d.toString()) !== ((_f = (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.zip) === null || _f === void 0 ? void 0 : _f.toString()));
2535
- });
2536
- const blockedAttempts = ordersBlockedWithCpf
2537
- .concat(blockedUniqueEmails)
2538
- .concat(blockedUniqueCeps)
2539
- .concat(blockedUniquePhone);
2540
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2541
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2542
- return false;
2543
- }
2544
- return true;
2545
- }
2546
- async verifyDayAndWeekOrders(checkout, card) {
2547
- var _a, _b, _c, _d, _e, _f, _g, _h;
2548
- const ordersPerDay = await this.validateOrdersByRange((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf, (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email, (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.phone, (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.zip, card, this.getDateRange('day'));
2549
- for (const key in ordersPerDay) {
2550
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2551
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2552
- return false;
2553
- }
2554
- }
2555
- const ordersPerWeek = await this.validateOrdersByRange((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.cpf, (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.email, (_g = checkout.user) === null || _g === void 0 ? void 0 : _g.phone, (_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip, card, this.getDateRange('week'));
2556
- for (const key in ordersPerWeek) {
2557
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2558
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2559
- return false;
2560
- }
2561
- }
2562
- return true;
2563
- }
2564
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2565
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2566
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2567
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2568
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2569
- return {
2570
- cpf: ordersCpf,
2571
- email: ordersByEmail,
2572
- phone: ordersByPhone,
2573
- zip: ordersByZip,
2574
- };
2575
- }
2576
- async countOrdersByField(property, field, value, range) {
2577
- const filters = {
2578
- [property]: {
2579
- [field]: value,
2580
- },
2581
- ['createdAt']: [
2582
- { operator: Where.GTE, value: range.firstDate },
2583
- { operator: Where.LTE, value: range.lastDate },
2584
- ],
2585
- };
2586
- const docs = await (await this.orderRepository.find({ filters })).count;
2587
- return docs;
2588
- }
2589
- getDateRange(range = 'day') {
2590
- switch (range) {
2591
- case 'day':
2592
- return {
2593
- firstDate: startOfDay(new Date()).getTime(),
2594
- lastDate: endOfDay(new Date()).getTime(),
2595
- };
2596
- case 'week':
2597
- return {
2598
- firstDate: startOfDay(subDays(new Date(), 7)).getTime(),
2599
- lastDate: endOfDay(new Date()).getTime(),
2600
- };
2601
- default:
2602
- return {
2603
- firstDate: startOfDay(new Date()).getTime(),
2604
- lastDate: endOfDay(new Date()).getTime(),
2605
- };
2606
- }
2607
- }
2608
- }
2609
-
2610
- class AntifraudGlampointsService {
2611
- constructor() { }
2612
- async validate(checkout) {
2613
- return true;
2614
- }
2615
- }
2616
-
2617
- class AntifraudPixService {
2618
- constructor() { }
2619
- async validate(checkout) {
2620
- return true;
2621
- }
2622
- }
2623
-
2624
- class GlampointsPaymentService {
2625
- constructor(paymentRepository) {
2626
- this.paymentRepository = paymentRepository;
2627
- }
2628
- async pay(checkout) {
2629
- const payment = await this.paymentRepository.create(Payment.toInstance({
2630
- createdAt: new Date(),
2631
- updatedAt: new Date(),
2632
- userId: checkout.user.id,
2633
- checkoutId: checkout.id,
2634
- totalPrice: checkout.totalPrice,
2635
- paymentProvider: 'glampoints',
2636
- transaction: {
2637
- amount: 0,
2638
- acquirerResponseCode: '0000',
2639
- acquirerName: 'glampoints',
2640
- authorizedAmount: 0,
2641
- captureMethod: 'ecommerce',
2642
- installments: 1,
2643
- cost: 0,
2644
- paidAmount: 0,
2645
- paidAt: new Date().toISOString(),
2646
- paymentMethod: 'glampoints',
2647
- referer: 'api_key',
2648
- refundedAmount: 0,
2649
- status: 'paid',
2650
- statusReason: 'acquirer',
2651
- },
2652
- }));
2653
- return payment;
2654
- }
2655
- }
2656
-
2657
2264
  class RoundProductPricesHelper {
2658
2265
  static roundProductPrices(product) {
2659
2266
  product.price.price = Number(product.price.price.toFixed(2));
@@ -2674,12 +2281,6 @@ class LogDocument extends BaseModel {
2674
2281
  }
2675
2282
  }
2676
2283
 
2677
- class Sequence extends BaseModel {
2678
- static get identifiersFields() {
2679
- return ['id'];
2680
- }
2681
- }
2682
-
2683
2284
  var FilterType;
2684
2285
  (function (FilterType) {
2685
2286
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2818,82 +2419,29 @@ class ShopSettings extends BaseModel {
2818
2419
  }
2819
2420
  }
2820
2421
 
2821
- class AdyenCardAxiosAdapter {
2822
- constructor(credentials, paymentRepository, orderBlockedRepository) {
2823
- this.credentials = credentials;
2824
- this.paymentRepository = paymentRepository;
2825
- this.orderBlockedRepository = orderBlockedRepository;
2826
- }
2827
- createCardHash(bu) {
2828
- throw new Error('Method not implemented.');
2829
- }
2830
- async pay(checkout, card) {
2831
- try {
2832
- const result = await axios({
2833
- method: 'POST',
2834
- url: this.credentials.URL_TRANSACTION,
2835
- headers: {
2836
- 'x-api-key': this.credentials.API_KEY,
2837
- 'content-type': 'application/json',
2838
- },
2839
- data: this.createCardPayment(checkout, card),
2840
- });
2841
- if (result.data.resultCode !== 'Authorised') {
2842
- this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2843
- return Promise.reject(new PaymentError(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`, {
2844
- checkoutId: checkout.id,
2845
- userEmail: checkout.user.email,
2846
- info: result.data,
2847
- }));
2848
- }
2849
- const payment = await this.paymentRepository.create(Payment.toInstance({
2850
- createdAt: new Date(),
2851
- updatedAt: new Date(),
2852
- userId: checkout.user.id,
2853
- checkoutId: checkout.id,
2854
- totalPrice: checkout.totalPrice,
2855
- paymentProvider: 'adyen',
2856
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2857
- }));
2858
- return payment;
2859
- }
2860
- catch (error) {
2861
- throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
2862
- checkoutId: checkout.id,
2863
- userEmail: checkout.user.email,
2864
- info: error.message,
2865
- });
2866
- }
2867
- }
2868
- createCardPayment(checkout, card) {
2869
- return {
2870
- amount: {
2871
- currency: 'BRL',
2872
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2873
- },
2874
- paymentMethod: {
2875
- type: 'scheme',
2876
- storedPaymentMethodId: card.cardId,
2877
- },
2878
- reference: checkout.id,
2879
- shopperInteraction: 'Ecommerce',
2880
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2881
- shopperReference: checkout.user.id,
2882
- recurringProcessingModel: 'CardOnFile',
2883
- returnUrl: this.credentials.URL_POSTBACK,
2884
- installments: {
2885
- value: card.installments,
2886
- },
2887
- };
2422
+ class InvalidArgumentError extends CustomError {
2423
+ constructor(message) {
2424
+ super(message);
2888
2425
  }
2889
- addCard() {
2890
- throw new Error('Method not implemented.');
2426
+ }
2427
+
2428
+ class RequiredArgumentError extends CustomError {
2429
+ constructor(args) {
2430
+ super(`Required arguments: ${args.join(', ')}`);
2431
+ this.args = args;
2432
+ this.arguments = args;
2891
2433
  }
2892
- getCardByToken(token) {
2893
- throw new Error('Method not implemented.');
2434
+ }
2435
+
2436
+ class NotFoundError extends CustomError {
2437
+ constructor(message) {
2438
+ super(message);
2894
2439
  }
2895
- createTransaction(info) {
2896
- throw new Error('Method not implemented.');
2440
+ }
2441
+
2442
+ class DuplicatedResultsError extends CustomError {
2443
+ constructor(message) {
2444
+ super(message);
2897
2445
  }
2898
2446
  }
2899
2447
 
@@ -3795,17 +3343,6 @@ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore
3795
3343
  }
3796
3344
  }
3797
3345
 
3798
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3799
- constructor({ firestore, interceptors }) {
3800
- super({
3801
- firestore,
3802
- collectionName: 'sequences',
3803
- model: Sequence,
3804
- interceptors,
3805
- });
3806
- }
3807
- }
3808
-
3809
3346
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3810
3347
  constructor({ firestore, interceptors }) {
3811
3348
  super({
@@ -4046,7 +3583,11 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
4046
3583
  limiteRange,
4047
3584
  type,
4048
3585
  card,
4049
- checkout,
3586
+ checkout: {
3587
+ id: checkout.id,
3588
+ shop: checkout.shop,
3589
+ total: checkout.totalPrice,
3590
+ },
4050
3591
  date: new Date(),
4051
3592
  }));
4052
3593
  }
@@ -6017,6 +5558,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6017
5558
  fields: ['id', 'name', 'reference', 'slug'],
6018
5559
  },
6019
5560
  },
5561
+ 'group',
5562
+ 'validity',
6020
5563
  ];
6021
5564
  this.fields = [
6022
5565
  ...commonFields,
@@ -6589,6 +6132,8 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
6589
6132
  type: HasuraGraphQLColumnType.Jsonb,
6590
6133
  },
6591
6134
  },
6135
+ 'group',
6136
+ 'validity',
6592
6137
  ],
6593
6138
  });
6594
6139
  }
@@ -6945,310 +6490,6 @@ __decorate([
6945
6490
  __metadata("design:returntype", Promise)
6946
6491
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
6947
6492
 
6948
- class PagarmeBankSlipAxiosAdapter {
6949
- constructor(credentials, paymentRepository) {
6950
- this.credentials = credentials;
6951
- this.paymentRepository = paymentRepository;
6952
- }
6953
- async pay(checkout) {
6954
- try {
6955
- const result = await axios({
6956
- method: 'POST',
6957
- url: `${this.credentials.URL}/transactions`,
6958
- data: this.createBoletoPayment(checkout),
6959
- });
6960
- if (result.data.status !== PagarmePaymentStatus['Em processamento']) {
6961
- return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
6962
- checkoutId: checkout.id,
6963
- userEmail: checkout.user.email,
6964
- info: result.data,
6965
- }));
6966
- }
6967
- const payment = await this.paymentRepository.create(Payment.toInstance({
6968
- createdAt: new Date(),
6969
- updatedAt: new Date(),
6970
- userId: checkout.user.id,
6971
- checkoutId: checkout.id,
6972
- totalPrice: checkout.totalPrice,
6973
- paymentProvider: 'pagarMe',
6974
- transaction: result.data,
6975
- }));
6976
- return payment;
6977
- }
6978
- catch (error) {
6979
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
6980
- checkoutId: checkout.id,
6981
- userEmail: checkout.user.email,
6982
- info: error.response.data,
6983
- });
6984
- }
6985
- }
6986
- async getBoletoTransaction(paymentId) {
6987
- try {
6988
- const { data } = await axios({
6989
- method: 'GET',
6990
- url: `${this.credentials.URL}/transactions/${paymentId}`,
6991
- data: {
6992
- api_key: this.credentials.API_KEY,
6993
- },
6994
- });
6995
- return data;
6996
- }
6997
- catch (error) {
6998
- throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
6999
- paymentId,
7000
- info: error.response.data,
7001
- });
7002
- }
7003
- }
7004
- createBoletoPayment(checkout) {
7005
- return {
7006
- api_key: this.credentials.API_KEY,
7007
- amount: Math.floor(checkout.totalPrice * 100),
7008
- boleto_rules: ['strict_expiration_date'],
7009
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
7010
- boleto_expiration_date: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
7011
- payment_method: 'boleto',
7012
- postback_url: this.credentials.URL_POSTBACK,
7013
- customer: {
7014
- external_id: checkout.user.id,
7015
- type: 'individual',
7016
- country: 'br',
7017
- name: checkout.user.displayName,
7018
- documents: [
7019
- {
7020
- type: 'cpf',
7021
- number: checkout.user.cpf,
7022
- },
7023
- ],
7024
- },
7025
- };
7026
- }
7027
- }
7028
-
7029
- class PagarmeCardAxiosAdapter {
7030
- constructor(credentials, paymentRepository, orderBlockedRepository) {
7031
- this.credentials = credentials;
7032
- this.paymentRepository = paymentRepository;
7033
- this.orderBlockedRepository = orderBlockedRepository;
7034
- }
7035
- async pay(checkout, card) {
7036
- var _a;
7037
- try {
7038
- const result = await axios({
7039
- method: 'POST',
7040
- url: `${this.credentials.URL}/transactions`,
7041
- data: this.createCardPayment(checkout, card),
7042
- });
7043
- if (result.data.status !== PagarmePaymentStatus.Pago) {
7044
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
7045
- return Promise.reject(new PaymentError(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`, {
7046
- checkoutId: checkout.id,
7047
- userEmail: checkout.user.email,
7048
- info: result.data,
7049
- }));
7050
- }
7051
- const payment = await this.paymentRepository.create(Payment.toInstance({
7052
- createdAt: new Date(),
7053
- updatedAt: new Date(),
7054
- userId: checkout.user.id,
7055
- checkoutId: checkout.id,
7056
- totalPrice: checkout.totalPrice,
7057
- paymentProvider: PaymentProviders.PAGARME,
7058
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
7059
- }));
7060
- return payment;
7061
- }
7062
- catch (error) {
7063
- throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
7064
- checkoutId: checkout.id,
7065
- userEmail: checkout.user.email,
7066
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
7067
- });
7068
- }
7069
- }
7070
- async addCard(card) {
7071
- try {
7072
- const { data } = await axios({
7073
- method: 'POST',
7074
- url: `${this.credentials.URL}/cards`,
7075
- data: {
7076
- api_key: this.credentials.API_KEY,
7077
- card_number: card.number,
7078
- card_expiration_date: card.expirationDate.replace('/', ''),
7079
- card_holder_name: card.name,
7080
- card_cvv: card.cvv,
7081
- },
7082
- });
7083
- return data;
7084
- }
7085
- catch (error) {
7086
- throw new BusinessError('Houve uma falha adicionar o cartão', {
7087
- info: error.response.data,
7088
- });
7089
- }
7090
- }
7091
- async createCardHash(bu) {
7092
- const key = bu === BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
7093
- try {
7094
- const { data } = await axios({
7095
- method: 'GET',
7096
- headers: {
7097
- 'content-type': 'application/json',
7098
- },
7099
- url: `${this.credentials.URL}/transactions/card_hash_key`,
7100
- data: JSON.stringify({
7101
- api_key: key,
7102
- }),
7103
- });
7104
- return data;
7105
- }
7106
- catch (error) {
7107
- console.log('createCardHash axios error', error);
7108
- throw new BusinessError('Houve uma falha gerar o hash', {
7109
- info: error.response.data,
7110
- });
7111
- }
7112
- }
7113
- async getCardByToken(id) {
7114
- try {
7115
- const { data } = await axios({
7116
- method: 'POST',
7117
- url: `${this.credentials.URL}/cards/${id}`,
7118
- data: {
7119
- api_key: this.credentials.API_KEY,
7120
- },
7121
- });
7122
- return data;
7123
- }
7124
- catch (error) {
7125
- throw new BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
7126
- info: error.response.data,
7127
- });
7128
- }
7129
- }
7130
- async createTransaction(info) {
7131
- try {
7132
- const { data } = await axios({
7133
- method: 'POST',
7134
- url: `${this.credentials.URL}/transactions`,
7135
- data: Object.assign(Object.assign({}, info), { api_key: this.credentials.API_KEY }),
7136
- });
7137
- return data;
7138
- }
7139
- catch (error) {
7140
- throw new BusinessError('Houve uma falha ao criar a transação', {
7141
- info: error.response.data,
7142
- });
7143
- }
7144
- }
7145
- createCardPayment(checkout, card) {
7146
- var _a, _b, _c, _d, _e, _f;
7147
- return {
7148
- api_key: this.credentials.API_KEY,
7149
- amount: Math.floor(checkout.totalPrice * 100),
7150
- card_id: card.cardId,
7151
- payment_method: 'credit_card',
7152
- installments: card.installments,
7153
- soft_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : "Men's Market",
7154
- customer: {
7155
- external_id: checkout.user.id,
7156
- name: checkout.user.displayName,
7157
- type: 'individual',
7158
- country: 'br',
7159
- email: checkout.user.email,
7160
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
7161
- documents: [
7162
- {
7163
- type: 'cpf',
7164
- number: checkout.user.cpf,
7165
- },
7166
- ],
7167
- },
7168
- billing: {
7169
- name: checkout.user.displayName,
7170
- address: {
7171
- country: 'br',
7172
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
7173
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
7174
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
7175
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
7176
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
7177
- zipcode: checkout.billingAddress
7178
- ? checkout.billingAddress.zip.replace('-', '')
7179
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
7180
- },
7181
- },
7182
- items: checkout.lineItems.map((item) => {
7183
- return {
7184
- id: item.id,
7185
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
7186
- unit_price: Math.floor(item.pricePaid * 100),
7187
- quantity: item.quantity,
7188
- tangible: true,
7189
- };
7190
- }),
7191
- };
7192
- }
7193
- }
7194
-
7195
- class PagarmePixAxiosAdapter {
7196
- constructor(credentials, paymentRepository) {
7197
- this.credentials = credentials;
7198
- this.paymentRepository = paymentRepository;
7199
- }
7200
- async pay(checkout) {
7201
- var _a;
7202
- try {
7203
- const result = await axios({
7204
- method: 'POST',
7205
- url: `${this.credentials.URL}/transactions`,
7206
- data: this.createPixPayment(checkout),
7207
- });
7208
- const payment = await this.paymentRepository.create(Payment.toInstance({
7209
- createdAt: new Date(),
7210
- updatedAt: new Date(),
7211
- userId: checkout.user.id,
7212
- checkoutId: checkout.id,
7213
- totalPrice: checkout.totalPrice,
7214
- paymentProvider: 'pagarMe',
7215
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
7216
- }));
7217
- return payment;
7218
- }
7219
- catch (error) {
7220
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
7221
- checkoutId: checkout.id,
7222
- userEmail: checkout.user.email,
7223
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
7224
- });
7225
- }
7226
- }
7227
- createPixPayment(checkout) {
7228
- return {
7229
- payment_method: 'pix',
7230
- amount: Math.floor(checkout.totalPrice * 100),
7231
- api_key: this.credentials.API_KEY,
7232
- postback_url: this.credentials.URL_POSTBACK,
7233
- pix_expiration_date: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
7234
- customer: {
7235
- external_id: checkout.user.id,
7236
- type: 'individual',
7237
- country: 'br',
7238
- name: checkout.user.displayName,
7239
- email: checkout.user.email.trim(),
7240
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
7241
- documents: [
7242
- {
7243
- type: 'cpf',
7244
- number: checkout.user.cpf,
7245
- },
7246
- ],
7247
- },
7248
- };
7249
- }
7250
- }
7251
-
7252
6493
  class VertexAxiosAdapter {
7253
6494
  constructor(config) {
7254
6495
  this.config = config;
@@ -7402,4 +6643,4 @@ class ProductsVertexSearch {
7402
6643
  }
7403
6644
  }
7404
6645
 
7405
- 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, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, 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, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, 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, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6646
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, 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, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, 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, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };