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.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ # Version 0.0.685
2
+ - Redsys redirect: el modal ahora finaliza el flujo escuchando `postMessage` y `storage`, sin depender únicamente del polling.
3
+ - Redsys redirect: se corrige el cierre automático del modal cuando el pago termina con `ok` o falla con `menosuno`.
4
+ - Redsys bridge: `redsysProBase.html`, `redsysFrameRedirectBase.html`, `redsysFrameRedirectOutBase.html` y `redsysStateBase.html` notifican el estado al checkout con `postMessage` y storage local.
5
+ - Redsys bridge: se elimina la dependencia de la ruta `/cart/checkout/redsys/ok`, que podía dejar el iframe cargando indefinidamente en legacy y single.
6
+ - Redsys out: el flujo de ventana externa quedó alineado con los mismos estados de éxito/error para mantener consistencia entre checkout legacy y single.
1
7
  # Version 0.0.684
2
8
  - Checkout legacy: el campo `postcode` ahora se muestra y se requiere según `checkoutRequiredFields.postalCode` del país seleccionado.
3
9
  - Si el backend no envía `checkoutRequiredFields.postalCode`, se mantiene el comportamiento base anterior del checkout: visible y requerido.
@@ -76,7 +76,10 @@
76
76
 
77
77
  const processError = (error) => {
78
78
  console.log("ERROR ENVIO BACK ", error);
79
- sessionStorage.setItem('state', 'error')
79
+ try { sessionStorage.setItem('state', 'menosuno'); } catch (e) { }
80
+ try { localStorage.setItem('state', 'menosuno'); } catch (e) { }
81
+ try { window.parent && window.parent.postMessage('menosuno', '*'); } catch (e) { }
82
+ try { window.opener && window.opener.postMessage('menosuno', '*'); } catch (e) { }
80
83
  }
81
84
 
