vk-payments 0.2.31 → 0.2.33

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.
@@ -5,6 +5,7 @@ import { Router, RouterModule } from '@angular/router';
5
5
  import { HttpHeaders, HttpClient, HttpClientModule } from '@angular/common/http';
6
6
  import sha256 from 'sha256';
7
7
  import { __awaiter } from 'tslib';
8
+ import { toDataURL } from 'qrcode';
8
9
 
9
10
  /**
10
11
  * @fileoverview added by tsickle
@@ -3462,6 +3463,414 @@ BankTransferModule.decorators = [
3462
3463
  },] }
3463
3464
  ];
3464
3465
 
3466
+ /**
3467
+ * @fileoverview added by tsickle
3468
+ * Generated from: lib/galicia/services/galicia.api.service.ts
3469
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3470
+ */
3471
+ class GaliciaApiService {
3472
+ /**
3473
+ * @param {?} httpClient
3474
+ */
3475
+ constructor(httpClient) {
3476
+ this.httpClient = httpClient;
3477
+ }
3478
+ /**
3479
+ * @param {?} url
3480
+ * @return {?}
3481
+ */
3482
+ normalizeUrl(url) {
3483
+ if (url.length > 0 && url.charAt(url.length - 1) == '/') {
3484
+ url = url.substr(0, url.length - 1);
3485
+ }
3486
+ return url;
3487
+ }
3488
+ /**
3489
+ * @param {?} url
3490
+ * @param {?} initPayment
3491
+ * @return {?}
3492
+ */
3493
+ initPayment(url, initPayment) {
3494
+ /** @type {?} */
3495
+ const body = {
3496
+ storeId: initPayment.storeId,
3497
+ userId: initPayment.userId,
3498
+ sessionId: initPayment.sessionId,
3499
+ storeName: initPayment.storeName,
3500
+ checkoutId: initPayment.checkoutId
3501
+ };
3502
+ return this.httpClient.post(this.normalizeUrl(url) + '/init-payment', body);
3503
+ }
3504
+ /**
3505
+ * @param {?} url
3506
+ * @param {?} billNumber
3507
+ * @return {?}
3508
+ */
3509
+ paymentStatus(url, billNumber) {
3510
+ return this.httpClient.get(this.normalizeUrl(url) + '/payment-status?billNumber=' + billNumber);
3511
+ }
3512
+ }
3513
+ GaliciaApiService.decorators = [
3514
+ { type: Injectable, args: [{
3515
+ providedIn: 'root'
3516
+ },] }
3517
+ ];
3518
+ /** @nocollapse */
3519
+ GaliciaApiService.ctorParameters = () => [
3520
+ { type: HttpClient }
3521
+ ];
3522
+ /** @nocollapse */ GaliciaApiService.ngInjectableDef = ɵɵdefineInjectable({ factory: function GaliciaApiService_Factory() { return new GaliciaApiService(ɵɵinject(HttpClient)); }, token: GaliciaApiService, providedIn: "root" });
3523
+ if (false) {
3524
+ /**
3525
+ * @type {?}
3526
+ * @private
3527
+ */
3528
+ GaliciaApiService.prototype.authHeaders;
3529
+ /**
3530
+ * @type {?}
3531
+ * @private
3532
+ */
3533
+ GaliciaApiService.prototype.httpClient;
3534
+ }
3535
+
3536
+ /**
3537
+ * @fileoverview added by tsickle
3538
+ * Generated from: lib/galicia/components/galicia.component.ts
3539
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3540
+ */
3541
+ class GaliciaComponent {
3542
+ /**
3543
+ * @param {?} galiciaApiService
3544
+ */
3545
+ constructor(galiciaApiService) {
3546
+ this.galiciaApiService = galiciaApiService;
3547
+ this.statusPay = new EventEmitter();
3548
+ this.qrImage = '';
3549
+ this.billNumber = '';
3550
+ this.errorMessage = '';
3551
+ this.isGeneratingQr = true;
3552
+ this.paymentCompleted = false;
3553
+ this.paymentId = '';
3554
+ this.showQr = false;
3555
+ this.expired = false;
3556
+ this.isLoading = false;
3557
+ this.hasError = false;
3558
+ this.minutes = 0;
3559
+ this.seconds = 0;
3560
+ this.paymentResult = { success: false, paymentId: '', integrator: 'GALICIA' };
3561
+ }
3562
+ /**
3563
+ * @return {?}
3564
+ */
3565
+ ngOnInit() {
3566
+ this.createInitPayment();
3567
+ }
3568
+ /**
3569
+ * @param {?} datos
3570
+ * @return {?}
3571
+ */
3572
+ generateQr(datos) {
3573
+ /** @type {?} */
3574
+ const decoded = atob(datos);
3575
+ toDataURL(decoded, {
3576
+ width: 300,
3577
+ margin: 2
3578
+ })
3579
+ .then((/**
3580
+ * @param {?} url
3581
+ * @return {?}
3582
+ */
3583
+ url => {
3584
+ this.qrImage = url;
3585
+ this.isGeneratingQr = false;
3586
+ this.showQr = true;
3587
+ this.expired = false;
3588
+ this.startTimer();
3589
+ this.startPaymentValidation();
3590
+ }));
3591
+ }
3592
+ /**
3593
+ * @return {?}
3594
+ */
3595
+ createInitPayment() {
3596
+ this.OinitPayment = {
3597
+ sessionId: '',
3598
+ userId: this.userId,
3599
+ storeId: this.storeId,
3600
+ storeName: this.storeName,
3601
+ checkoutId: this.checkoutId
3602
+ };
3603
+ this.initPayment();
3604
+ }
3605
+ /**
3606
+ * @return {?}
3607
+ */
3608
+ initPayment() {
3609
+ this.isGeneratingQr = true;
3610
+ this.galiciaApiService.initPayment(this.vkUrlApi, this.OinitPayment)
3611
+ .subscribe({
3612
+ next: (/**
3613
+ * @param {?} v
3614
+ * @return {?}
3615
+ */
3616
+ (v) => this.initPaymentResponseHandler(v)),
3617
+ error: (/**
3618
+ * @param {?} v
3619
+ * @return {?}
3620
+ */
3621
+ (v) => this.initPaymentErrorHandler(v))
3622
+ });
3623
+ }
3624
+ /**
3625
+ * @private
3626
+ * @param {?} response
3627
+ * @return {?}
3628
+ */
3629
+ initPaymentResponseHandler(response) {
3630
+ if (!response.success) {
3631
+ this.isLoading = false;
3632
+ this.hasError = true;
3633
+ this.statusPay.emit(this.paymentResult);
3634
+ this.errorMessage = response.errorsMessages[0] || 'Ocurrió un error al generar el código QR.';
3635
+ return;
3636
+ }
3637
+ /** @type {?} */
3638
+ var qrData = response.data.bills[0].qr.datos;
3639
+ this.billNumber = response.data.bills[0].nroBoleta;
3640
+ this.generateQr(qrData);
3641
+ }
3642
+ /**
3643
+ * @private
3644
+ * @param {?} error
3645
+ * @return {?}
3646
+ */
3647
+ initPaymentErrorHandler(error) {
3648
+ this.isLoading = false;
3649
+ this.hasError = true;
3650
+ this.errorMessage = error.errorsMessages[0] || 'Ocurrió un error al generar el código QR.';
3651
+ this.paymentResult.success = false;
3652
+ this.statusPay.emit(this.paymentResult);
3653
+ }
3654
+ /**
3655
+ * @return {?}
3656
+ */
3657
+ startTimer() {
3658
+ clearInterval(this.interval);
3659
+ this.minutes = 1;
3660
+ this.seconds = 0;
3661
+ this.interval = setInterval((/**
3662
+ * @return {?}
3663
+ */
3664
+ () => {
3665
+ if (this.seconds === 0) {
3666
+ if (this.minutes === 0) {
3667
+ this.stopValidation();
3668
+ this.showQr = false;
3669
+ this.expired = true;
3670
+ return;
3671
+ }
3672
+ this.minutes--;
3673
+ this.seconds = 59;
3674
+ }
3675
+ else {
3676
+ this.seconds--;
3677
+ }
3678
+ }), 1000);
3679
+ }
3680
+ /**
3681
+ * @return {?}
3682
+ */
3683
+ startPaymentValidation() {
3684
+ this.validationInterval = setInterval((/**
3685
+ * @return {?}
3686
+ */
3687
+ () => {
3688
+ this.galiciaApiService.paymentStatus(this.vkUrlApi, this.billNumber)
3689
+ .subscribe({
3690
+ next: (/**
3691
+ * @param {?} v
3692
+ * @return {?}
3693
+ */
3694
+ (v) => this.paymentStatusResponseHandler(v)),
3695
+ error: (/**
3696
+ * @param {?} v
3697
+ * @return {?}
3698
+ */
3699
+ (v) => this.paymentStatusErrorHandler(v))
3700
+ });
3701
+ }), 5000);
3702
+ }
3703
+ /**
3704
+ * @param {?} response
3705
+ * @return {?}
3706
+ */
3707
+ paymentStatusResponseHandler(response) {
3708
+ if (!response.success) {
3709
+ this.isLoading = false;
3710
+ this.statusPay.emit(this.paymentResult);
3711
+ return;
3712
+ }
3713
+ if (response.data.isPaid) {
3714
+ this.stopValidation();
3715
+ this.showQr = false;
3716
+ this.expired = false;
3717
+ this.paymentCompleted = true;
3718
+ this.paymentId = response.data.paymentId;
3719
+ this.paymentResult = {
3720
+ success: true,
3721
+ paymentId: this.paymentId,
3722
+ integrator: 'GALICIA'
3723
+ };
3724
+ this.statusPay.emit(this.paymentResult);
3725
+ }
3726
+ }
3727
+ /**
3728
+ * @private
3729
+ * @param {?} error
3730
+ * @return {?}
3731
+ */
3732
+ paymentStatusErrorHandler(error) {
3733
+ clearInterval(this.validationInterval);
3734
+ this.hasError = true;
3735
+ }
3736
+ /**
3737
+ * @return {?}
3738
+ */
3739
+ showQrAgain() {
3740
+ this.showQr = true;
3741
+ this.expired = false;
3742
+ this.startTimer();
3743
+ this.startPaymentValidation();
3744
+ }
3745
+ /**
3746
+ * @private
3747
+ * @return {?}
3748
+ */
3749
+ stopValidation() {
3750
+ clearInterval(this.validationInterval);
3751
+ clearInterval(this.interval);
3752
+ }
3753
+ }
3754
+ GaliciaComponent.decorators = [
3755
+ { type: Component, args: [{
3756
+ selector: 'lib-galicia',
3757
+ template: "<div class=\"gc-payment\">\n <div class=\"formRow\">\n <p>\n Escane\u00E1 el c\u00F3digo QR con tu aplicaci\u00F3n bancaria para realizar el pago.\n </p>\n </div>\n\n <div *ngIf=\"isGeneratingQr && !hasError\" class=\"loading-container\">\n <div class=\"spinner\"></div>\n <p>Generando c\u00F3digo QR...</p>\n </div>\n\n <div *ngIf=\"showQr\">\n <div class=\"qr-container\">\n <img [src]=\"qrImage\" alt=\"QR Galicia\" />\n </div>\n\n <div class=\"timer\">\n Tiempo restante: {{ minutes }}:{{ seconds < 10 ? '0' + seconds : seconds }} \n </div>\n </div>\n\n <div *ngIf=\"hasError\" class=\"payment-error\">\n <div class=\"error-icon\">\n \u26A0\n </div>\n\n <div class=\"error-message\">\n <h3>No fue posible generar el c\u00F3digo QR</h3>\n\n <p>{{ errorMessage }}</p>\n </div>\n </div>\n\n <div *ngIf=\"paymentCompleted\" class=\"payment-success\">\n <div class=\"success-icon\">\n \u2713\n </div>\n\n <div class=\"success-message\">\n <h3>Pago realizado correctamente</h3>\n\n <p>\n ID de pago Galicia: <strong>{{ paymentId }}</strong>\n </p>\n </div>\n </div>\n\n <div *ngIf=\"expired\">\n <div class=\"pay-message info\">\n El c\u00F3digo QR expir\u00F3.\n </div>\n\n <button type=\"button\" (click)=\"showQrAgain()\">\n Regenerar c\u00F3digo QR\n </button>\n\n </div>\n</div>",
3758
+ styles: [".gc-payment{display:flex;flex-direction:column;align-items:center;text-align:center}.formRow{width:100%;max-width:400px;margin-bottom:20px}.loading-container{text-align:center;padding:30px}.spinner{width:40px;height:40px;margin:0 auto 15px;border:4px solid #e0e0e0;border-top:4px solid #06c;border-radius:50%;-webkit-animation:1s linear infinite spin;animation:1s linear infinite spin}.qr-container{margin:20px 0}.qr-container img{max-width:300px;width:100%;height:auto}.timer{margin-top:10px;font-size:18px;font-weight:600}.payment-error{text-align:center;padding:30px;max-width:400px}.error-icon{width:80px;height:80px;margin:0 auto 15px;border-radius:50%;background:#fc2626;color:#fff;font-size:48px;font-weight:700;display:flex;align-items:center;justify-content:center}.error-message h3{color:#fc2626;margin-bottom:10px}.payment-success{text-align:center;padding:30px}.success-icon{width:80px;height:80px;margin:0 auto 15px;border-radius:50%;background:#28a745;color:#fff;font-size:48px;font-weight:700;display:flex;align-items:center;justify-content:center}.success-message h3{color:#28a745;margin-bottom:10px}@-webkit-keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}"]
3759
+ }] }
3760
+ ];
3761
+ /** @nocollapse */
3762
+ GaliciaComponent.ctorParameters = () => [
3763
+ { type: GaliciaApiService }
3764
+ ];
3765
+ GaliciaComponent.propDecorators = {
3766
+ accessToken: [{ type: Input }],
3767
+ gaUrlApi: [{ type: Input }],
3768
+ vkUrlApi: [{ type: Input }],
3769
+ userId: [{ type: Input }],
3770
+ logoGa: [{ type: Input }],
3771
+ storeId: [{ type: Input }],
3772
+ storeName: [{ type: Input }],
3773
+ sessionId: [{ type: Input }],
3774
+ checkoutId: [{ type: Input }],
3775
+ data: [{ type: Input }],
3776
+ statusPay: [{ type: Output }]
3777
+ };
3778
+ if (false) {
3779
+ /** @type {?} */
3780
+ GaliciaComponent.prototype.accessToken;
3781
+ /** @type {?} */
3782
+ GaliciaComponent.prototype.gaUrlApi;
3783
+ /** @type {?} */
3784
+ GaliciaComponent.prototype.vkUrlApi;
3785
+ /** @type {?} */
3786
+ GaliciaComponent.prototype.userId;
3787
+ /** @type {?} */
3788
+ GaliciaComponent.prototype.logoGa;
3789
+ /** @type {?} */
3790
+ GaliciaComponent.prototype.storeId;
3791
+ /** @type {?} */
3792
+ GaliciaComponent.prototype.storeName;
3793
+ /** @type {?} */
3794
+ GaliciaComponent.prototype.sessionId;
3795
+ /** @type {?} */
3796
+ GaliciaComponent.prototype.checkoutId;
3797
+ /** @type {?} */
3798
+ GaliciaComponent.prototype.data;
3799
+ /** @type {?} */
3800
+ GaliciaComponent.prototype.statusPay;
3801
+ /** @type {?} */
3802
+ GaliciaComponent.prototype.qrImage;
3803
+ /** @type {?} */
3804
+ GaliciaComponent.prototype.billNumber;
3805
+ /** @type {?} */
3806
+ GaliciaComponent.prototype.errorMessage;
3807
+ /** @type {?} */
3808
+ GaliciaComponent.prototype.OinitPayment;
3809
+ /** @type {?} */
3810
+ GaliciaComponent.prototype.isGeneratingQr;
3811
+ /** @type {?} */
3812
+ GaliciaComponent.prototype.paymentCompleted;
3813
+ /** @type {?} */
3814
+ GaliciaComponent.prototype.paymentId;
3815
+ /** @type {?} */
3816
+ GaliciaComponent.prototype.showQr;
3817
+ /** @type {?} */
3818
+ GaliciaComponent.prototype.expired;
3819
+ /** @type {?} */
3820
+ GaliciaComponent.prototype.isLoading;
3821
+ /** @type {?} */
3822
+ GaliciaComponent.prototype.hasError;
3823
+ /** @type {?} */
3824
+ GaliciaComponent.prototype.minutes;
3825
+ /** @type {?} */
3826
+ GaliciaComponent.prototype.seconds;
3827
+ /**
3828
+ * @type {?}
3829
+ * @private
3830
+ */
3831
+ GaliciaComponent.prototype.interval;
3832
+ /** @type {?} */
3833
+ GaliciaComponent.prototype.validationInterval;
3834
+ /** @type {?} */
3835
+ GaliciaComponent.prototype.paymentResult;
3836
+ /**
3837
+ * @type {?}
3838
+ * @private
3839
+ */
3840
+ GaliciaComponent.prototype.galiciaApiService;
3841
+ }
3842
+
3843
+ /**
3844
+ * @fileoverview added by tsickle
3845
+ * Generated from: lib/galicia/galicia.module.ts
3846
+ * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3847
+ */
3848
+ /** @type {?} */
3849
+ const COMPONENTS$2 = [
3850
+ GaliciaComponent
3851
+ ];
3852
+ class GaliciaModule {
3853
+ }
3854
+ GaliciaModule.decorators = [
3855
+ { type: NgModule, args: [{
3856
+ declarations: [
3857
+ COMPONENTS$2
3858
+ ],
3859
+ exports: [
3860
+ COMPONENTS$2
3861
+ ],
3862
+ imports: [
3863
+ CommonModule,
3864
+ FormsModule,
3865
+ ReactiveFormsModule,
3866
+ RouterModule,
3867
+ ],
3868
+ providers: [
3869
+ GaliciaApiService
3870
+ ]
3871
+ },] }
3872
+ ];
3873
+
3465
3874
  /**
3466
3875
  * @fileoverview added by tsickle
3467
3876
  * Generated from: lib/vk-payments.module.ts
@@ -3473,15 +3882,17 @@ const LIB_MODULES = [
3473
3882
  SpsDecidirModule,
3474
3883
  PaypalModule,
3475
3884
  GoCuotasModule,
3885
+ BankTransferModule,
3476
3886
  ModoModule,
3477
- BankTransferModule
3887
+ GaliciaModule
3478
3888
  ];
3479
3889
  class VkPaymentsModule {
3480
3890
  }
3481
3891
  VkPaymentsModule.decorators = [
3482
3892
  { type: NgModule, args: [{
3483
3893
  imports: LIB_MODULES,
3484
- exports: LIB_MODULES
3894
+ exports: LIB_MODULES,
3895
+ declarations: []
3485
3896
  },] }
3486
3897
  ];
3487
3898
 
@@ -3497,5 +3908,5 @@ VkPaymentsModule.decorators = [
3497
3908
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3498
3909
  */
