ng-easycommerce 0.0.684 → 0.0.685

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.
@@ -16832,6 +16832,7 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16832
16832
  _this.isDobleAuth = false;
16833
16833
  _this.urls = [];
16834
16834
  _this.closeModalReason = ''; // Renombrado para evitar confusión
16835
+ _this.finished = false;
16835
16836
  _this.dataRedirect = function () { return _this.consts.getUrlBase() + 'shop-api/' + _this.consts.getChannel() + '/redsys/redirect/' + _this.cartService.cart_token + '/process-payment'; };
16836
16837
  _this.clearStorageState = function () {
16837
16838
  sessionStorage.removeItem('state');
@@ -16840,31 +16841,23 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16840
16841
  // Método que se llama desde la X de la cabecera del modal en el HTML
16841
16842
  _this.clickClose = function () {
16842
16843
  _this.closeModalReason = 'cancel';
16844
+ _this.finished = true;
16845
+ if (_this.stateTimeout) {
16846
+ clearTimeout(_this.stateTimeout);
16847
+ _this.stateTimeout = null;
16848
+ }
16843
16849
  if (_this.modalRef) {
16844
16850
  _this.modalRef.hide();
16845
16851
  }
16846
16852
  _this.processError('Se canceló el pago con tarjeta');
16847
16853
  };
16848
16854
  _this.callState = function () {
16849
- var _a, _b, _c;
16855
+ if (_this.finished) {
16856
+ return;
16857
+ }
16850
16858
  var state = _this.closeModalReason != '' ? _this.closeModalReason : sessionStorage.getItem('state');
16851
16859
  if (state) {
16852
- _this.clearStorageState();
16853
- if (state == 'ok') {
16854
- (_a = _this.modalRef) === null || _a === void 0 ? void 0 : _a.hide();
16855
- _this.ready.emit(true);
16856
- return;
16857
- }
16858
- if (state == 'menosuno') {
16859
- (_b = _this.modalRef) === null || _b === void 0 ? void 0 : _b.hide();
16860
- _this.processError('Error en el pago');
16861
- return;
16862
- }
16863
- if (state == 'cancel') {
16864
- return; // El modal ya se escondió dentro de clickClose()
16865
- }
16866
- (_c = _this.modalRef) === null || _c === void 0 ? void 0 : _c.hide();
16867
- _this.processError('Error desconocido en la transacción');
16860
+ _this.handleState(state);
16868
16861
  return;
16869
16862
  }
16870
16863
  // Guardamos el timeout en una variable de clase
@@ -16872,6 +16865,33 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16872
16865
  _this.callState();
16873
16866
  }, 6000);
16874
16867
  };
16868
+ _this.handleState = function (state) {
16869
+ var _a, _b, _c, _d;
16870
+ if (_this.finished)
16871
+ return;
16872
+ _this.finished = true;
16873
+ if (_this.stateTimeout) {
16874
+ clearTimeout(_this.stateTimeout);
16875
+ _this.stateTimeout = null;
16876
+ }
16877
+ _this.clearStorageState();
16878
+ if (state === 'ok') {
16879
+ (_a = _this.modalRef) === null || _a === void 0 ? void 0 : _a.hide();
16880
+ _this.ready.emit(true);
16881
+ return;
16882
+ }
16883
+ if (state === 'menosuno' || state === 'error' || state === 'failure') {
16884
+ (_b = _this.modalRef) === null || _b === void 0 ? void 0 : _b.hide();
16885
+ _this.processError('Error en el pago');
16886
+ return;
16887
+ }
16888
+ if (state === 'cancel') {
16889
+ (_c = _this.modalRef) === null || _c === void 0 ? void 0 : _c.hide();
16890
+ return;
16891
+ }
16892
+ (_d = _this.modalRef) === null || _d === void 0 ? void 0 : _d.hide();
16893
+ _this.processError('Error desconocido en la transacción');
16894
+ };
16875
16895
  _this.processError = function (err) {
16876
16896
  _this.toastrService.show(err != '' ? err : 'payment-error');
16877
16897
  console.log("ERROR ENVIO BACK ", err);
@@ -16890,10 +16910,11 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16890
16910
  }
16891
16911
  };
16892
16912
  RedSysRedirectEcComponent.prototype.ngOnChanges = function () {
16893
- console.log("SE CAMBIO");
16913
+ // console.log("SE CAMBIO");
16894
16914
  };
16895
16915
  RedSysRedirectEcComponent.prototype.openModal = function (template) {
16896
16916
  this.clearStorageState();
16917
+ this.finished = false;
16897
16918
  sessionStorage.setItem('dataRedirect', this.dataRedirect());
16898
16919
  // Abrimos el modal y guardamos la referencia en this.modalRef
16899
16920
  this.modalRef = this.modalService.show(template, { class: 'modal-lg modal-dialog-centered', keyboard: false, backdrop: 'static', animated: true });
@@ -16902,11 +16923,33 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16902
16923
  };