82
85
  setTimeout(() => {
@@ -100,4 +103,4 @@
100
103
  </script>
101
104
  </body>
102
105
 
103
- </html>
106
+ </html>
@@ -76,7 +76,7 @@
76
76
 
77
77
  const processError = (error) => {
78
78
  console.log("ERROR ENVIO BACK ", error);
79
- localStorage.setItem('state', 'error')
79
+ localStorage.setItem('state', 'menosuno')
80
80
  }
81
81
 
82
82
  setTimeout(() => {
@@ -100,4 +100,4 @@
100
100
  </script>
101
101
  </body>
102
102
 
103
- </html>
103
+ </html>
@@ -203,8 +203,7 @@
203
203
  switch (status) {
204
204
  case 200:
205
205
  console.log('ESTATUS 200 ', res);
206
- console.log('URL -> ', `${urlOrigin}/cart/checkout/redsys/ok`);
207
- location.href = `${urlOrigin}/cart/checkout/redsys/ok`
206
+ notifyCheckoutState('ok')
208
207
  break;
209
208
  case 401:
210
209
  console.log('ESTATUS 401 ', res);
@@ -212,8 +211,7 @@
212
211
  if (!res.error) {
213
212
  setDobleAuthVuno(res)
214
213
  } else {
215
- console.log('URL -> ', `${urlOrigin}/cart/checkout/redsys/error`);
216
- location.href = `${urlOrigin}/cart/checkout/redsys/error`
214
+ notifyCheckoutState('menosuno')
217
215
  }
218
216
  } else {
219
217
  setDobleAuthVuno(res)
@@ -229,8 +227,7 @@
229
227
  break;
230
228
  case 500:
231
229
  console.log('ESTATUS 500 ', res);
232
- console.log('URL -> ', `${urlOrigin}/cart/checkout/redsys/error`);
233
- location.href = `${urlOrigin}/cart/checkout/redsys/error`
230
+ notifyCheckoutState('menosuno')
234
231
  break;
235
232
  default:
236
233
  console.log('NO ERA 200 ', res);
@@ -267,11 +264,20 @@
267
264
  //this.toastrService.show(err != '' ? err : 'payment-error');
268
265
  console.log("ERROR ENVIO BACK ", err);
269
266
  sessionStorage.setItem('state', 'error')
267
+ notifyCheckoutState('menosuno')
270
268
  //window.document.getElementById('redsys-hosted-pay-button').remove()
271
269
  //this.loading = true;
272
270
  //this.renderInit()
273
271
  }
274
272
 
273
+ const notifyCheckoutState = (state) => {
274
+ try { sessionStorage.setItem('state', state); } catch (error) { }
275
+ try { localStorage.setItem('state', state); } catch (error) { }
276
+ try { window.parent && window.parent.postMessage(state, '*'); } catch (error) { }
277
+ try { window.opener && window.opener.postMessage(state, '*'); } catch (error) { }
278
+ try { window.close(); } catch (error) { }
279
+ }
280
+
275
281
  const setDobleAuthVuno = (res) => {
276
282
  const { status, status_detail, paRequest, autSession, acsUrl } = res
277
283
  sessionStorage.setItem('status_detail', status_detail)
@@ -397,4 +403,4 @@
397
403
  </script>
398
404
  </body>
399
405
 
400
- </html>
406
+ </html>
@@ -53,12 +53,20 @@
53
53
 
54
54
  <script>
55
55
 
56
+ const notifyCheckoutState = (state) => {
57
+ try { sessionStorage.setItem('state', state); } catch (error) { }
58
+ try { localStorage.setItem('state', state); } catch (error) { }
59
+ try { window.parent && window.parent.postMessage(state, '*'); } catch (error) { }
60
+ try { window.opener && window.opener.postMessage(state, '*'); } catch (error) { }
61
+ try { window.close(); } catch (error) { }
62
+ }
63
+
56
64
  setTimeout(() => {
57
- let state = 'ok' //o lo que pinte!!!
58
- //sessionStorage.setItem('state', state)
59
- location.href = `http://ags.easycommercetech.tienda/cart/checkout/redsys/ok`
65
+ const params = new URLSearchParams(window.location.search);
66
+ const state = params.get('state') || 'ok';
67
+ notifyCheckoutState(state);
60
68
  }, 2000);
61
69
  </script>
62
70
  </body>
63
71
 
64
- </html>
72
+ </html>
@@ -16817,6 +16817,7 @@
16817
16817
  _this.isDobleAuth = false;
16818
16818
  _this.urls = [];
16819
16819
  _this.closeModalReason = ''; // Renombrado para evitar confusión
16820
+ _this.finished = false;
16820
16821
  _this.dataRedirect = function () { return _this.consts.getUrlBase() + 'shop-api/' + _this.consts.getChannel() + '/redsys/redirect/' + _this.cartService.cart_token + '/process-payment'; };
16821
16822
  _this.clearStorageState = function () {
16822
16823
  sessionStorage.removeItem('state');
@@ -16825,31 +16826,23 @@
16825
16826
  // Método que se llama desde la X de la cabecera del modal en el HTML
16826
16827
  _this.clickClose = function () {
16827
16828
  _this.closeModalReason = 'cancel';
16829
+ _this.finished = true;
16830
+ if (_this.stateTimeout) {
16831
+ clearTimeout(_this.stateTimeout);
16832
+ _this.stateTimeout = null;
16833
+ }
16828
16834
  if (_this.modalRef) {
16829
16835
  _this.modalRef.hide();
16830
16836
  }
16831
16837
  _this.processError('Se canceló el pago con tarjeta');
16832
16838
  };
16833
16839
  _this.callState = function () {
16834
- var _a, _b, _c;
16840
+ if (_this.finished) {
16841
+ return;
16842
+ }
16835
16843
  var state = _this.closeModalReason != '' ? _this.closeModalReason : sessionStorage.getItem('state');
16836
16844
  if (state) {
16837
- _this.clearStorageState();
16838
- if (state == 'ok') {
16839
- (_a = _this.modalRef) === null || _a === void 0 ? void 0 : _a.hide();
16840
- _this.ready.emit(true);
16841
- return;
16842
- }
16843
- if (state == 'menosuno') {
16844
- (_b = _this.modalRef) === null || _b === void 0 ? void 0 : _b.hide();
16845
- _this.processError('Error en el pago');
16846
- return;
16847
- }
16848
- if (state == 'cancel') {
16849
- return; // El modal ya se escondió dentro de clickClose()
16850
- }
16851
- (_c = _this.modalRef) === null || _c === void 0 ? void 0 : _c.hide();
16852
- _this.processError('Error desconocido en la transacción');
16845
+ _this.handleState(state);
16853
16846
  return;
16854
16847
  }
16855
16848
  // Guardamos el timeout en una variable de clase
@@ -16857,6 +16850,33 @@
16857
16850
  _this.callState();
16858
16851
  }, 6000);
16859
16852
  };
16853
+ _this.handleState = function (state) {
16854
+ var _a, _b, _c, _d;
16855
+ if (_this.finished)
16856
+ return;
16857
+ _this.finished = true;
16858
+ if (_this.stateTimeout) {
16859
+ clearTimeout(_this.stateTimeout);
16860
+ _this.stateTimeout = null;
16861
+ }
16862
+ _this.clearStorageState();
16863
+ if (state === 'ok') {
16864
+ (_a = _this.modalRef) === null || _a === void 0 ? void 0 : _a.hide();
16865
+ _this.ready.emit(true);
16866
+ return;
16867
+ }
16868
+ if (state === 'menosuno' || state === 'error' || state === 'failure') {
16869
+ (_b = _this.modalRef) === null || _b === void 0 ? void 0 : _b.hide();
16870
+ _this.processError('Error en el pago');
16871
+ return;
16872
+ }
16873
+ if (state === 'cancel') {
16874
+ (_c = _this.modalRef) === null || _c === void 0 ? void 0 : _c.hide();
16875
+ return;
16876
+ }
16877
+ (_d = _this.modalRef) === null || _d === void 0 ? void 0 : _d.hide();
16878
+ _this.processError('Error desconocido en la transacción');
16879
+ };
16860
16880
  _this.processError = function (err) {
16861
16881
  _this.toastrService.show(err != '' ? err : 'payment-error');
16862
16882
  console.log("ERROR ENVIO BACK ", err);
@@ -16875,10 +16895,11 @@
16875
16895
  }
16876
16896
  };
16877
16897
  RedSysRedirectEcComponent.prototype.ngOnChanges = function () {
16878
- console.log("SE CAMBIO");
16898
+ // console.log("SE CAMBIO");
16879
16899
  };
16880
16900
  RedSysRedirectEcComponent.prototype.openModal = function (template) {
16881
16901
  this.clearStorageState();
16902
+ this.finished = false;
16882
16903
  sessionStorage.setItem('dataRedirect', this.dataRedirect());
16883
16904
  // Abrimos el modal y guardamos la referencia en this.modalRef
16884
16905
  this.modalRef = this.modalService.show(template, { class: 'modal-lg modal-dialog-centered', keyboard: false, backdrop: 'static', animated: true });
@@ -16887,11 +16908,33 @@
16887
16908
  };
16888
16909
  // Opcional pero recomendado: Capturar mensajes enviados desde el Iframe de Redsys
16889
16910
  RedSysRedirectEcComponent.prototype.onMessage = function (event) {
16890
- if (event.data === 'pago_completado' || event.data === 'ok') {
16891
- sessionStorage.setItem('state', 'ok');
16911
+ var _a, _b, _c, _d;
16912
+ var data = (_a = event) === null || _a === void 0 ? void 0 : _a.data;
16913
+ var state = typeof data === 'string'
16914
+ ? data
16915
+ : ((_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;
16916
+ if (!state) {
16917
+ return;
16918
+ }
16919
+ if (state === 'pago_completado' || state === 'ok' || state === 'success') {
16920
+ this.handleState('ok');
16921
+ return;
16922
+ }
16923
+ if (state === 'pago_error' || state === 'menosuno' || state === 'error' || state === 'failure') {
16924
+ this.handleState('menosuno');
16925
+ }
16926
+ };
16927
+ RedSysRedirectEcComponent.prototype.onStorage = function (event) {
16928
+ var _a;
16929
+ if (!((_a = event) === null || _a === void 0 ? void 0 : _a.key) || event.key !== 'state' || !event.newValue) {
16930
+ return;
16931
+ }
16932
+ if (event.newValue === 'ok' || event.newValue === 'success') {
16933
+ this.handleState('ok');
16934
+ return;
16892
16935
  }
16893
- else if (event.data === 'pago_error' || event.data === 'menosuno') {
16894
- sessionStorage.setItem('state', 'menosuno');
16936
+ if (event.newValue === 'menosuno' || event.newValue === 'error' || event.newValue === 'failure') {
16937
+ this.handleState('menosuno');
16895
16938
  }
16896
16939
  };
16897
16940
  RedSysRedirectEcComponent.ctorParameters = function () { return [
@@ -16921,6 +16964,9 @@
16921
16964
  __decorate$1m([
16922
16965
  core.HostListener('window:message', ['$event'])
16923
16966
  ], RedSysRedirectEcComponent.prototype, "onMessage", null);
16967
+ __decorate$1m([
16968
+ core.HostListener('window:storage', ['$event'])
16969
+ ], RedSysRedirectEcComponent.prototype, "onStorage", null);
16924
16970
  RedSysRedirectEcComponent = __decorate$1m([
16925
16971
  core.Component({
16926
16972
  selector: 'app-redsys-redirect-ec',
@@ -19126,7 +19172,7 @@
19126
19172
  (_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.close();
19127
19173
  };
19128
19174
  _this.callState = function () {
19129
- var _a, _b, _c, _d, _e;
19175
+ var _a, _b, _c, _d;
19130
19176
  var state = _this.closeModal != '' ? _this.closeModal : localStorage.getItem('state');
19131
19177
  !state && _this.ventana.closed && (state = 'cancel');
19132
19178
  _this.loading = true;
@@ -19134,27 +19180,22 @@
19134
19180
  if (state) {
19135
19181
  _this.loading = false;
19136
19182
  localStorage.removeItem('state');
19137
- if (state == 'success' || state == 'ok') {
19183
+ if (state == 'success' || state == 'ok' || state == 'pending') {
19138
19184
  (_a = _this.ventana) === null || _a === void 0 ? void 0 : _a.close();
19139
19185
  _this.ready.emit(true);
19140
19186
  return;
19141
19187
  }
19142
- if (state == 'pending' || state == 'ok') {
19188
+ if (state == 'failure' || state == 'error' || state == 'menosuno') {
19143
19189
  (_b = _this.ventana) === null || _b === void 0 ? void 0 : _b.close();
19144
- _this.ready.emit(true);
19145
- return;
19146
- }
19147
- if (state == 'failure' || state == 'error') {
19148
- (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19149
19190
  _this.processError('');
19150
19191
  return;
19151
19192
  }
19152
19193
  if (state == 'cancel') {
19153
- (_d = _this.ventana) === null || _d === void 0 ? void 0 : _d.close();
19194
+ (_c = _this.ventana) === null || _c === void 0 ? void 0 : _c.close();
19154
19195
  _this.processError('Se cancelo el pago con redsys');
19155
19196
  return;
19156
19197
  }
19157
- (_e = _this.ventana) === null || _e === void 0 ? void 0 : _e.close();
19198
+ (_d = _this.ventana) === null || _d === void 0 ? void 0 : _d.close();
19158
19199
  _this.processError('');
19159
19200
  return;
19160
19201
  }