@ikas/storefront 0.0.164-alpha.3 → 0.0.164-alpha.5

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.
@@ -23,7 +23,6 @@ export default class CheckoutViewModel {
23
23
  step: CheckoutStep;
24
24
  merchantSettings?: IkasMerchantSettings;
25
25
  cardData?: CreditCardData | null;
26
- paymentGatewayId?: string | null;
27
26
  paymentGateways: IkasPaymentGateway[];
28
27
  installmentInfo?: IkasInstallmentInfo | null;
29
28
  useDifferentAddress: boolean;
@@ -48,7 +47,6 @@ export default class CheckoutViewModel {
48
47
  getMerchantSettings: () => Promise<void>;
49
48
  get cart(): import("../../models/data/cart/index").IkasCart | null | undefined;
50
49
  get selectedPaymentGatewayIndex(): number;
51
- get selectedPaymentGateway(): IkasPaymentGateway | undefined;
52
50
  get selectedInstallmentIndex(): number;
53
51
  get checkoutUrl(): string;
54
52
  get customerAddressOptions(): {
package/build/index.es.js CHANGED
@@ -11328,6 +11328,8 @@ var IkasOrderAddress = /** @class */ (function () {
11328
11328
  this.identityNumber = data.identityNumber || null;
11329
11329
  this.taxNumber = data.taxNumber || null;
11330
11330
  this.taxOffice = data.taxOffice || null;
11331
+ this.checkoutSettings = data.checkoutSettings;
11332
+ this.isDistrictRequired = data.isDistrictRequired || false;
11331
11333
  makeAutoObservable(this);
11332
11334
  }
11333
11335
  Object.defineProperty(IkasOrderAddress.prototype, "addressText", {
@@ -22807,7 +22809,6 @@ var CheckoutViewModel = /** @class */ (function () {
22807
22809
  this.isChangingShippingMethod = false;
22808
22810
  this.step = CheckoutStep.INFO;
22809
22811
  this.cardData = null;
22810
- this.paymentGatewayId = null;
22811
22812
  this.paymentGateways = [];
22812
22813
  this.installmentInfo = null;
22813
22814
  this.useDifferentAddress = false;
@@ -22840,7 +22841,7 @@ var CheckoutViewModel = /** @class */ (function () {
22840
22841
  });
22841
22842
  }); };
22842
22843
  this.initStep = function (queryParams) { return __awaiter(_this, void 0, void 0, function () {
22843
- var _a, transactions;
22844
+ var _a, transactions, paymentGatewayId_1;
22844
22845
  return __generator(this, function (_b) {
22845
22846
  switch (_b.label) {
22846
22847
  case 0:
@@ -22912,6 +22913,10 @@ var CheckoutViewModel = /** @class */ (function () {
22912
22913
  this.successTransaction = transactions.length
22913
22914
  ? transactions[0]
22914
22915
  : undefined;
22916
+ if (this.successTransaction) {
22917
+ paymentGatewayId_1 = this.successTransaction.paymentGatewayId;
22918
+ this.checkout.selectedPaymentGateway = this.paymentGateways.find(function (pg) { return pg.id === paymentGatewayId_1; });
22919
+ }
22915
22920
  _b.label = 11;
22916
22921
  case 11:
22917
22922
  this.isCheckoutLoaded = true;
@@ -23091,7 +23096,7 @@ var CheckoutViewModel = /** @class */ (function () {
23091
23096
  orderedPaymentGateways.push(_pg);
23092
23097
  });
23093
23098
  this.paymentGateways = isLocal ? paymentGateways : orderedPaymentGateways;
23094
- if (!this.paymentGatewayId)
23099
+ if (!this.checkout.selectedPaymentGateway)
23095
23100
  this.setPaymentGateway(0);
23096
23101
  return [2 /*return*/];
23097
23102
  }
@@ -23185,10 +23190,7 @@ var CheckoutViewModel = /** @class */ (function () {
23185
23190
  newCheckout = _a.sent();
23186
23191
  if (newCheckout) {
23187
23192
  oldCheckout = this.checkout;
23188
- this.checkout = newCheckout;
23189
- this.checkout.customer = oldCheckout.customer;
23190
- this.checkout.shippingAddress = oldCheckout.shippingAddress;
23191
- this.checkout.billingAddress = oldCheckout.billingAddress;
23193
+ this.checkout = new IkasCheckout(__assign(__assign({}, newCheckout), { shippingAddress: oldCheckout.shippingAddress, billingAddress: oldCheckout.billingAddress, customer: oldCheckout.customer }));
23192
23194
  }
23193
23195
  return [3 /*break*/, 4];
23194
23196
  case 3:
@@ -23245,7 +23247,7 @@ var CheckoutViewModel = /** @class */ (function () {
23245
23247
  if (oldOriginalValue.length < 6 && originalValue.length >= 6) {
23246
23248
  _this.retrieveInstallmentInfo({
23247
23249
  binNumber: originalValue.slice(0, 6),
23248
- paymentGatewayId: _this.paymentGatewayId,
23250
+ paymentGatewayId: _this.checkout.selectedPaymentGateway.id,
23249
23251
  price: _this.checkout.totalFinalPrice,
23250
23252
  });
23251
23253
  }
@@ -23484,15 +23486,17 @@ var CheckoutViewModel = /** @class */ (function () {
23484
23486
  }); };
23485
23487
  this.createSaleTransaction = function () { return __awaiter(_this, void 0, void 0, function () {
23486
23488
  var response, transactionStatus, transactionSuccess, transactionPending;
23487
- var _a;
23488
- return __generator(this, function (_b) {
23489
- switch (_b.label) {
23490
- case 0: return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.paymentGatewayId, ((_a = this.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.paymentMethodType) ===
23491
- IkasPaymentMethodType.CREDIT_CARD && this.cardData
23492
- ? this.cardData.toInput()
23493
- : undefined)];
23489
+ return __generator(this, function (_a) {
23490
+ switch (_a.label) {
23491
+ case 0:
23492
+ if (!this.checkout.selectedPaymentGateway)
23493
+ return [2 /*return*/];
23494
+ return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.checkout.selectedPaymentGateway.id, this.checkout.selectedPaymentGateway.paymentMethodType ===
23495
+ IkasPaymentMethodType.CREDIT_CARD && this.cardData
23496
+ ? this.cardData.toInput()
23497
+ : undefined)];
23494
23498
  case 1:
23495
- response = _b.sent();
23499
+ response = _a.sent();
23496
23500
  transactionStatus = response === null || response === void 0 ? void 0 : response.transactionStatus;
23497
23501
  transactionSuccess = transactionStatus &&
23498
23502
  [
@@ -23503,7 +23507,7 @@ var CheckoutViewModel = /** @class */ (function () {
23503
23507
  if (!transactionSuccess) return [3 /*break*/, 3];
23504
23508
  return [4 /*yield*/, this.onCheckoutTransactionSuccess()];
23505
23509
  case 2:
23506
- _b.sent();
23510
+ _a.sent();
23507
23511
  return [3 /*break*/, 4];
23508
23512
  case 3:
23509
23513
  if (transactionPending && !!(response === null || response === void 0 ? void 0 : response.returnSlug)) {
@@ -23515,7 +23519,7 @@ var CheckoutViewModel = /** @class */ (function () {
23515
23519
  type: ErrorType.UNKNOWN,
23516
23520
  };
23517
23521
  }
23518
- _b.label = 4;
23522
+ _a.label = 4;
23519
23523
  case 4: return [2 /*return*/];
23520
23524
  }
23521
23525
  });
@@ -23565,12 +23569,13 @@ var CheckoutViewModel = /** @class */ (function () {
23565
23569
  };
23566
23570
  this.setPaymentGateway = function (index) {
23567
23571
  var paymentGateway = _this.paymentGateways[index];
23568
- _this.paymentGatewayId = paymentGateway.id;
23569
- if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23570
- _this.cardData = new CreditCardData();
23571
- }
23572
23572
  _this.checkout.selectedPaymentGateway = paymentGateway;
23573
- _this.installmentInfo = undefined;
23573
+ if (_this.step !== CheckoutStep.SUCCESS) {
23574
+ if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23575
+ _this.cardData = new CreditCardData();
23576
+ }
23577
+ _this.installmentInfo = undefined;
23578
+ }
23574
23579
  };
23575
23580
  this.setInstallmentCount = function (count) {
23576
23581
  if (!_this.cardData)
@@ -23635,15 +23640,7 @@ var CheckoutViewModel = /** @class */ (function () {
23635
23640
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
23636
23641
  get: function () {
23637
23642
  var _this = this;
23638
- return this.paymentGateways.findIndex(function (pg) { return pg.id === _this.paymentGatewayId; });
23639
- },
23640
- enumerable: false,
23641
- configurable: true
23642
- });
23643
- Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGateway", {
23644
- get: function () {
23645
- var _this = this;
23646
- return this.paymentGateways.find(function (pg) { return pg.id === _this.paymentGatewayId; });
23643
+ return this.paymentGateways.findIndex(function (pg) { var _a; return pg.id === ((_a = _this.checkout.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.id); });
23647
23644
  },
23648
23645
  enumerable: false,
23649
23646
  configurable: true
@@ -23742,7 +23739,7 @@ var CheckoutViewModel = /** @class */ (function () {
23742
23739
  return false;
23743
23740
  return (this.canProceedToShipping &&
23744
23741
  !!((_a = this.checkout.billingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23745
- (((_b = this.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23742
+ (((_b = this.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23746
23743
  IkasPaymentMethodType.CREDIT_CARD
23747
23744
  ? (_c = this.cardData) === null || _c === void 0 ? void 0 : _c.isValid : true));
23748
23745
  },
@@ -61102,7 +61099,8 @@ var CartSummary = observer(function (_a) {
61102
61099
  !!vm.installmentExtraPrice && (createElement(InfoRow, { label: t("checkout-page:cartInterest"), value: formatMoney(vm.installmentExtraPrice, cart.currencyCode) })),
61103
61100
  createElement(Adjustments, { vm: vm }),
61104
61101
  createElement(CalculatedAdditionalPrices, { vm: vm }),
61105
- ((vm.step === CheckoutStep.SUCCESS && !!vm.checkout.note) ||
61102
+ ((vm.step === CheckoutStep.SUCCESS &&
61103
+ (!!vm.checkout.note || !!vm.checkout.appliedCouponCode)) ||
61106
61104
  vm.step !== CheckoutStep.SUCCESS) && (createElement("div", { className: styles$h.Divider, style: { marginTop: "24px", marginBottom: "24px" } })),
61107
61105
  createElement(Coupon, { vm: vm, isAddingCoupon: isAddingCoupon, setAddingCoupon: setAddingCoupon, setCouponError: setCouponError }),
61108
61106
  createElement(Note, { vm: vm, isAddingNote: isAddingNote, setAddingNote: setAddingNote })),
@@ -61145,14 +61143,15 @@ var CalculatedAdditionalPrices = observer(function (_a) {
61145
61143
  if (!vm.cart)
61146
61144
  return null;
61147
61145
  return (createElement(Fragment$1, null,
61148
- (((_b = vm.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61149
- .filter(function (adjustment) { return adjustment.amount !== 0; })
61150
- .map(function (adjustment, index) { return (createElement("div", { className: styles$h.InfoRow, key: index },
61151
- createElement("div", { className: styles$h.Label }, adjustment.name),
61152
- createElement("div", { className: styles$h.Value },
61153
- createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61154
- " ",
61155
- createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61146
+ vm.step !== CheckoutStep.SUCCESS &&
61147
+ (((_b = vm.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61148
+ .filter(function (adjustment) { return adjustment.amount !== 0; })
61149
+ .map(function (adjustment, index) { return (createElement("div", { className: styles$h.InfoRow, key: index },
61150
+ createElement("div", { className: styles$h.Label }, adjustment.name),
61151
+ createElement("div", { className: styles$h.Value },
61152
+ createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61153
+ " ",
61154
+ createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61156
61155
  _c.map(function (gpl, index) { return (createElement("div", { className: styles$h.InfoRow, key: index },
61157
61156
  createElement("div", { className: styles$h.Label },
61158
61157
  createElement("div", { className: styles$h.GiftLabel },
@@ -61202,7 +61201,8 @@ var Coupon = observer(function (_a) {
61202
61201
  }
61203
61202
  });
61204
61203
  }); };
61205
- if (vm.step === CheckoutStep.SUCCESS)
61204
+ var isSuccess = vm.step === CheckoutStep.SUCCESS;
61205
+ if (isSuccess && !vm.checkout.appliedCouponCode)
61206
61206
  return null;
61207
61207
  var adjustment = vm.checkout.couponAdjustment;
61208
61208
  return (createElement("div", { className: styles$h.InfoRow },
@@ -61216,8 +61216,8 @@ var Coupon = observer(function (_a) {
61216
61216
  t("checkout-page:couponCode"),
61217
61217
  createElement("span", { className: styles$h.AppliedCoupon },
61218
61218
  createElement("span", { className: styles$h.CouponCode }, vm.checkout.appliedCouponCode),
61219
- createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61220
- createElement(SVGCross, null))))),
61219
+ vm.step !== CheckoutStep.SUCCESS && (createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61220
+ createElement(SVGCross, null)))))),
61221
61221
  !!vm.checkout.appliedCouponCode && !isAddingCoupon && (createElement("div", { className: styles$h.Value },
61222
61222
  createElement("span", null, (adjustment === null || adjustment === void 0 ? void 0 : adjustment.type) === "DECREMENT" ? "- " : ""),
61223
61223
  " ",
@@ -62456,7 +62456,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62456
62456
  });
62457
62457
 
62458
62458
  var CheckoutPage = function (_a) {
62459
- var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62459
+ var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62460
62460
  var router = useRouter();
62461
62461
  var _b = useState(), checkout = _b[0], setCheckout = _b[1];
62462
62462
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62484,10 +62484,7 @@ var CheckoutPage = function (_a) {
62484
62484
  }, [customizationProps]);
62485
62485
  useEffect(function () {
62486
62486
  store.checkLocalization();
62487
- if (!editorCheckout)
62488
- getCheckout();
62489
- else
62490
- setCheckout(editorCheckout);
62487
+ getCheckout();
62491
62488
  }, []);
62492
62489
  var getCheckout = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62493
62490
  var checkout;
package/build/index.js CHANGED
@@ -11344,6 +11344,8 @@ var IkasOrderAddress = /** @class */ (function () {
11344
11344
  this.identityNumber = data.identityNumber || null;
11345
11345
  this.taxNumber = data.taxNumber || null;
11346
11346
  this.taxOffice = data.taxOffice || null;
11347
+ this.checkoutSettings = data.checkoutSettings;
11348
+ this.isDistrictRequired = data.isDistrictRequired || false;
11347
11349
  mobx.makeAutoObservable(this);
11348
11350
  }
11349
11351
  Object.defineProperty(IkasOrderAddress.prototype, "addressText", {
@@ -22815,7 +22817,6 @@ var CheckoutViewModel = /** @class */ (function () {
22815
22817
  this.isChangingShippingMethod = false;
22816
22818
  this.step = CheckoutStep.INFO;
22817
22819
  this.cardData = null;
22818
- this.paymentGatewayId = null;
22819
22820
  this.paymentGateways = [];
22820
22821
  this.installmentInfo = null;
22821
22822
  this.useDifferentAddress = false;
@@ -22848,7 +22849,7 @@ var CheckoutViewModel = /** @class */ (function () {
22848
22849
  });
22849
22850
  }); };
22850
22851
  this.initStep = function (queryParams) { return __awaiter(_this, void 0, void 0, function () {
22851
- var _a, transactions;
22852
+ var _a, transactions, paymentGatewayId_1;
22852
22853
  return __generator(this, function (_b) {
22853
22854
  switch (_b.label) {
22854
22855
  case 0:
@@ -22920,6 +22921,10 @@ var CheckoutViewModel = /** @class */ (function () {
22920
22921
  this.successTransaction = transactions.length
22921
22922
  ? transactions[0]
22922
22923
  : undefined;
22924
+ if (this.successTransaction) {
22925
+ paymentGatewayId_1 = this.successTransaction.paymentGatewayId;
22926
+ this.checkout.selectedPaymentGateway = this.paymentGateways.find(function (pg) { return pg.id === paymentGatewayId_1; });
22927
+ }
22923
22928
  _b.label = 11;
22924
22929
  case 11:
22925
22930
  this.isCheckoutLoaded = true;
@@ -23099,7 +23104,7 @@ var CheckoutViewModel = /** @class */ (function () {
23099
23104
  orderedPaymentGateways.push(_pg);
23100
23105
  });
23101
23106
  this.paymentGateways = isLocal ? paymentGateways : orderedPaymentGateways;
23102
- if (!this.paymentGatewayId)
23107
+ if (!this.checkout.selectedPaymentGateway)
23103
23108
  this.setPaymentGateway(0);
23104
23109
  return [2 /*return*/];
23105
23110
  }
@@ -23193,10 +23198,7 @@ var CheckoutViewModel = /** @class */ (function () {
23193
23198
  newCheckout = _a.sent();
23194
23199
  if (newCheckout) {
23195
23200
  oldCheckout = this.checkout;
23196
- this.checkout = newCheckout;
23197
- this.checkout.customer = oldCheckout.customer;
23198
- this.checkout.shippingAddress = oldCheckout.shippingAddress;
23199
- this.checkout.billingAddress = oldCheckout.billingAddress;
23201
+ this.checkout = new IkasCheckout(__assign(__assign({}, newCheckout), { shippingAddress: oldCheckout.shippingAddress, billingAddress: oldCheckout.billingAddress, customer: oldCheckout.customer }));
23200
23202
  }
23201
23203
  return [3 /*break*/, 4];
23202
23204
  case 3:
@@ -23253,7 +23255,7 @@ var CheckoutViewModel = /** @class */ (function () {
23253
23255
  if (oldOriginalValue.length < 6 && originalValue.length >= 6) {
23254
23256
  _this.retrieveInstallmentInfo({
23255
23257
  binNumber: originalValue.slice(0, 6),
23256
- paymentGatewayId: _this.paymentGatewayId,
23258
+ paymentGatewayId: _this.checkout.selectedPaymentGateway.id,
23257
23259
  price: _this.checkout.totalFinalPrice,
23258
23260
  });
23259
23261
  }
@@ -23492,15 +23494,17 @@ var CheckoutViewModel = /** @class */ (function () {
23492
23494
  }); };
23493
23495
  this.createSaleTransaction = function () { return __awaiter(_this, void 0, void 0, function () {
23494
23496
  var response, transactionStatus, transactionSuccess, transactionPending;
23495
- var _a;
23496
- return __generator(this, function (_b) {
23497
- switch (_b.label) {
23498
- case 0: return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.paymentGatewayId, ((_a = this.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.paymentMethodType) ===
23499
- IkasPaymentMethodType.CREDIT_CARD && this.cardData
23500
- ? this.cardData.toInput()
23501
- : undefined)];
23497
+ return __generator(this, function (_a) {
23498
+ switch (_a.label) {
23499
+ case 0:
23500
+ if (!this.checkout.selectedPaymentGateway)
23501
+ return [2 /*return*/];
23502
+ return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.checkout.selectedPaymentGateway.id, this.checkout.selectedPaymentGateway.paymentMethodType ===
23503
+ IkasPaymentMethodType.CREDIT_CARD && this.cardData
23504
+ ? this.cardData.toInput()
23505
+ : undefined)];
23502
23506
  case 1:
23503
- response = _b.sent();
23507
+ response = _a.sent();
23504
23508
  transactionStatus = response === null || response === void 0 ? void 0 : response.transactionStatus;
23505
23509
  transactionSuccess = transactionStatus &&
23506
23510
  [
@@ -23511,7 +23515,7 @@ var CheckoutViewModel = /** @class */ (function () {
23511
23515
  if (!transactionSuccess) return [3 /*break*/, 3];
23512
23516
  return [4 /*yield*/, this.onCheckoutTransactionSuccess()];
23513
23517
  case 2:
23514
- _b.sent();
23518
+ _a.sent();
23515
23519
  return [3 /*break*/, 4];
23516
23520
  case 3:
23517
23521
  if (transactionPending && !!(response === null || response === void 0 ? void 0 : response.returnSlug)) {
@@ -23523,7 +23527,7 @@ var CheckoutViewModel = /** @class */ (function () {
23523
23527
  type: ErrorType.UNKNOWN,
23524
23528
  };
23525
23529
  }
23526
- _b.label = 4;
23530
+ _a.label = 4;
23527
23531
  case 4: return [2 /*return*/];
23528
23532
  }
23529
23533
  });
@@ -23573,12 +23577,13 @@ var CheckoutViewModel = /** @class */ (function () {
23573
23577
  };
23574
23578
  this.setPaymentGateway = function (index) {
23575
23579
  var paymentGateway = _this.paymentGateways[index];
23576
- _this.paymentGatewayId = paymentGateway.id;
23577
- if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23578
- _this.cardData = new CreditCardData();
23579
- }
23580
23580
  _this.checkout.selectedPaymentGateway = paymentGateway;
23581
- _this.installmentInfo = undefined;
23581
+ if (_this.step !== CheckoutStep.SUCCESS) {
23582
+ if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23583
+ _this.cardData = new CreditCardData();
23584
+ }
23585
+ _this.installmentInfo = undefined;
23586
+ }
23582
23587
  };
23583
23588
  this.setInstallmentCount = function (count) {
23584
23589
  if (!_this.cardData)
@@ -23643,15 +23648,7 @@ var CheckoutViewModel = /** @class */ (function () {
23643
23648
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
23644
23649
  get: function () {
23645
23650
  var _this = this;
23646
- return this.paymentGateways.findIndex(function (pg) { return pg.id === _this.paymentGatewayId; });
23647
- },
23648
- enumerable: false,
23649
- configurable: true
23650
- });
23651
- Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGateway", {
23652
- get: function () {
23653
- var _this = this;
23654
- return this.paymentGateways.find(function (pg) { return pg.id === _this.paymentGatewayId; });
23651
+ return this.paymentGateways.findIndex(function (pg) { var _a; return pg.id === ((_a = _this.checkout.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.id); });
23655
23652
  },
23656
23653
  enumerable: false,
23657
23654
  configurable: true
@@ -23750,7 +23747,7 @@ var CheckoutViewModel = /** @class */ (function () {
23750
23747
  return false;
23751
23748
  return (this.canProceedToShipping &&
23752
23749
  !!((_a = this.checkout.billingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23753
- (((_b = this.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23750
+ (((_b = this.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23754
23751
  IkasPaymentMethodType.CREDIT_CARD
23755
23752
  ? (_c = this.cardData) === null || _c === void 0 ? void 0 : _c.isValid : true));
23756
23753
  },
@@ -61081,7 +61078,8 @@ var CartSummary = mobxReactLite.observer(function (_a) {
61081
61078
  !!vm.installmentExtraPrice && (React.createElement(InfoRow, { label: t("checkout-page:cartInterest"), value: formatMoney(vm.installmentExtraPrice, cart.currencyCode) })),
61082
61079
  React.createElement(Adjustments, { vm: vm }),
61083
61080
  React.createElement(CalculatedAdditionalPrices, { vm: vm }),
61084
- ((vm.step === CheckoutStep.SUCCESS && !!vm.checkout.note) ||
61081
+ ((vm.step === CheckoutStep.SUCCESS &&
61082
+ (!!vm.checkout.note || !!vm.checkout.appliedCouponCode)) ||
61085
61083
  vm.step !== CheckoutStep.SUCCESS) && (React.createElement("div", { className: styles$h.Divider, style: { marginTop: "24px", marginBottom: "24px" } })),
61086
61084
  React.createElement(Coupon, { vm: vm, isAddingCoupon: isAddingCoupon, setAddingCoupon: setAddingCoupon, setCouponError: setCouponError }),
61087
61085
  React.createElement(Note, { vm: vm, isAddingNote: isAddingNote, setAddingNote: setAddingNote })),
@@ -61124,14 +61122,15 @@ var CalculatedAdditionalPrices = mobxReactLite.observer(function (_a) {
61124
61122
  if (!vm.cart)
61125
61123
  return null;
61126
61124
  return (React.createElement(React.Fragment, null,
61127
- (((_b = vm.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61128
- .filter(function (adjustment) { return adjustment.amount !== 0; })
61129
- .map(function (adjustment, index) { return (React.createElement("div", { className: styles$h.InfoRow, key: index },
61130
- React.createElement("div", { className: styles$h.Label }, adjustment.name),
61131
- React.createElement("div", { className: styles$h.Value },
61132
- React.createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61133
- " ",
61134
- React.createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61125
+ vm.step !== CheckoutStep.SUCCESS &&
61126
+ (((_b = vm.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61127
+ .filter(function (adjustment) { return adjustment.amount !== 0; })
61128
+ .map(function (adjustment, index) { return (React.createElement("div", { className: styles$h.InfoRow, key: index },
61129
+ React.createElement("div", { className: styles$h.Label }, adjustment.name),
61130
+ React.createElement("div", { className: styles$h.Value },
61131
+ React.createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61132
+ " ",
61133
+ React.createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61135
61134
  _c.map(function (gpl, index) { return (React.createElement("div", { className: styles$h.InfoRow, key: index },
61136
61135
  React.createElement("div", { className: styles$h.Label },
61137
61136
  React.createElement("div", { className: styles$h.GiftLabel },
@@ -61181,7 +61180,8 @@ var Coupon = mobxReactLite.observer(function (_a) {
61181
61180
  }
61182
61181
  });
61183
61182
  }); };
61184
- if (vm.step === CheckoutStep.SUCCESS)
61183
+ var isSuccess = vm.step === CheckoutStep.SUCCESS;
61184
+ if (isSuccess && !vm.checkout.appliedCouponCode)
61185
61185
  return null;
61186
61186
  var adjustment = vm.checkout.couponAdjustment;
61187
61187
  return (React.createElement("div", { className: styles$h.InfoRow },
@@ -61195,8 +61195,8 @@ var Coupon = mobxReactLite.observer(function (_a) {
61195
61195
  t("checkout-page:couponCode"),
61196
61196
  React.createElement("span", { className: styles$h.AppliedCoupon },
61197
61197
  React.createElement("span", { className: styles$h.CouponCode }, vm.checkout.appliedCouponCode),
61198
- React.createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61199
- React.createElement(SVGCross, null))))),
61198
+ vm.step !== CheckoutStep.SUCCESS && (React.createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61199
+ React.createElement(SVGCross, null)))))),
61200
61200
  !!vm.checkout.appliedCouponCode && !isAddingCoupon && (React.createElement("div", { className: styles$h.Value },
61201
61201
  React.createElement("span", null, (adjustment === null || adjustment === void 0 ? void 0 : adjustment.type) === "DECREMENT" ? "- " : ""),
61202
61202
  " ",
@@ -62435,7 +62435,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62435
62435
  });
62436
62436
 
62437
62437
  var CheckoutPage = function (_a) {
62438
- var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62438
+ var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62439
62439
  var router$1 = router.useRouter();
62440
62440
  var _b = React.useState(), checkout = _b[0], setCheckout = _b[1];
62441
62441
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62463,10 +62463,7 @@ var CheckoutPage = function (_a) {
62463
62463
  }, [customizationProps]);
62464
62464
  React.useEffect(function () {
62465
62465
  store.checkLocalization();
62466
- if (!editorCheckout)
62467
- getCheckout();
62468
- else
62469
- setCheckout(editorCheckout);
62466
+ getCheckout();
62470
62467
  }, []);
62471
62468
  var getCheckout = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62472
62469
  var checkout;
@@ -3,10 +3,8 @@ import * as React from "react";
3
3
  import { GetServerSideProps } from "next";
4
4
  import { ParsedUrlQuery } from "querystring";
5
5
  import { IkasCheckoutCustomizationProps } from "../../components/checkout/index";
6
- import { IkasCheckout } from "../../models/index";
7
6
  declare type Props = {
8
7
  checkoutId: string;
9
- editorCheckout?: IkasCheckout;
10
8
  checkoutSettingsStr: string | null;
11
9
  customizationProps: IkasCheckoutCustomizationProps;
12
10
  returnPolicy: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.164-alpha.3",
3
+ "version": "0.0.164-alpha.5",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",