ng-easycommerce 0.0.689 → 0.0.690
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/README.md +5 -0
- package/bundles/ng-easycommerce.umd.js +262 -78
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/ec-component/checkout-ec/payment-ec/payment-ec.component.js +3 -2
- package/esm2015/lib/ec-component/widgets-ec/mobbex-ec/mobbex-ec.component.js +237 -85
- package/esm5/lib/ec-component/checkout-ec/payment-ec/payment-ec.component.js +3 -2
- package/esm5/lib/ec-component/widgets-ec/mobbex-ec/mobbex-ec.component.js +263 -85
- package/fesm2015/ng-easycommerce.js +236 -78
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +262 -78
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/widgets-ec/mobbex-ec/mobbex-ec.component.d.ts +34 -32
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -9450,7 +9450,8 @@ let PaymentEcComponent = class PaymentEcComponent extends ComponentHelper {
|
|
|
9450
9450
|
this.isRedirectRedsys(code) ||
|
|
9451
9451
|
this.isRedirectCecaBank(code) ||
|
|
9452
9452
|
this.isPeyPalExpress(code) ||
|
|
9453
|
-
this.isPlaceToPay(code)
|
|
9453
|
+
this.isPlaceToPay(code) ||
|
|
9454
|
+
this.isMobbex(code));
|
|
9454
9455
|
};
|
|
9455
9456
|
this.ecOnConstruct();
|
|
9456
9457
|
}
|
|
@@ -17167,109 +17168,270 @@ var __decorate$1F = (this && this.__decorate) || function (decorators, target, k
|
|
|
17167
17168
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17168
17169
|
};
|
|
17169
17170
|
let MobbexEcComponent = class MobbexEcComponent extends ComponentHelper {
|
|
17170
|
-
constructor(
|
|
17171
|
+
constructor(toastrService, cartService) {
|
|
17171
17172
|
super();
|
|
17172
|
-
this.renderer = renderer;
|
|
17173
|
-
this.connection = connection;
|
|
17174
17173
|
this.toastrService = toastrService;
|
|
17175
|
-
this.consts = consts;
|
|
17176
17174
|
this.cartService = cartService;
|
|
17177
|
-
this.toastr = toastr;
|
|
17178
|
-
this.activedRoute = activedRoute;
|
|
17179
|
-
this.sanitizer = sanitizer;
|
|
17180
|
-
this.modalService = modalService;
|
|
17181
17175
|
this.method = null;
|
|
17182
17176
|
this.total_amount = 0;
|
|
17183
17177
|
this.user_data = null;
|
|
17184
17178
|
this.ready = new EventEmitter();
|
|
17185
|
-
this.loading =
|
|
17186
|
-
this.
|
|
17187
|
-
this.
|
|
17188
|
-
this.
|
|
17189
|
-
this.
|
|
17190
|
-
this.
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17194
|
-
this.
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
this.
|
|
17198
|
-
|
|
17199
|
-
|
|
17179
|
+
this.loading = true;
|
|
17180
|
+
this.processing = false;
|
|
17181
|
+
this.url = null;
|
|
17182
|
+
this.checkoutData = null;
|
|
17183
|
+
this.popup = null;
|
|
17184
|
+
this.pollTimer = null;
|
|
17185
|
+
this.startedAt = 0;
|
|
17186
|
+
this.finished = false;
|
|
17187
|
+
this.checkoutKey = '';
|
|
17188
|
+
this.bc = null;
|
|
17189
|
+
this.checkoutRequestInFlight = false;
|
|
17190
|
+
this.openCheckout = () => {
|
|
17191
|
+
if (!this.url || this.processing || typeof window === 'undefined')
|
|
17192
|
+
return;
|
|
17193
|
+
this.clearStateKeys();
|
|
17194
|
+
this.finished = false;
|
|
17195
|
+
this.processing = true;
|
|
17196
|
+
this.startedAt = Date.now();
|
|
17197
|
+
this.popup = window.open(this.url, '_blank');
|
|
17198
|
+
if (!this.popup || this.popup.closed) {
|
|
17199
|
+
this.processing = false;
|
|
17200
|
+
this.toastrService.show('No se pudo abrir la pasarela de pago. Verifique que su navegador permita nuevas pestañas.');
|
|
17201
|
+
return;
|
|
17202
|
+
}
|
|
17200
17203
|
try {
|
|
17201
|
-
|
|
17202
|
-
this.loading = true;
|
|
17203
|
-
state && console.log(state);
|
|
17204
|
-
if (state) {
|
|
17205
|
-
this.loading = false;
|
|
17206
|
-
sessionStorage.removeItem('state');
|
|
17207
|
-
localStorage.removeItem('state');
|
|
17208
|
-
if (state == 'success') {
|
|
17209
|
-
this.ready.emit(true);
|
|
17210
|
-
}
|
|
17211
|
-
if (state == 'cancel') {
|
|
17212
|
-
return;
|
|
17213
|
-
}
|
|
17214
|
-
if (state == 'failure') {
|
|
17215
|
-
this.processError('');
|
|
17216
|
-
}
|
|
17217
|
-
this.modalRef.hide();
|
|
17218
|
-
return;
|
|
17219
|
-
}
|
|
17220
|
-
setTimeout(() => {
|
|
17221
|
-
this.callState();
|
|
17222
|
-
}, 5000);
|
|
17204
|
+
this.popup.opener = null;
|
|
17223
17205
|
}
|
|
17224
|
-
catch (
|
|
17225
|
-
|
|
17206
|
+
catch (_a) {
|
|
17207
|
+
// Nothing to do.
|
|
17226
17208
|
}
|
|
17209
|
+
this.startPolling();
|
|
17227
17210
|
};
|
|
17228
|
-
this.
|
|
17229
|
-
this.
|
|
17230
|
-
|
|
17211
|
+
this.cancelCheckout = () => {
|
|
17212
|
+
if (this.finished)
|
|
17213
|
+
return;
|
|
17214
|
+
this.finishWithState('cancel', true);
|
|
17231
17215
|
};
|
|
17232
17216
|
this.getCheckoutMobbex = () => {
|
|
17217
|
+
if (this.checkoutRequestInFlight)
|
|
17218
|
+
return;
|
|
17233
17219
|
this.loading = true;
|
|
17234
|
-
this.
|
|
17220
|
+
this.checkoutRequestInFlight = true;
|
|
17221
|
+
const payload = this.user_data || this.allData || {};
|
|
17222
|
+
this.paymentServiceInst.getCheckoutMobbex(payload).then(res => {
|
|
17235
17223
|
var _a, _b, _c, _d;
|
|
17236
|
-
this.
|
|
17237
|
-
this.
|
|
17224
|
+
this.checkoutData = res || null;
|
|
17225
|
+
this.checkoutKey = String(((_b = (_a = res) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.id) || this.cartService.cart_token || '');
|
|
17226
|
+
this.url = ((_d = (_c = res) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.url) || null;
|
|
17227
|
+
this.safeSetStorage('mobbex:checkout-id', this.checkoutKey);
|
|
17238
17228
|
this.loading = false;
|
|
17239
|
-
|
|
17240
|
-
this.
|
|
17229
|
+
this.checkoutRequestInFlight = false;
|
|
17230
|
+
if (!this.url) {
|
|
17231
|
+
this.processError('operation-error');
|
|
17232
|
+
}
|
|
17233
|
+
}, () => {
|
|
17241
17234
|
this.loading = false;
|
|
17235
|
+
this.checkoutRequestInFlight = false;
|
|
17236
|
+
this.processError('operation-error');
|
|
17242
17237
|
});
|
|
17243
17238
|
};
|
|
17239
|
+
this.onStorage = (event) => {
|
|
17240
|
+
var _a;
|
|
17241
|
+
if (!((_a = event) === null || _a === void 0 ? void 0 : _a.key) || this.finished)
|
|
17242
|
+
return;
|
|
17243
|
+
if (!this.getStateKeys().includes(event.key))
|
|
17244
|
+
return;
|
|
17245
|
+
const state = this.normalizeState(event.newValue);
|
|
17246
|
+
if (state) {
|
|
17247
|
+
this.finishWithState(state, true);
|
|
17248
|
+
}
|
|
17249
|
+
};
|
|
17250
|
+
this.onMessage = (event) => {
|
|
17251
|
+
this.onBroadcastMessage(event);
|
|
17252
|
+
};
|
|
17253
|
+
this.clearStorageState = () => {
|
|
17254
|
+
sessionStorage.removeItem('state');
|
|
17255
|
+
localStorage.removeItem('state');
|
|
17256
|
+
};
|
|
17257
|
+
this.processError = (err) => {
|
|
17258
|
+
this.toastrService.show(err !== '' ? err : 'payment-error');
|
|
17259
|
+
};
|
|
17244
17260
|
this.ecOnConstruct();
|
|
17245
17261
|
}
|
|
17246
17262
|
ngOnInit() {
|
|
17247
|
-
|
|
17263
|
+
if (typeof window !== 'undefined') {
|
|
17264
|
+
window.addEventListener('storage', this.onStorage);
|
|
17265
|
+
window.addEventListener('message', this.onMessage);
|
|
17266
|
+
if (window.BroadcastChannel) {
|
|
17267
|
+
this.bc = new BroadcastChannel('mobbex_payment');
|
|
17268
|
+
this.bc.onmessage = (event) => this.onBroadcastMessage(event);
|
|
17269
|
+
}
|
|
17270
|
+
}
|
|
17271
|
+
this.loadCheckout();
|
|
17248
17272
|
this.ecOnInit();
|
|
17249
17273
|
}
|
|
17250
17274
|
ngOnDestroy() {
|
|
17251
|
-
|
|
17275
|
+
if (typeof window !== 'undefined') {
|
|
17276
|
+
window.removeEventListener('storage', this.onStorage);
|
|
17277
|
+
window.removeEventListener('message', this.onMessage);
|
|
17278
|
+
}
|
|
17279
|
+
if (this.bc) {
|
|
17280
|
+
try {
|
|
17281
|
+
this.bc.close();
|
|
17282
|
+
}
|
|
17283
|
+
catch (_a) {
|
|
17284
|
+
// Nothing to do.
|
|
17285
|
+
}
|
|
17286
|
+
this.bc = null;
|
|
17287
|
+
}
|
|
17288
|
+
this.stopPolling();
|
|
17289
|
+
this.closePopup();
|
|
17252
17290
|
}
|
|
17253
|
-
|
|
17254
|
-
|
|
17291
|
+
loadCheckout() {
|
|
17292
|
+
if (!this.paymentServiceInst || !this.method)
|
|
17293
|
+
return;
|
|
17294
|
+
if (this.url && !this.loading)
|
|
17295
|
+
return;
|
|
17296
|
+
this.getCheckoutMobbex();
|
|
17255
17297
|
}
|
|
17256
|
-
|
|
17298
|
+
startPolling() {
|
|
17299
|
+
this.stopPolling();
|
|
17300
|
+
this.pollTimer = setInterval(() => {
|
|
17301
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17302
|
+
if (this.finished) {
|
|
17303
|
+
this.stopPolling();
|
|
17304
|
+
return;
|
|
17305
|
+
}
|
|
17306
|
+
const state = this.readState();
|
|
17307
|
+
if (state) {
|
|
17308
|
+
this.finishWithState(state, true);
|
|
17309
|
+
return;
|
|
17310
|
+
}
|
|
17311
|
+
if ((_a = this.popup) === null || _a === void 0 ? void 0 : _a.closed) {
|
|
17312
|
+
this.finishWithState('cancel', true);
|
|
17313
|
+
return;
|
|
17314
|
+
}
|
|
17315
|
+
const rawTimeoutMinutes = Number((_f = (_d = (_c = (_b = this.checkoutData) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.timeout, (_d !== null && _d !== void 0 ? _d : (_e = this.checkoutData) === null || _e === void 0 ? void 0 : _e.timeout)), (_f !== null && _f !== void 0 ? _f : 60)));
|
|
17316
|
+
const timeoutMinutes = Number.isFinite(rawTimeoutMinutes) && rawTimeoutMinutes > 0 ? rawTimeoutMinutes : 60;
|
|
17317
|
+
const timeoutMs = Math.max(5, timeoutMinutes + 1) * 60 * 1000;
|
|
17318
|
+
if (Date.now() - this.startedAt > timeoutMs) {
|
|
17319
|
+
this.finishWithState('failure', true, 'Tiempo de espera agotado al procesar el pago con Mobbex.');
|
|
17320
|
+
}
|
|
17321
|
+
}, 1000);
|
|
17322
|
+
}
|
|
17323
|
+
onBroadcastMessage(event) {
|
|
17324
|
+
var _a;
|
|
17325
|
+
const payload = (_a = event) === null || _a === void 0 ? void 0 : _a.data;
|
|
17326
|
+
if (!payload || payload.type !== 'mobbex:state' || this.finished)
|
|
17327
|
+
return;
|
|
17328
|
+
if (this.checkoutKey && payload.checkoutKey && payload.checkoutKey !== this.checkoutKey)
|
|
17329
|
+
return;
|
|
17330
|
+
const state = this.normalizeState(payload.state);
|
|
17331
|
+
if (state) {
|
|
17332
|
+
this.finishWithState(state, true);
|
|
17333
|
+
}
|
|
17334
|
+
}
|
|
17335
|
+
finishWithState(state, closePopup = false, customMessage = '') {
|
|
17336
|
+
if (this.finished)
|
|
17337
|
+
return;
|
|
17338
|
+
this.finished = true;
|
|
17339
|
+
this.processing = false;
|
|
17340
|
+
this.stopPolling();
|
|
17341
|
+
if (closePopup) {
|
|
17342
|
+
this.closePopup();
|
|
17343
|
+
}
|
|
17344
|
+
this.clearStateKeys();
|
|
17345
|
+
if (state === 'success' || state === 'pending') {
|
|
17346
|
+
this.ready.emit(true);
|
|
17347
|
+
return;
|
|
17348
|
+
}
|
|
17349
|
+
this.processError(customMessage || (state === 'cancel' ? 'Se canceló el pago con Mobbex' : ''));
|
|
17350
|
+
}
|
|
17351
|
+
readState() {
|
|
17352
|
+
const keys = this.getStateKeys();
|
|
17353
|
+
for (const key of keys) {
|
|
17354
|
+
const value = this.safeGetStorage(key);
|
|
17355
|
+
const normalized = this.normalizeState(value);
|
|
17356
|
+
if (normalized)
|
|
17357
|
+
return normalized;
|
|
17358
|
+
}
|
|
17359
|
+
return null;
|
|
17360
|
+
}
|
|
17361
|
+
normalizeState(value) {
|
|
17362
|
+
const raw = String(value || '').toLowerCase();
|
|
17363
|
+
if (!raw)
|
|
17364
|
+
return null;
|
|
17365
|
+
if (raw === '200' || raw === 'ok' || raw === 'success')
|
|
17366
|
+
return 'success';
|
|
17367
|
+
if (raw === 'pending' || raw === 'in_process' || raw === 'in_review' || raw === 'challenge')
|
|
17368
|
+
return 'pending';
|
|
17369
|
+
if (raw === 'cancel' || raw === '0' || raw === 'none')
|
|
17370
|
+
return 'cancel';
|
|
17371
|
+
if (raw === 'failure' || raw === 'error' || raw === 'expired' || raw === '401')
|
|
17372
|
+
return 'failure';
|
|
17373
|
+
return null;
|
|
17374
|
+
}
|
|
17375
|
+
getStateKeys() {
|
|
17376
|
+
const keys = ['state'];
|
|
17377
|
+
if (this.checkoutKey) {
|
|
17378
|
+
keys.unshift(`mobbex:state:${this.checkoutKey}`);
|
|
17379
|
+
}
|
|
17380
|
+
return keys;
|
|
17381
|
+
}
|
|
17382
|
+
clearStateKeys() {
|
|
17257
17383
|
this.clearStorageState();
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17384
|
+
if (this.checkoutKey) {
|
|
17385
|
+
this.safeRemoveStorage(`mobbex:state:${this.checkoutKey}`);
|
|
17386
|
+
this.safeRemoveStorage('mobbex:checkout-id');
|
|
17387
|
+
}
|
|
17388
|
+
}
|
|
17389
|
+
stopPolling() {
|
|
17390
|
+
if (this.pollTimer) {
|
|
17391
|
+
clearInterval(this.pollTimer);
|
|
17392
|
+
this.pollTimer = null;
|
|
17393
|
+
}
|
|
17394
|
+
}
|
|
17395
|
+
closePopup() {
|
|
17396
|
+
if (!this.popup)
|
|
17397
|
+
return;
|
|
17398
|
+
try {
|
|
17399
|
+
if (!this.popup.closed)
|
|
17400
|
+
this.popup.close();
|
|
17401
|
+
}
|
|
17402
|
+
catch (_a) {
|
|
17403
|
+
// Nothing to do.
|
|
17404
|
+
}
|
|
17405
|
+
this.popup = null;
|
|
17406
|
+
}
|
|
17407
|
+
safeGetStorage(key) {
|
|
17408
|
+
try {
|
|
17409
|
+
return localStorage.getItem(key);
|
|
17410
|
+
}
|
|
17411
|
+
catch (_a) {
|
|
17412
|
+
return null;
|
|
17413
|
+
}
|
|
17414
|
+
}
|
|
17415
|
+
safeRemoveStorage(key) {
|
|
17416
|
+
try {
|
|
17417
|
+
localStorage.removeItem(key);
|
|
17418
|
+
}
|
|
17419
|
+
catch (_a) {
|
|
17420
|
+
// Nothing to do.
|
|
17421
|
+
}
|
|
17422
|
+
}
|
|
17423
|
+
safeSetStorage(key, value) {
|
|
17424
|
+
try {
|
|
17425
|
+
localStorage.setItem(key, value);
|
|
17426
|
+
}
|
|
17427
|
+
catch (_a) {
|
|
17428
|
+
// Nothing to do.
|
|
17429
|
+
}
|
|
17261
17430
|
}
|
|
17262
17431
|
};
|
|
17263
17432
|
MobbexEcComponent.ctorParameters = () => [
|
|
17264
|
-
{ type: Renderer2 },
|
|
17265
|
-
{ type: ConnectionService },
|
|
17266
17433
|
{ type: ToastService },
|
|
17267
|
-
{ type:
|
|
17268
|
-
{ type: CartService },
|
|
17269
|
-
{ type: ToastService },
|
|
17270
|
-
{ type: ActivatedRoute },
|
|
17271
|
-
{ type: DomSanitizer },
|
|
17272
|
-
{ type: BsModalService }
|
|
17434
|
+
{ type: CartService }
|
|
17273
17435
|
];
|
|
17274
17436
|
__decorate$1F([
|
|
17275
17437
|
Input()
|
|
@@ -17289,15 +17451,11 @@ __decorate$1F([
|
|
|
17289
17451
|
__decorate$1F([
|
|
17290
17452
|
Output()
|
|
17291
17453
|
], MobbexEcComponent.prototype, "ready", void 0);
|
|
17292
|
-
__decorate$1F([
|
|
17293
|
-
ViewChild('template')
|
|
17294
|
-
], MobbexEcComponent.prototype, "template", void 0);
|
|
17295
17454
|
MobbexEcComponent = __decorate$1F([
|
|
17296
17455
|
Component({
|
|
17297
17456
|
selector: 'app-mobbex-ec',
|
|
17298
|
-
template: "<div class=\"text-center\">\n <h3>Continuar con el pago en Mobbex</h3>\n <p *ngIf=\"method\" class=\"px-5\">{{ method?.description }}</p>\n <p *ngIf=\"method\" class=\"px-5\">{{ method?.instructions }}</p>\n <ng-container *ngIf=\"
|
|
17299
|
-
|
|
17300
|
-
styles: [".half-width{width:49%!important}.ml-1{margin-left:1%}#card-form{height:450px}.iframeStyle{height:800px;width:100%;max-height:800px}"]
|
|
17457
|
+
template: "<div class=\"text-center\">\n <h3>Continuar con el pago en Mobbex</h3>\n <p *ngIf=\"method\" class=\"px-5\">{{ method?.description }}</p>\n <p *ngIf=\"method\" class=\"px-5\">{{ method?.instructions }}</p>\n\n <ng-container *ngIf=\"loading; else checkoutReady\">\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <app-loading-full-ec></app-loading-full-ec>\n <p class=\"mt-3 px-5 mobbex-note\">Preparando la pasarela de pago...</p>\n </div>\n </ng-container>\n\n <ng-template #checkoutReady>\n <p class=\"mt-3 px-5 mobbex-note\">\n Se abrir\u00E1 una nueva pesta\u00F1a para completar el pago.\n </p>\n\n <div class=\"d-flex flex-column align-items-center\">\n <button\n class=\"btn btn-outline-secondary comprar\"\n [disabled]=\"processing || !url\"\n (click)=\"openCheckout()\">\n Ir al sitio de Mobbex\n </button>\n\n <a\n *ngIf=\"url\"\n class=\"mt-2 small mobbex-link\"\n [href]=\"url\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n (click)=\"$event.preventDefault(); openCheckout()\">\n Si el bot\u00F3n no abre una nueva pesta\u00F1a, toc\u00E1 aqu\u00ED para continuar.\n </a>\n\n <button\n *ngIf=\"processing\"\n type=\"button\"\n class=\"btn btn-link text-secondary mt-2\"\n (click)=\"cancelCheckout()\">\n Cancelar pago\n </button>\n\n <p *ngIf=\"!url\" class=\"mt-2 px-5 text-danger\">\n No fue posible preparar la pasarela de pago.\n </p>\n </div>\n </ng-template>\n</div>\n",
|
|
17458
|
+
styles: [".mobbex-note{color:#6c757d}"]
|
|
17301
17459
|
})
|
|
17302
17460
|
], MobbexEcComponent);
|
|
17303
17461
|
|