3499
3910
 
3500
- export { VkPaymentsModule, MercadopagoModule as ɵa, MercadoPagoComponent as ɵb, MercadopagoApiService as ɵc, PromotionBankComponent as ɵd, SpsDecidirModule as ɵe, SpsDecidirComponent as ɵf, SpsDecidirApiService as ɵg, PaypalModule as ɵh, PayPalNewComponent as ɵi, GoCuotasModule as ɵj, GoCuotasComponent as ɵk, ModalComponent as ɵl, GoCuotasApiService as ɵm, ModoModule as ɵn, ModoComponent as ɵo, ModoApiService as ɵp, BankTransferModule as ɵq, BankTransferComponent as ɵr, BankTransferApiService as ɵs };
3911
+ export { VkPaymentsModule, MercadopagoModule as ɵa, MercadoPagoComponent as ɵb, MercadopagoApiService as ɵc, PromotionBankComponent as ɵd, SpsDecidirModule as ɵe, SpsDecidirComponent as ɵf, SpsDecidirApiService as ɵg, PaypalModule as ɵh, PayPalNewComponent as ɵi, GoCuotasModule as ɵj, GoCuotasComponent as ɵk, ModalComponent as ɵl, GoCuotasApiService as ɵm, BankTransferModule as ɵn, BankTransferComponent as ɵo, BankTransferApiService as ɵp, ModoModule as ɵq, ModoComponent as ɵr, ModoApiService as ɵs, GaliciaModule as ɵt, GaliciaComponent as ɵu, GaliciaApiService as ɵv };
3501
3912
  //# sourceMappingURL=vk-payments.js.map