@infrab4a/connect 4.21.3 → 4.22.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +882 -243
- package/index.esm.js +860 -247
- 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,370 @@ 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.info('[rewards - rewardByOrder] reward success:', JSON.stringify(result));
|
|
2541
|
+
return result.data;
|
|
2542
|
+
}
|
|
2543
|
+
catch (err) {
|
|
2544
|
+
console.log(err);
|
|
2545
|
+
console.error('[rewards - rewardByOrder] reward request error', JSON.stringify(err));
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
async negativateRewardByOrderId(order) {
|
|
2549
|
+
try {
|
|
2550
|
+
const result = await axios__default["default"]({
|
|
2551
|
+
method: 'POST',
|
|
2552
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2553
|
+
headers: {
|
|
2554
|
+
'Content-Type': 'application/json',
|
|
2555
|
+
Authorization: `Bearer ${this.glamCredentials.integrationToken}`,
|
|
2556
|
+
Origin: 'https://cloudfunctions.b4a.com.br',
|
|
2557
|
+
},
|
|
2558
|
+
timeout: 60000,
|
|
2559
|
+
data: JSON.stringify({
|
|
2560
|
+
rewardType: 51,
|
|
2561
|
+
referenceName: `Pedido #${order.id} cancelado`,
|
|
2562
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2563
|
+
orderId: order.id,
|
|
2564
|
+
orderNumber: order.orderNumber,
|
|
2565
|
+
}),
|
|
2566
|
+
});
|
|
2567
|
+
return result;
|
|
2568
|
+
}
|
|
2569
|
+
catch (error) {
|
|
2570
|
+
return error;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2284
2575
|
class RoundProductPricesHelper {
|
|
2285
2576
|
static roundProductPrices(product) {
|
|
2286
2577
|
product.price.price = Number(product.price.price.toFixed(2));
|
|
@@ -2301,6 +2592,12 @@ class LogDocument extends BaseModel {
|
|
|
2301
2592
|
}
|
|
2302
2593
|
}
|
|
2303
2594
|
|
|
2595
|
+
class Sequence extends BaseModel {
|
|
2596
|
+
static get identifiersFields() {
|
|
2597
|
+
return ['id'];
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2304
2601
|
exports.FilterType = void 0;
|
|
2305
2602
|
(function (FilterType) {
|
|
2306
2603
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2439,29 +2736,82 @@ class ShopSettings extends BaseModel {
|
|
|
2439
2736
|
}
|
|
2440
2737
|
}
|
|
2441
2738
|
|
|
2442
|
-
class
|
|
2443
|
-
constructor(
|
|
2444
|
-
|
|
2739
|
+
class AdyenCardAxiosAdapter {
|
|
2740
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
2741
|
+
this.credentials = credentials;
|
|
2742
|
+
this.paymentRepository = paymentRepository;
|
|
2743
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
2445
2744
|
}
|
|
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;
|
|
2745
|
+
createCardHash(bu) {
|
|
2746
|
+
throw new Error('Method not implemented.');
|
|
2453
2747
|
}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2748
|
+
async pay(checkout, card) {
|
|
2749
|
+
try {
|
|
2750
|
+
const result = await axios__default["default"]({
|
|
2751
|
+
method: 'POST',
|
|
2752
|
+
url: this.credentials.URL_TRANSACTION,
|
|
2753
|
+
headers: {
|
|
2754
|
+
'x-api-key': this.credentials.API_KEY,
|
|
2755
|
+
'content-type': 'application/json',
|
|
2756
|
+
},
|
|
2757
|
+
data: this.createCardPayment(checkout, card),
|
|
2758
|
+
});
|
|
2759
|
+
if (result.data.resultCode !== 'Authorised') {
|
|
2760
|
+
this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
2761
|
+
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`, {
|
|
2762
|
+
checkoutId: checkout.id,
|
|
2763
|
+
userEmail: checkout.user.email,
|
|
2764
|
+
info: result.data,
|
|
2765
|
+
}));
|
|
2766
|
+
}
|
|
2767
|
+
const payment = await this.paymentRepository.create(Payment.toInstance({
|
|
2768
|
+
createdAt: new Date(),
|
|
2769
|
+
updatedAt: new Date(),
|
|
2770
|
+
userId: checkout.user.id,
|
|
2771
|
+
checkoutId: checkout.id,
|
|
2772
|
+
totalPrice: checkout.totalPrice,
|
|
2773
|
+
paymentProvider: 'adyen',
|
|
2774
|
+
transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
|
|
2775
|
+
}));
|
|
2776
|
+
return payment;
|
|
2777
|
+
}
|
|
2778
|
+
catch (error) {
|
|
2779
|
+
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', {
|
|
2780
|
+
checkoutId: checkout.id,
|
|
2781
|
+
userEmail: checkout.user.email,
|
|
2782
|
+
info: error.message,
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2459
2785
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2786
|
+
createCardPayment(checkout, card) {
|
|
2787
|
+
return {
|
|
2788
|
+
amount: {
|
|
2789
|
+
currency: 'BRL',
|
|
2790
|
+
value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
|
|
2791
|
+
},
|
|
2792
|
+
paymentMethod: {
|
|
2793
|
+
type: 'scheme',
|
|
2794
|
+
storedPaymentMethodId: card.cardId,
|
|
2795
|
+
},
|
|
2796
|
+
reference: checkout.id,
|
|
2797
|
+
shopperInteraction: 'Ecommerce',
|
|
2798
|
+
merchantAccount: this.credentials.MERCHANT_ACCOUNT,
|
|
2799
|
+
shopperReference: checkout.user.id,
|
|
2800
|
+
recurringProcessingModel: 'CardOnFile',
|
|
2801
|
+
returnUrl: this.credentials.URL_POSTBACK,
|
|
2802
|
+
installments: {
|
|
2803
|
+
value: card.installments,
|
|
2804
|
+
},
|
|
2805
|
+
};
|
|
2806
|
+
}
|
|
2807
|
+
addCard() {
|
|
2808
|
+
throw new Error('Method not implemented.');
|
|
2809
|
+
}
|
|
2810
|
+
getCardByToken(token) {
|
|
2811
|
+
throw new Error('Method not implemented.');
|
|
2812
|
+
}
|
|
2813
|
+
createTransaction(info) {
|
|
2814
|
+
throw new Error('Method not implemented.');
|
|
2465
2815
|
}
|
|
2466
2816
|
}
|
|
2467
2817
|
|
|
@@ -3314,9 +3664,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3314
3664
|
async fetchPaginatedReviews() {
|
|
3315
3665
|
return Promise.resolve([]);
|
|
3316
3666
|
}
|
|
3317
|
-
productVariantFullReport() {
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
3667
|
}
|
|
3321
3668
|
tslib.__decorate([
|
|
3322
3669
|
Log(),
|
|
@@ -3366,6 +3713,17 @@ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore
|
|
|
3366
3713
|
}
|
|
3367
3714
|
}
|
|
3368
3715
|
|
|
3716
|
+
class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3717
|
+
constructor({ firestore, interceptors }) {
|
|
3718
|
+
super({
|
|
3719
|
+
firestore,
|
|
3720
|
+
collectionName: 'sequences',
|
|
3721
|
+
model: Sequence,
|
|
3722
|
+
interceptors,
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3369
3727
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3370
3728
|
constructor({ firestore, interceptors }) {
|
|
3371
3729
|
super({
|
|
@@ -3606,11 +3964,7 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
3606
3964
|
limiteRange,
|
|
3607
3965
|
type,
|
|
3608
3966
|
card,
|
|
3609
|
-
checkout
|
|
3610
|
-
id: checkout.id,
|
|
3611
|
-
shop: checkout.shop,
|
|
3612
|
-
total: checkout.totalPrice,
|
|
3613
|
-
},
|
|
3967
|
+
checkout,
|
|
3614
3968
|
date: new Date(),
|
|
3615
3969
|
}));
|
|
3616
3970
|
}
|
|
@@ -5901,56 +6255,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5901
6255
|
});
|
|
5902
6256
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
5903
6257
|
}
|
|
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
6258
|
}
|
|
5955
6259
|
tslib.__decorate([
|
|
5956
6260
|
Log(),
|
|
@@ -6507,6 +6811,315 @@ tslib.__decorate([
|
|
|
6507
6811
|
tslib.__metadata("design:returntype", Promise)
|
|
6508
6812
|
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6509
6813
|
|
|
6814
|
+
class PagarmeBankSlipAxiosAdapter {
|
|
6815
|
+
constructor(credentials, paymentRepository) {
|
|
6816
|
+
this.credentials = credentials;
|
|
6817
|
+
this.paymentRepository = paymentRepository;
|
|
6818
|
+
}
|
|
6819
|
+
async pay(checkout) {
|
|
6820
|
+
try {
|
|
6821
|
+
const payload = this.createBoletoPayment(checkout);
|
|
6822
|
+
const result = await axios__default["default"]({
|
|
6823
|
+
method: 'POST',
|
|
6824
|
+
url: `${this.credentials.URL}/transactions`,
|
|
6825
|
+
data: this.createBoletoPayment(checkout),
|
|
6826
|
+
});
|
|
6827
|
+
console.log('[PAGARME BOLETO DATA TO SEND]', payload);
|
|
6828
|
+
if (result.data.status !== exports.PagarmePaymentStatus['Em processamento']) {
|
|
6829
|
+
return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
|
|
6830
|
+
checkoutId: checkout.id,
|
|
6831
|
+
userEmail: checkout.user.email,
|
|
6832
|
+
info: result.data,
|
|
6833
|
+
}));
|
|
6834
|
+
}
|
|
6835
|
+
const payment = await this.paymentRepository.create({
|
|
6836
|
+
createdAt: new Date(),
|
|
6837
|
+
updatedAt: new Date(),
|
|
6838
|
+
userId: checkout.user.id,
|
|
6839
|
+
checkoutId: checkout.id,
|
|
6840
|
+
totalPrice: checkout.totalPrice,
|
|
6841
|
+
paymentProvider: 'pagarMe',
|
|
6842
|
+
transaction: result.data,
|
|
6843
|
+
});
|
|
6844
|
+
return payment;
|
|
6845
|
+
}
|
|
6846
|
+
catch (error) {
|
|
6847
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
6848
|
+
checkoutId: checkout.id,
|
|
6849
|
+
userEmail: checkout.user.email,
|
|
6850
|
+
info: error.response.data,
|
|
6851
|
+
});
|
|
6852
|
+
}
|
|
6853
|
+
}
|
|
6854
|
+
async getBoletoTransaction(paymentId) {
|
|
6855
|
+
try {
|
|
6856
|
+
const { data } = await axios__default["default"]({
|
|
6857
|
+
method: 'GET',
|
|
6858
|
+
url: `${this.credentials.URL}/transactions/${paymentId}`,
|
|
6859
|
+
data: {
|
|
6860
|
+
api_key: this.credentials.API_KEY,
|
|
6861
|
+
},
|
|
6862
|
+
});
|
|
6863
|
+
return data;
|
|
6864
|
+
}
|
|
6865
|
+
catch (error) {
|
|
6866
|
+
throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
|
|
6867
|
+
paymentId,
|
|
6868
|
+
info: error.response.data,
|
|
6869
|
+
});
|
|
6870
|
+
}
|
|
6871
|
+
}
|
|
6872
|
+
createBoletoPayment(checkout) {
|
|
6873
|
+
return {
|
|
6874
|
+
api_key: this.credentials.API_KEY,
|
|
6875
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
6876
|
+
boleto_rules: ['strict_expiration_date'],
|
|
6877
|
+
boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
|
|
6878
|
+
boleto_expiration_date: dateFns.format(dateFns.addDays(new Date(), 3), 'yyyy-MM-dd'),
|
|
6879
|
+
payment_method: 'boleto',
|
|
6880
|
+
postback_url: this.credentials.URL_POSTBACK,
|
|
6881
|
+
customer: {
|
|
6882
|
+
external_id: checkout.user.id,
|
|
6883
|
+
type: 'individual',
|
|
6884
|
+
country: 'br',
|
|
6885
|
+
name: checkout.user.displayName,
|
|
6886
|
+
documents: [
|
|
6887
|
+
{
|
|
6888
|
+
type: 'cpf',
|
|
6889
|
+
number: checkout.user.cpf,
|
|
6890
|
+
},
|
|
6891
|
+
],
|
|
6892
|
+
},
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6895
|
+
}
|
|
6896
|
+
|
|
6897
|
+
class PagarmeCardAxiosAdapter {
|
|
6898
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
6899
|
+
this.credentials = credentials;
|
|
6900
|
+
this.paymentRepository = paymentRepository;
|
|
6901
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
6902
|
+
}
|
|
6903
|
+
async pay(checkout, card) {
|
|
6904
|
+
var _a;
|
|
6905
|
+
try {
|
|
6906
|
+
const payload = this.createCardPayment(checkout, card);
|
|
6907
|
+
const result = await axios__default["default"]({
|
|
6908
|
+
method: 'POST',
|
|
6909
|
+
url: `${this.credentials.URL}/transactions`,
|
|
6910
|
+
data: payload,
|
|
6911
|
+
});
|
|
6912
|
+
console.log('[PAGARME CARD DATA TO SEND]', payload);
|
|
6913
|
+
if (result.data.status !== exports.PagarmePaymentStatus.Pago) {
|
|
6914
|
+
await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
|
|
6915
|
+
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`, {
|
|
6916
|
+
checkoutId: checkout.id,
|
|
6917
|
+
userEmail: checkout.user.email,
|
|
6918
|
+
info: result.data,
|
|
6919
|
+
}));
|
|
6920
|
+
}
|
|
6921
|
+
const payment = await this.paymentRepository.create({
|
|
6922
|
+
createdAt: new Date(),
|
|
6923
|
+
updatedAt: new Date(),
|
|
6924
|
+
userId: checkout.user.id,
|
|
6925
|
+
checkoutId: checkout.id,
|
|
6926
|
+
totalPrice: checkout.totalPrice,
|
|
6927
|
+
paymentProvider: exports.PaymentProviders.PAGARME,
|
|
6928
|
+
transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
|
|
6929
|
+
});
|
|
6930
|
+
return payment;
|
|
6931
|
+
}
|
|
6932
|
+
catch (error) {
|
|
6933
|
+
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', {
|
|
6934
|
+
checkoutId: checkout.id,
|
|
6935
|
+
userEmail: checkout.user.email,
|
|
6936
|
+
info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
6937
|
+
});
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
async addCard(card) {
|
|
6941
|
+
try {
|
|
6942
|
+
const { data } = await axios__default["default"]({
|
|
6943
|
+
method: 'POST',
|
|
6944
|
+
url: `${this.credentials.URL}/cards`,
|
|
6945
|
+
data: {
|
|
6946
|
+
api_key: this.credentials.API_KEY,
|
|
6947
|
+
card_number: card.number,
|
|
6948
|
+
card_expiration_date: card.expirationDate.replace('/', ''),
|
|
6949
|
+
card_holder_name: card.name,
|
|
6950
|
+
card_cvv: card.cvv,
|
|
6951
|
+
},
|
|
6952
|
+
});
|
|
6953
|
+
return data;
|
|
6954
|
+
}
|
|
6955
|
+
catch (error) {
|
|
6956
|
+
throw new BusinessError('Houve uma falha adicionar o cartão', {
|
|
6957
|
+
info: error.response.data,
|
|
6958
|
+
});
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
async createCardHash(bu) {
|
|
6962
|
+
const key = bu === exports.BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
|
|
6963
|
+
try {
|
|
6964
|
+
const { data } = await axios__default["default"]({
|
|
6965
|
+
method: 'GET',
|
|
6966
|
+
headers: {
|
|
6967
|
+
'content-type': 'application/json',
|
|
6968
|
+
},
|
|
6969
|
+
url: `${this.credentials.URL}/transactions/card_hash_key`,
|
|
6970
|
+
data: JSON.stringify({
|
|
6971
|
+
api_key: key,
|
|
6972
|
+
}),
|
|
6973
|
+
});
|
|
6974
|
+
return data;
|
|
6975
|
+
}
|
|
6976
|
+
catch (error) {
|
|
6977
|
+
throw new BusinessError('Houve uma falha gerar o hash', {
|
|
6978
|
+
info: error.response.data,
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
}
|
|
6982
|
+
async getCardByToken(id) {
|
|
6983
|
+
try {
|
|
6984
|
+
const { data } = await axios__default["default"]({
|
|
6985
|
+
method: 'POST',
|
|
6986
|
+
url: `${this.credentials.URL}/cards/${id}`,
|
|
6987
|
+
data: {
|
|
6988
|
+
api_key: this.credentials.API_KEY,
|
|
6989
|
+
},
|
|
6990
|
+
});
|
|
6991
|
+
return data;
|
|
6992
|
+
}
|
|
6993
|
+
catch (error) {
|
|
6994
|
+
throw new BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
|
|
6995
|
+
info: error.response.data,
|
|
6996
|
+
});
|
|
6997
|
+
}
|
|
6998
|
+
}
|
|
6999
|
+
async createTransaction(info) {
|
|
7000
|
+
try {
|
|
7001
|
+
const { data } = await axios__default["default"]({
|
|
7002
|
+
method: 'POST',
|
|
7003
|
+
url: `${this.credentials.URL}/transactions`,
|
|
7004
|
+
data: Object.assign(Object.assign({}, info), { api_key: this.credentials.API_KEY }),
|
|
7005
|
+
});
|
|
7006
|
+
return data;
|
|
7007
|
+
}
|
|
7008
|
+
catch (error) {
|
|
7009
|
+
throw new BusinessError('Houve uma falha ao criar a transação', {
|
|
7010
|
+
info: error.response.data,
|
|
7011
|
+
});
|
|
7012
|
+
}
|
|
7013
|
+
}
|
|
7014
|
+
createCardPayment(checkout, card) {
|
|
7015
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7016
|
+
return {
|
|
7017
|
+
api_key: this.credentials.API_KEY,
|
|
7018
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
7019
|
+
card_id: card.cardId,
|
|
7020
|
+
payment_method: 'credit_card',
|
|
7021
|
+
installments: card.installments,
|
|
7022
|
+
soft_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'Glam' : "Men's Market",
|
|
7023
|
+
customer: {
|
|
7024
|
+
external_id: checkout.user.id,
|
|
7025
|
+
name: checkout.user.displayName,
|
|
7026
|
+
type: 'individual',
|
|
7027
|
+
country: 'br',
|
|
7028
|
+
email: checkout.user.email,
|
|
7029
|
+
phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
|
|
7030
|
+
documents: [
|
|
7031
|
+
{
|
|
7032
|
+
type: 'cpf',
|
|
7033
|
+
number: checkout.user.cpf,
|
|
7034
|
+
},
|
|
7035
|
+
],
|
|
7036
|
+
},
|
|
7037
|
+
billing: {
|
|
7038
|
+
name: checkout.user.displayName,
|
|
7039
|
+
address: {
|
|
7040
|
+
country: 'br',
|
|
7041
|
+
state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
|
|
7042
|
+
city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
|
|
7043
|
+
neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
|
|
7044
|
+
street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
|
|
7045
|
+
street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
|
|
7046
|
+
zipcode: checkout.billingAddress
|
|
7047
|
+
? checkout.billingAddress.zip.replace('-', '')
|
|
7048
|
+
: (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
|
|
7049
|
+
},
|
|
7050
|
+
},
|
|
7051
|
+
items: checkout.lineItems.map((item) => {
|
|
7052
|
+
return {
|
|
7053
|
+
id: item.id,
|
|
7054
|
+
title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
|
|
7055
|
+
unit_price: Math.floor(item.pricePaid * 100),
|
|
7056
|
+
quantity: item.quantity,
|
|
7057
|
+
tangible: true,
|
|
7058
|
+
};
|
|
7059
|
+
}),
|
|
7060
|
+
};
|
|
7061
|
+
}
|
|
7062
|
+
}
|
|
7063
|
+
|
|
7064
|
+
class PagarmePixAxiosAdapter {
|
|
7065
|
+
constructor(credentials, paymentRepository) {
|
|
7066
|
+
this.credentials = credentials;
|
|
7067
|
+
this.paymentRepository = paymentRepository;
|
|
7068
|
+
}
|
|
7069
|
+
async pay(checkout) {
|
|
7070
|
+
var _a;
|
|
7071
|
+
try {
|
|
7072
|
+
const payload = this.createPixPayment(checkout);
|
|
7073
|
+
const result = await axios__default["default"]({
|
|
7074
|
+
method: 'POST',
|
|
7075
|
+
url: `${this.credentials.URL}/transactions`,
|
|
7076
|
+
data: payload,
|
|
7077
|
+
});
|
|
7078
|
+
console.log('[PAGARME PIX DATA TO SEND]', payload);
|
|
7079
|
+
const payment = await this.paymentRepository.create({
|
|
7080
|
+
createdAt: new Date(),
|
|
7081
|
+
updatedAt: new Date(),
|
|
7082
|
+
userId: checkout.user.id,
|
|
7083
|
+
checkoutId: checkout.id,
|
|
7084
|
+
totalPrice: checkout.totalPrice,
|
|
7085
|
+
paymentProvider: 'pagarMe',
|
|
7086
|
+
transaction: result.data,
|
|
7087
|
+
});
|
|
7088
|
+
return payment;
|
|
7089
|
+
}
|
|
7090
|
+
catch (error) {
|
|
7091
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
7092
|
+
checkoutId: checkout.id,
|
|
7093
|
+
userEmail: checkout.user.email,
|
|
7094
|
+
info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
|
|
7095
|
+
});
|
|
7096
|
+
}
|
|
7097
|
+
}
|
|
7098
|
+
createPixPayment(checkout) {
|
|
7099
|
+
return {
|
|
7100
|
+
payment_method: 'pix',
|
|
7101
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
7102
|
+
api_key: this.credentials.API_KEY,
|
|
7103
|
+
postback_url: this.credentials.URL_POSTBACK,
|
|
7104
|
+
pix_expiration_date: dateFns.format(dateFns.addDays(new Date(), 1), 'yyyy-MM-dd'),
|
|
7105
|
+
customer: {
|
|
7106
|
+
external_id: checkout.user.id,
|
|
7107
|
+
type: 'individual',
|
|
7108
|
+
country: 'br',
|
|
7109
|
+
name: checkout.user.displayName,
|
|
7110
|
+
email: checkout.user.email.trim(),
|
|
7111
|
+
phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
|
|
7112
|
+
documents: [
|
|
7113
|
+
{
|
|
7114
|
+
type: 'cpf',
|
|
7115
|
+
number: checkout.user.cpf,
|
|
7116
|
+
},
|
|
7117
|
+
],
|
|
7118
|
+
},
|
|
7119
|
+
};
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7122
|
+
|
|
6510
7123
|
class VertexAxiosAdapter {
|
|
6511
7124
|
constructor(config) {
|
|
6512
7125
|
this.config = config;
|
|
@@ -6704,6 +7317,10 @@ Object.defineProperty(exports, 'sub', {
|
|
|
6704
7317
|
enumerable: true,
|
|
6705
7318
|
get: function () { return dateFns.sub; }
|
|
6706
7319
|
});
|
|
7320
|
+
Object.defineProperty(exports, 'subDays', {
|
|
7321
|
+
enumerable: true,
|
|
7322
|
+
get: function () { return dateFns.subDays; }
|
|
7323
|
+
});
|
|
6707
7324
|
Object.defineProperty(exports, 'chunk', {
|
|
6708
7325
|
enumerable: true,
|
|
6709
7326
|
get: function () { return lodash.chunk; }
|
|
@@ -6777,6 +7394,13 @@ Object.defineProperty(exports, 'unset', {
|
|
|
6777
7394
|
get: function () { return lodash.unset; }
|
|
6778
7395
|
});
|
|
6779
7396
|
exports.Address = Address;
|
|
7397
|
+
exports.AdyenCardAxiosAdapter = AdyenCardAxiosAdapter;
|
|
7398
|
+
exports.AdyenPaymentMethodFactory = AdyenPaymentMethodFactory;
|
|
7399
|
+
exports.AntifraudBankSlipService = AntifraudBankSlipService;
|
|
7400
|
+
exports.AntifraudCardService = AntifraudCardService;
|
|
7401
|
+
exports.AntifraudGlampointsService = AntifraudGlampointsService;
|
|
7402
|
+
exports.AntifraudPixService = AntifraudPixService;
|
|
7403
|
+
exports.AntifraudProviderFactory = AntifraudProviderFactory;
|
|
6780
7404
|
exports.Authentication = Authentication;
|
|
6781
7405
|
exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
|
|
6782
7406
|
exports.AxiosAdapter = AxiosAdapter;
|
|
@@ -6784,6 +7408,7 @@ exports.Base = Base;
|
|
|
6784
7408
|
exports.BaseModel = BaseModel;
|
|
6785
7409
|
exports.BeautyProfile = BeautyProfile;
|
|
6786
7410
|
exports.BeautyQuestionsHelper = BeautyQuestionsHelper;
|
|
7411
|
+
exports.BusinessError = BusinessError;
|
|
6787
7412
|
exports.Buy2Win = Buy2Win;
|
|
6788
7413
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
6789
7414
|
exports.Campaign = Campaign;
|
|
@@ -6823,6 +7448,9 @@ exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
|
|
|
6823
7448
|
exports.FilterOption = FilterOption;
|
|
6824
7449
|
exports.FilterOptionHasuraGraphQLRepository = FilterOptionHasuraGraphQLRepository;
|
|
6825
7450
|
exports.FirebaseFileUploaderService = FirebaseFileUploaderService;
|
|
7451
|
+
exports.FraudValidationError = FraudValidationError;
|
|
7452
|
+
exports.GlampointsPaymentMethodFactory = GlampointsPaymentMethodFactory;
|
|
7453
|
+
exports.GlampointsPaymentService = GlampointsPaymentService;
|
|
6826
7454
|
exports.Home = Home;
|
|
6827
7455
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
6828
7456
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -6841,8 +7469,15 @@ exports.Order = Order;
|
|
|
6841
7469
|
exports.OrderBlocked = OrderBlocked;
|
|
6842
7470
|
exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
|
|
6843
7471
|
exports.OrderFirestoreRepository = OrderFirestoreRepository;
|
|
7472
|
+
exports.PagarmeBankSlipAxiosAdapter = PagarmeBankSlipAxiosAdapter;
|
|
7473
|
+
exports.PagarmeCardAxiosAdapter = PagarmeCardAxiosAdapter;
|
|
7474
|
+
exports.PagarmePaymentMethodFactory = PagarmePaymentMethodFactory;
|
|
7475
|
+
exports.PagarmePixAxiosAdapter = PagarmePixAxiosAdapter;
|
|
6844
7476
|
exports.Payment = Payment;
|
|
7477
|
+
exports.PaymentError = PaymentError;
|
|
6845
7478
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
7479
|
+
exports.PaymentProviderFactory = PaymentProviderFactory;
|
|
7480
|
+
exports.PaymentTransaction = PaymentTransaction;
|
|
6846
7481
|
exports.Product = Product;
|
|
6847
7482
|
exports.ProductFirestoreRepository = ProductFirestoreRepository;
|
|
6848
7483
|
exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
|
|
@@ -6860,12 +7495,16 @@ exports.Register = Register;
|
|
|
6860
7495
|
exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
|
|
6861
7496
|
exports.RequiredArgumentError = RequiredArgumentError;
|
|
6862
7497
|
exports.RoundProductPricesHelper = RoundProductPricesHelper;
|
|
7498
|
+
exports.Sequence = Sequence;
|
|
7499
|
+
exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
|
|
6863
7500
|
exports.ShippingMethod = ShippingMethod;
|
|
6864
7501
|
exports.ShopMenu = ShopMenu;
|
|
6865
7502
|
exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;
|
|
6866
7503
|
exports.ShopSettings = ShopSettings;
|
|
6867
7504
|
exports.ShopSettingsFirestoreRepository = ShopSettingsFirestoreRepository;
|
|
6868
7505
|
exports.SignOut = SignOut;
|
|
7506
|
+
exports.StockLimitError = StockLimitError;
|
|
7507
|
+
exports.StockOutError = StockOutError;
|
|
6869
7508
|
exports.Subscription = Subscription;
|
|
6870
7509
|
exports.SubscriptionEditionFirestoreRepository = SubscriptionEditionFirestoreRepository;
|
|
6871
7510
|
exports.SubscriptionFirestoreRepository = SubscriptionFirestoreRepository;
|