@infrab4a/connect 4.20.0-beta.11 → 4.20.0-beta.13
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 +61 -175
- package/index.esm.js +62 -176
- package/package.json +1 -1
- package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +4 -0
- package/src/domain/shopping/models/payment-transaction.d.ts +60 -60
- package/src/domain/shopping/services/glampoints-payment.service.d.ts +7 -2
- package/src/domain/shopping/types/glam-credentials.type.d.ts +6 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/payment-card-info.type.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -650,171 +650,7 @@ exports.Status = void 0;
|
|
|
650
650
|
})(exports.Status || (exports.Status = {}));
|
|
651
651
|
|
|
652
652
|
class PaymentTransaction extends BaseModel {
|
|
653
|
-
}
|
|
654
|
-
tslib.__decorate([
|
|
655
|
-
classTransformer.Expose({ name: 'refuse_reason' }),
|
|
656
|
-
tslib.__metadata("design:type", String)
|
|
657
|
-
], PaymentTransaction.prototype, "refuseReason", void 0);
|
|
658
|
-
tslib.__decorate([
|
|
659
|
-
classTransformer.Expose({ name: 'status_reason' }),
|
|
660
|
-
tslib.__metadata("design:type", String)
|
|
661
|
-
], PaymentTransaction.prototype, "statusReason", void 0);
|
|
662
|
-
tslib.__decorate([
|
|
663
|
-
classTransformer.Expose({ name: 'acquirer_response_code' }),
|
|
664
|
-
tslib.__metadata("design:type", String)
|
|
665
|
-
], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
|
|
666
|
-
tslib.__decorate([
|
|
667
|
-
classTransformer.Expose({ name: 'acquirer_name' }),
|
|
668
|
-
tslib.__metadata("design:type", String)
|
|
669
|
-
], PaymentTransaction.prototype, "acquirerName", void 0);
|
|
670
|
-
tslib.__decorate([
|
|
671
|
-
classTransformer.Expose({ name: 'acquirer_id' }),
|
|
672
|
-
tslib.__metadata("design:type", String)
|
|
673
|
-
], PaymentTransaction.prototype, "acquirerId", void 0);
|
|
674
|
-
tslib.__decorate([
|
|
675
|
-
classTransformer.Expose({ name: 'authorization_code' }),
|
|
676
|
-
tslib.__metadata("design:type", String)
|
|
677
|
-
], PaymentTransaction.prototype, "authorizationCode", void 0);
|
|
678
|
-
tslib.__decorate([
|
|
679
|
-
classTransformer.Expose({ name: 'soft_descriptor' }),
|
|
680
|
-
tslib.__metadata("design:type", String)
|
|
681
|
-
], PaymentTransaction.prototype, "softDescriptor", void 0);
|
|
682
|
-
tslib.__decorate([
|
|
683
|
-
classTransformer.Expose({ name: 'date_created' }),
|
|
684
|
-
tslib.__metadata("design:type", String)
|
|
685
|
-
], PaymentTransaction.prototype, "dateCreated", void 0);
|
|
686
|
-
tslib.__decorate([
|
|
687
|
-
classTransformer.Expose({ name: 'date_updated' }),
|
|
688
|
-
tslib.__metadata("design:type", String)
|
|
689
|
-
], PaymentTransaction.prototype, "dateUpdated", void 0);
|
|
690
|
-
tslib.__decorate([
|
|
691
|
-
classTransformer.Expose({ name: 'authorized_amount' }),
|
|
692
|
-
tslib.__metadata("design:type", Number)
|
|
693
|
-
], PaymentTransaction.prototype, "authorizedAmount", void 0);
|
|
694
|
-
tslib.__decorate([
|
|
695
|
-
classTransformer.Expose({ name: 'paid_amount' }),
|
|
696
|
-
tslib.__metadata("design:type", Number)
|
|
697
|
-
], PaymentTransaction.prototype, "paidAmount", void 0);
|
|
698
|
-
tslib.__decorate([
|
|
699
|
-
classTransformer.Expose({ name: 'paid_at' }),
|
|
700
|
-
tslib.__metadata("design:type", String)
|
|
701
|
-
], PaymentTransaction.prototype, "paidAt", void 0);
|
|
702
|
-
tslib.__decorate([
|
|
703
|
-
classTransformer.Expose({ name: 'refunded_amount' }),
|
|
704
|
-
tslib.__metadata("design:type", Number)
|
|
705
|
-
], PaymentTransaction.prototype, "refundedAmount", void 0);
|
|
706
|
-
tslib.__decorate([
|
|
707
|
-
classTransformer.Expose({ name: 'card_holder_name' }),
|
|
708
|
-
tslib.__metadata("design:type", String)
|
|
709
|
-
], PaymentTransaction.prototype, "cardHolderName", void 0);
|
|
710
|
-
tslib.__decorate([
|
|
711
|
-
classTransformer.Expose({ name: 'card_last_digits' }),
|
|
712
|
-
tslib.__metadata("design:type", String)
|
|
713
|
-
], PaymentTransaction.prototype, "cardLastDigits", void 0);
|
|
714
|
-
tslib.__decorate([
|
|
715
|
-
classTransformer.Expose({ name: 'card_first_digits' }),
|
|
716
|
-
tslib.__metadata("design:type", String)
|
|
717
|
-
], PaymentTransaction.prototype, "cardFirstDigits", void 0);
|
|
718
|
-
tslib.__decorate([
|
|
719
|
-
classTransformer.Expose({ name: 'card_brand' }),
|
|
720
|
-
tslib.__metadata("design:type", String)
|
|
721
|
-
], PaymentTransaction.prototype, "cardBrand", void 0);
|
|
722
|
-
tslib.__decorate([
|
|
723
|
-
classTransformer.Expose({ name: 'card_pin_mode' }),
|
|
724
|
-
tslib.__metadata("design:type", String)
|
|
725
|
-
], PaymentTransaction.prototype, "cardPinMode", void 0);
|
|
726
|
-
tslib.__decorate([
|
|
727
|
-
classTransformer.Expose({ name: 'card_magstripe_fallback' }),
|
|
728
|
-
tslib.__metadata("design:type", Boolean)
|
|
729
|
-
], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
|
|
730
|
-
tslib.__decorate([
|
|
731
|
-
classTransformer.Expose({ name: 'cvm_pin' }),
|
|
732
|
-
tslib.__metadata("design:type", Boolean)
|
|
733
|
-
], PaymentTransaction.prototype, "cvmPin", void 0);
|
|
734
|
-
tslib.__decorate([
|
|
735
|
-
classTransformer.Expose({ name: 'postback_url' }),
|
|
736
|
-
tslib.__metadata("design:type", String)
|
|
737
|
-
], PaymentTransaction.prototype, "postbackUrl", void 0);
|
|
738
|
-
tslib.__decorate([
|
|
739
|
-
classTransformer.Expose({ name: 'payment_method' }),
|
|
740
|
-
tslib.__metadata("design:type", String)
|
|
741
|
-
], PaymentTransaction.prototype, "paymentMethod", void 0);
|
|
742
|
-
tslib.__decorate([
|
|
743
|
-
classTransformer.Expose({ name: 'capture_method' }),
|
|
744
|
-
tslib.__metadata("design:type", String)
|
|
745
|
-
], PaymentTransaction.prototype, "captureMethod", void 0);
|
|
746
|
-
tslib.__decorate([
|
|
747
|
-
classTransformer.Expose({ name: 'antifraud_score' }),
|
|
748
|
-
tslib.__metadata("design:type", String)
|
|
749
|
-
], PaymentTransaction.prototype, "antifraudScore", void 0);
|
|
750
|
-
tslib.__decorate([
|
|
751
|
-
classTransformer.Expose({ name: 'boleto_url' }),
|
|
752
|
-
tslib.__metadata("design:type", String)
|
|
753
|
-
], PaymentTransaction.prototype, "boletoUrl", void 0);
|
|
754
|
-
tslib.__decorate([
|
|
755
|
-
classTransformer.Expose({ name: 'boleto_barcode' }),
|
|
756
|
-
tslib.__metadata("design:type", String)
|
|
757
|
-
], PaymentTransaction.prototype, "boletoBarcode", void 0);
|
|
758
|
-
tslib.__decorate([
|
|
759
|
-
classTransformer.Expose({ name: 'boleto_expiration_date' }),
|
|
760
|
-
tslib.__metadata("design:type", String)
|
|
761
|
-
], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
|
|
762
|
-
tslib.__decorate([
|
|
763
|
-
classTransformer.Expose({ name: 'subscription_id' }),
|
|
764
|
-
tslib.__metadata("design:type", String)
|
|
765
|
-
], PaymentTransaction.prototype, "subscriptionId", void 0);
|
|
766
|
-
tslib.__decorate([
|
|
767
|
-
classTransformer.Expose({ name: 'split_rules' }),
|
|
768
|
-
tslib.__metadata("design:type", String)
|
|
769
|
-
], PaymentTransaction.prototype, "splitRules", void 0);
|
|
770
|
-
tslib.__decorate([
|
|
771
|
-
classTransformer.Expose({ name: 'antifraud_metadata' }),
|
|
772
|
-
tslib.__metadata("design:type", Object)
|
|
773
|
-
], PaymentTransaction.prototype, "antifraudMetadata", void 0);
|
|
774
|
-
tslib.__decorate([
|
|
775
|
-
classTransformer.Expose({ name: 'reference_key' }),
|
|
776
|
-
tslib.__metadata("design:type", String)
|
|
777
|
-
], PaymentTransaction.prototype, "referenceKey", void 0);
|
|
778
|
-
tslib.__decorate([
|
|
779
|
-
classTransformer.Expose({ name: 'local_transaction_id' }),
|
|
780
|
-
tslib.__metadata("design:type", String)
|
|
781
|
-
], PaymentTransaction.prototype, "localTransactionId", void 0);
|
|
782
|
-
tslib.__decorate([
|
|
783
|
-
classTransformer.Expose({ name: 'local_time' }),
|
|
784
|
-
tslib.__metadata("design:type", String)
|
|
785
|
-
], PaymentTransaction.prototype, "localTime", void 0);
|
|
786
|
-
tslib.__decorate([
|
|
787
|
-
classTransformer.Expose({ name: 'fraud_covered' }),
|
|
788
|
-
tslib.__metadata("design:type", Boolean)
|
|
789
|
-
], PaymentTransaction.prototype, "fraudCovered", void 0);
|
|
790
|
-
tslib.__decorate([
|
|
791
|
-
classTransformer.Expose({ name: 'fraud_reimbursed' }),
|
|
792
|
-
tslib.__metadata("design:type", String)
|
|
793
|
-
], PaymentTransaction.prototype, "fraudReimbursed", void 0);
|
|
794
|
-
tslib.__decorate([
|
|
795
|
-
classTransformer.Expose({ name: 'order_id' }),
|
|
796
|
-
tslib.__metadata("design:type", String)
|
|
797
|
-
], PaymentTransaction.prototype, "orderId", void 0);
|
|
798
|
-
tslib.__decorate([
|
|
799
|
-
classTransformer.Expose({ name: 'risk_level' }),
|
|
800
|
-
tslib.__metadata("design:type", String)
|
|
801
|
-
], PaymentTransaction.prototype, "riskLevel", void 0);
|
|
802
|
-
tslib.__decorate([
|
|
803
|
-
classTransformer.Expose({ name: 'receipt_url' }),
|
|
804
|
-
tslib.__metadata("design:type", String)
|
|
805
|
-
], PaymentTransaction.prototype, "receiptUrl", void 0);
|
|
806
|
-
tslib.__decorate([
|
|
807
|
-
classTransformer.Expose({ name: 'private_label' }),
|
|
808
|
-
tslib.__metadata("design:type", String)
|
|
809
|
-
], PaymentTransaction.prototype, "privateLabel", void 0);
|
|
810
|
-
tslib.__decorate([
|
|
811
|
-
classTransformer.Expose({ name: 'pix_qr_code' }),
|
|
812
|
-
tslib.__metadata("design:type", String)
|
|
813
|
-
], PaymentTransaction.prototype, "pixQrCode", void 0);
|
|
814
|
-
tslib.__decorate([
|
|
815
|
-
classTransformer.Expose({ name: 'pix_expiration_date' }),
|
|
816
|
-
tslib.__metadata("design:type", String)
|
|
817
|
-
], PaymentTransaction.prototype, "pixExpirationDate", void 0);
|
|
653
|
+
}
|
|
818
654
|
|
|
819
655
|
class Payment extends BaseModel {
|
|
820
656
|
static get identifiersFields() {
|
|
@@ -2628,7 +2464,8 @@ class AntifraudPixService {
|
|
|
2628
2464
|
}
|
|
2629
2465
|
|
|
2630
2466
|
class GlampointsPaymentService {
|
|
2631
|
-
constructor(paymentRepository) {
|
|
2467
|
+
constructor(glamCredentials, paymentRepository) {
|
|
2468
|
+
this.glamCredentials = glamCredentials;
|
|
2632
2469
|
this.paymentRepository = paymentRepository;
|
|
2633
2470
|
}
|
|
2634
2471
|
async pay(checkout) {
|
|
@@ -2641,23 +2478,72 @@ class GlampointsPaymentService {
|
|
|
2641
2478
|
paymentProvider: 'glampoints',
|
|
2642
2479
|
transaction: {
|
|
2643
2480
|
amount: 0,
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2481
|
+
acquirer_response_code: '0000',
|
|
2482
|
+
acquirer_name: 'glampoints',
|
|
2483
|
+
authorized_amount: 0,
|
|
2484
|
+
capture_method: 'ecommerce',
|
|
2648
2485
|
installments: 1,
|
|
2649
2486
|
cost: 0,
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2487
|
+
paid_amount: 0,
|
|
2488
|
+
paid_at: new Date().toISOString(),
|
|
2489
|
+
payment_method: 'glampoints',
|
|
2653
2490
|
referer: 'api_key',
|
|
2654
|
-
|
|
2491
|
+
refunded_amount: 0,
|
|
2655
2492
|
status: 'paid',
|
|
2656
|
-
|
|
2493
|
+
status_reason: 'acquirer',
|
|
2494
|
+
date_created: new Date().toISOString(),
|
|
2657
2495
|
},
|
|
2658
2496
|
}));
|
|
2659
2497
|
return payment;
|
|
2660
2498
|
}
|
|
2499
|
+
async rewardByOrder(orderId, user, lineItens) {
|
|
2500
|
+
try {
|
|
2501
|
+
const points = lineItens.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2502
|
+
const result = await axios__default["default"]({
|
|
2503
|
+
method: 'POST',
|
|
2504
|
+
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
2505
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2506
|
+
timeout: 60000,
|
|
2507
|
+
data: {
|
|
2508
|
+
personId: user.id,
|
|
2509
|
+
rewardType: 50,
|
|
2510
|
+
referenceId: 0,
|
|
2511
|
+
referenceName: `Compra - ${points} produto(s)`,
|
|
2512
|
+
points: points,
|
|
2513
|
+
productId: '',
|
|
2514
|
+
token: this.glamCredentials.integrationToken,
|
|
2515
|
+
orderId,
|
|
2516
|
+
},
|
|
2517
|
+
});
|
|
2518
|
+
console.info('[rewards - rewardByOrder] reward success:', JSON.stringify(result));
|
|
2519
|
+
return result.data;
|
|
2520
|
+
}
|
|
2521
|
+
catch (err) {
|
|
2522
|
+
console.error('[rewards - rewardByOrder] reward request error', JSON.stringify(err));
|
|
2523
|
+
return err;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
async negativateRewardByOrderId(orderId, orderNumber) {
|
|
2527
|
+
try {
|
|
2528
|
+
const result = await axios__default["default"]({
|
|
2529
|
+
method: 'POST',
|
|
2530
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2531
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2532
|
+
timeout: 60000,
|
|
2533
|
+
data: {
|
|
2534
|
+
rewardType: 51,
|
|
2535
|
+
referenceName: `Pedido #${orderId} cancelado`,
|
|
2536
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2537
|
+
orderId,
|
|
2538
|
+
orderNumber: parseInt(orderNumber.replace(/\D/g, ''), 10),
|
|
2539
|
+
},
|
|
2540
|
+
});
|
|
2541
|
+
return result;
|
|
2542
|
+
}
|
|
2543
|
+
catch (error) {
|
|
2544
|
+
return error;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2661
2547
|
}
|
|
2662
2548
|
|
|
2663
2549
|
class RoundProductPricesHelper {
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { __decorate, __metadata, __values, __spreadArray, __read, __extends, __rest } from 'tslib';
|
|
3
|
-
import { plainToInstance, instanceToPlain, Type
|
|
3
|
+
import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
|
|
4
4
|
import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
|
|
6
6
|
import { isNil, isArray, first, last, flatten, compact, get, isString, each, unset, isObject, set, isNumber, chunk, isEmpty, isDate, isBoolean, isInteger, isNaN as isNaN$1, sortBy, omit } from 'lodash';
|
|
@@ -644,171 +644,7 @@ var Status;
|
|
|
644
644
|
})(Status || (Status = {}));
|
|
645
645
|
|
|
646
646
|
class PaymentTransaction extends BaseModel {
|
|
647
|
-
}
|
|
648
|
-
__decorate([
|
|
649
|
-
Expose({ name: 'refuse_reason' }),
|
|
650
|
-
__metadata("design:type", String)
|
|
651
|
-
], PaymentTransaction.prototype, "refuseReason", void 0);
|
|
652
|
-
__decorate([
|
|
653
|
-
Expose({ name: 'status_reason' }),
|
|
654
|
-
__metadata("design:type", String)
|
|
655
|
-
], PaymentTransaction.prototype, "statusReason", void 0);
|
|
656
|
-
__decorate([
|
|
657
|
-
Expose({ name: 'acquirer_response_code' }),
|
|
658
|
-
__metadata("design:type", String)
|
|
659
|
-
], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
|
|
660
|
-
__decorate([
|
|
661
|
-
Expose({ name: 'acquirer_name' }),
|
|
662
|
-
__metadata("design:type", String)
|
|
663
|
-
], PaymentTransaction.prototype, "acquirerName", void 0);
|
|
664
|
-
__decorate([
|
|
665
|
-
Expose({ name: 'acquirer_id' }),
|
|
666
|
-
__metadata("design:type", String)
|
|
667
|
-
], PaymentTransaction.prototype, "acquirerId", void 0);
|
|
668
|
-
__decorate([
|
|
669
|
-
Expose({ name: 'authorization_code' }),
|
|
670
|
-
__metadata("design:type", String)
|
|
671
|
-
], PaymentTransaction.prototype, "authorizationCode", void 0);
|
|
672
|
-
__decorate([
|
|
673
|
-
Expose({ name: 'soft_descriptor' }),
|
|
674
|
-
__metadata("design:type", String)
|
|
675
|
-
], PaymentTransaction.prototype, "softDescriptor", void 0);
|
|
676
|
-
__decorate([
|
|
677
|
-
Expose({ name: 'date_created' }),
|
|
678
|
-
__metadata("design:type", String)
|
|
679
|
-
], PaymentTransaction.prototype, "dateCreated", void 0);
|
|
680
|
-
__decorate([
|
|
681
|
-
Expose({ name: 'date_updated' }),
|
|
682
|
-
__metadata("design:type", String)
|
|
683
|
-
], PaymentTransaction.prototype, "dateUpdated", void 0);
|
|
684
|
-
__decorate([
|
|
685
|
-
Expose({ name: 'authorized_amount' }),
|
|
686
|
-
__metadata("design:type", Number)
|
|
687
|
-
], PaymentTransaction.prototype, "authorizedAmount", void 0);
|
|
688
|
-
__decorate([
|
|
689
|
-
Expose({ name: 'paid_amount' }),
|
|
690
|
-
__metadata("design:type", Number)
|
|
691
|
-
], PaymentTransaction.prototype, "paidAmount", void 0);
|
|
692
|
-
__decorate([
|
|
693
|
-
Expose({ name: 'paid_at' }),
|
|
694
|
-
__metadata("design:type", String)
|
|
695
|
-
], PaymentTransaction.prototype, "paidAt", void 0);
|
|
696
|
-
__decorate([
|
|
697
|
-
Expose({ name: 'refunded_amount' }),
|
|
698
|
-
__metadata("design:type", Number)
|
|
699
|
-
], PaymentTransaction.prototype, "refundedAmount", void 0);
|
|
700
|
-
__decorate([
|
|
701
|
-
Expose({ name: 'card_holder_name' }),
|
|
702
|
-
__metadata("design:type", String)
|
|
703
|
-
], PaymentTransaction.prototype, "cardHolderName", void 0);
|
|
704
|
-
__decorate([
|
|
705
|
-
Expose({ name: 'card_last_digits' }),
|
|
706
|
-
__metadata("design:type", String)
|
|
707
|
-
], PaymentTransaction.prototype, "cardLastDigits", void 0);
|
|
708
|
-
__decorate([
|
|
709
|
-
Expose({ name: 'card_first_digits' }),
|
|
710
|
-
__metadata("design:type", String)
|
|
711
|
-
], PaymentTransaction.prototype, "cardFirstDigits", void 0);
|
|
712
|
-
__decorate([
|
|
713
|
-
Expose({ name: 'card_brand' }),
|
|
714
|
-
__metadata("design:type", String)
|
|
715
|
-
], PaymentTransaction.prototype, "cardBrand", void 0);
|
|
716
|
-
__decorate([
|
|
717
|
-
Expose({ name: 'card_pin_mode' }),
|
|
718
|
-
__metadata("design:type", String)
|
|
719
|
-
], PaymentTransaction.prototype, "cardPinMode", void 0);
|
|
720
|
-
__decorate([
|
|
721
|
-
Expose({ name: 'card_magstripe_fallback' }),
|
|
722
|
-
__metadata("design:type", Boolean)
|
|
723
|
-
], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
|
|
724
|
-
__decorate([
|
|
725
|
-
Expose({ name: 'cvm_pin' }),
|
|
726
|
-
__metadata("design:type", Boolean)
|
|
727
|
-
], PaymentTransaction.prototype, "cvmPin", void 0);
|
|
728
|
-
__decorate([
|
|
729
|
-
Expose({ name: 'postback_url' }),
|
|
730
|
-
__metadata("design:type", String)
|
|
731
|
-
], PaymentTransaction.prototype, "postbackUrl", void 0);
|
|
732
|
-
__decorate([
|
|
733
|
-
Expose({ name: 'payment_method' }),
|
|
734
|
-
__metadata("design:type", String)
|
|
735
|
-
], PaymentTransaction.prototype, "paymentMethod", void 0);
|
|
736
|
-
__decorate([
|
|
737
|
-
Expose({ name: 'capture_method' }),
|
|
738
|
-
__metadata("design:type", String)
|
|
739
|
-
], PaymentTransaction.prototype, "captureMethod", void 0);
|
|
740
|
-
__decorate([
|
|
741
|
-
Expose({ name: 'antifraud_score' }),
|
|
742
|
-
__metadata("design:type", String)
|
|
743
|
-
], PaymentTransaction.prototype, "antifraudScore", void 0);
|
|
744
|
-
__decorate([
|
|
745
|
-
Expose({ name: 'boleto_url' }),
|
|
746
|
-
__metadata("design:type", String)
|
|
747
|
-
], PaymentTransaction.prototype, "boletoUrl", void 0);
|
|
748
|
-
__decorate([
|
|
749
|
-
Expose({ name: 'boleto_barcode' }),
|
|
750
|
-
__metadata("design:type", String)
|
|
751
|
-
], PaymentTransaction.prototype, "boletoBarcode", void 0);
|
|
752
|
-
__decorate([
|
|
753
|
-
Expose({ name: 'boleto_expiration_date' }),
|
|
754
|
-
__metadata("design:type", String)
|
|
755
|
-
], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
|
|
756
|
-
__decorate([
|
|
757
|
-
Expose({ name: 'subscription_id' }),
|
|
758
|
-
__metadata("design:type", String)
|
|
759
|
-
], PaymentTransaction.prototype, "subscriptionId", void 0);
|
|
760
|
-
__decorate([
|
|
761
|
-
Expose({ name: 'split_rules' }),
|
|
762
|
-
__metadata("design:type", String)
|
|
763
|
-
], PaymentTransaction.prototype, "splitRules", void 0);
|
|
764
|
-
__decorate([
|
|
765
|
-
Expose({ name: 'antifraud_metadata' }),
|
|
766
|
-
__metadata("design:type", Object)
|
|
767
|
-
], PaymentTransaction.prototype, "antifraudMetadata", void 0);
|
|
768
|
-
__decorate([
|
|
769
|
-
Expose({ name: 'reference_key' }),
|
|
770
|
-
__metadata("design:type", String)
|
|
771
|
-
], PaymentTransaction.prototype, "referenceKey", void 0);
|
|
772
|
-
__decorate([
|
|
773
|
-
Expose({ name: 'local_transaction_id' }),
|
|
774
|
-
__metadata("design:type", String)
|
|
775
|
-
], PaymentTransaction.prototype, "localTransactionId", void 0);
|
|
776
|
-
__decorate([
|
|
777
|
-
Expose({ name: 'local_time' }),
|
|
778
|
-
__metadata("design:type", String)
|
|
779
|
-
], PaymentTransaction.prototype, "localTime", void 0);
|
|
780
|
-
__decorate([
|
|
781
|
-
Expose({ name: 'fraud_covered' }),
|
|
782
|
-
__metadata("design:type", Boolean)
|
|
783
|
-
], PaymentTransaction.prototype, "fraudCovered", void 0);
|
|
784
|
-
__decorate([
|
|
785
|
-
Expose({ name: 'fraud_reimbursed' }),
|
|
786
|
-
__metadata("design:type", String)
|
|
787
|
-
], PaymentTransaction.prototype, "fraudReimbursed", void 0);
|
|
788
|
-
__decorate([
|
|
789
|
-
Expose({ name: 'order_id' }),
|
|
790
|
-
__metadata("design:type", String)
|
|
791
|
-
], PaymentTransaction.prototype, "orderId", void 0);
|
|
792
|
-
__decorate([
|
|
793
|
-
Expose({ name: 'risk_level' }),
|
|
794
|
-
__metadata("design:type", String)
|
|
795
|
-
], PaymentTransaction.prototype, "riskLevel", void 0);
|
|
796
|
-
__decorate([
|
|
797
|
-
Expose({ name: 'receipt_url' }),
|
|
798
|
-
__metadata("design:type", String)
|
|
799
|
-
], PaymentTransaction.prototype, "receiptUrl", void 0);
|
|
800
|
-
__decorate([
|
|
801
|
-
Expose({ name: 'private_label' }),
|
|
802
|
-
__metadata("design:type", String)
|
|
803
|
-
], PaymentTransaction.prototype, "privateLabel", void 0);
|
|
804
|
-
__decorate([
|
|
805
|
-
Expose({ name: 'pix_qr_code' }),
|
|
806
|
-
__metadata("design:type", String)
|
|
807
|
-
], PaymentTransaction.prototype, "pixQrCode", void 0);
|
|
808
|
-
__decorate([
|
|
809
|
-
Expose({ name: 'pix_expiration_date' }),
|
|
810
|
-
__metadata("design:type", String)
|
|
811
|
-
], PaymentTransaction.prototype, "pixExpirationDate", void 0);
|
|
647
|
+
}
|
|
812
648
|
|
|
813
649
|
class Payment extends BaseModel {
|
|
814
650
|
static get identifiersFields() {
|
|
@@ -2622,7 +2458,8 @@ class AntifraudPixService {
|
|
|
2622
2458
|
}
|
|
2623
2459
|
|
|
2624
2460
|
class GlampointsPaymentService {
|
|
2625
|
-
constructor(paymentRepository) {
|
|
2461
|
+
constructor(glamCredentials, paymentRepository) {
|
|
2462
|
+
this.glamCredentials = glamCredentials;
|
|
2626
2463
|
this.paymentRepository = paymentRepository;
|
|
2627
2464
|
}
|
|
2628
2465
|
async pay(checkout) {
|
|
@@ -2635,23 +2472,72 @@ class GlampointsPaymentService {
|
|
|
2635
2472
|
paymentProvider: 'glampoints',
|
|
2636
2473
|
transaction: {
|
|
2637
2474
|
amount: 0,
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2475
|
+
acquirer_response_code: '0000',
|
|
2476
|
+
acquirer_name: 'glampoints',
|
|
2477
|
+
authorized_amount: 0,
|
|
2478
|
+
capture_method: 'ecommerce',
|
|
2642
2479
|
installments: 1,
|
|
2643
2480
|
cost: 0,
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2481
|
+
paid_amount: 0,
|
|
2482
|
+
paid_at: new Date().toISOString(),
|
|
2483
|
+
payment_method: 'glampoints',
|
|
2647
2484
|
referer: 'api_key',
|
|
2648
|
-
|
|
2485
|
+
refunded_amount: 0,
|
|
2649
2486
|
status: 'paid',
|
|
2650
|
-
|
|
2487
|
+
status_reason: 'acquirer',
|
|
2488
|
+
date_created: new Date().toISOString(),
|
|
2651
2489
|
},
|
|
2652
2490
|
}));
|
|
2653
2491
|
return payment;
|
|
2654
2492
|
}
|
|
2493
|
+
async rewardByOrder(orderId, user, lineItens) {
|
|
2494
|
+
try {
|
|
2495
|
+
const points = lineItens.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2496
|
+
const result = await axios({
|
|
2497
|
+
method: 'POST',
|
|
2498
|
+
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
2499
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2500
|
+
timeout: 60000,
|
|
2501
|
+
data: {
|
|
2502
|
+
personId: user.id,
|
|
2503
|
+
rewardType: 50,
|
|
2504
|
+
referenceId: 0,
|
|
2505
|
+
referenceName: `Compra - ${points} produto(s)`,
|
|
2506
|
+
points: points,
|
|
2507
|
+
productId: '',
|
|
2508
|
+
token: this.glamCredentials.integrationToken,
|
|
2509
|
+
orderId,
|
|
2510
|
+
},
|
|
2511
|
+
});
|
|
2512
|
+
console.info('[rewards - rewardByOrder] reward success:', JSON.stringify(result));
|
|
2513
|
+
return result.data;
|
|
2514
|
+
}
|
|
2515
|
+
catch (err) {
|
|
2516
|
+
console.error('[rewards - rewardByOrder] reward request error', JSON.stringify(err));
|
|
2517
|
+
return err;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
async negativateRewardByOrderId(orderId, orderNumber) {
|
|
2521
|
+
try {
|
|
2522
|
+
const result = await axios({
|
|
2523
|
+
method: 'POST',
|
|
2524
|
+
url: `${this.glamCredentials.baseUrl}/integration/negativate/reward`,
|
|
2525
|
+
headers: { 'Content-Type': 'application/json' },
|
|
2526
|
+
timeout: 60000,
|
|
2527
|
+
data: {
|
|
2528
|
+
rewardType: 51,
|
|
2529
|
+
referenceName: `Pedido #${orderId} cancelado`,
|
|
2530
|
+
token: '$2a$12$2DAPE64UUWAo4TT/1eQ9TOJO40b5z2jdomOJG3X7LeexwOHYtPydW',
|
|
2531
|
+
orderId,
|
|
2532
|
+
orderNumber: parseInt(orderNumber.replace(/\D/g, ''), 10),
|
|
2533
|
+
},
|
|
2534
|
+
});
|
|
2535
|
+
return result;
|
|
2536
|
+
}
|
|
2537
|
+
catch (error) {
|
|
2538
|
+
return error;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2655
2541
|
}
|
|
2656
2542
|
|
|
2657
2543
|
class RoundProductPricesHelper {
|
package/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { User } from '../../users';
|
|
2
|
+
import { LineItem } from '../models';
|
|
1
3
|
import { Checkout } from '../models/checkout';
|
|
2
4
|
import { Payment } from '../models/payment';
|
|
3
5
|
export interface PaymentProviderGlampoints {
|
|
4
6
|
pay(checkout: Checkout): Promise<Payment>;
|
|
7
|
+
rewardByOrder(orderId: string, user: User, lineItems: LineItem[]): Promise<void>;
|
|
8
|
+
negativateRewardByOrderId(orderId: string, orderNumber: string): Promise<any>;
|
|
5
9
|
}
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { BaseModel } from '../../generic/model/base.model';
|
|
2
2
|
import { PaymentBilling, PaymentCard, PaymentCustomer, PaymentItem, PaymentShipping } from './types';
|
|
3
3
|
export declare class PaymentTransaction extends BaseModel<PaymentTransaction> {
|
|
4
|
-
id
|
|
5
|
-
object
|
|
6
|
-
status
|
|
7
|
-
tid
|
|
8
|
-
nsu
|
|
4
|
+
id?: number;
|
|
5
|
+
object?: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
tid?: number;
|
|
8
|
+
nsu?: number;
|
|
9
9
|
amount: number;
|
|
10
10
|
cost: number;
|
|
11
|
-
installments
|
|
11
|
+
installments?: number;
|
|
12
12
|
referer: string;
|
|
13
|
-
ip
|
|
14
|
-
phone
|
|
15
|
-
address
|
|
16
|
-
metadata
|
|
17
|
-
device
|
|
18
|
-
payment
|
|
19
|
-
addition
|
|
20
|
-
discount
|
|
21
|
-
customer
|
|
22
|
-
billing
|
|
23
|
-
shipping
|
|
24
|
-
items
|
|
25
|
-
card
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fraudCovered
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
13
|
+
ip?: string;
|
|
14
|
+
phone?: string;
|
|
15
|
+
address?: string;
|
|
16
|
+
metadata?: any;
|
|
17
|
+
device?: string;
|
|
18
|
+
payment?: string;
|
|
19
|
+
addition?: string;
|
|
20
|
+
discount?: string;
|
|
21
|
+
customer?: PaymentCustomer;
|
|
22
|
+
billing?: PaymentBilling;
|
|
23
|
+
shipping?: PaymentShipping;
|
|
24
|
+
items?: PaymentItem[];
|
|
25
|
+
card?: PaymentCard;
|
|
26
|
+
refuse_reason?: string;
|
|
27
|
+
status_reason?: string;
|
|
28
|
+
acquirer_response_code?: string;
|
|
29
|
+
acquirer_name?: string;
|
|
30
|
+
acquirer_id?: string;
|
|
31
|
+
authorization_code?: string;
|
|
32
|
+
soft_descriptor?: string;
|
|
33
|
+
date_created?: string;
|
|
34
|
+
date_updated?: string;
|
|
35
|
+
authorized_amount?: number;
|
|
36
|
+
paid_amount?: number;
|
|
37
|
+
paid_at?: string;
|
|
38
|
+
refunded_amount?: number;
|
|
39
|
+
card_holder_name?: string;
|
|
40
|
+
card_last_digits?: string;
|
|
41
|
+
card_first_digits?: string;
|
|
42
|
+
card_brand?: string;
|
|
43
|
+
card_pin_mode?: string;
|
|
44
|
+
card_magstripe_fallback?: boolean;
|
|
45
|
+
cvm_pin?: boolean;
|
|
46
|
+
postback_url?: string;
|
|
47
|
+
payment_method?: string;
|
|
48
|
+
capture_method?: string;
|
|
49
|
+
antifraud_score?: string;
|
|
50
|
+
boleto_url?: string;
|
|
51
|
+
boleto_barcode?: string;
|
|
52
|
+
boleto_expiration_date?: string;
|
|
53
|
+
subscription_id?: string;
|
|
54
|
+
split_rules?: string;
|
|
55
|
+
antifraud_metadata?: any;
|
|
56
|
+
reference_key?: string;
|
|
57
|
+
local_transaction_id?: string;
|
|
58
|
+
local_time?: string;
|
|
59
|
+
fraudCovered?: boolean;
|
|
60
|
+
fraud_reimbursed?: string;
|
|
61
|
+
order_id?: string;
|
|
62
|
+
risk_level?: string;
|
|
63
|
+
receipt_url?: string;
|
|
64
|
+
private_label?: string;
|
|
65
|
+
pix_qr_code?: string;
|
|
66
|
+
pix_expiration_date?: string;
|
|
67
67
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { User } from '../../users';
|
|
1
2
|
import { PaymentProviderGlampoints } from '../interfaces';
|
|
2
|
-
import { Checkout, Payment } from '../models';
|
|
3
|
+
import { Checkout, LineItem, Payment } from '../models';
|
|
3
4
|
import { PaymentRepository } from '../repositories';
|
|
5
|
+
import { GlamCredentials } from '../types';
|
|
4
6
|
export declare class GlampointsPaymentService implements PaymentProviderGlampoints {
|
|
7
|
+
private glamCredentials;
|
|
5
8
|
private paymentRepository;
|
|
6
|
-
constructor(paymentRepository: PaymentRepository);
|
|
9
|
+
constructor(glamCredentials: GlamCredentials, paymentRepository: PaymentRepository);
|
|
7
10
|
pay(checkout: Checkout): Promise<Payment>;
|
|
11
|
+
rewardByOrder(orderId: string, user: User, lineItens: LineItem[]): Promise<any>;
|
|
12
|
+
negativateRewardByOrderId(orderId: string, orderNumber: string): Promise<any>;
|
|
8
13
|
}
|
|
@@ -2,6 +2,7 @@ export * from './adyen-card.type';
|
|
|
2
2
|
export * from './adyen-credentials.type';
|
|
3
3
|
export * from './antifraud-provider.type';
|
|
4
4
|
export * from './card-info.type';
|
|
5
|
+
export * from './glam-credentials.type';
|
|
5
6
|
export * from './order-tracking-events.type';
|
|
6
7
|
export * from './pagarme-card.type';
|
|
7
8
|
export * from './pagarme-credentials.type';
|