@infrab4a/connect 4.21.3 → 4.22.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +887 -243
- package/index.esm.js +866 -248
- package/package.json +1 -1
- package/src/domain/catalog/models/types/index.d.ts +0 -1
- package/src/domain/catalog/repositories/product.repository.d.ts +1 -2
- package/src/domain/general/models/index.d.ts +1 -0
- package/src/domain/general/models/sequences.d.ts +9 -0
- package/src/domain/general/repositories/index.d.ts +1 -0
- package/src/domain/general/repositories/sequences.repository.d.ts +4 -0
- package/src/domain/shopping/enums/antifraud-providers.enum.d.ts +6 -0
- package/src/domain/shopping/enums/business-unit.enum.d.ts +4 -0
- package/src/domain/shopping/enums/index.d.ts +6 -0
- package/src/domain/shopping/enums/order-blocked.enum.d.ts +5 -0
- package/src/domain/shopping/enums/pagarme-payment-status.enum.d.ts +10 -0
- package/src/domain/shopping/enums/payment-methods.enum.d.ts +6 -0
- package/src/domain/shopping/enums/payment-providers.enum.d.ts +5 -0
- package/src/domain/shopping/factories/adyen-payment-method.factory.d.ts +9 -0
- package/src/domain/shopping/factories/antifraud-provider.factory.d.ts +15 -0
- package/src/domain/shopping/factories/base-payment-method.factory.d.ts +7 -0
- package/src/domain/shopping/factories/glampoints-payment-method.factory.d.ts +8 -0
- package/src/domain/shopping/factories/index.d.ts +5 -0
- package/src/domain/shopping/factories/pagarme-payment-method.factory.d.ts +11 -0
- package/src/domain/shopping/factories/payment-provider.factory.d.ts +15 -0
- package/src/domain/shopping/index.d.ts +4 -0
- package/src/domain/shopping/interfaces/antifraud-method-factory.interface.d.ts +11 -0
- package/src/domain/shopping/interfaces/antifraud-provider.interface.d.ts +5 -0
- package/src/domain/shopping/interfaces/index.d.ts +7 -0
- package/src/domain/shopping/interfaces/payment-method-factory.interface.d.ts +14 -0
- package/src/domain/shopping/interfaces/payment-provider-bank-slip.interface.d.ts +7 -0
- package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +13 -0
- package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +9 -0
- package/src/domain/shopping/interfaces/payment-provider-pix.interface.d.ts +5 -0
- package/src/domain/shopping/models/index.d.ts +1 -0
- package/src/domain/shopping/models/order-blocked.d.ts +4 -6
- package/src/domain/shopping/models/order.d.ts +2 -2
- package/src/domain/shopping/models/payment-transaction.d.ts +67 -0
- package/src/domain/shopping/models/payment.d.ts +10 -63
- package/src/domain/shopping/models/types/index.d.ts +4 -4
- package/src/domain/shopping/services/antifraud-bankslip.service.d.ts +9 -0
- package/src/domain/shopping/services/antifraud-card.service.d.ts +18 -0
- package/src/domain/shopping/services/antifraud-glampoints.service.d.ts +6 -0
- package/src/domain/shopping/services/antifraud-pix.service.d.ts +6 -0
- package/src/domain/shopping/services/glampoints-payment.service.d.ts +13 -0
- package/src/domain/shopping/services/index.d.ts +5 -0
- package/src/domain/shopping/types/adyen-card.type.d.ts +3 -0
- package/src/domain/shopping/types/adyen-credentials.type.d.ts +6 -0
- package/src/domain/shopping/types/antifraud-provider.type.d.ts +2 -0
- package/src/domain/shopping/types/base-card.type.d.ts +2 -0
- package/src/domain/shopping/types/card-info.type.d.ts +8 -0
- package/src/domain/shopping/types/glam-credentials.type.d.ts +6 -0
- package/src/domain/shopping/types/index.d.ts +9 -0
- package/src/domain/shopping/types/pagarme-card-manual-hash.type.d.ts +6 -0
- package/src/domain/shopping/types/pagarme-card.type.d.ts +16 -0
- package/src/domain/shopping/types/pagarme-credentials.type.d.ts +7 -0
- package/src/domain/shopping/types/payment-card-info.type.d.ts +3 -0
- package/src/domain/shopping/types/payment-method.type.d.ts +2 -0
- package/src/domain/shopping/types/payment-provider.type.d.ts +2 -0
- package/src/errors/business.error.d.ts +7 -0
- package/src/errors/fraud-validation.error.d.ts +7 -0
- package/src/errors/index.d.ts +8 -2
- package/src/errors/payment.error.d.ts +7 -0
- package/src/errors/stock-limit.error.d.ts +5 -0
- package/src/errors/stock-out.error.d.ts +5 -0
- package/src/errors/types/checkout-additional-data-erro.type.d.ts +6 -0
- package/src/errors/types/index.d.ts +2 -0
- package/src/errors/types/pagarme-erros.type.d.ts +9 -0
- package/src/infra/adyen/adapters/adyen-card-payment-axios.adapter.d.ts +17 -0
- package/src/infra/adyen/adapters/index.d.ts +1 -0
- package/src/infra/adyen/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +7 -0
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -1
- package/src/infra/firebase/firestore/repositories/shopping/{order-blocked-firestore.repository.ts.d.ts → order-blocked-firestore.repository.d.ts} +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +1 -2
- package/src/infra/index.d.ts +2 -0
- package/src/infra/pagarme/adapters/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/pagarme-bank-slip-payment-axios.adapter.d.ts +12 -0
- package/src/infra/pagarme/adapters/pagarme-card-payment-axios.adapter.d.ts +17 -0
- package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/index.d.ts +1 -0
- package/src/utils/index.d.ts +2 -2
- package/src/domain/catalog/models/types/product-variant-report.type.d.ts +0 -46
package/index.cjs.js
CHANGED
|
@@ -19,6 +19,90 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
|
|
20
20
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
21
21
|
|
|
22
|
+
exports.AntifraudProviders = void 0;
|
|
23
|
+
(function (AntifraudProviders) {
|
|
24
|
+
AntifraudProviders["BANKSLIP"] = "bankSlip";
|
|
25
|
+
AntifraudProviders["CARD"] = "card";
|
|
26
|
+
AntifraudProviders["PIX"] = "pix";
|
|
27
|
+
AntifraudProviders["POINTS"] = "glampoints";
|
|
28
|
+
})(exports.AntifraudProviders || (exports.AntifraudProviders = {}));
|
|
29
|
+
|
|
30
|
+
exports.BusinessUnitEnum = void 0;
|
|
31
|
+
(function (BusinessUnitEnum) {
|
|
32
|
+
BusinessUnitEnum[BusinessUnitEnum["SUBSCRIPTION"] = 1] = "SUBSCRIPTION";
|
|
33
|
+
BusinessUnitEnum[BusinessUnitEnum["SHOP"] = 2] = "SHOP";
|
|
34
|
+
})(exports.BusinessUnitEnum || (exports.BusinessUnitEnum = {}));
|
|
35
|
+
|
|
36
|
+
exports.OrderBlockedType = void 0;
|
|
37
|
+
(function (OrderBlockedType) {
|
|
38
|
+
OrderBlockedType["Checkout"] = "Checkout";
|
|
39
|
+
OrderBlockedType["Card"] = "Card";
|
|
40
|
+
OrderBlockedType["Boleto"] = "Boleto";
|
|
41
|
+
})(exports.OrderBlockedType || (exports.OrderBlockedType = {}));
|
|
42
|
+
|
|
43
|
+
exports.PagarmePaymentStatus = void 0;
|
|
44
|
+
(function (PagarmePaymentStatus) {
|
|
45
|
+
PagarmePaymentStatus["Em processamento"] = "processing";
|
|
46
|
+
PagarmePaymentStatus["Autorizada"] = "authorized";
|
|
47
|
+
PagarmePaymentStatus["Pago"] = "paid";
|
|
48
|
+
PagarmePaymentStatus["Estornada"] = "refunded";
|
|
49
|
+
PagarmePaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
50
|
+
PagarmePaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
51
|
+
PagarmePaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
|
|
52
|
+
PagarmePaymentStatus["Chargedback"] = "chargedback";
|
|
53
|
+
})(exports.PagarmePaymentStatus || (exports.PagarmePaymentStatus = {}));
|
|
54
|
+
|
|
55
|
+
exports.PaymentMethods = void 0;
|
|
56
|
+
(function (PaymentMethods) {
|
|
57
|
+
PaymentMethods["CARD"] = "card";
|
|
58
|
+
PaymentMethods["BANKSLIP"] = "bankSlip";
|
|
59
|
+
PaymentMethods["PIX"] = "pix";
|
|
60
|
+
PaymentMethods["POINTS"] = "glampoints";
|
|
61
|
+
})(exports.PaymentMethods || (exports.PaymentMethods = {}));
|
|
62
|
+
|
|
63
|
+
exports.PaymentProviders = void 0;
|
|
64
|
+
(function (PaymentProviders) {
|
|
65
|
+
PaymentProviders["PAGARME"] = "pagarMe";
|
|
66
|
+
PaymentProviders["ADYEN"] = "adyen";
|
|
67
|
+
PaymentProviders["GLAMPOINTS"] = "glampoints";
|
|
68
|
+
})(exports.PaymentProviders || (exports.PaymentProviders = {}));
|
|
69
|
+
|
|
70
|
+
class BasePaymentMethodFactory {
|
|
71
|
+
constructor(methods) {
|
|
72
|
+
this.methods = methods;
|
|
73
|
+
}
|
|
74
|
+
build(method) {
|
|
75
|
+
return this.methods[method];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class AntifraudProviderFactory {
|
|
83
|
+
constructor(antifraudProviders) {
|
|
84
|
+
this.antifraudProviders = antifraudProviders;
|
|
85
|
+
}
|
|
86
|
+
build(provider) {
|
|
87
|
+
return this.antifraudProviders[provider];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
class PaymentProviderFactory {
|
|
98
|
+
constructor(paymentProviders) {
|
|
99
|
+
this.paymentProviders = paymentProviders;
|
|
100
|
+
}
|
|
101
|
+
build(provider) {
|
|
102
|
+
return this.paymentProviders[provider];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
22
106
|
class BaseModel {
|
|
23
107
|
get identifier() {
|
|
24
108
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
@@ -579,175 +663,18 @@ exports.Status = void 0;
|
|
|
579
663
|
Status["CANCELLED"] = "Cancelado";
|
|
580
664
|
})(exports.Status || (exports.Status = {}));
|
|
581
665
|
|
|
666
|
+
class PaymentTransaction extends BaseModel {
|
|
667
|
+
}
|
|
668
|
+
|
|
582
669
|
class Payment extends BaseModel {
|
|
583
670
|
static get identifiersFields() {
|
|
584
671
|
return ['id'];
|
|
585
672
|
}
|
|
586
673
|
}
|
|
587
674
|
tslib.__decorate([
|
|
588
|
-
classTransformer.
|
|
589
|
-
tslib.__metadata("design:type",
|
|
590
|
-
], Payment.prototype, "
|
|
591
|
-
tslib.__decorate([
|
|
592
|
-
classTransformer.Expose({ name: 'status_reason' }),
|
|
593
|
-
tslib.__metadata("design:type", String)
|
|
594
|
-
], Payment.prototype, "statusReason", void 0);
|
|
595
|
-
tslib.__decorate([
|
|
596
|
-
classTransformer.Expose({ name: 'acquirer_response_code' }),
|
|
597
|
-
tslib.__metadata("design:type", String)
|
|
598
|
-
], Payment.prototype, "acquirerResponseCode", void 0);
|
|
599
|
-
tslib.__decorate([
|
|
600
|
-
classTransformer.Expose({ name: 'acquirer_name' }),
|
|
601
|
-
tslib.__metadata("design:type", String)
|
|
602
|
-
], Payment.prototype, "acquirerName", void 0);
|
|
603
|
-
tslib.__decorate([
|
|
604
|
-
classTransformer.Expose({ name: 'acquirer_id' }),
|
|
605
|
-
tslib.__metadata("design:type", String)
|
|
606
|
-
], Payment.prototype, "acquirerId", void 0);
|
|
607
|
-
tslib.__decorate([
|
|
608
|
-
classTransformer.Expose({ name: 'authorization_code' }),
|
|
609
|
-
tslib.__metadata("design:type", String)
|
|
610
|
-
], Payment.prototype, "authorizationCode", void 0);
|
|
611
|
-
tslib.__decorate([
|
|
612
|
-
classTransformer.Expose({ name: 'soft_descriptor' }),
|
|
613
|
-
tslib.__metadata("design:type", String)
|
|
614
|
-
], Payment.prototype, "softDescriptor", void 0);
|
|
615
|
-
tslib.__decorate([
|
|
616
|
-
classTransformer.Expose({ name: 'date_created' }),
|
|
617
|
-
tslib.__metadata("design:type", String)
|
|
618
|
-
], Payment.prototype, "dateCreated", void 0);
|
|
619
|
-
tslib.__decorate([
|
|
620
|
-
classTransformer.Expose({ name: 'date_updated' }),
|
|
621
|
-
tslib.__metadata("design:type", String)
|
|
622
|
-
], Payment.prototype, "dateUpdated", void 0);
|
|
623
|
-
tslib.__decorate([
|
|
624
|
-
classTransformer.Expose({ name: 'authorized_amount' }),
|
|
625
|
-
tslib.__metadata("design:type", Number)
|
|
626
|
-
], Payment.prototype, "authorizedAmount", void 0);
|
|
627
|
-
tslib.__decorate([
|
|
628
|
-
classTransformer.Expose({ name: 'paid_amount' }),
|
|
629
|
-
tslib.__metadata("design:type", Number)
|
|
630
|
-
], Payment.prototype, "paidAmount", void 0);
|
|
631
|
-
tslib.__decorate([
|
|
632
|
-
classTransformer.Expose({ name: 'paid_at' }),
|
|
633
|
-
tslib.__metadata("design:type", String)
|
|
634
|
-
], Payment.prototype, "paidAt", void 0);
|
|
635
|
-
tslib.__decorate([
|
|
636
|
-
classTransformer.Expose({ name: 'refunded_amount' }),
|
|
637
|
-
tslib.__metadata("design:type", Number)
|
|
638
|
-
], Payment.prototype, "refundedAmount", void 0);
|
|
639
|
-
tslib.__decorate([
|
|
640
|
-
classTransformer.Expose({ name: 'card_holder_name' }),
|
|
641
|
-
tslib.__metadata("design:type", String)
|
|
642
|
-
], Payment.prototype, "cardHolderName", void 0);
|
|
643
|
-
tslib.__decorate([
|
|
644
|
-
classTransformer.Expose({ name: 'card_last_digits' }),
|
|
645
|
-
tslib.__metadata("design:type", String)
|
|
646
|
-
], Payment.prototype, "cardLastDigits", void 0);
|
|
647
|
-
tslib.__decorate([
|
|
648
|
-
classTransformer.Expose({ name: 'card_first_digits' }),
|
|
649
|
-
tslib.__metadata("design:type", String)
|
|
650
|
-
], Payment.prototype, "cardFirstDigits", void 0);
|
|
651
|
-
tslib.__decorate([
|
|
652
|
-
classTransformer.Expose({ name: 'card_brand' }),
|
|
653
|
-
tslib.__metadata("design:type", String)
|
|
654
|
-
], Payment.prototype, "cardBrand", void 0);
|
|
655
|
-
tslib.__decorate([
|
|
656
|
-
classTransformer.Expose({ name: 'card_pin_mode' }),
|
|
657
|
-
tslib.__metadata("design:type", String)
|
|
658
|
-
], Payment.prototype, "cardPinMode", void 0);
|
|
659
|
-
tslib.__decorate([
|
|
660
|
-
classTransformer.Expose({ name: 'card_magstripe_fallback' }),
|
|
661
|
-
tslib.__metadata("design:type", Boolean)
|
|
662
|
-
], Payment.prototype, "cardMagstripeFallback", void 0);
|
|
663
|
-
tslib.__decorate([
|
|
664
|
-
classTransformer.Expose({ name: 'cvm_pin' }),
|
|
665
|
-
tslib.__metadata("design:type", Boolean)
|
|
666
|
-
], Payment.prototype, "cvmPin", void 0);
|
|
667
|
-
tslib.__decorate([
|
|
668
|
-
classTransformer.Expose({ name: 'postback_url' }),
|
|
669
|
-
tslib.__metadata("design:type", String)
|
|
670
|
-
], Payment.prototype, "postbackUrl", void 0);
|
|
671
|
-
tslib.__decorate([
|
|
672
|
-
classTransformer.Expose({ name: 'payment_method' }),
|
|
673
|
-
tslib.__metadata("design:type", String)
|
|
674
|
-
], Payment.prototype, "paymentMethod", void 0);
|
|
675
|
-
tslib.__decorate([
|
|
676
|
-
classTransformer.Expose({ name: 'capture_method' }),
|
|
677
|
-
tslib.__metadata("design:type", String)
|
|
678
|
-
], Payment.prototype, "captureMethod", void 0);
|
|
679
|
-
tslib.__decorate([
|
|
680
|
-
classTransformer.Expose({ name: 'antifraud_score' }),
|
|
681
|
-
tslib.__metadata("design:type", String)
|
|
682
|
-
], Payment.prototype, "antifraudScore", void 0);
|
|
683
|
-
tslib.__decorate([
|
|
684
|
-
classTransformer.Expose({ name: 'boleto_url' }),
|
|
685
|
-
tslib.__metadata("design:type", String)
|
|
686
|
-
], Payment.prototype, "boletoUrl", void 0);
|
|
687
|
-
tslib.__decorate([
|
|
688
|
-
classTransformer.Expose({ name: 'boleto_barcode' }),
|
|
689
|
-
tslib.__metadata("design:type", String)
|
|
690
|
-
], Payment.prototype, "boletoBarcode", void 0);
|
|
691
|
-
tslib.__decorate([
|
|
692
|
-
classTransformer.Expose({ name: 'boleto_expiration_date' }),
|
|
693
|
-
tslib.__metadata("design:type", String)
|
|
694
|
-
], Payment.prototype, "boletoExpirationDate", void 0);
|
|
695
|
-
tslib.__decorate([
|
|
696
|
-
classTransformer.Expose({ name: 'subscription_id' }),
|
|
697
|
-
tslib.__metadata("design:type", String)
|
|
698
|
-
], Payment.prototype, "subscriptionId", void 0);
|
|
699
|
-
tslib.__decorate([
|
|
700
|
-
classTransformer.Expose({ name: 'split_rules' }),
|
|
701
|
-
tslib.__metadata("design:type", String)
|
|
702
|
-
], Payment.prototype, "splitRules", void 0);
|
|
703
|
-
tslib.__decorate([
|
|
704
|
-
classTransformer.Expose({ name: 'antifraud_metadata' }),
|
|
705
|
-
tslib.__metadata("design:type", Object)
|
|
706
|
-
], Payment.prototype, "antifraudMetadata", void 0);
|
|
707
|
-
tslib.__decorate([
|
|
708
|
-
classTransformer.Expose({ name: 'reference_key' }),
|
|
709
|
-
tslib.__metadata("design:type", String)
|
|
710
|
-
], Payment.prototype, "referenceKey", void 0);
|
|
711
|
-
tslib.__decorate([
|
|
712
|
-
classTransformer.Expose({ name: 'local_transaction_id' }),
|
|
713
|
-
tslib.__metadata("design:type", String)
|
|
714
|
-
], Payment.prototype, "localTransactionId", void 0);
|
|
715
|
-
tslib.__decorate([
|
|
716
|
-
classTransformer.Expose({ name: 'local_time' }),
|
|
717
|
-
tslib.__metadata("design:type", String)
|
|
718
|
-
], Payment.prototype, "localTime", void 0);
|
|
719
|
-
tslib.__decorate([
|
|
720
|
-
classTransformer.Expose({ name: 'fraud_covered' }),
|
|
721
|
-
tslib.__metadata("design:type", Boolean)
|
|
722
|
-
], Payment.prototype, "fraudCovered", void 0);
|
|
723
|
-
tslib.__decorate([
|
|
724
|
-
classTransformer.Expose({ name: 'fraud_reimbursed' }),
|
|
725
|
-
tslib.__metadata("design:type", String)
|
|
726
|
-
], Payment.prototype, "fraudReimbursed", void 0);
|
|
727
|
-
tslib.__decorate([
|
|
728
|
-
classTransformer.Expose({ name: 'order_id' }),
|
|
729
|
-
tslib.__metadata("design:type", String)
|
|
730
|
-
], Payment.prototype, "orderId", void 0);
|
|
731
|
-
tslib.__decorate([
|
|
732
|
-
classTransformer.Expose({ name: 'risk_level' }),
|
|
733
|
-
tslib.__metadata("design:type", String)
|
|
734
|
-
], Payment.prototype, "riskLevel", void 0);
|
|
735
|
-
tslib.__decorate([
|
|
736
|
-
classTransformer.Expose({ name: 'receipt_url' }),
|
|
737
|
-
tslib.__metadata("design:type", String)
|
|
738
|
-
], Payment.prototype, "receiptUrl", void 0);
|
|
739
|
-
tslib.__decorate([
|
|
740
|
-
classTransformer.Expose({ name: 'private_label' }),
|
|
741
|
-
tslib.__metadata("design:type", String)
|
|
742
|
-
], Payment.prototype, "privateLabel", void 0);
|
|
743
|
-
tslib.__decorate([
|
|
744
|
-
classTransformer.Expose({ name: 'pix_qr_code' }),
|
|
745
|
-
tslib.__metadata("design:type", String)
|
|
746
|
-
], Payment.prototype, "pixQrCode", void 0);
|
|
747
|
-
tslib.__decorate([
|
|
748
|
-
classTransformer.Expose({ name: 'pix_expiration_date' }),
|
|
749
|
-
tslib.__metadata("design:type", String)
|
|
750
|
-
], Payment.prototype, "pixExpirationDate", void 0);
|
|
675
|
+
classTransformer.Type(() => PaymentTransaction),
|
|
676
|
+
tslib.__metadata("design:type", PaymentTransaction)
|
|
677
|
+
], Payment.prototype, "transaction", void 0);
|
|
751
678
|
|
|
752
679
|
class SubscriptionPayment extends BaseModel {
|
|
753
680
|
static get identifiersFields() {
|
|
@@ -2249,8 +2176,8 @@ exports.OrderStatus = void 0;
|
|
|
2249
2176
|
class Order extends Checkout {
|
|
2250
2177
|
}
|
|
2251
2178
|
tslib.__decorate([
|
|
2252
|
-
classTransformer.Type(() =>
|
|
2253
|
-
tslib.__metadata("design:type",
|
|
2179
|
+
classTransformer.Type(() => PaymentTransaction),
|
|
2180
|
+
tslib.__metadata("design:type", PaymentTransaction)
|
|
2254
2181
|
], Order.prototype, "payment", void 0);
|
|
2255
2182
|
|
|
2256
2183
|
class OrderBlocked extends BaseModel {
|
|
@@ -2281,6 +2208,375 @@ tslib.__decorate([
|
|
|
2281
2208
|
tslib.__metadata("design:type", Coupon)
|
|
2282
2209
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
2283
2210
|
|
|
2211
|
+
class BusinessError extends tsCustomError.CustomError {
|
|
2212
|
+
constructor(message, additionalData, type = '') {
|
|
2213
|
+
super(message);
|
|
2214
|
+
this.additionalData = additionalData;
|
|
2215
|
+
this.type = type;
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
class DuplicatedResultsError extends tsCustomError.CustomError {
|
|
2220
|
+
constructor(message) {
|
|
2221
|
+
super(message);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
class FraudValidationError extends tsCustomError.CustomError {
|
|
2226
|
+
constructor(message, additionalData) {
|
|
2227
|
+
super(message);
|
|
2228
|
+
this.additionalData = additionalData;
|
|
2229
|
+
this.type = 'antifraud';
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
class InvalidArgumentError extends tsCustomError.CustomError {
|
|
2234
|
+
constructor(message) {
|
|
2235
|
+
super(message);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
class NotFoundError extends tsCustomError.CustomError {
|
|
2240
|
+
constructor(message) {
|
|
2241
|
+
super(message);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
class PaymentError extends tsCustomError.CustomError {
|
|
2246
|
+
constructor(message, additionalData) {
|
|
2247
|
+
super(message);
|
|
2248
|
+
this.additionalData = additionalData;
|
|
2249
|
+
this.type = 'payment';
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
class RequiredArgumentError extends tsCustomError.CustomError {
|
|
2254
|
+
constructor(args) {
|
|
2255
|
+
super(`Required arguments: ${args.join(', ')}`);
|
|
2256
|
+
this.args = args;
|
|
2257
|
+
this.arguments = args;
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
class StockLimitError extends BusinessError {
|
|
2262
|
+
constructor(message, additionalData) {
|
|
2263
|
+
super(message, additionalData);
|
|
2264
|
+
this.type = 'stock-limit';
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
class StockOutError extends BusinessError {
|
|
2269
|
+
constructor(message, additionalData) {
|
|
2270
|
+
super(message, additionalData);
|
|
2271
|
+
this.type = 'stock-out';
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
class AntifraudBankSlipService {
|
|
2276
|
+
constructor(orderBlockedRepository) {
|
|
2277
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
2278
|
+
this.MAX_ORDER_VALUE = 5000;
|
|
2279
|
+
}
|
|
2280
|
+
async validate(checkout) {
|
|
2281
|
+
var _a, _b;
|
|
2282
|
+
if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
|
|
2283
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
|
|
2284
|
+
throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
|
|
2285
|
+
checkoutId: checkout.id,
|
|
2286
|
+
userEmail: checkout.user.email,
|
|
2287
|
+
info: {
|
|
2288
|
+
isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
|
|
2289
|
+
subtotal: checkout.subTotalPrice,
|
|
2290
|
+
total: checkout.totalPrice,
|
|
2291
|
+
},
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
return true;
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
class AntifraudCardService {
|
|
2299
|
+
constructor(orderRepository, orderBlockedRepository) {
|
|
2300
|
+
this.orderRepository = orderRepository;
|
|
2301
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
2302
|
+
this.LIMIT_ORDERS_DAY = 2;
|
|
2303
|
+
this.LIMIT_ORDERS_WEEK = 7;
|
|
2304
|
+
this.LIMIT_BLOCKED_ORDERS_DAY = 5;
|
|
2305
|
+
}
|
|
2306
|
+
async validate(checkout, card) {
|
|
2307
|
+
var _a, _b;
|
|
2308
|
+
if (!(await this.verifyBlockedOrderAttempts(checkout, card)))
|
|
2309
|
+
throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
|
|
2310
|
+
checkoutId: checkout.id,
|
|
2311
|
+
userEmail: checkout.user.email,
|
|
2312
|
+
info: {
|
|
2313
|
+
isSubscriber: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber,
|
|
2314
|
+
subtotal: checkout.subTotalPrice,
|
|
2315
|
+
total: checkout.totalPrice,
|
|
2316
|
+
},
|
|
2317
|
+
});
|
|
2318
|
+
if (!(await this.verifyDayAndWeekOrders(checkout, card)))
|
|
2319
|
+
throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
|
|
2320
|
+
checkoutId: checkout.id,
|
|
2321
|
+
userEmail: checkout.user.email,
|
|
2322
|
+
info: {
|
|
2323
|
+
isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
|
|
2324
|
+
subtotal: checkout.subTotalPrice,
|
|
2325
|
+
total: checkout.totalPrice,
|
|
2326
|
+
},
|
|
2327
|
+
});
|
|
2328
|
+
return true;
|
|
2329
|
+
}
|
|
2330
|
+
async verifyBlockedOrderAttempts(checkout, card) {
|
|
2331
|
+
var _a, _b, _c, _d;
|
|
2332
|
+
const day = `${dateFns.format(new Date(), 'yyyy-MM-dd')}T00:00:00`;
|
|
2333
|
+
const endOfDay = `${dateFns.format(new Date(), 'yyyy-MM-dd')}T23:59:59`;
|
|
2334
|
+
const ordersBlockedWithCpf = await this.orderBlockedRepository
|
|
2335
|
+
.find({
|
|
2336
|
+
filters: {
|
|
2337
|
+
customer: { cpf: { operator: exports.Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
|
|
2338
|
+
['date']: [
|
|
2339
|
+
{ operator: exports.Where.GTE, value: new Date(day) },
|
|
2340
|
+
{ operator: exports.Where.LTE, value: new Date(endOfDay) },
|
|
2341
|
+
],
|
|
2342
|
+
},
|
|
2343
|
+
})
|
|
2344
|
+
.then((data) => data.data);
|
|
2345
|
+
const ordersBlockedWithEmail = await this.orderBlockedRepository
|
|
2346
|
+
.find({
|
|
2347
|
+
filters: {
|
|
2348
|
+
customer: { email: { operator: exports.Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
|
|
2349
|
+
['date']: [
|
|
2350
|
+
{ operator: exports.Where.GTE, value: new Date(day) },
|
|
2351
|
+
{ operator: exports.Where.LTE, value: new Date(endOfDay) },
|
|
2352
|
+
],
|
|
2353
|
+
},
|
|
2354
|
+
})
|
|
2355
|
+
.then((data) => data.data);
|
|
2356
|
+
const ordersBlockedWithCep = await this.orderBlockedRepository
|
|
2357
|
+
.find({
|
|
2358
|
+
filters: {
|
|
2359
|
+
customer: { shippingAddress: { zip: { operator: exports.Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
|
|
2360
|
+
['date']: [
|
|
2361
|
+
{ operator: exports.Where.GTE, value: new Date(day) },
|
|
2362
|
+
{ operator: exports.Where.LTE, value: new Date(endOfDay) },
|
|
2363
|
+
],
|
|
2364
|
+
},
|
|
2365
|
+
})
|
|
2366
|
+
.then((data) => data.data);
|
|
2367
|
+
const ordersBlockedWithPhone = await this.orderBlockedRepository
|
|
2368
|
+
.find({
|
|
2369
|
+
filters: {
|
|
2370
|
+
customer: { phoneNumber: { operator: exports.Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
|
|
2371
|
+
['date']: [
|
|
2372
|
+
{ operator: exports.Where.GTE, value: new Date(day) },
|
|
2373
|
+
{ operator: exports.Where.LTE, value: new Date(endOfDay) },
|
|
2374
|
+
],
|
|
2375
|
+
},
|
|
2376
|
+
})
|
|
2377
|
+
.then((data) => data.data);
|
|
2378
|
+
const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
|
|
2379
|
+
var _a;
|
|
2380
|
+
return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
|
|
2381
|
+
});
|
|
2382
|
+
const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
|
|
2383
|
+
var _a, _b;
|
|
2384
|
+
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);
|
|
2385
|
+
});
|
|
2386
|
+
const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
|
|
2387
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2388
|
+
return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
|
|
2389
|
+
e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
|
|
2390
|
+
((_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()));
|
|
2391
|
+
});
|
|
2392
|
+
const blockedAttempts = ordersBlockedWithCpf
|
|
2393
|
+
.concat(blockedUniqueEmails)
|
|
2394
|
+
.concat(blockedUniqueCeps)
|
|
2395
|
+
.concat(blockedUniquePhone);
|
|
2396
|
+
if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
|
|
2397
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
|
|
2398
|
+
return false;
|
|
2399
|
+
}
|
|
2400
|
+
return true;
|
|
2401
|
+
}
|
|
2402
|
+
async verifyDayAndWeekOrders(checkout, card) {
|
|
2403
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2404
|
+
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'));
|
|
2405
|
+
for (const key in ordersPerDay) {
|
|
2406
|
+
if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
|
|
2407
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
|
|
2408
|
+
return false;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
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'));
|
|
2412
|
+
for (const key in ordersPerWeek) {
|
|
2413
|
+
if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
|
|
2414
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
|
|
2415
|
+
return false;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return true;
|
|
2419
|
+
}
|
|
2420
|
+
async validateOrdersByRange(cpf, email, phone, zip, card, range) {
|
|
2421
|
+
const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
|
|
2422
|
+
const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
|
|
2423
|
+
const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
|
|
2424
|
+
const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
|
|
2425
|
+
return {
|
|
2426
|
+
cpf: ordersCpf,
|
|
2427
|
+
email: ordersByEmail,
|
|
2428
|
+
phone: ordersByPhone,
|
|
2429
|
+
zip: ordersByZip,
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
async countOrdersByField(property, field, value, range) {
|
|
2433
|
+
const filters = {
|
|
2434
|
+
[property]: {
|
|
2435
|
+
[field]: value,
|
|
2436
|
+
},
|
|
2437
|
+
['createdAt']: [
|
|
2438
|
+
{ operator: exports.Where.GTE, value: range.firstDate },
|
|
2439
|
+
{ operator: exports.Where.LTE, value: range.lastDate },
|
|
2440
|
+
],
|
|
2441
|
+
};
|
|
2442
|
+
const docs = await (await this.orderRepository.find({ filters })).count;
|
|
2443
|
+
return docs;
|
|
2444
|
+
}
|
|
2445
|
+
getDateRange(range = 'day') {
|
|
2446
|
+
switch (range) {
|
|
2447
|
+
case 'day':
|
|
2448
|
+
return {
|
|
2449
|
+
firstDate: dateFns.startOfDay(new Date()).getTime(),
|
|
2450
|
+
lastDate: dateFns.endOfDay(new Date()).getTime(),
|
|
2451
|
+
};
|
|
2452
|
+
case 'week':
|
|
2453
|
+
return {
|
|
2454
|
+
firstDate: dateFns.startOfDay(dateFns.subDays(new Date(), 7)).getTime(),
|
|
2455
|
+
lastDate: dateFns.endOfDay(new Date()).getTime(),
|
|
2456
|
+
};
|
|
2457
|
+
default:
|
|
2458
|
+
return {
|
|
2459
|
+
firstDate: dateFns.startOfDay(new Date()).getTime(),
|
|
2460
|
+
lastDate: dateFns.endOfDay(new Date()).getTime(),
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
class AntifraudGlampointsService {
|
|
2467
|
+
constructor() { }
|
|
2468
|
+
async validate(checkout) {
|
|
2469
|
+
return true;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
class AntifraudPixService {
|
|
2474
|
+
constructor() { }
|
|
2475
|
+
async validate(checkout) {
|
|
2476
|
+
return true;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
class GlampointsPaymentService {
|
|
2481
|
+
constructor(glamCredentials, paymentRepository) {
|
|
2482
|
+
this.glamCredentials = glamCredentials;
|
|
2483
|
+
this.paymentRepository = paymentRepository;
|
|
2484
|
+
}
|
|
2485
|
+
async pay(checkout) {
|
|
2486
|
+
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
2487
|
+
createdAt: new Date(),
|
|
2488
|
+
updatedAt: new Date(),
|
|
2489
|
+
userId: checkout.user.id,
|
|
2490
|
+
checkoutId: checkout.id,
|
|
2491
|
+
totalPrice: checkout.totalPrice,
|
|
2492
|
+
paymentProvider: 'glampoints',
|
|
2493
|
+
transaction: {
|
|
2494
|
+
amount: 0,
|
|
2495
|
+
acquirer_response_code: '0000',
|
|
2496
|
+
acquirer_name: 'glampoints',
|
|
2497
|
+
authorized_amount: 0,
|
|
2498
|
+
capture_method: 'ecommerce',
|
|
2499
|
+
installments: 1,
|
|
2500
|
+
cost: 0,
|
|
2501
|
+
paid_amount: 0,
|
|
2502
|
+
paid_at: new Date().toISOString(),
|
|
2503
|
+
payment_method: 'glampoints',
|
|
2504
|
+
referer: 'api_key',
|
|
2505
|
+
refunded_amount: 0,
|
|
2506
|
+
status: 'paid',
|
|
2507
|
+
status_reason: 'acquirer',
|
|
2508
|
+
date_created: new Date().toISOString(),
|
|
2509
|
+
},
|
|
2510
|
+
}));
|
|
2511
|
+
return payment;
|
|
2512
|
+
}
|
|
2513
|
+
async rewardByOrder(order, user) {
|
|
2514
|
+
var _a;
|
|
2515
|
+
try {
|
|
2516
|
+
const points = order.lineItems.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2517
|
+
const hasGlambeauty = (_a = order.lineItems) === null || _a === void 0 ? void 0 : _a.some((doc) => doc.brand && doc.brand.toUpperCase() === 'GLAM BEAUTY');
|
|
2518
|
+
const result = await axios__default["default"]({
|
|
2519
|
+
method: 'POST',
|
|
2520
|
+
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
2521
|
+
headers: {
|
|
2522
|
+
'Content-Type': 'application/json',
|
|
2523
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2524
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2525
|
+
},
|
|
2526
|
+
timeout: 60000,
|
|
2527
|
+
data: JSON.stringify({
|
|
2528
|
+
personId: user.id,
|
|
2529
|
+
rewardType: 50,
|
|
2530
|
+
referenceId: 0,
|
|
2531
|
+
referenceName: `Compra - ${points} produto(s)`,
|
|
2532
|
+
points,
|
|
2533
|
+
productId: '',
|
|
2534
|
+
token: this.glamCredentials.integrationToken,
|
|
2535
|
+
orderId: order.id,
|
|
2536
|
+
orderNumber: order.orderNumber,
|
|
2537
|
+
glambeauty: hasGlambeauty,
|
|
2538
|
+
}),
|
|
2539
|
+
});
|
|
2540
|
+
console.log('[rewards - rewardByOrder] reward success:', order.orderNumber, JSON.stringify(result.data));
|
|
2541
|
+
return result.data;
|
|
2542
|
+
}
|
|
2543
|
+
catch (error) {
|
|
2544
|
+
if (error instanceof axios.AxiosError)
|
|
2545
|
+
console.error('[rewards - rewardByOrder] reward request error', error.response.status, JSON.stringify(error.response.data.message), order.orderNumber);
|
|
2546
|
+
else
|
|
2547
|
+
console.log(JSON.stringify(error));
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
async negativateRewardByOrderId(order) {
|
|
2551
|
+
try {
|
|
2552
|
+
const result = await axios__default["default"]({
|
|
2553
|
+
method: 'POST',
|
|
2554
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2555
|
+
headers: {
|
|
2556
|
+
'Content-Type': 'application/json',
|
|
2557
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2558
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2559
|
+
},
|
|
2560
|
+
timeout: 60000,
|
|
2561
|
+
data: JSON.stringify({
|
|
2562
|
+
rewardType: 51,
|
|
2563
|
+
referenceName: `Pedido #${order.id} cancelado`,
|
|
2564
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2565
|
+
orderId: order.id,
|
|
2566
|
+
orderNumber: order.orderNumber,
|
|
2567
|
+
}),
|
|
2568
|
+
});
|
|
2569
|
+
return result;
|
|
2570
|
+
}
|
|
2571
|
+
catch (error) {
|
|
2572
|
+
if (error instanceof axios.AxiosError)
|
|
2573
|
+
console.error('[negativateRewardByOrderId] request error', error.response.status, JSON.stringify(error.response.data.message), order.orderNumber);
|
|
2574
|
+
else
|
|
2575
|
+
console.log(JSON.stringify(error));
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2284
2580
|
class RoundProductPricesHelper {
|
|
2285
2581
|
static roundProductPrices(product) {
|
|
2286
2582
|
product.price.price = Number(product.price.price.toFixed(2));
|
|
@@ -2301,6 +2597,12 @@ class LogDocument extends BaseModel {
|
|
|
2301
2597
|
}
|
|
2302
2598
|
}
|
|
2303
2599
|
|
|
2600
|
+
class Sequence extends BaseModel {
|
|
2601
|
+
static get identifiersFields() {
|
|
2602
|
+
return ['id'];
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2304
2606
|
exports.FilterType = void 0;
|
|
2305
2607
|
(function (FilterType) {
|
|
2306
2608
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2439,29 +2741,82 @@ class ShopSettings extends BaseModel {
|
|
|
2439
2741
|
}
|
|
2440
2742
|
}
|
|
2441
2743
|
|
|
2442
|
-
class
|
|
2443
|
-
constructor(
|
|
2444
|
-
|
|
2744
|
+
class AdyenCardAxiosAdapter {
|
|
2745
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
2746
|
+
this.credentials = credentials;
|
|
2747
|
+
this.paymentRepository = paymentRepository;
|
|
2748
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
2445
2749
|
}
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
class RequiredArgumentError extends tsCustomError.CustomError {
|
|
2449
|
-
constructor(args) {
|
|
2450
|
-
super(`Required arguments: ${args.join(', ')}`);
|
|
2451
|
-
this.args = args;
|
|
2452
|
-
this.arguments = args;
|
|
2750
|
+
createCardHash(bu) {
|
|
2751
|
+
throw new Error('Method not implemented.');
|
|
2453
2752
|
}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2753
|
+
async pay(checkout, card) {
|
|
2754
|
+
try {
|
|
2755
|
+
const result = await axios__default["default"]({
|
|
2756
|
+
method: 'POST',
|
|
2757
|
+
url: this.credentials.URL_TRANSACTION,
|
|
2758
|
+
headers: {
|
|
2759
|
+
'x-api-key': this.credentials.API_KEY,
|
|
2760
|
+
'content-type': 'application/json',
|
|
2761
|
+
},
|
|
2762
|
+
data: this.createCardPayment(checkout, card),
|
|
2763
|
+
});
|
|
2764
|
+
if (result.data.resultCode !== 'Authorised') {
|
|
2765
|
+
this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
2766
|
+
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`, {
|
|
2767
|
+
checkoutId: checkout.id,
|
|
2768
|
+
userEmail: checkout.user.email,
|
|
2769
|
+
info: result.data,
|
|
2770
|
+
}));
|
|
2771
|
+
}
|
|
2772
|
+
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
2773
|
+
createdAt: new Date(),
|
|
2774
|
+
updatedAt: new Date(),
|
|
2775
|
+
userId: checkout.user.id,
|
|
2776
|
+
checkoutId: checkout.id,
|
|
2777
|
+
totalPrice: checkout.totalPrice,
|
|
2778
|
+
paymentProvider: 'adyen',
|
|
2779
|
+
transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
|
|
2780
|
+
}));
|
|
2781
|
+
return payment;
|
|
2782
|
+
}
|
|
2783
|
+
catch (error) {
|
|
2784
|
+
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', {
|
|
2785
|
+
checkoutId: checkout.id,
|
|
2786
|
+
userEmail: checkout.user.email,
|
|
2787
|
+
info: error.message,
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2459
2790
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2791
|
+
createCardPayment(checkout, card) {
|
|
2792
|
+
return {
|
|
2793
|
+
amount: {
|
|
2794
|
+
currency: 'BRL',
|
|
2795
|
+
value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
|
|
2796
|
+
},
|
|
2797
|
+
paymentMethod: {
|
|
2798
|
+
type: 'scheme',
|
|
2799
|
+
storedPaymentMethodId: card.cardId,
|
|
2800
|
+
},
|
|
2801
|
+
reference: checkout.id,
|
|
2802
|
+
shopperInteraction: 'Ecommerce',
|
|
2803
|
+
merchantAccount: this.credentials.MERCHANT_ACCOUNT,
|
|
2804
|
+
shopperReference: checkout.user.id,
|
|
2805
|
+
recurringProcessingModel: 'CardOnFile',
|
|
2806
|
+
returnUrl: this.credentials.URL_POSTBACK,
|
|
2807
|
+
installments: {
|
|
2808
|
+
value: card.installments,
|
|
2809
|
+
},
|
|
2810
|
+
};
|
|
2811
|
+
}
|
|
2812
|
+
addCard() {
|
|
2813
|
+
throw new Error('Method not implemented.');
|
|
2814
|
+
}
|
|
2815
|
+
getCardByToken(token) {
|
|
2816
|
+
throw new Error('Method not implemented.');
|
|
2817
|
+
}
|
|
2818
|
+
createTransaction(info) {
|
|
2819
|
+
throw new Error('Method not implemented.');
|
|
2465
2820
|
}
|
|
2466
2821
|
}
|
|
2467
2822
|
|
|
@@ -3314,9 +3669,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3314
3669
|
async fetchPaginatedReviews() {
|
|
3315
3670
|
return Promise.resolve([]);
|
|
3316
3671
|
}
|
|
3317
|
-
productVariantFullReport() {
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
3672
|
}
|
|
3321
3673
|
tslib.__decorate([
|
|
3322
3674
|
Log(),
|
|
@@ -3366,6 +3718,17 @@ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore
|
|
|
3366
3718
|
}
|
|
3367
3719
|
}
|
|
3368
3720
|
|
|
3721
|
+
class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3722
|
+
constructor({ firestore, interceptors }) {
|
|
3723
|
+
super({
|
|
3724
|
+
firestore,
|
|
3725
|
+
collectionName: 'sequences',
|
|
3726
|
+
model: Sequence,
|
|
3727
|
+
interceptors,
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3369
3732
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3370
3733
|
constructor({ firestore, interceptors }) {
|
|
3371
3734
|
super({
|
|
@@ -3606,11 +3969,7 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
3606
3969
|
limiteRange,
|
|
3607
3970
|
type,
|
|
3608
3971
|
card,
|
|
3609
|
-
checkout
|
|
3610
|
-
id: checkout.id,
|
|
3611
|
-
shop: checkout.shop,
|
|
3612
|
-
total: checkout.totalPrice,
|
|
3613
|
-
},
|
|
3972
|
+
checkout,
|
|
3614
3973
|
date: new Date(),
|
|
3615
3974
|
}));
|
|
3616
3975
|
}
|
|
@@ -5901,56 +6260,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5901
6260
|
});
|
|
5902
6261
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
5903
6262
|
}
|
|
5904
|
-
async productVariantFullReport() {
|
|
5905
|
-
const fields = [
|
|
5906
|
-
'id',
|
|
5907
|
-
'name',
|
|
5908
|
-
'description',
|
|
5909
|
-
'slug',
|
|
5910
|
-
'sku',
|
|
5911
|
-
'ean',
|
|
5912
|
-
'cest',
|
|
5913
|
-
'ncm',
|
|
5914
|
-
'has_variants',
|
|
5915
|
-
'is_variant',
|
|
5916
|
-
'grade',
|
|
5917
|
-
'type',
|
|
5918
|
-
'is_kit',
|
|
5919
|
-
'tags',
|
|
5920
|
-
'published',
|
|
5921
|
-
'stock',
|
|
5922
|
-
'brand',
|
|
5923
|
-
'brand_description',
|
|
5924
|
-
'images',
|
|
5925
|
-
'miniatures',
|
|
5926
|
-
'video',
|
|
5927
|
-
'weight',
|
|
5928
|
-
'cost_price',
|
|
5929
|
-
'full_price',
|
|
5930
|
-
'price',
|
|
5931
|
-
'subscriber_discount_percentage',
|
|
5932
|
-
'subscriber_price',
|
|
5933
|
-
'how_to_use',
|
|
5934
|
-
'who_must_use',
|
|
5935
|
-
'differentials',
|
|
5936
|
-
'ingredients',
|
|
5937
|
-
'purpose',
|
|
5938
|
-
'filters',
|
|
5939
|
-
'category_id',
|
|
5940
|
-
'outlet',
|
|
5941
|
-
'label',
|
|
5942
|
-
'group',
|
|
5943
|
-
'validity',
|
|
5944
|
-
'gender',
|
|
5945
|
-
'shopping_count',
|
|
5946
|
-
'rating',
|
|
5947
|
-
'reviews_total',
|
|
5948
|
-
'created_at',
|
|
5949
|
-
'updated_at',
|
|
5950
|
-
];
|
|
5951
|
-
const { product_variant_report_query: data } = await this.query('product_variant_report_query', fields);
|
|
5952
|
-
return data;
|
|
5953
|
-
}
|
|
5954
6263
|
}
|
|
5955
6264
|
tslib.__decorate([
|
|
5956
6265
|
Log(),
|
|
@@ -6507,6 +6816,315 @@ tslib.__decorate([
|
|
|
6507
6816
|
tslib.__metadata("design:returntype", Promise)
|
|
6508
6817
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6509
6818
|
|
|
6819
|
+
class PagarmeBankSlipAxiosAdapter {
|
|
6820
|
+
constructor(credentials, paymentRepository) {
|
|
6821
|
+
this.credentials = credentials;
|
|
6822
|
+
this.paymentRepository = paymentRepository;
|
|
6823
|
+
}
|
|
6824
|
+
async pay(checkout) {
|
|
6825
|
+
try {
|
|
6826
|
+
const payload = this.createBoletoPayment(checkout);
|
|
6827
|
+
const result = await axios__default["default"]({
|
|
6828
|
+
method: 'POST',
|
|
6829
|
+
url: `${this.credentials.URL}/transactions`,
|
|
6830
|
+
data: this.createBoletoPayment(checkout),
|
|
6831
|
+
});
|
|
6832
|
+
console.log('[PAGARME BOLETO DATA TO SEND]', payload);
|
|
6833
|
+
if (result.data.status !== exports.PagarmePaymentStatus['Em processamento']) {
|
|
6834
|
+
return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
|
|
6835
|
+
checkoutId: checkout.id,
|
|
6836
|
+
userEmail: checkout.user.email,
|
|
6837
|
+
info: result.data,
|
|
6838
|
+
}));
|
|
6839
|
+
}
|
|
6840
|
+
const payment = await this.paymentRepository.create({
|
|
6841
|
+
createdAt: new Date(),
|
|
6842
|
+
updatedAt: new Date(),
|
|
6843
|
+
userId: checkout.user.id,
|
|
6844
|
+
checkoutId: checkout.id,
|
|
6845
|
+
totalPrice: checkout.totalPrice,
|
|
6846
|
+
paymentProvider: 'pagarMe',
|
|
6847
|
+
transaction: result.data,
|
|
6848
|
+
});
|
|
6849
|
+
return payment;
|
|
6850
|
+
}
|
|
6851
|
+
catch (error) {
|
|
6852
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
6853
|
+
checkoutId: checkout.id,
|
|
6854
|
+
userEmail: checkout.user.email,
|
|
6855
|
+
info: error.response.data,
|
|
6856
|
+
});
|
|
6857
|
+
}
|
|
6858
|
+
}
|
|
6859
|
+
async getBoletoTransaction(paymentId) {
|
|
6860
|
+
try {
|
|
6861
|
+
const { data } = await axios__default["default"]({
|
|
6862
|
+
method: 'GET',
|
|
6863
|
+
url: `${this.credentials.URL}/transactions/${paymentId}`,
|
|
6864
|
+
data: {
|
|
6865
|
+
api_key: this.credentials.API_KEY,
|
|
6866
|
+
},
|
|
6867
|
+
});
|
|
6868
|
+
return data;
|
|
6869
|
+
}
|
|
6870
|
+
catch (error) {
|
|
6871
|
+
throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
|
|
6872
|
+
paymentId,
|
|
6873
|
+
info: error.response.data,
|
|
6874
|
+
});
|
|
6875
|
+
}
|
|
6876
|
+
}
|
|
6877
|
+
createBoletoPayment(checkout) {
|
|
6878
|
+
return {
|
|
6879
|
+
api_key: this.credentials.API_KEY,
|
|
6880
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
6881
|
+
boleto_rules: ['strict_expiration_date'],
|
|
6882
|
+
boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
|
|
6883
|
+
boleto_expiration_date: dateFns.format(dateFns.addDays(new Date(), 3), 'yyyy-MM-dd'),
|
|
6884
|
+
payment_method: 'boleto',
|
|
6885
|
+
postback_url: this.credentials.URL_POSTBACK,
|
|
6886
|
+
customer: {
|
|
6887
|
+
external_id: checkout.user.id,
|
|
6888
|
+
type: 'individual',
|
|
6889
|
+
country: 'br',
|
|
6890
|
+
name: checkout.user.displayName,
|
|
6891
|
+
documents: [
|
|
6892
|
+
{
|
|
6893
|
+
type: 'cpf',
|
|
6894
|
+
number: checkout.user.cpf,
|
|
6895
|
+
},
|
|
6896
|
+
],
|
|
6897
|
+
},
|
|
6898
|
+
};
|
|
6899
|
+
}
|
|
6900
|
+
}
|
|
6901
|
+
|
|
6902
|
+
class PagarmeCardAxiosAdapter {
|
|
6903
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
6904
|
+
this.credentials = credentials;
|
|
6905
|
+
this.paymentRepository = paymentRepository;
|
|
6906
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
6907
|
+
}
|
|
6908
|
+
async pay(checkout, card) {
|
|
6909
|
+
var _a;
|
|
6910
|
+
try {
|
|
6911
|
+
const payload = this.createCardPayment(checkout, card);
|
|
6912
|
+
const result = await axios__default["default"]({
|
|
6913
|
+
method: 'POST',
|
|
6914
|
+
url: `${this.credentials.URL}/transactions`,
|
|
6915
|
+
data: payload,
|
|
6916
|
+
});
|
|
6917
|
+
console.log('[PAGARME CARD DATA TO SEND]', payload);
|
|
6918
|
+
if (result.data.status !== exports.PagarmePaymentStatus.Pago) {
|
|
6919
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
6920
|
+
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`, {
|
|
6921
|
+
checkoutId: checkout.id,
|
|
6922
|
+
userEmail: checkout.user.email,
|
|
6923
|
+
info: result.data,
|
|
6924
|
+
}));
|
|
6925
|
+
}
|
|
6926
|
+
const payment = await this.paymentRepository.create({
|
|
6927
|
+
createdAt: new Date(),
|
|
6928
|
+
updatedAt: new Date(),
|
|
6929
|
+
userId: checkout.user.id,
|
|
6930
|
+
checkoutId: checkout.id,
|
|
6931
|
+
totalPrice: checkout.totalPrice,
|
|
6932
|
+
paymentProvider: exports.PaymentProviders.PAGARME,
|
|
6933
|
+
transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
|
|
6934
|
+
});
|
|
6935
|
+
return payment;
|
|
6936
|
+
}
|
|
6937
|
+
catch (error) {
|
|
6938
|
+
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', {
|
|
6939
|
+
checkoutId: checkout.id,
|
|
6940
|
+
userEmail: checkout.user.email,
|
|
6941
|
+
info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
6942
|
+
});
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
async addCard(card) {
|
|
6946
|
+
try {
|
|
6947
|
+
const { data } = await axios__default["default"]({
|
|
6948
|
+
method: 'POST',
|
|
6949
|
+
url: `${this.credentials.URL}/cards`,
|
|
6950
|
+
data: {
|
|
6951
|
+
api_key: this.credentials.API_KEY,
|
|
6952
|
+
card_number: card.number,
|
|
6953
|
+
card_expiration_date: card.expirationDate.replace('/', ''),
|
|
6954
|
+
card_holder_name: card.name,
|
|
6955
|
+
card_cvv: card.cvv,
|
|
6956
|
+
},
|
|
6957
|
+
});
|
|
6958
|
+
return data;
|
|
6959
|
+
}
|
|
6960
|
+
catch (error) {
|
|
6961
|
+
throw new BusinessError('Houve uma falha adicionar o cartão', {
|
|
6962
|
+
info: error.response.data,
|
|
6963
|
+
});
|
|
6964
|
+
}
|
|
6965
|
+
}
|
|
6966
|
+
async createCardHash(bu) {
|
|
6967
|
+
const key = bu === exports.BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
|
|
6968
|
+
try {
|
|
6969
|
+
const { data } = await axios__default["default"]({
|
|
6970
|
+
method: 'GET',
|
|
6971
|
+
headers: {
|
|
6972
|
+
'content-type': 'application/json',
|
|
6973
|
+
},
|
|
6974
|
+
url: `${this.credentials.URL}/transactions/card_hash_key`,
|
|
6975
|
+
data: JSON.stringify({
|
|
6976
|
+
api_key: key,
|
|
6977
|
+
}),
|
|
6978
|
+
});
|
|
6979
|
+
return data;
|
|
6980
|
+
}
|
|
6981
|
+
catch (error) {
|
|
6982
|
+
throw new BusinessError('Houve uma falha gerar o hash', {
|
|
6983
|
+
info: error.response.data,
|
|
6984
|
+
});
|
|
6985
|
+
}
|
|
6986
|
+
}
|
|
6987
|
+
async getCardByToken(id) {
|
|
6988
|
+
try {
|
|
6989
|
+
const { data } = await axios__default["default"]({
|
|
6990
|
+
method: 'POST',
|
|
6991
|
+
url: `${this.credentials.URL}/cards/${id}`,
|
|
6992
|
+
data: {
|
|
6993
|
+
api_key: this.credentials.API_KEY,
|
|
6994
|
+
},
|
|
6995
|
+
});
|
|
6996
|
+
return data;
|
|
6997
|
+
}
|
|
6998
|
+
catch (error) {
|
|
6999
|
+
throw new BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
|
|
7000
|
+
info: error.response.data,
|
|
7001
|
+
});
|
|
7002
|
+
}
|
|
7003
|
+
}
|
|
7004
|
+
async createTransaction(info) {
|
|
7005
|
+
try {
|
|
7006
|
+
const { data } = await axios__default["default"]({
|
|
7007
|
+
method: 'POST',
|
|
7008
|
+
url: `${this.credentials.URL}/transactions`,
|
|
7009
|
+
data: Object.assign(Object.assign({}, info), { api_key: this.credentials.API_KEY }),
|
|
7010
|
+
});
|
|
7011
|
+
return data;
|
|
7012
|
+
}
|
|
7013
|
+
catch (error) {
|
|
7014
|
+
throw new BusinessError('Houve uma falha ao criar a transação', {
|
|
7015
|
+
info: error.response.data,
|
|
7016
|
+
});
|
|
7017
|
+
}
|
|
7018
|
+
}
|
|
7019
|
+
createCardPayment(checkout, card) {
|
|
7020
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7021
|
+
return {
|
|
7022
|
+
api_key: this.credentials.API_KEY,
|
|
7023
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
7024
|
+
card_id: card.cardId,
|
|
7025
|
+
payment_method: 'credit_card',
|
|
7026
|
+
installments: card.installments,
|
|
7027
|
+
soft_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'Glam' : "Men's Market",
|
|
7028
|
+
customer: {
|
|
7029
|
+
external_id: checkout.user.id,
|
|
7030
|
+
name: checkout.user.displayName,
|
|
7031
|
+
type: 'individual',
|
|
7032
|
+
country: 'br',
|
|
7033
|
+
email: checkout.user.email,
|
|
7034
|
+
phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
|
|
7035
|
+
documents: [
|
|
7036
|
+
{
|
|
7037
|
+
type: 'cpf',
|
|
7038
|
+
number: checkout.user.cpf,
|
|
7039
|
+
},
|
|
7040
|
+
],
|
|
7041
|
+
},
|
|
7042
|
+
billing: {
|
|
7043
|
+
name: checkout.user.displayName,
|
|
7044
|
+
address: {
|
|
7045
|
+
country: 'br',
|
|
7046
|
+
state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
|
|
7047
|
+
city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
|
|
7048
|
+
neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
|
|
7049
|
+
street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
|
|
7050
|
+
street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
|
|
7051
|
+
zipcode: checkout.billingAddress
|
|
7052
|
+
? checkout.billingAddress.zip.replace('-', '')
|
|
7053
|
+
: (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
|
|
7054
|
+
},
|
|
7055
|
+
},
|
|
7056
|
+
items: checkout.lineItems.map((item) => {
|
|
7057
|
+
return {
|
|
7058
|
+
id: item.id,
|
|
7059
|
+
title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
|
|
7060
|
+
unit_price: Math.floor(item.pricePaid * 100),
|
|
7061
|
+
quantity: item.quantity,
|
|
7062
|
+
tangible: true,
|
|
7063
|
+
};
|
|
7064
|
+
}),
|
|
7065
|
+
};
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
|
|
7069
|
+
class PagarmePixAxiosAdapter {
|
|
7070
|
+
constructor(credentials, paymentRepository) {
|
|
7071
|
+
this.credentials = credentials;
|
|
7072
|
+
this.paymentRepository = paymentRepository;
|
|
7073
|
+
}
|
|
7074
|
+
async pay(checkout) {
|
|
7075
|
+
var _a;
|
|
7076
|
+
try {
|
|
7077
|
+
const payload = this.createPixPayment(checkout);
|
|
7078
|
+
const result = await axios__default["default"]({
|
|
7079
|
+
method: 'POST',
|
|
7080
|
+
url: `${this.credentials.URL}/transactions`,
|
|
7081
|
+
data: payload,
|
|
7082
|
+
});
|
|
7083
|
+
console.log('[PAGARME PIX DATA TO SEND]', payload);
|
|
7084
|
+
const payment = await this.paymentRepository.create({
|
|
7085
|
+
createdAt: new Date(),
|
|
7086
|
+
updatedAt: new Date(),
|
|
7087
|
+
userId: checkout.user.id,
|
|
7088
|
+
checkoutId: checkout.id,
|
|
7089
|
+
totalPrice: checkout.totalPrice,
|
|
7090
|
+
paymentProvider: 'pagarMe',
|
|
7091
|
+
transaction: result.data,
|
|
7092
|
+
});
|
|
7093
|
+
return payment;
|
|
7094
|
+
}
|
|
7095
|
+
catch (error) {
|
|
7096
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
7097
|
+
checkoutId: checkout.id,
|
|
7098
|
+
userEmail: checkout.user.email,
|
|
7099
|
+
info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
7100
|
+
});
|
|
7101
|
+
}
|
|
7102
|
+
}
|
|
7103
|
+
createPixPayment(checkout) {
|
|
7104
|
+
return {
|
|
7105
|
+
payment_method: 'pix',
|
|
7106
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
7107
|
+
api_key: this.credentials.API_KEY,
|
|
7108
|
+
postback_url: this.credentials.URL_POSTBACK,
|
|
7109
|
+
pix_expiration_date: dateFns.format(dateFns.addDays(new Date(), 1), 'yyyy-MM-dd'),
|
|
7110
|
+
customer: {
|
|
7111
|
+
external_id: checkout.user.id,
|
|
7112
|
+
type: 'individual',
|
|
7113
|
+
country: 'br',
|
|
7114
|
+
name: checkout.user.displayName,
|
|
7115
|
+
email: checkout.user.email.trim(),
|
|
7116
|
+
phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
|
|
7117
|
+
documents: [
|
|
7118
|
+
{
|
|
7119
|
+
type: 'cpf',
|
|
7120
|
+
number: checkout.user.cpf,
|
|
7121
|
+
},
|
|
7122
|
+
],
|
|
7123
|
+
},
|
|
7124
|
+
};
|
|
7125
|
+
}
|
|
7126
|
+
}
|
|
7127
|
+
|
|
6510
7128
|
class VertexAxiosAdapter {
|
|
6511
7129
|
constructor(config) {
|
|
6512
7130
|
this.config = config;
|
|
@@ -6704,6 +7322,10 @@ Object.defineProperty(exports, 'sub', {
|
|
|
6704
7322
|
enumerable: true,
|
|
6705
7323
|
get: function () { return dateFns.sub; }
|
|
6706
7324
|
});
|
|
7325
|
+
Object.defineProperty(exports, 'subDays', {
|
|
7326
|
+
enumerable: true,
|
|
7327
|
+
get: function () { return dateFns.subDays; }
|
|
7328
|
+
});
|
|
6707
7329
|
Object.defineProperty(exports, 'chunk', {
|
|
6708
7330
|
enumerable: true,
|
|
6709
7331
|
get: function () { return lodash.chunk; }
|
|
@@ -6777,6 +7399,13 @@ Object.defineProperty(exports, 'unset', {
|
|
|
6777
7399
|
get: function () { return lodash.unset; }
|
|
6778
7400
|
});
|
|
6779
7401
|
exports.Address = Address;
|
|
7402
|
+
exports.AdyenCardAxiosAdapter = AdyenCardAxiosAdapter;
|
|
7403
|
+
exports.AdyenPaymentMethodFactory = AdyenPaymentMethodFactory;
|
|
7404
|
+
exports.AntifraudBankSlipService = AntifraudBankSlipService;
|
|
7405
|
+
exports.AntifraudCardService = AntifraudCardService;
|
|
7406
|
+
exports.AntifraudGlampointsService = AntifraudGlampointsService;
|
|
7407
|
+
exports.AntifraudPixService = AntifraudPixService;
|
|
7408
|
+
exports.AntifraudProviderFactory = AntifraudProviderFactory;
|
|
6780
7409
|
exports.Authentication = Authentication;
|
|
6781
7410
|
exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
|
|
6782
7411
|
exports.AxiosAdapter = AxiosAdapter;
|
|
@@ -6784,6 +7413,7 @@ exports.Base = Base;
|
|
|
6784
7413
|
exports.BaseModel = BaseModel;
|
|
6785
7414
|
exports.BeautyProfile = BeautyProfile;
|
|
6786
7415
|
exports.BeautyQuestionsHelper = BeautyQuestionsHelper;
|
|
7416
|
+
exports.BusinessError = BusinessError;
|
|
6787
7417
|
exports.Buy2Win = Buy2Win;
|
|
6788
7418
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
6789
7419
|
exports.Campaign = Campaign;
|
|
@@ -6823,6 +7453,9 @@ exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
|
|
|
6823
7453
|
exports.FilterOption = FilterOption;
|
|
6824
7454
|
exports.FilterOptionHasuraGraphQLRepository = FilterOptionHasuraGraphQLRepository;
|
|
6825
7455
|
exports.FirebaseFileUploaderService = FirebaseFileUploaderService;
|
|
7456
|
+
exports.FraudValidationError = FraudValidationError;
|
|
7457
|
+
exports.GlampointsPaymentMethodFactory = GlampointsPaymentMethodFactory;
|
|
7458
|
+
exports.GlampointsPaymentService = GlampointsPaymentService;
|
|
6826
7459
|
exports.Home = Home;
|
|
6827
7460
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
6828
7461
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -6841,8 +7474,15 @@ exports.Order = Order;
|
|
|
6841
7474
|
exports.OrderBlocked = OrderBlocked;
|
|
6842
7475
|
exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
|
|
6843
7476
|
exports.OrderFirestoreRepository = OrderFirestoreRepository;
|
|
7477
|
+
exports.PagarmeBankSlipAxiosAdapter = PagarmeBankSlipAxiosAdapter;
|
|
7478
|
+
exports.PagarmeCardAxiosAdapter = PagarmeCardAxiosAdapter;
|
|
7479
|
+
exports.PagarmePaymentMethodFactory = PagarmePaymentMethodFactory;
|
|
7480
|
+
exports.PagarmePixAxiosAdapter = PagarmePixAxiosAdapter;
|
|
6844
7481
|
exports.Payment = Payment;
|
|
7482
|
+
exports.PaymentError = PaymentError;
|
|
6845
7483
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
7484
|
+
exports.PaymentProviderFactory = PaymentProviderFactory;
|
|
7485
|
+
exports.PaymentTransaction = PaymentTransaction;
|
|
6846
7486
|
exports.Product = Product;
|
|
6847
7487
|
exports.ProductFirestoreRepository = ProductFirestoreRepository;
|
|
6848
7488
|
exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
|
|
@@ -6860,12 +7500,16 @@ exports.Register = Register;
|
|
|
6860
7500
|
exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
|
|
6861
7501
|
exports.RequiredArgumentError = RequiredArgumentError;
|
|
6862
7502
|
exports.RoundProductPricesHelper = RoundProductPricesHelper;
|
|
7503
|
+
exports.Sequence = Sequence;
|
|
7504
|
+
exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
|
|
6863
7505
|
exports.ShippingMethod = ShippingMethod;
|
|
6864
7506
|
exports.ShopMenu = ShopMenu;
|
|
6865
7507
|
exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;
|
|
6866
7508
|
exports.ShopSettings = ShopSettings;
|
|
6867
7509
|
exports.ShopSettingsFirestoreRepository = ShopSettingsFirestoreRepository;
|
|
6868
7510
|
exports.SignOut = SignOut;
|
|
7511
|
+
exports.StockLimitError = StockLimitError;
|
|
7512
|
+
exports.StockOutError = StockOutError;
|
|
6869
7513
|
exports.Subscription = Subscription;
|
|
6870
7514
|
exports.SubscriptionEditionFirestoreRepository = SubscriptionEditionFirestoreRepository;
|
|
6871
7515
|
exports.SubscriptionFirestoreRepository = SubscriptionFirestoreRepository;
|