ng-easycommerce 0.0.639 → 0.0.640

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.
@@ -7583,7 +7583,7 @@ let SuccessEcComponent = class SuccessEcComponent extends ComponentHelper {
7583
7583
  }
7584
7584
  ngOnInit() {
7585
7585
  this.checkoutService.order$.subscribe(res => {
7586
- var _a, _b, _c, _d, _e, _f, _g, _h;
7586
+ var _a, _b, _c, _d, _e;
7587
7587
  //console.log('LO QUE LLEGA EN ORDEN', res);
7588
7588
  ((_a = res) === null || _a === void 0 ? void 0 : _a.number) ? this.params = {
7589
7589
  external_reference: res.number,
@@ -7591,7 +7591,11 @@ let SuccessEcComponent = class SuccessEcComponent extends ComponentHelper {
7591
7591
  //this.payments = [{method:{code:'bank_transsfer'}}]
7592
7592
  this.payments = ((_b = res) === null || _b === void 0 ? void 0 : _b.payments) ? res.payments : null;
7593
7593
  if (((_e = (_d = (_c = this.payments) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.method) === null || _e === void 0 ? void 0 : _e.code) && this.isPlaceToPay(this.payments[0].method.code)) {
7594
- this.totalAmount = (_h = (_g = (_f = res) === null || _f === void 0 ? void 0 : _f.totals) === null || _g === void 0 ? void 0 : _g.total, (_h !== null && _h !== void 0 ? _h : null));
7594
+ const stored = localStorage.getItem('total_amount');
7595
+ if (stored !== null) {
7596
+ this.totalAmount = parseFloat(stored);
7597
+ localStorage.removeItem('total_amount');
7598
+ }
7595
7599
  const now = new Date();
7596
7600
  this.paymentDate = now.toLocaleDateString('es-AR', {
7597
7601
  day: '2-digit',
@@ -8924,18 +8928,19 @@ let ProductDetailService = class ProductDetailService {
8924
8928
  options && options.forEach(option => Object.keys(option).forEach(key => this.setOption(key, option[key])));
8925
8929
  };
8926
8930
  this.generateAsociatedDataFromVariants = () => {
8927
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
8931
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
8928
8932
  let asociated = {};
8929
8933
  if (this.isReady()) {
8930
8934
  asociated.stock = this.variants[0].stock;
8931
8935
  // Precio: si viene taxLegendInfo usamos su price, si no el v.price
8932
8936
  const rawPrice = (_b = (_a = this.variants[0].taxLegendInfo) === null || _a === void 0 ? void 0 : _a.price, (_b !== null && _b !== void 0 ? _b : this.variants[0].price));
8933
8937
  asociated.price = rawPrice.toString();
8934
- asociated.saleprice = this.variants[0].saleprice && this.variants[0].saleprice.toString() || undefined;
8935
- asociated.discount = ((_c = this.variants[0]) === null || _c === void 0 ? void 0 : _c.discount) || undefined;
8938
+ const rawSalePrice = (_d = (_c = this.variants[0].taxLegendInfo) === null || _c === void 0 ? void 0 : _c.saleprice, (_d !== null && _d !== void 0 ? _d : this.variants[0].saleprice));
8939
+ asociated.saleprice = rawSalePrice ? rawSalePrice.toString() : undefined;
8940
+ asociated.discount = ((_e = this.variants[0]) === null || _e === void 0 ? void 0 : _e.discount) || undefined;
8936
8941
  asociated.properties = this.variants[0].properties ? this.beautifyProperties(this.variants[0].properties) : undefined;
8937
- asociated.uniqueExternalCode = ((_d = this.variants[0]) === null || _d === void 0 ? void 0 : _d.uniqueExternalCode) || undefined;
8938
- asociated.multipleQuantity = ((_e = this.variants[0]) === null || _e === void 0 ? void 0 : _e.multipleQuantity) || undefined;
8942
+ asociated.uniqueExternalCode = ((_f = this.variants[0]) === null || _f === void 0 ? void 0 : _f.uniqueExternalCode) || undefined;
8943
+ asociated.multipleQuantity = ((_g = this.variants[0]) === null || _g === void 0 ? void 0 : _g.multipleQuantity) || undefined;
8939
8944
  }
8940
8945
  else {
8941
8946
  asociated.price = this.cratePrice();
@@ -8946,31 +8951,31 @@ let ProductDetailService = class ProductDetailService {
8946
8951
  ('images' in this.variants[0] && this.variants[0].images.length > 0)
8947
8952
  ? asociated.picture = this.variants[0].images[0]
8948
8953
  : asociated.picture = (this.asociatedDataSubject.value.picture || this.productSubject.value.picturesdefault[0]);
8949
- asociated.maximumAmount = ((_f = this.variants[0]) === null || _f === void 0 ? void 0 : _f.maximumAmount) || 0;
8950
- asociated.minimumAmount = ((_g = this.variants[0]) === null || _g === void 0 ? void 0 : _g.minimumAmount) || 0;
8951
- asociated.maximumItemsQuantity = ((_h = this.variants[0]) === null || _h === void 0 ? void 0 : _h.stock) > 0 && 'maximumItemsQuantity' in this.variants[0] ? (_j = this.variants[0]) === null || _j === void 0 ? void 0 : _j.maximumItemsQuantity : (_k = this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock;
8952
- asociated.minimumItemsQuantity = ((_l = this.variants[0]) === null || _l === void 0 ? void 0 : _l.stock) > 0 && 'minimumItemsQuantity' in this.variants[0]
8953
- && ((_m = this.variants[0]) === null || _m === void 0 ? void 0 : _m.minimumItemsQuantity) > 0 ? (_o = this.variants[0]) === null || _o === void 0 ? void 0 : _o.minimumItemsQuantity : (((_p = this.variants[0]) === null || _p === void 0 ? void 0 : _p.multipleQuantity) ? (_q = this.variants[0]) === null || _q === void 0 ? void 0 : _q.multipleQuantity : 1);
8954
+ asociated.maximumAmount = ((_h = this.variants[0]) === null || _h === void 0 ? void 0 : _h.maximumAmount) || 0;
8955
+ asociated.minimumAmount = ((_j = this.variants[0]) === null || _j === void 0 ? void 0 : _j.minimumAmount) || 0;
8956
+ asociated.maximumItemsQuantity = ((_k = this.variants[0]) === null || _k === void 0 ? void 0 : _k.stock) > 0 && 'maximumItemsQuantity' in this.variants[0] ? (_l = this.variants[0]) === null || _l === void 0 ? void 0 : _l.maximumItemsQuantity : (_m = this.variants[0]) === null || _m === void 0 ? void 0 : _m.stock;
8957
+ asociated.minimumItemsQuantity = ((_o = this.variants[0]) === null || _o === void 0 ? void 0 : _o.stock) > 0 && 'minimumItemsQuantity' in this.variants[0]
8958
+ && ((_p = this.variants[0]) === null || _p === void 0 ? void 0 : _p.minimumItemsQuantity) > 0 ? (_q = this.variants[0]) === null || _q === void 0 ? void 0 : _q.minimumItemsQuantity : (((_r = this.variants[0]) === null || _r === void 0 ? void 0 : _r.multipleQuantity) ? (_s = this.variants[0]) === null || _s === void 0 ? void 0 : _s.multipleQuantity : 1);
8954
8959
  asociated.finalConsumer = {
8955
- finalConsumerPrice: (_r = this.variants[0]) === null || _r === void 0 ? void 0 : _r.final_consumer_price,
8956
- originalFinalConsumerPrice: (_s = this.variants[0]) === null || _s === void 0 ? void 0 : _s.original_final_consumer_price,
8960
+ finalConsumerPrice: (_t = this.variants[0]) === null || _t === void 0 ? void 0 : _t.final_consumer_price,
8961
+ originalFinalConsumerPrice: (_u = this.variants[0]) === null || _u === void 0 ? void 0 : _u.original_final_consumer_price,
8957
8962
  };
8958
8963
  asociated.taxes = {
8959
- taxIncluded: (_t = this.variants[0]) === null || _t === void 0 ? void 0 : _t.taxIncluded,
8960
- taxCategory: (_u = this.variants[0]) === null || _u === void 0 ? void 0 : _u.taxCategory,
8964
+ taxIncluded: (_v = this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxIncluded,
8965
+ taxCategory: (_w = this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxCategory,
8961
8966
  };
8962
8967
  // Segun version del backend
8963
- if ((_v = this.variants[0]) === null || _v === void 0 ? void 0 : _v.taxLegendInfo) {
8968
+ if ((_x = this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo) {
8964
8969
  // Nuevo backend
8965
- asociated.priceWithoutTaxes = (_w = this.variants[0]) === null || _w === void 0 ? void 0 : _w.taxLegendInfo.priceWithoutTaxes;
8966
- asociated.taxeAmount = (_x = this.variants[0]) === null || _x === void 0 ? void 0 : _x.taxLegendInfo.taxes;
8967
- asociated.taxRate = (_y = this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.taxRate;
8970
+ asociated.priceWithoutTaxes = (_y = this.variants[0]) === null || _y === void 0 ? void 0 : _y.taxLegendInfo.priceWithoutTaxes;
8971
+ asociated.taxeAmount = (_z = this.variants[0]) === null || _z === void 0 ? void 0 : _z.taxLegendInfo.taxes;
8972
+ asociated.taxRate = (_0 = this.variants[0]) === null || _0 === void 0 ? void 0 : _0.taxLegendInfo.taxRate;
8968
8973
  }
8969
8974
  else {
8970
8975
  // Backend antiguo
8971
- asociated.priceWithoutTaxes = (_0 = (_z = this.variants[0]) === null || _z === void 0 ? void 0 : _z.priceWithoutTaxes, (_0 !== null && _0 !== void 0 ? _0 : undefined));
8972
- asociated.taxeAmount = (_2 = (_1 = this.variants[0]) === null || _1 === void 0 ? void 0 : _1.taxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
8973
- asociated.taxRate = (_4 = (_3 = this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxRate, (_4 !== null && _4 !== void 0 ? _4 : undefined));
8976
+ asociated.priceWithoutTaxes = (_2 = (_1 = this.variants[0]) === null || _1 === void 0 ? void 0 : _1.priceWithoutTaxes, (_2 !== null && _2 !== void 0 ? _2 : undefined));
8977
+ asociated.taxeAmount = (_4 = (_3 = this.variants[0]) === null || _3 === void 0 ? void 0 : _3.taxes, (_4 !== null && _4 !== void 0 ? _4 : undefined));
8978
+ asociated.taxRate = (_6 = (_5 = this.variants[0]) === null || _5 === void 0 ? void 0 : _5.taxRate, (_6 !== null && _6 !== void 0 ? _6 : undefined));
8974
8979
  }
8975
8980
  this.asociatedDataSubject.next(asociated);
8976
8981
  };
@@ -10613,15 +10618,24 @@ let RedsysCatchEcComponent = class RedsysCatchEcComponent extends ComponentHelpe
10613
10618
  case '200':
10614
10619
  state = 'success';
10615
10620
  this.setStateInLocal('Su pago fue procesado con éxito.', state);
10621
+ if (queryParams.total_amount) {
10622
+ localStorage.setItem('total_amount', queryParams.total_amount);
10623
+ }
10616
10624
  break;
10617
10625
  case 'success':
10618
10626
  this.setStateInLocal('Su pago fue procesado con éxito.', state);
10627
+ if (queryParams.total_amount) {
10628
+ localStorage.setItem('total_amount', queryParams.total_amount);
10629
+ }
10619
10630
  break;
10620
10631
  case 'pending':
10621
10632
  this.setStateInLocal('Su pago fue procesado con éxito.', state);
10622
10633
  break;
10623
10634
  case 'failure':
10624
10635
  this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
10636
+ if (queryParams.total_amount) {
10637
+ localStorage.setItem('total_amount', queryParams.total_amount);
10638
+ }
10625
10639
  break;
10626
10640
  case 'cancel':
10627
10641
  this.setStateInLocal('Se ha cancelado el proceso de pago.', state);
@@ -16303,6 +16317,10 @@ let PlaceToPayEcComponent = class PlaceToPayEcComponent extends ComponentHelper
16303
16317
  this.ready = new EventEmitter();
16304
16318
  this.loading = false;
16305
16319
  this.closeModal = '';
16320
+ this.hasPreviousFailure = false;
16321
+ this.previousFailureAmount = null;
16322
+ this.previousFailureDate = null;
16323
+ this.buttonText = 'Pagar';
16306
16324
  this.dataRedirect = () => this.consts.getUrlBase() + 'shop-api/' + this.consts.getChannel() + '/place-to-pay/' + this.cartService.cart_token + '/process-payment';
16307
16325
  this.iniciar = () => {
16308
16326
  this.closeModal = '';
@@ -16323,17 +16341,33 @@ let PlaceToPayEcComponent = class PlaceToPayEcComponent extends ComponentHelper
16323
16341
  var _a, _b, _c, _d;
16324
16342
  let state = this.closeModal !== '' ? this.closeModal : localStorage.getItem('state');
16325
16343
  !state && ((_a = this.ventana) === null || _a === void 0 ? void 0 : _a.closed) && (state = 'cancel');
16344
+ this.hasPreviousFailure = false;
16326
16345
  this.loading = true;
16327
16346
  if (state) {
16328
- this.loading = false;
16329
16347
  localStorage.removeItem('state');
16330
16348
  if (state === 'success' || state === 'pending') {
16331
16349
  (_b = this.ventana) === null || _b === void 0 ? void 0 : _b.close();
16332
16350
  this.ready.emit(true);
16333
16351
  return;
16334
16352
  }
16353
+ this.loading = false;
16335
16354
  if (state === 'failure' || state === 'cancel') {
16336
16355
  (_c = this.ventana) === null || _c === void 0 ? void 0 : _c.close();
16356
+ if (state === 'failure') {
16357
+ const amt = localStorage.getItem('total_amount');
16358
+ if (amt) {
16359
+ this.hasPreviousFailure = true;
16360
+ this.previousFailureAmount = parseFloat(amt);
16361
+ this.previousFailureDate = new Date().toLocaleDateString('es-AR', {
16362
+ day: '2-digit',
16363
+ month: '2-digit',
16364
+ year: 'numeric',
16365
+ });
16366
+ this.buttonText = 'Reintentar pago';
16367
+ localStorage.removeItem('total_amount');
16368
+ localStorage.removeItem('payment_date');
16369
+ }
16370
+ }
16337
16371
  this.getPreference();
16338
16372
  this.processError(state === 'cancel' ? 'Se canceló el pago con Place to Pay' : '');
16339
16373
  return;
@@ -16396,7 +16430,7 @@ __decorate$20([
16396
16430
  PlaceToPayEcComponent = __decorate$20([
16397
16431
  Component({
16398
16432
  selector: 'app-place-to-pay-ec',
16399
- template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">Pagar</button>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\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 </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
16433
+ template: "<div class=\"text-center\">\n <ng-container *ngIf=\"url; else loadingUrl\">\n <ng-container *ngIf=\"!loading; else loadingTemp\">\n <button (click)=\"iniciar()\" class=\"btn btn-outline-secondary rounded-0 comprar mt-3\">\n {{ buttonText }}\n </button>\n\n <!-- Mensaje de intento previo fallido -->\n <div *ngIf=\"hasPreviousFailure\" class=\"alert alert-danger mt-3\">\n El pago no se pudo realizar el {{ previousFailureDate }}\n por un monto de {{ previousFailureAmount | ecCurrencySymbol }}.\n </div>\n </ng-container>\n </ng-container>\n</div>\n\n<ng-template #loadingUrl>\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 </div>\n</ng-template>\n\n<ng-template #loadingTemp>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <h3>Procesando el pago por Place to Pay</h3>\n <h5>Recuerde hacer click en \"Volver al sitio\" desde Place to Pay para finalizar la compra.</h5>\n <app-loading-full-ec></app-loading-full-ec>\n </div>\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-5\">\n <hr>\n </div>\n <div class=\"col-2 text-center\">\n <label>o</label>\n </div>\n <div class=\"col-5\">\n <hr>\n </div>\n </div>\n </div>\n <div class=\"d-flex flex-column justify-content-center align-items-center mt-2\">\n <button (click)=\"clickClose()\" class=\"btn btn-outline-secondary rounded-0 comprar\">Cancelar pago</button>\n </div>\n</ng-template>",
16400
16434
  styles: [""]
16401
16435
  })
16402
16436
  ], PlaceToPayEcComponent);