16903
16924
  // Opcional pero recomendado: Capturar mensajes enviados desde el Iframe de Redsys
16904
16925
  RedSysRedirectEcComponent.prototype.onMessage = function (event) {
16905
- if (event.data === 'pago_completado' || event.data === 'ok') {
16906
- sessionStorage.setItem('state', 'ok');
16926
+ var _a, _b, _c, _d;
16927
+ var data = (_a = event) === null || _a === void 0 ? void 0 : _a.data;
16928
+ var state = typeof data === 'string'
16929
+ ? data
16930
+ : ((_b = data) === null || _b === void 0 ? void 0 : _b.state) || ((_c = data) === null || _c === void 0 ? void 0 : _c.status) || ((_d = data) === null || _d === void 0 ? void 0 : _d.result) || null;
16931
+ if (!state) {
16932
+ return;
16933
+ }
16934
+ if (state === 'pago_completado' || state === 'ok' || state === 'success') {
16935
+ this.handleState('ok');
16936
+ return;
16937
+ }
16938
+ if (state === 'pago_error' || state === 'menosuno' || state === 'error' || state === 'failure') {
16939
+ this.handleState('menosuno');
16940
+ }
16941
+ };
16942
+ RedSysRedirectEcComponent.prototype.onStorage = function (event) {
16943
+ var _a;
16944
+ if (!((_a = event) === null || _a === void 0 ? void 0 : _a.key) || event.key !== 'state' || !event.newValue) {
16945
+ return;
16946
+ }
16947
+ if (event.newValue === 'ok' || event.newValue === 'success') {
16948
+ this.handleState('ok');
16949
+ return;
16907
16950
  }
16908
- else if (event.data === 'pago_error' || event.data === 'menosuno') {
16909
- sessionStorage.setItem('state', 'menosuno');
16951
+ if (event.newValue === 'menosuno' || event.newValue === 'error' || event.newValue === 'failure') {
16952
+ this.handleState('menosuno');
16910
16953
  }
16911
16954
  };
16912
16955
  RedSysRedirectEcComponent.ctorParameters = function () { return [
@@ -16936,6 +16979,9 @@ var RedSysRedirectEcComponent = /** @class */ (function (_super) {
16936
16979
  __decorate$1m([
16937
16980
  HostListener('window:message', ['$event'])
16938
16981
  ], RedSysRedirectEcComponent.prototype, "onMessage", null);
16982
+ __decorate$1m([
16983
+ HostListener('window:storage', ['$event'])
16984
+ ], RedSysRedirectEcComponent.prototype, "onStorage", null);
16939
16985
  RedSysRedirectEcComponent = __decorate$1m([
16940
16986
  Component({
16941
16987
  selector: 'app-redsys-redirect-ec',
@@ -19141,7 +19187,7 @@ var RedSysRedirectOutEcComponent = /** @class */ (function (_super) {
19141
19187
  (_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.close();
19142
19188
  };
19143
19189
  _this.callState = function () {
19144
- var _a, _b, _c, _d, _e;
19190
+ var _a, _b, _c, _d;
19145
19191
  var state = _this.closeModal != '' ? _this.closeModal : localStorage.getItem('state');
19146
19192
  !state && _this.ventana.closed && (state = 'cancel');
19147
19193
  _this.loading = true;
@@ -19149,27 +19195,22 @@ var RedSysRedirectOutEcComponent = /** @class */ (function (_super) {
19149
19195
  if (state) {
19150
19196
  _this.loading = false;
19151
19197
  localStorage.removeItem('state');
19152
- if (state == 'success' || state == 'ok') {
19198
+ if (state == 'success' || state == 'ok' || state == 'pending') {
19153
19199
  (_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.close();
19154
19200
  _this.ready.emit(true);
19155
19201
  return;
19156
19202
  }
19157
- if (state == 'pending' || state == 'ok') {
19203
+ if (state == 'failure' || state == 'error' || state == 'menosuno') {
19158
19204
  (_b = _this.ventana) === null || _b === void 0 ? void 0 : _b.close();
19159
- _this.ready.emit(true);
19160
- return;
19161
- }
19162
- if (state == 'failure' || state == 'error') {
19163
- (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19164
19205
  _this.processError('');
19165
19206
  return;
19166
19207
  }
19167
19208
  if (state == 'cancel') {
19168
- (_d = _this.ventana) === null || _d === void 0 ? void 0 : _d.close();
19209
+ (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19169
19210
  _this.processError('Se cancelo el pago con redsys');
19170
19211
  return;
19171
19212
  }
19172
- (_e = _this.ventana) === null || _e === void 0 ? void 0 : _e.close();
19213
+ (_d = _this.ventana) === null || _d === void 0 ? void 0 : _d.close();
19173
19214
  _this.processError('');
19174
19215
  return;
19175
19216
  }