vk-payments 0.2.14 → 0.2.15
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/bundles/vk-payments.umd.js +158 -53
- package/bundles/vk-payments.umd.js.map +1 -1
- package/bundles/vk-payments.umd.min.js +1 -1
- package/bundles/vk-payments.umd.min.js.map +1 -1
- package/esm2015/lib/modo/components/modo/modo.component.js +146 -48
- package/esm5/lib/modo/components/modo/modo.component.js +160 -54
- package/fesm2015/vk-payments.js +145 -48
- package/fesm2015/vk-payments.js.map +1 -1
- package/fesm5/vk-payments.js +159 -54
- package/fesm5/vk-payments.js.map +1 -1
- package/lib/modo/components/modo/modo.component.d.ts +8 -5
- package/package.json +1 -1
- package/vk-payments.metadata.json +1 -1
|
@@ -3511,10 +3511,12 @@
|
|
|
3511
3511
|
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3512
3512
|
*/
|
|
3513
3513
|
var ModoComponent = /** @class */ (function () {
|
|
3514
|
-
function ModoComponent(modoApi) {
|
|
3514
|
+
function ModoComponent(modoApi, route) {
|
|
3515
3515
|
this.modoApi = modoApi;
|
|
3516
|
+
this.route = route;
|
|
3516
3517
|
this.statusPay = new core.EventEmitter();
|
|
3517
3518
|
this.isLoading = false;
|
|
3519
|
+
this.executionEnv = 'desktop';
|
|
3518
3520
|
}
|
|
3519
3521
|
/**
|
|
3520
3522
|
* @return {?}
|
|
@@ -3523,7 +3525,47 @@
|
|
|
3523
3525
|
* @return {?}
|
|
3524
3526
|
*/
|
|
3525
3527
|
function () {
|
|
3526
|
-
this.
|
|
3528
|
+
this.detectEnvironment();
|
|
3529
|
+
if (this.executionEnv === 'desktop') {
|
|
3530
|
+
this.loadModoScript();
|
|
3531
|
+
}
|
|
3532
|
+
};
|
|
3533
|
+
/**
|
|
3534
|
+
* @private
|
|
3535
|
+
* @return {?}
|
|
3536
|
+
*/
|
|
3537
|
+
ModoComponent.prototype.detectEnvironment = /**
|
|
3538
|
+
* @private
|
|
3539
|
+
* @return {?}
|
|
3540
|
+
*/
|
|
3541
|
+
function () {
|
|
3542
|
+
try {
|
|
3543
|
+
/** @type {?} */
|
|
3544
|
+
var params = this.route.snapshot.params;
|
|
3545
|
+
/** @type {?} */
|
|
3546
|
+
var guid = params['guid'];
|
|
3547
|
+
/** @type {?} */
|
|
3548
|
+
var platform = (/** @type {?} */ (params['platform']));
|
|
3549
|
+
if (platform === 'iOS' || platform === 'Android' || guid === 'app') {
|
|
3550
|
+
this.executionEnv = 'native-app';
|
|
3551
|
+
this.devicePlatform = platform;
|
|
3552
|
+
console.log("MODO Payment: Entorno detectado -> Nativo (" + (this.devicePlatform || 'app') + ")");
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
}
|
|
3556
|
+
catch (error) {
|
|
3557
|
+
console.warn('MODO Payment: No se pudo leer los parámetros de la ruta. Se continuará con la detección por User Agent.');
|
|
3558
|
+
}
|
|
3559
|
+
/** @type {?} */
|
|
3560
|
+
var userAgent = navigator.userAgent || navigator.vendor || ((/** @type {?} */ (window))).opera;
|
|
3561
|
+
if (/android/i.test(userAgent) || /iPad|iPhone|iPod/.test(userAgent)) {
|
|
3562
|
+
this.executionEnv = 'mobile-browser';
|
|
3563
|
+
console.log('MODO Payment: Entorno detectado -> Navegador Móvil');
|
|
3564
|
+
}
|
|
3565
|
+
else {
|
|
3566
|
+
this.executionEnv = 'desktop';
|
|
3567
|
+
console.log('MODO Payment: Entorno detectado -> Desktop');
|
|
3568
|
+
}
|
|
3527
3569
|
};
|
|
3528
3570
|
/**
|
|
3529
3571
|
* @return {?}
|
|
@@ -3533,8 +3575,7 @@
|
|
|
3533
3575
|
*/
|
|
3534
3576
|
function () {
|
|
3535
3577
|
return __awaiter(this, void 0, void 0, function () {
|
|
3536
|
-
var
|
|
3537
|
-
var _this = this;
|
|
3578
|
+
var initialData, error_1;
|
|
3538
3579
|
return __generator(this, function (_a) {
|
|
3539
3580
|
switch (_a.label) {
|
|
3540
3581
|
case 0:
|
|
@@ -3544,49 +3585,23 @@
|
|
|
3544
3585
|
_a.trys.push([1, 3, , 4]);
|
|
3545
3586
|
return [4 /*yield*/, this.createModoPayment()];
|
|
3546
3587
|
case 2:
|
|
3547
|
-
|
|
3588
|
+
initialData = _a.sent();
|
|
3548
3589
|
this.isLoading = false;
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
* @return {?}
|
|
3565
|
-
*/
|
|
3566
|
-
function () {
|
|
3567
|
-
_this.statusPay.emit({ success: true, paymentId: initialData_1.checkoutId });
|
|
3568
|
-
}),
|
|
3569
|
-
onFailure: (/**
|
|
3570
|
-
* @return {?}
|
|
3571
|
-
*/
|
|
3572
|
-
function () {
|
|
3573
|
-
_this.statusPay.emit({ success: false, paymentId: initialData_1.checkoutId });
|
|
3574
|
-
}),
|
|
3575
|
-
onCancel: (/**
|
|
3576
|
-
* @return {?}
|
|
3577
|
-
*/
|
|
3578
|
-
function () {
|
|
3579
|
-
console.log('Pago cancelado por el usuario en el celular.');
|
|
3580
|
-
}),
|
|
3581
|
-
onClose: (/**
|
|
3582
|
-
* @return {?}
|
|
3583
|
-
*/
|
|
3584
|
-
function () {
|
|
3585
|
-
console.log('Modal de MODO cerrado.');
|
|
3586
|
-
}),
|
|
3587
|
-
};
|
|
3588
|
-
// 3. Inicia el SDK de MODO
|
|
3589
|
-
ModoSDK.modoInitPayment(modalObject);
|
|
3590
|
+
switch (this.executionEnv) {
|
|
3591
|
+
case 'native-app':
|
|
3592
|
+
// Llama a la función nativa para abrir en un navegador externo
|
|
3593
|
+
this.openOnNativeNavigator(initialData.deeplink);
|
|
3594
|
+
break;
|
|
3595
|
+
case 'mobile-browser':
|
|
3596
|
+
// Abre el deeplink en una nueva pestaña
|
|
3597
|
+
window.open(initialData.deeplink, '_blank');
|
|
3598
|
+
break;
|
|
3599
|
+
case 'desktop':
|
|
3600
|
+
default:
|
|
3601
|
+
// Abrir el modal del SDK
|
|
3602
|
+
this.initModoSdkModal(initialData);
|
|
3603
|
+
break;
|
|
3604
|
+
}
|
|
3590
3605
|
return [3 /*break*/, 4];
|
|
3591
3606
|
case 3:
|
|
3592
3607
|
error_1 = _a.sent();
|
|
@@ -3600,18 +3615,92 @@
|
|
|
3600
3615
|
});
|
|
3601
3616
|
};
|
|
3602
3617
|
/**
|
|
3603
|
-
*
|
|
3604
|
-
*
|
|
3618
|
+
* @private
|
|
3619
|
+
* @param {?} url
|
|
3620
|
+
* @return {?}
|
|
3605
3621
|
*/
|
|
3622
|
+
ModoComponent.prototype.openOnNativeNavigator = /**
|
|
3623
|
+
* @private
|
|
3624
|
+
* @param {?} url
|
|
3625
|
+
* @return {?}
|
|
3626
|
+
*/
|
|
3627
|
+
function (url) {
|
|
3628
|
+
try {
|
|
3629
|
+
if (this.devicePlatform === 'iOS') {
|
|
3630
|
+
((/** @type {?} */ (window))).webkit.messageHandlers.externalURL.postMessage(url);
|
|
3631
|
+
}
|
|
3632
|
+
else if (this.devicePlatform === 'Android') {
|
|
3633
|
+
((/** @type {?} */ (window))).externalURL.postMessage(url);
|
|
3634
|
+
}
|
|
3635
|
+
else {
|
|
3636
|
+
// Fallback si por alguna razón no se detectó la plataforma pero sí el entorno nativo
|
|
3637
|
+
window.open(url, '_blank');
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
catch (e) {
|
|
3641
|
+
console.error('Error al intentar invocar el message handler nativo:', e);
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
/**
|
|
3645
|
+
* @private
|
|
3646
|
+
* @param {?} initialData
|
|
3647
|
+
* @return {?}
|
|
3648
|
+
*/
|
|
3649
|
+
ModoComponent.prototype.initModoSdkModal = /**
|
|
3650
|
+
* @private
|
|
3651
|
+
* @param {?} initialData
|
|
3652
|
+
* @return {?}
|
|
3653
|
+
*/
|
|
3654
|
+
function (initialData) {
|
|
3655
|
+
var _this = this;
|
|
3656
|
+
/** @type {?} */
|
|
3657
|
+
var modalObject = {
|
|
3658
|
+
version: '2',
|
|
3659
|
+
qrString: initialData.qrString,
|
|
3660
|
+
checkoutId: initialData.checkoutId,
|
|
3661
|
+
deeplink: {
|
|
3662
|
+
url: initialData.deeplink,
|
|
3663
|
+
callbackURL: this.callbackUrl,
|
|
3664
|
+
callbackURLSuccess: this.callbackUrlSuccess
|
|
3665
|
+
},
|
|
3666
|
+
callbackURL: this.callbackUrl,
|
|
3667
|
+
refreshData: (/**
|
|
3668
|
+
* @return {?}
|
|
3669
|
+
*/
|
|
3670
|
+
function () { return _this.createModoPayment(); }),
|
|
3671
|
+
onSuccess: (/**
|
|
3672
|
+
* @return {?}
|
|
3673
|
+
*/
|
|
3674
|
+
function () {
|
|
3675
|
+
_this.statusPay.emit({ success: true, paymentId: initialData.checkoutId });
|
|
3676
|
+
}),
|
|
3677
|
+
onFailure: (/**
|
|
3678
|
+
* @return {?}
|
|
3679
|
+
*/
|
|
3680
|
+
function () {
|
|
3681
|
+
_this.statusPay.emit({ success: false, paymentId: initialData.checkoutId });
|
|
3682
|
+
}),
|
|
3683
|
+
onCancel: (/**
|
|
3684
|
+
* @return {?}
|
|
3685
|
+
*/
|
|
3686
|
+
function () {
|
|
3687
|
+
console.log('Pago cancelado por el usuario en el celular.');
|
|
3688
|
+
}),
|
|
3689
|
+
onClose: (/**
|
|
3690
|
+
* @return {?}
|
|
3691
|
+
*/
|
|
3692
|
+
function () {
|
|
3693
|
+
console.log('Modal de MODO cerrado.');
|
|
3694
|
+
}),
|
|
3695
|
+
};
|
|
3696
|
+
// 3. Inicia el SDK de MODO
|
|
3697
|
+
ModoSDK.modoInitPayment(modalObject);
|
|
3698
|
+
};
|
|
3606
3699
|
/**
|
|
3607
|
-
* Esta función se encarga de llamar a tu backend.
|
|
3608
|
-
* Se usa tanto para la carga inicial como para el refresco del SDK.
|
|
3609
3700
|
* @private
|
|
3610
3701
|
* @return {?}
|
|
3611
3702
|
*/
|
|
3612
3703
|
ModoComponent.prototype.createModoPayment = /**
|
|
3613
|
-
* Esta función se encarga de llamar a tu backend.
|
|
3614
|
-
* Se usa tanto para la carga inicial como para el refresco del SDK.
|
|
3615
3704
|
* @private
|
|
3616
3705
|
* @return {?}
|
|
3617
3706
|
*/
|
|
@@ -3673,7 +3762,8 @@
|
|
|
3673
3762
|
];
|
|
3674
3763
|
/** @nocollapse */
|
|
3675
3764
|
ModoComponent.ctorParameters = function () { return [
|
|
3676
|
-
{ type: ModoApiService }
|
|
3765
|
+
{ type: ModoApiService },
|
|
3766
|
+
{ type: router.ActivatedRoute }
|
|
3677
3767
|
]; };
|
|
3678
3768
|
ModoComponent.propDecorators = {
|
|
3679
3769
|
accessToken: [{ type: core.Input }],
|
|
@@ -3712,11 +3802,26 @@
|
|
|
3712
3802
|
ModoComponent.prototype.statusPay;
|
|
3713
3803
|
/** @type {?} */
|
|
3714
3804
|
ModoComponent.prototype.isLoading;
|
|
3805
|
+
/**
|
|
3806
|
+
* @type {?}
|
|
3807
|
+
* @private
|
|
3808
|
+
*/
|
|
3809
|
+
ModoComponent.prototype.executionEnv;
|
|
3810
|
+
/**
|
|
3811
|
+
* @type {?}
|
|
3812
|
+
* @private
|
|
3813
|
+
*/
|
|
3814
|
+
ModoComponent.prototype.devicePlatform;
|
|
3715
3815
|
/**
|
|
3716
3816
|
* @type {?}
|
|
3717
3817
|
* @private
|
|
3718
3818
|
*/
|
|
3719
3819
|
ModoComponent.prototype.modoApi;
|
|
3820
|
+
/**
|
|
3821
|
+
* @type {?}
|
|
3822
|
+
* @private
|
|
3823
|
+
*/
|
|
3824
|
+
ModoComponent.prototype.route;
|
|
3720
3825
|
}
|
|
3721
3826
|
|
|
3722
3827
|
/**
|