@ikas/storefront 0.0.164-alpha.4 → 0.0.165-alpha.1

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
@@ -3,6 +3,7 @@ import fs from 'fs';
3
3
  import path$1 from 'path';
4
4
  import getConfig from 'next/config';
5
5
  import React, { createElement, Fragment as Fragment$1, useEffect, useState, useRef, useCallback, useMemo } from 'react';
6
+ import Script from 'next/script';
6
7
  import { observer } from 'mobx-react-lite';
7
8
  import Head from 'next/head';
8
9
  import { useRouter } from 'next/router';
@@ -22809,7 +22810,6 @@ var CheckoutViewModel = /** @class */ (function () {
22809
22810
  this.isChangingShippingMethod = false;
22810
22811
  this.step = CheckoutStep.INFO;
22811
22812
  this.cardData = null;
22812
- this.paymentGatewayId = null;
22813
22813
  this.paymentGateways = [];
22814
22814
  this.installmentInfo = null;
22815
22815
  this.useDifferentAddress = false;
@@ -22842,7 +22842,7 @@ var CheckoutViewModel = /** @class */ (function () {
22842
22842
  });
22843
22843
  }); };
22844
22844
  this.initStep = function (queryParams) { return __awaiter(_this, void 0, void 0, function () {
22845
- var _a, transactions;
22845
+ var _a, transactions, paymentGatewayId_1;
22846
22846
  return __generator(this, function (_b) {
22847
22847
  switch (_b.label) {
22848
22848
  case 0:
@@ -22914,6 +22914,10 @@ var CheckoutViewModel = /** @class */ (function () {
22914
22914
  this.successTransaction = transactions.length
22915
22915
  ? transactions[0]
22916
22916
  : undefined;
22917
+ if (this.successTransaction) {
22918
+ paymentGatewayId_1 = this.successTransaction.paymentGatewayId;
22919
+ this.checkout.selectedPaymentGateway = this.paymentGateways.find(function (pg) { return pg.id === paymentGatewayId_1; });
22920
+ }
22917
22921
  _b.label = 11;
22918
22922
  case 11:
22919
22923
  this.isCheckoutLoaded = true;
@@ -23093,7 +23097,7 @@ var CheckoutViewModel = /** @class */ (function () {
23093
23097
  orderedPaymentGateways.push(_pg);
23094
23098
  });
23095
23099
  this.paymentGateways = isLocal ? paymentGateways : orderedPaymentGateways;
23096
- if (!this.paymentGatewayId)
23100
+ if (!this.checkout.selectedPaymentGateway)
23097
23101
  this.setPaymentGateway(0);
23098
23102
  return [2 /*return*/];
23099
23103
  }
@@ -23244,7 +23248,7 @@ var CheckoutViewModel = /** @class */ (function () {
23244
23248
  if (oldOriginalValue.length < 6 && originalValue.length >= 6) {
23245
23249
  _this.retrieveInstallmentInfo({
23246
23250
  binNumber: originalValue.slice(0, 6),
23247
- paymentGatewayId: _this.paymentGatewayId,
23251
+ paymentGatewayId: _this.checkout.selectedPaymentGateway.id,
23248
23252
  price: _this.checkout.totalFinalPrice,
23249
23253
  });
23250
23254
  }
@@ -23483,15 +23487,17 @@ var CheckoutViewModel = /** @class */ (function () {
23483
23487
  }); };
23484
23488
  this.createSaleTransaction = function () { return __awaiter(_this, void 0, void 0, function () {
23485
23489
  var response, transactionStatus, transactionSuccess, transactionPending;
23486
- var _a;
23487
- return __generator(this, function (_b) {
23488
- switch (_b.label) {
23489
- case 0: return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.paymentGatewayId, ((_a = this.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.paymentMethodType) ===
23490
- IkasPaymentMethodType.CREDIT_CARD && this.cardData
23491
- ? this.cardData.toInput()
23492
- : undefined)];
23490
+ return __generator(this, function (_a) {
23491
+ switch (_a.label) {
23492
+ case 0:
23493
+ if (!this.checkout.selectedPaymentGateway)
23494
+ return [2 /*return*/];
23495
+ return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.checkout.selectedPaymentGateway.id, this.checkout.selectedPaymentGateway.paymentMethodType ===
23496
+ IkasPaymentMethodType.CREDIT_CARD && this.cardData
23497
+ ? this.cardData.toInput()
23498
+ : undefined)];
23493
23499
  case 1:
23494
- response = _b.sent();
23500
+ response = _a.sent();
23495
23501
  transactionStatus = response === null || response === void 0 ? void 0 : response.transactionStatus;
23496
23502
  transactionSuccess = transactionStatus &&
23497
23503
  [
@@ -23502,7 +23508,7 @@ var CheckoutViewModel = /** @class */ (function () {
23502
23508
  if (!transactionSuccess) return [3 /*break*/, 3];
23503
23509
  return [4 /*yield*/, this.onCheckoutTransactionSuccess()];
23504
23510
  case 2:
23505
- _b.sent();
23511
+ _a.sent();
23506
23512
  return [3 /*break*/, 4];
23507
23513
  case 3:
23508
23514
  if (transactionPending && !!(response === null || response === void 0 ? void 0 : response.returnSlug)) {
@@ -23514,7 +23520,7 @@ var CheckoutViewModel = /** @class */ (function () {
23514
23520
  type: ErrorType.UNKNOWN,
23515
23521
  };
23516
23522
  }
23517
- _b.label = 4;
23523
+ _a.label = 4;
23518
23524
  case 4: return [2 /*return*/];
23519
23525
  }
23520
23526
  });
@@ -23564,12 +23570,13 @@ var CheckoutViewModel = /** @class */ (function () {
23564
23570
  };
23565
23571
  this.setPaymentGateway = function (index) {
23566
23572
  var paymentGateway = _this.paymentGateways[index];
23567
- _this.paymentGatewayId = paymentGateway.id;
23568
- if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23569
- _this.cardData = new CreditCardData();
23570
- }
23571
23573
  _this.checkout.selectedPaymentGateway = paymentGateway;
23572
- _this.installmentInfo = undefined;
23574
+ if (_this.step !== CheckoutStep.SUCCESS) {
23575
+ if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23576
+ _this.cardData = new CreditCardData();
23577
+ }
23578
+ _this.installmentInfo = undefined;
23579
+ }
23573
23580
  };
23574
23581
  this.setInstallmentCount = function (count) {
23575
23582
  if (!_this.cardData)
@@ -23634,15 +23641,7 @@ var CheckoutViewModel = /** @class */ (function () {
23634
23641
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
23635
23642
  get: function () {
23636
23643
  var _this = this;
23637
- return this.paymentGateways.findIndex(function (pg) { return pg.id === _this.paymentGatewayId; });
23638
- },
23639
- enumerable: false,
23640
- configurable: true
23641
- });
23642
- Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGateway", {
23643
- get: function () {
23644
- var _this = this;
23645
- return this.paymentGateways.find(function (pg) { return pg.id === _this.paymentGatewayId; });
23644
+ return this.paymentGateways.findIndex(function (pg) { var _a; return pg.id === ((_a = _this.checkout.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.id); });
23646
23645
  },
23647
23646
  enumerable: false,
23648
23647
  configurable: true
@@ -23741,7 +23740,7 @@ var CheckoutViewModel = /** @class */ (function () {
23741
23740
  return false;
23742
23741
  return (this.canProceedToShipping &&
23743
23742
  !!((_a = this.checkout.billingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23744
- (((_b = this.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23743
+ (((_b = this.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23745
23744
  IkasPaymentMethodType.CREDIT_CARD
23746
23745
  ? (_c = this.cardData) === null || _c === void 0 ? void 0 : _c.isValid : true));
23747
23746
  },
@@ -24238,19 +24237,23 @@ var AnalyticsHead = function (_a) {
24238
24237
  __html: "dataLayer = [{'gtm.blocklist': ['html']}];",
24239
24238
  } })),
24240
24239
  gtmId && (createElement("script", { dangerouslySetInnerHTML: {
24241
- __html: "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','" + gtmId + "');",
24240
+ __html: "(function(w,l){" +
24241
+ "w[l] = w[l] || [];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});" +
24242
+ "})(window,'dataLayer');",
24242
24243
  } })),
24243
24244
  fbpId && (createElement("script", { dangerouslySetInnerHTML: {
24244
- __html: "!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '" + fbpId + "');\n fbq('track', 'PageView');",
24245
+ __html: "!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];}(window);\n fbq('init', '" + fbpId + "');\n fbq('track', 'PageView');",
24245
24246
  } }))));
24246
24247
  };
24247
24248
  var AnalyticsBody = function () {
24248
24249
  var gtmId = IkasStorefrontConfig.gtmId;
24249
24250
  var fbpId = IkasStorefrontConfig.fbpId;
24250
24251
  return (createElement(Fragment$1, null,
24252
+ gtmId && (createElement(Script, { src: "https://www.googletagmanager.com/gtm.js?id=" + gtmId })),
24251
24253
  gtmId && (createElement("noscript", { dangerouslySetInnerHTML: {
24252
24254
  __html: "<iframe src=\"https://www.googletagmanager.com/ns.html?id=" + gtmId + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>",
24253
24255
  } })),
24256
+ fbpId && (createElement(Script, { src: "https://connect.facebook.net/en_US/fbevents.js" })),
24254
24257
  fbpId && (createElement("noscript", { dangerouslySetInnerHTML: {
24255
24258
  __html: "<img height=\"1\" width=\"1\" style=\"display:none\" \n src=\"https://www.facebook.com/tr?id=" + fbpId + "&ev=PageView&noscript=1\"/>",
24256
24259
  } }))));
@@ -61145,14 +61148,15 @@ var CalculatedAdditionalPrices = observer(function (_a) {
61145
61148
  if (!vm.cart)
61146
61149
  return null;
61147
61150
  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 :
61151
+ vm.step !== CheckoutStep.SUCCESS &&
61152
+ (((_b = vm.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61153
+ .filter(function (adjustment) { return adjustment.amount !== 0; })
61154
+ .map(function (adjustment, index) { return (createElement("div", { className: styles$h.InfoRow, key: index },
61155
+ createElement("div", { className: styles$h.Label }, adjustment.name),
61156
+ createElement("div", { className: styles$h.Value },
61157
+ createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61158
+ " ",
61159
+ createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61156
61160
  _c.map(function (gpl, index) { return (createElement("div", { className: styles$h.InfoRow, key: index },
61157
61161
  createElement("div", { className: styles$h.Label },
61158
61162
  createElement("div", { className: styles$h.GiftLabel },
@@ -62457,7 +62461,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62457
62461
  });
62458
62462
 
62459
62463
  var CheckoutPage = function (_a) {
62460
- var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62464
+ var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62461
62465
  var router = useRouter();
62462
62466
  var _b = useState(), checkout = _b[0], setCheckout = _b[1];
62463
62467
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62485,10 +62489,7 @@ var CheckoutPage = function (_a) {
62485
62489
  }, [customizationProps]);
62486
62490
  useEffect(function () {
62487
62491
  store.checkLocalization();
62488
- if (!editorCheckout)
62489
- getCheckout();
62490
- else
62491
- setCheckout(editorCheckout);
62492
+ getCheckout();
62492
62493
  }, []);
62493
62494
  var getCheckout = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62494
62495
  var checkout;
package/build/index.js CHANGED
@@ -7,6 +7,7 @@ var fs = require('fs');
7
7
  var path$1 = require('path');
8
8
  var getConfig = require('next/config');
9
9
  var React = require('react');
10
+ var Script = require('next/script');
10
11
  var mobxReactLite = require('mobx-react-lite');
11
12
  var Head = require('next/head');
12
13
  var router = require('next/router');
@@ -22,6 +23,7 @@ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
22
23
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
23
24
  var getConfig__default = /*#__PURE__*/_interopDefaultLegacy(getConfig);
24
25
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
26
+ var Script__default = /*#__PURE__*/_interopDefaultLegacy(Script);
25
27
  var Head__default = /*#__PURE__*/_interopDefaultLegacy(Head);
26
28
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto$1);
27
29
  var NextImage__default = /*#__PURE__*/_interopDefaultLegacy(NextImage);
@@ -22817,7 +22819,6 @@ var CheckoutViewModel = /** @class */ (function () {
22817
22819
  this.isChangingShippingMethod = false;
22818
22820
  this.step = CheckoutStep.INFO;
22819
22821
  this.cardData = null;
22820
- this.paymentGatewayId = null;
22821
22822
  this.paymentGateways = [];
22822
22823
  this.installmentInfo = null;
22823
22824
  this.useDifferentAddress = false;
@@ -22850,7 +22851,7 @@ var CheckoutViewModel = /** @class */ (function () {
22850
22851
  });
22851
22852
  }); };
22852
22853
  this.initStep = function (queryParams) { return __awaiter(_this, void 0, void 0, function () {
22853
- var _a, transactions;
22854
+ var _a, transactions, paymentGatewayId_1;
22854
22855
  return __generator(this, function (_b) {
22855
22856
  switch (_b.label) {
22856
22857
  case 0:
@@ -22922,6 +22923,10 @@ var CheckoutViewModel = /** @class */ (function () {
22922
22923
  this.successTransaction = transactions.length
22923
22924
  ? transactions[0]
22924
22925
  : undefined;
22926
+ if (this.successTransaction) {
22927
+ paymentGatewayId_1 = this.successTransaction.paymentGatewayId;
22928
+ this.checkout.selectedPaymentGateway = this.paymentGateways.find(function (pg) { return pg.id === paymentGatewayId_1; });
22929
+ }
22925
22930
  _b.label = 11;
22926
22931
  case 11:
22927
22932
  this.isCheckoutLoaded = true;
@@ -23101,7 +23106,7 @@ var CheckoutViewModel = /** @class */ (function () {
23101
23106
  orderedPaymentGateways.push(_pg);
23102
23107
  });
23103
23108
  this.paymentGateways = isLocal ? paymentGateways : orderedPaymentGateways;
23104
- if (!this.paymentGatewayId)
23109
+ if (!this.checkout.selectedPaymentGateway)
23105
23110
  this.setPaymentGateway(0);
23106
23111
  return [2 /*return*/];
23107
23112
  }
@@ -23252,7 +23257,7 @@ var CheckoutViewModel = /** @class */ (function () {
23252
23257
  if (oldOriginalValue.length < 6 && originalValue.length >= 6) {
23253
23258
  _this.retrieveInstallmentInfo({
23254
23259
  binNumber: originalValue.slice(0, 6),
23255
- paymentGatewayId: _this.paymentGatewayId,
23260
+ paymentGatewayId: _this.checkout.selectedPaymentGateway.id,
23256
23261
  price: _this.checkout.totalFinalPrice,
23257
23262
  });
23258
23263
  }
@@ -23491,15 +23496,17 @@ var CheckoutViewModel = /** @class */ (function () {
23491
23496
  }); };
23492
23497
  this.createSaleTransaction = function () { return __awaiter(_this, void 0, void 0, function () {
23493
23498
  var response, transactionStatus, transactionSuccess, transactionPending;
23494
- var _a;
23495
- return __generator(this, function (_b) {
23496
- switch (_b.label) {
23497
- case 0: return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.paymentGatewayId, ((_a = this.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.paymentMethodType) ===
23498
- IkasPaymentMethodType.CREDIT_CARD && this.cardData
23499
- ? this.cardData.toInput()
23500
- : undefined)];
23499
+ return __generator(this, function (_a) {
23500
+ switch (_a.label) {
23501
+ case 0:
23502
+ if (!this.checkout.selectedPaymentGateway)
23503
+ return [2 /*return*/];
23504
+ return [4 /*yield*/, IkasCheckoutAPI.createSaleTransactionWithCheckout(this.checkout.id, this.checkout.selectedPaymentGateway.id, this.checkout.selectedPaymentGateway.paymentMethodType ===
23505
+ IkasPaymentMethodType.CREDIT_CARD && this.cardData
23506
+ ? this.cardData.toInput()
23507
+ : undefined)];
23501
23508
  case 1:
23502
- response = _b.sent();
23509
+ response = _a.sent();
23503
23510
  transactionStatus = response === null || response === void 0 ? void 0 : response.transactionStatus;
23504
23511
  transactionSuccess = transactionStatus &&
23505
23512
  [
@@ -23510,7 +23517,7 @@ var CheckoutViewModel = /** @class */ (function () {
23510
23517
  if (!transactionSuccess) return [3 /*break*/, 3];
23511
23518
  return [4 /*yield*/, this.onCheckoutTransactionSuccess()];
23512
23519
  case 2:
23513
- _b.sent();
23520
+ _a.sent();
23514
23521
  return [3 /*break*/, 4];
23515
23522
  case 3:
23516
23523
  if (transactionPending && !!(response === null || response === void 0 ? void 0 : response.returnSlug)) {
@@ -23522,7 +23529,7 @@ var CheckoutViewModel = /** @class */ (function () {
23522
23529
  type: ErrorType.UNKNOWN,
23523
23530
  };
23524
23531
  }
23525
- _b.label = 4;
23532
+ _a.label = 4;
23526
23533
  case 4: return [2 /*return*/];
23527
23534
  }
23528
23535
  });
@@ -23572,12 +23579,13 @@ var CheckoutViewModel = /** @class */ (function () {
23572
23579
  };
23573
23580
  this.setPaymentGateway = function (index) {
23574
23581
  var paymentGateway = _this.paymentGateways[index];
23575
- _this.paymentGatewayId = paymentGateway.id;
23576
- if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23577
- _this.cardData = new CreditCardData();
23578
- }
23579
23582
  _this.checkout.selectedPaymentGateway = paymentGateway;
23580
- _this.installmentInfo = undefined;
23583
+ if (_this.step !== CheckoutStep.SUCCESS) {
23584
+ if (paymentGateway.paymentMethodType === IkasPaymentMethodType.CREDIT_CARD) {
23585
+ _this.cardData = new CreditCardData();
23586
+ }
23587
+ _this.installmentInfo = undefined;
23588
+ }
23581
23589
  };
23582
23590
  this.setInstallmentCount = function (count) {
23583
23591
  if (!_this.cardData)
@@ -23642,15 +23650,7 @@ var CheckoutViewModel = /** @class */ (function () {
23642
23650
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
23643
23651
  get: function () {
23644
23652
  var _this = this;
23645
- return this.paymentGateways.findIndex(function (pg) { return pg.id === _this.paymentGatewayId; });
23646
- },
23647
- enumerable: false,
23648
- configurable: true
23649
- });
23650
- Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGateway", {
23651
- get: function () {
23652
- var _this = this;
23653
- return this.paymentGateways.find(function (pg) { return pg.id === _this.paymentGatewayId; });
23653
+ return this.paymentGateways.findIndex(function (pg) { var _a; return pg.id === ((_a = _this.checkout.selectedPaymentGateway) === null || _a === void 0 ? void 0 : _a.id); });
23654
23654
  },
23655
23655
  enumerable: false,
23656
23656
  configurable: true
@@ -23749,7 +23749,7 @@ var CheckoutViewModel = /** @class */ (function () {
23749
23749
  return false;
23750
23750
  return (this.canProceedToShipping &&
23751
23751
  !!((_a = this.checkout.billingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23752
- (((_b = this.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23752
+ (((_b = this.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.paymentMethodType) ===
23753
23753
  IkasPaymentMethodType.CREDIT_CARD
23754
23754
  ? (_c = this.cardData) === null || _c === void 0 ? void 0 : _c.isValid : true));
23755
23755
  },
@@ -24246,19 +24246,23 @@ var AnalyticsHead = function (_a) {
24246
24246
  __html: "dataLayer = [{'gtm.blocklist': ['html']}];",
24247
24247
  } })),
24248
24248
  gtmId && (React.createElement("script", { dangerouslySetInnerHTML: {
24249
- __html: "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','" + gtmId + "');",
24249
+ __html: "(function(w,l){" +
24250
+ "w[l] = w[l] || [];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});" +
24251
+ "})(window,'dataLayer');",
24250
24252
  } })),
24251
24253
  fbpId && (React.createElement("script", { dangerouslySetInnerHTML: {
24252
- __html: "!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '" + fbpId + "');\n fbq('track', 'PageView');",
24254
+ __html: "!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];}(window);\n fbq('init', '" + fbpId + "');\n fbq('track', 'PageView');",
24253
24255
  } }))));
24254
24256
  };
24255
24257
  var AnalyticsBody = function () {
24256
24258
  var gtmId = IkasStorefrontConfig.gtmId;
24257
24259
  var fbpId = IkasStorefrontConfig.fbpId;
24258
24260
  return (React.createElement(React.Fragment, null,
24261
+ gtmId && (React.createElement(Script__default['default'], { src: "https://www.googletagmanager.com/gtm.js?id=" + gtmId })),
24259
24262
  gtmId && (React.createElement("noscript", { dangerouslySetInnerHTML: {
24260
24263
  __html: "<iframe src=\"https://www.googletagmanager.com/ns.html?id=" + gtmId + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>",
24261
24264
  } })),
24265
+ fbpId && (React.createElement(Script__default['default'], { src: "https://connect.facebook.net/en_US/fbevents.js" })),
24262
24266
  fbpId && (React.createElement("noscript", { dangerouslySetInnerHTML: {
24263
24267
  __html: "<img height=\"1\" width=\"1\" style=\"display:none\" \n src=\"https://www.facebook.com/tr?id=" + fbpId + "&ev=PageView&noscript=1\"/>",
24264
24268
  } }))));
@@ -61124,14 +61128,15 @@ var CalculatedAdditionalPrices = mobxReactLite.observer(function (_a) {
61124
61128
  if (!vm.cart)
61125
61129
  return null;
61126
61130
  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 :
61131
+ vm.step !== CheckoutStep.SUCCESS &&
61132
+ (((_b = vm.checkout.selectedPaymentGateway) === null || _b === void 0 ? void 0 : _b.getCalculatedAdditionalPrices(vm.checkout.totalFinalPrice || 0, vm.checkout.shippingLines || null)) || [])
61133
+ .filter(function (adjustment) { return adjustment.amount !== 0; })
61134
+ .map(function (adjustment, index) { return (React.createElement("div", { className: styles$h.InfoRow, key: index },
61135
+ React.createElement("div", { className: styles$h.Label }, adjustment.name),
61136
+ React.createElement("div", { className: styles$h.Value },
61137
+ React.createElement("span", null, adjustment.type === "DECREMENT" ? "- " : ""),
61138
+ " ",
61139
+ React.createElement("span", null, formatMoney(adjustment.amount, vm.cart.currencyCode))))); }), (_c = vm.checkout.giftPackageLines) === null || _c === void 0 ? void 0 :
61135
61140
  _c.map(function (gpl, index) { return (React.createElement("div", { className: styles$h.InfoRow, key: index },
61136
61141
  React.createElement("div", { className: styles$h.Label },
61137
61142
  React.createElement("div", { className: styles$h.GiftLabel },
@@ -62436,7 +62441,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62436
62441
  });
62437
62442
 
62438
62443
  var CheckoutPage = function (_a) {
62439
- var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62444
+ var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62440
62445
  var router$1 = router.useRouter();
62441
62446
  var _b = React.useState(), checkout = _b[0], setCheckout = _b[1];
62442
62447
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62464,10 +62469,7 @@ var CheckoutPage = function (_a) {
62464
62469
  }, [customizationProps]);
62465
62470
  React.useEffect(function () {
62466
62471
  store.checkLocalization();
62467
- if (!editorCheckout)
62468
- getCheckout();
62469
- else
62470
- setCheckout(editorCheckout);
62472
+ getCheckout();
62471
62473
  }, []);
62472
62474
  var getCheckout = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62473
62475
  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.4",
3
+ "version": "0.0.165-alpha.1",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",
@@ -18,9 +18,9 @@
18
18
  "peerDependencies": {
19
19
  "mobx": "^6.1.3",
20
20
  "mobx-react-lite": "^3.1.5",
21
- "next": "10.0.6",
22
- "react": "17.0.1",
23
- "react-dom": "17.0.1"
21
+ "next": "11.1.2",
22
+ "react": "17.0.2",
23
+ "react-dom": "17.0.2"
24
24
  },
25
25
  "dependencies": {
26
26
  "@apollo/client": "^3.2.0",
@@ -71,12 +71,12 @@
71
71
  "jest": "^26.4.2",
72
72
  "mobx": "^6.1.3",
73
73
  "mobx-react-lite": "^3.1.5",
74
- "next": "10.0.6",
74
+ "next": "11.1.2",
75
75
  "node-sass": "^5.0.0",
76
76
  "postcss": "^8.2.4",
77
77
  "prettier": "^2.2.1",
78
- "react": "17.0.1",
79
- "react-dom": "17.0.1",
78
+ "react": "17.0.2",
79
+ "react-dom": "17.0.2",
80
80
  "rollup": "^2.38.4",
81
81
  "rollup-plugin-copy-assets": "^2.0.3",
82
82
  "rollup-plugin-node-polyfills": "^0.2.1",