@quintype/components 3.8.0 → 3.8.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.
package/dist/cjs/index.js CHANGED
@@ -5050,30 +5050,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5050
5050
  _this = _super.call(this, props);
5051
5051
 
5052
5052
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "loadScript", function (callback) {
5053
- var accessTypeKey = get__default["default"](_this.props, ["accessTypeKey"]);
5054
- var isStaging = get__default["default"](_this.props, ["isStaging"]);
5055
- var enableAccesstype = get__default["default"](_this.props, ["enableAccesstype"]);
5053
+ var accessTypeKey = get__default["default"](_this.props, ['accessTypeKey']);
5054
+ var isStaging = get__default["default"](_this.props, ['isStaging']);
5055
+ var enableAccesstype = get__default["default"](_this.props, ['enableAccesstype']);
5056
5056
 
5057
5057
  if (!enableAccesstype) {
5058
5058
  return false;
5059
5059
  }
5060
5060
 
5061
5061
  var HOST = isStaging ? _this.stagingHost : _this.prodHost;
5062
- var environment = isStaging ? "&env=sandbox" : "";
5062
+ var environment = isStaging ? '&env=sandbox' : '';
5063
5063
  var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
5064
5064
  var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
5065
5065
 
5066
5066
  if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
5067
- var accessTypeScript = document.createElement("script");
5067
+ var accessTypeScript = document.createElement('script');
5068
5068
 
5069
5069
  accessTypeScript.onload = function () {
5070
5070
  _this.props.onATGlobalSet && _this.props.onATGlobalSet();
5071
5071
  callback();
5072
5072
  };
5073
5073
 
5074
- accessTypeScript.setAttribute("src", accessTypeHost);
5075
- accessTypeScript.setAttribute("id", "AccessTypeScript");
5076
- accessTypeScript.setAttribute("data-accessType-script", "1");
5074
+ accessTypeScript.setAttribute('src', accessTypeHost);
5075
+ accessTypeScript.setAttribute('id', 'AccessTypeScript');
5076
+ accessTypeScript.setAttribute('data-accessType-script', '1');
5077
5077
  accessTypeScript.async = 1;
5078
5078
  document.body.appendChild(accessTypeScript);
5079
5079
  return true;
@@ -5214,7 +5214,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5214
5214
  break;
5215
5215
  }
5216
5216
 
5217
- return _context3.abrupt("return", Promise.reject("Subscription id is not defined"));
5217
+ return _context3.abrupt("return", Promise.reject('Subscription id is not defined'));
5218
5218
 
5219
5219
  case 3:
5220
5220
  return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
@@ -5227,6 +5227,22 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5227
5227
  }, _callee3);
5228
5228
  })));
5229
5229
 
5230
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getPath", function (sketchesHost, relativePath) {
5231
+ try {
5232
+ var _URL = new URL(sketchesHost),
5233
+ pathname = _URL.pathname;
5234
+
5235
+ if (pathname && pathname !== '/') {
5236
+ return "".concat(sketchesHost).concat(relativePath);
5237
+ }
5238
+
5239
+ return relativePath;
5240
+ } catch (err) {
5241
+ console.log('Sketches host path error ---> ', err);
5242
+ return relativePath;
5243
+ }
5244
+ });
5245
+
5230
5246
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscription", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
5231
5247
  var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions;
5232
5248
 
@@ -5234,8 +5250,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5234
5250
  while (1) {
5235
5251
  switch (_context4.prev = _context4.next) {
5236
5252
  case 0:
5237
- accessTypeKey = get__default["default"](_this.props, ["accessTypeKey"]);
5238
- isStaging = get__default["default"](_this.props, ["isStaging"]);
5253
+ accessTypeKey = get__default["default"](_this.props, ['accessTypeKey']);
5254
+ isStaging = get__default["default"](_this.props, ['isStaging']);
5239
5255
  HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
5240
5256
 
5241
5257
  accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
@@ -5259,11 +5275,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5259
5275
  }
5260
5276
 
5261
5277
  return _context4.abrupt("return", {
5262
- error: "subscriptions fetch failed"
5278
+ error: 'subscriptions fetch failed'
5263
5279
  });
5264
5280
 
5265
5281
  case 15:
5266
- return _context4.abrupt("return", subscriptions["subscription_groups"] || []);
5282
+ return _context4.abrupt("return", subscriptions['subscription_groups'] || []);
5267
5283
 
5268
5284
  case 16:
5269
5285
  case "end":
@@ -5302,7 +5318,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5302
5318
  }
5303
5319
 
5304
5320
  return _context5.abrupt("return", {
5305
- error: "payment options fetch failed"
5321
+ error: 'payment options fetch failed'
5306
5322
  });
5307
5323
 
5308
5324
  case 9:
@@ -5328,7 +5344,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5328
5344
  while (1) {
5329
5345
  switch (_context6.prev = _context6.next) {
5330
5346
  case 0:
5331
- storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "";
5347
+ storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '';
5332
5348
 
5333
5349
  if (global.AccessType) {
5334
5350
  _context6.next = 3;
@@ -5341,7 +5357,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5341
5357
  _context6.next = 5;
5342
5358
  return awaitHelper(global.AccessType.getAssetPlans({
5343
5359
  id: storyId,
5344
- type: "story"
5360
+ type: 'story'
5345
5361
  }));
5346
5362
 
5347
5363
  case 5:
@@ -5356,7 +5372,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5356
5372
  }
5357
5373
 
5358
5374
  return _context6.abrupt("return", {
5359
- error: "asset plan fetch failed"
5375
+ error: 'asset plan fetch failed'
5360
5376
  });
5361
5377
 
5362
5378
  case 11:
@@ -5377,15 +5393,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5377
5393
  while (1) {
5378
5394
  switch (_context7.prev = _context7.next) {
5379
5395
  case 0:
5380
- isAccessTypeCampaignEnabled = get__default["default"](_this.props, ["isAccessTypeCampaignEnabled"], false);
5396
+ isAccessTypeCampaignEnabled = get__default["default"](_this.props, ['isAccessTypeCampaignEnabled'], false);
5381
5397
 
5382
5398
  if (!isAccessTypeCampaignEnabled) {
5383
5399
  _context7.next = 18;
5384
5400
  break;
5385
5401
  }
5386
5402
 
5387
- accessTypeKey = get__default["default"](_this.props, ["accessTypeKey"]);
5388
- isStaging = get__default["default"](_this.props, ["isStaging"]);
5403
+ accessTypeKey = get__default["default"](_this.props, ['accessTypeKey']);
5404
+ isStaging = get__default["default"](_this.props, ['isStaging']);
5389
5405
  HOST = isStaging ? _this.stagingHost : _this.prodHost;
5390
5406
  accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
5391
5407
  _context7.t0 = awaitHelper;
@@ -5408,11 +5424,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5408
5424
  }
5409
5425
 
5410
5426
  return _context7.abrupt("return", {
5411
- error: "subscriptions fetch failed"
5427
+ error: 'subscriptions fetch failed'
5412
5428
  });
5413
5429
 
5414
5430
  case 17:
5415
- return _context7.abrupt("return", campaignSubscriptions["subscription_groups"] || []);
5431
+ return _context7.abrupt("return", campaignSubscriptions['subscription_groups'] || []);
5416
5432
 
5417
5433
  case 18:
5418
5434
  return _context7.abrupt("return", []);
@@ -5426,7 +5442,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5426
5442
  })));
5427
5443
 
5428
5444
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8() {
5445
+ var _this$props;
5446
+
5429
5447
  var callback,
5448
+ url,
5430
5449
  jwtResponse,
5431
5450
  _yield$awaitHelper7,
5432
5451
  error,
@@ -5439,15 +5458,16 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5439
5458
  callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
5440
5459
  return null;
5441
5460
  };
5442
- _context8.next = 3;
5443
- return fetch("/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
5461
+ url = _this.getPath((_this$props = _this.props) === null || _this$props === void 0 ? void 0 : _this$props.sketchesHost, "/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
5462
+ _context8.next = 4;
5463
+ return fetch(url);
5444
5464
 
5445
- case 3:
5465
+ case 4:
5446
5466
  jwtResponse = _context8.sent;
5447
- _context8.next = 6;
5448
- return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get("x-integration-token"), !!jwtResponse.headers.get("x-integration-token")));
5467
+ _context8.next = 7;
5468
+ return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get('x-integration-token'), !!jwtResponse.headers.get('x-integration-token')));
5449
5469
 
5450
- case 6:
5470
+ case 7:
5451
5471
  _yield$awaitHelper7 = _context8.sent;
5452
5472
  error = _yield$awaitHelper7.error;
5453
5473
 
@@ -5476,7 +5496,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5476
5496
  }
5477
5497
  }
5478
5498
 
5479
- case 9:
5499
+ case 10:
5480
5500
  case "end":
5481
5501
  return _context8.stop();
5482
5502
  }
@@ -5547,11 +5567,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5547
5567
  break;
5548
5568
  }
5549
5569
 
5550
- throw new Error("planId is mandatory");
5570
+ throw new Error('planId is mandatory');
5551
5571
 
5552
5572
  case 4:
5553
5573
  _context10.next = 6;
5554
- return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, "switch"));
5574
+ return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, 'switch'));
5555
5575
 
5556
5576
  case 6:
5557
5577
  _yield$awaitHelper9 = _context10.sent;
@@ -5589,7 +5609,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5589
5609
  _this.loadScript(function () {
5590
5610
  // dont try to initialize accessType if integration id is not available
5591
5611
  if (accessTypeBkIntegrationId === undefined) {
5592
- console.warn("AccessType: Integration Id is undefined");
5612
+ console.warn('AccessType: Integration Id is undefined');
5593
5613
  return false;
5594
5614
  }
5595
5615
 
@@ -5628,11 +5648,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5628
5648
  switch (_context11.prev = _context11.next) {
5629
5649
  case 0:
5630
5650
  selectedPlanObj = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
5631
- planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
5632
- storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : "";
5633
- storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : "";
5634
- storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : "";
5635
- paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : "";
5651
+ planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : '';
5652
+ storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : '';
5653
+ storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : '';
5654
+ storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : '';
5655
+ paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : '';
5636
5656
  opts = _args11.length > 6 ? _args11[6] : undefined;
5637
5657
 
5638
5658
  if (selectedPlanObj) {
@@ -5640,15 +5660,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5640
5660
  break;
5641
5661
  }
5642
5662
 
5643
- console.warn("Razor pay needs a plan");
5663
+ console.warn('Razor pay needs a plan');
5644
5664
  return _context11.abrupt("return", false);
5645
5665
 
5646
5666
  case 10:
5647
- intent = get__default["default"](opts, ["intent"], "default");
5648
- switchType = get__default["default"](opts, ["switchType"]);
5667
+ intent = get__default["default"](opts, ['intent'], 'default');
5668
+ switchType = get__default["default"](opts, ['switchType']);
5649
5669
  planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
5650
5670
 
5651
- planObject["paymentType"] = paymentType || (get__default["default"](planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
5671
+ planObject['paymentType'] = paymentType || (get__default["default"](planObject, ['selectedPlan', 'recurring']) ? 'razorpay_recurring' : 'razorpay');
5652
5672
  paymentOptions = _this.props.paymentOptions;
5653
5673
  _planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
5654
5674
  paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
@@ -5679,13 +5699,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5679
5699
  }));
5680
5700
 
5681
5701
  case 25:
5682
- if (!(intent === "switch")) {
5702
+ if (!(intent === 'switch')) {
5683
5703
  _context11.next = 34;
5684
5704
  break;
5685
5705
  }
5686
5706
 
5687
5707
  _context11.next = 28;
5688
- return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
5708
+ return awaitHelper(global.AccessType.getPaymentOptions(null, null, 'switch'));
5689
5709
 
5690
5710
  case 28:
5691
5711
  _yield$awaitHelper11 = _context11.sent;
@@ -5697,7 +5717,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5697
5717
  break;
5698
5718
  }
5699
5719
 
5700
- throw new Error("payment options fetch failed");
5720
+ throw new Error('payment options fetch failed');
5701
5721
 
5702
5722
  case 33:
5703
5723
  return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
@@ -5721,19 +5741,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5721
5741
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5722
5742
 
5723
5743
  if (!options.selectedPlan) {
5724
- console.warn("Stripe pay needs a plan");
5744
+ console.warn('Stripe pay needs a plan');
5725
5745
  return false;
5726
5746
  }
5727
5747
 
5728
5748
  var paymentOptions = _this.props.paymentOptions;
5729
- var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "stripe_recurring" : "stripe";
5749
+ var paymentType = get__default["default"](options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
5730
5750
 
5731
5751
  var paymentObject = _this.makePaymentObject(_objectSpread({
5732
5752
  paymentType: paymentType
5733
5753
  }, options));
5734
5754
 
5735
5755
  return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
5736
- message: "Payment option is loading..."
5756
+ message: 'Payment option is loading...'
5737
5757
  });
5738
5758
  });
5739
5759
 
@@ -5741,12 +5761,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5741
5761
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5742
5762
 
5743
5763
  if (!options.selectedPlan) {
5744
- console.warn("Paypal pay needs a plan");
5764
+ console.warn('Paypal pay needs a plan');
5745
5765
  return false;
5746
5766
  }
5747
5767
 
5748
5768
  var paymentOptions = _this.props.paymentOptions;
5749
- var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "paypal_recurring" : "paypal";
5769
+ var paymentType = get__default["default"](options.selectedPlan, ['recurring']) ? 'paypal_recurring' : 'paypal';
5750
5770
 
5751
5771
  var paymentObject = _this.makePaymentObject(_objectSpread({
5752
5772
  paymentType: paymentType
@@ -5755,30 +5775,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5755
5775
  return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
5756
5776
  return response.proceed(paymentObject);
5757
5777
  }) : Promise.reject({
5758
- message: "Payment option is loading..."
5778
+ message: 'Payment option is loading...'
5759
5779
  });
5760
5780
  });
5761
5781
 
5762
5782
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initOmisePayment", function () {
5763
5783
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5764
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
5784
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5765
5785
 
5766
5786
  if (!selectedPlanObj) {
5767
- console.warn("Omise pay needs a plan");
5787
+ console.warn('Omise pay needs a plan');
5768
5788
  return false;
5769
5789
  }
5770
5790
 
5771
5791
  var planObject = _this.makePlanObject(selectedPlanObj, planType);
5772
5792
 
5773
- planObject["paymentType"] = get__default["default"](planObject, ["selectedPlan", "recurring"]) ? "omise_recurring" : "omise";
5793
+ planObject['paymentType'] = get__default["default"](planObject, ['selectedPlan', 'recurring']) ? 'omise_recurring' : 'omise';
5774
5794
 
5775
5795
  var paymentObject = _this.makePaymentObject(planObject);
5776
5796
 
5777
- var omise = get__default["default"](_this.props, ["paymentOptions", "omise"]);
5797
+ var omise = get__default["default"](_this.props, ['paymentOptions', 'omise']);
5778
5798
 
5779
5799
  if (!omise) {
5780
5800
  return Promise.reject({
5781
- message: "Payment option is loading..."
5801
+ message: 'Payment option is loading...'
5782
5802
  });
5783
5803
  }
5784
5804
 
@@ -5789,31 +5809,31 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5789
5809
 
5790
5810
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initAdyenPayment", function () {
5791
5811
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5792
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
5812
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5793
5813
  var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
5794
5814
  var locale = arguments.length > 3 ? arguments[3] : undefined;
5795
5815
 
5796
5816
  var adyenExecutor = function adyenExecutor(resolve, reject) {
5797
- if (!document.getElementById("adyen-modal")) {
5798
- var modalElement = document.createElement("div");
5799
- modalElement.setAttribute("id", "adyen-modal");
5817
+ if (!document.getElementById('adyen-modal')) {
5818
+ var modalElement = document.createElement('div');
5819
+ modalElement.setAttribute('id', 'adyen-modal');
5800
5820
  document.body.appendChild(modalElement);
5801
5821
  }
5802
5822
 
5803
5823
  var afterOpen = function afterOpen() {
5804
5824
  var planObject = _this.makePlanObject(selectedPlanObj, planType);
5805
5825
 
5806
- var isRecurring = get__default["default"](planObject, ["selectedPlan", "recurring"]);
5807
- var paymentType = isRecurring ? "adyen_recurring" : "adyen";
5826
+ var isRecurring = get__default["default"](planObject, ['selectedPlan', 'recurring']);
5827
+ var paymentType = isRecurring ? 'adyen_recurring' : 'adyen';
5808
5828
 
5809
5829
  var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
5810
5830
  paymentType: paymentType
5811
5831
  }));
5812
5832
 
5813
- var adyen = get__default["default"](_this.props, ["paymentOptions", "adyen"]);
5833
+ var adyen = get__default["default"](_this.props, ['paymentOptions', 'adyen']);
5814
5834
  paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
5815
- options: _objectSpread(_objectSpread({}, paymentObject["options"]), {}, {
5816
- dropin_container_id: "dropin-adyen",
5835
+ options: _objectSpread(_objectSpread({}, paymentObject['options']), {}, {
5836
+ dropin_container_id: 'dropin-adyen',
5817
5837
  locale: locale
5818
5838
  }),
5819
5839
  additional_data: {
@@ -5828,7 +5848,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5828
5848
  ReactDOM__default["default"].render( /*#__PURE__*/React__default["default"].createElement(AdyenModal, {
5829
5849
  afterOpen: afterOpen,
5830
5850
  afterClose: reject
5831
- }), document.getElementById("adyen-modal"));
5851
+ }), document.getElementById('adyen-modal'));
5832
5852
  };
5833
5853
 
5834
5854
  return new Promise(adyenExecutor);
@@ -5838,12 +5858,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5838
5858
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5839
5859
 
5840
5860
  if (!options.selectedPlan) {
5841
- console.warn("Paytrail needs a plan");
5861
+ console.warn('Paytrail needs a plan');
5842
5862
  return false;
5843
5863
  }
5844
5864
 
5845
5865
  var paymentOptions = _this.props.paymentOptions;
5846
- var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "paytrail_recurring" : "paytrail";
5866
+ var paymentType = get__default["default"](options.selectedPlan, ['recurring']) ? 'paytrail_recurring' : 'paytrail';
5847
5867
 
5848
5868
  var paymentObject = _this.makePaymentObject(_objectSpread({
5849
5869
  paymentType: paymentType
@@ -5852,7 +5872,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5852
5872
  return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
5853
5873
  return response.proceed(paymentObject);
5854
5874
  }) : Promise.reject({
5855
- message: "Payment option is loading..."
5875
+ message: 'Payment option is loading...'
5856
5876
  });
5857
5877
  });
5858
5878
 
@@ -5865,7 +5885,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5865
5885
  try {
5866
5886
  global.AccessType.pingbackAssetAccess(asset, accessData);
5867
5887
  } catch (e) {
5868
- console.log("error in pingbackAssetAccess", e);
5888
+ console.log('error in pingbackAssetAccess', e);
5869
5889
  }
5870
5890
 
5871
5891
  return _context12.abrupt("return", true);
@@ -5896,7 +5916,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5896
5916
  break;
5897
5917
  }
5898
5918
 
5899
- console.warn("AssetId is required");
5919
+ console.warn('AssetId is required');
5900
5920
  return _context13.abrupt("return", false);
5901
5921
 
5902
5922
  case 3:
@@ -5904,7 +5924,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5904
5924
 
5905
5925
  asset = {
5906
5926
  id: assetId,
5907
- type: "story"
5927
+ type: 'story'
5908
5928
  };
5909
5929
  _context13.next = 7;
5910
5930
  return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
@@ -5930,7 +5950,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5930
5950
 
5931
5951
  _ref16 = accessData || {}, granted = _ref16.granted, grantReason = _ref16.grantReason, _ref16$data = _ref16.data, data = _ref16$data === void 0 ? {} : _ref16$data;
5932
5952
 
5933
- if (!_this.props.disableMetering && granted && grantReason === "METERING") {
5953
+ if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
5934
5954
  _this.pingBackMeteredStory(asset, accessData);
5935
5955
 
5936
5956
  _this.props.meterUpdated(data.numberRemaining || -1);
@@ -6015,8 +6035,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
6015
6035
  };
6016
6036
  }());
6017
6037
 
6018
- _this.prodHost = props.prodHost || "https://www.accesstype.com";
6019
- _this.stagingHost = props.stagingHost || "https://staging.accesstype.com";
6038
+ _this.prodHost = props.prodHost || 'https://www.accesstype.com';
6039
+ _this.stagingHost = props.stagingHost || 'https://staging.accesstype.com';
6020
6040
  return _this;
6021
6041
  }
6022
6042
 
@@ -6031,25 +6051,25 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
6031
6051
  var _ref19$selectedPlan = _ref19.selectedPlan,
6032
6052
  selectedPlan = _ref19$selectedPlan === void 0 ? {} : _ref19$selectedPlan,
6033
6053
  _ref19$couponCode = _ref19.couponCode,
6034
- couponCode = _ref19$couponCode === void 0 ? "" : _ref19$couponCode,
6054
+ couponCode = _ref19$couponCode === void 0 ? '' : _ref19$couponCode,
6035
6055
  _ref19$recipientSubsc = _ref19.recipientSubscriber,
6036
6056
  recipientSubscriber = _ref19$recipientSubsc === void 0 ? {} : _ref19$recipientSubsc,
6037
6057
  _ref19$planType = _ref19.planType,
6038
- planType = _ref19$planType === void 0 ? "" : _ref19$planType,
6058
+ planType = _ref19$planType === void 0 ? '' : _ref19$planType,
6039
6059
  _ref19$storyId = _ref19.storyId,
6040
- storyId = _ref19$storyId === void 0 ? "" : _ref19$storyId,
6060
+ storyId = _ref19$storyId === void 0 ? '' : _ref19$storyId,
6041
6061
  _ref19$storyHeadline = _ref19.storyHeadline,
6042
- storyHeadline = _ref19$storyHeadline === void 0 ? "" : _ref19$storyHeadline,
6062
+ storyHeadline = _ref19$storyHeadline === void 0 ? '' : _ref19$storyHeadline,
6043
6063
  _ref19$storySlug = _ref19.storySlug,
6044
- storySlug = _ref19$storySlug === void 0 ? "" : _ref19$storySlug,
6064
+ storySlug = _ref19$storySlug === void 0 ? '' : _ref19$storySlug,
6045
6065
  _ref19$paymentType = _ref19.paymentType,
6046
- paymentType = _ref19$paymentType === void 0 ? "" : _ref19$paymentType,
6066
+ paymentType = _ref19$paymentType === void 0 ? '' : _ref19$paymentType,
6047
6067
  _ref19$successUrl = _ref19.successUrl,
6048
- successUrl = _ref19$successUrl === void 0 ? "" : _ref19$successUrl,
6068
+ successUrl = _ref19$successUrl === void 0 ? '' : _ref19$successUrl,
6049
6069
  _ref19$returnUrl = _ref19.returnUrl,
6050
- returnUrl = _ref19$returnUrl === void 0 ? "" : _ref19$returnUrl,
6070
+ returnUrl = _ref19$returnUrl === void 0 ? '' : _ref19$returnUrl,
6051
6071
  _ref19$cancelUrl = _ref19.cancelUrl,
6052
- cancelUrl = _ref19$cancelUrl === void 0 ? "" : _ref19$cancelUrl;
6072
+ cancelUrl = _ref19$cancelUrl === void 0 ? '' : _ref19$cancelUrl;
6053
6073
  var id = selectedPlan.id,
6054
6074
  title = selectedPlan.title,
6055
6075
  description = selectedPlan.description,
@@ -6094,9 +6114,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
6094
6114
  };
6095
6115
 
6096
6116
  if (returnUrl) {
6097
- paymentObject.options.urls["return_url"] = returnUrl;
6117
+ paymentObject.options.urls['return_url'] = returnUrl;
6098
6118
  } else {
6099
- paymentObject.options.urls["success_url"] = successUrl;
6119
+ paymentObject.options.urls['success_url'] = successUrl;
6100
6120
  }
6101
6121
  }
6102
6122
 
@@ -6106,11 +6126,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
6106
6126
  key: "makePlanObject",
6107
6127
  value: function makePlanObject() {
6108
6128
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6109
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
6110
- var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
6111
- var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
6112
- var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
6113
- return selectedPlanObj.argType && selectedPlanObj.argType === "options" ? {
6129
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
6130
+ var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
6131
+ var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
6132
+ var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
6133
+ return selectedPlanObj.argType && selectedPlanObj.argType === 'options' ? {
6114
6134
  selectedPlan: selectedPlanObj.selectedPlan,
6115
6135
  planType: selectedPlanObj.planType,
6116
6136
  storyId: selectedPlanObj.storyId,
@@ -18,13 +18,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
18
18
 
19
19
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
20
 
21
- import get from "lodash/get";
22
- import { bool, func, number, string } from "prop-types";
23
- import React from "react";
24
- import ReactDOM from "react-dom";
25
- import { batch, connect } from "react-redux";
26
- import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from "../store/actions";
27
- import { awaitHelper } from "../utils";
21
+ import get from 'lodash/get';
22
+ import { bool, func, number, string } from 'prop-types';
23
+ import React from 'react';
24
+ import ReactDOM from 'react-dom';
25
+ import { batch, connect } from 'react-redux';
26
+ import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from '../store/actions';
27
+ import { awaitHelper } from '../utils';
28
28
 
29
29
  var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
30
30
  _inherits(AccessTypeBase, _React$Component);
@@ -39,30 +39,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
39
39
  _this = _super.call(this, props);
40
40
 
41
41
  _defineProperty(_assertThisInitialized(_this), "loadScript", function (callback) {
42
- var accessTypeKey = get(_this.props, ["accessTypeKey"]);
43
- var isStaging = get(_this.props, ["isStaging"]);
44
- var enableAccesstype = get(_this.props, ["enableAccesstype"]);
42
+ var accessTypeKey = get(_this.props, ['accessTypeKey']);
43
+ var isStaging = get(_this.props, ['isStaging']);
44
+ var enableAccesstype = get(_this.props, ['enableAccesstype']);
45
45
 
46
46
  if (!enableAccesstype) {
47
47
  return false;
48
48
  }
49
49
 
50
50
  var HOST = isStaging ? _this.stagingHost : _this.prodHost;
51
- var environment = isStaging ? "&env=sandbox" : "";
51
+ var environment = isStaging ? '&env=sandbox' : '';
52
52
  var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
53
53
  var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
54
54
 
55
55
  if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
56
- var accessTypeScript = document.createElement("script");
56
+ var accessTypeScript = document.createElement('script');
57
57
 
58
58
  accessTypeScript.onload = function () {
59
59
  _this.props.onATGlobalSet && _this.props.onATGlobalSet();
60
60
  callback();
61
61
  };
62
62
 
63
- accessTypeScript.setAttribute("src", accessTypeHost);
64
- accessTypeScript.setAttribute("id", "AccessTypeScript");
65
- accessTypeScript.setAttribute("data-accessType-script", "1");
63
+ accessTypeScript.setAttribute('src', accessTypeHost);
64
+ accessTypeScript.setAttribute('id', 'AccessTypeScript');
65
+ accessTypeScript.setAttribute('data-accessType-script', '1');
66
66
  accessTypeScript.async = 1;
67
67
  document.body.appendChild(accessTypeScript);
68
68
  return true;
@@ -203,7 +203,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
203
203
  break;
204
204
  }
205
205
 
206
- return _context3.abrupt("return", Promise.reject("Subscription id is not defined"));
206
+ return _context3.abrupt("return", Promise.reject('Subscription id is not defined'));
207
207
 
208
208
  case 3:
209
209
  return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
@@ -216,6 +216,22 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
216
216
  }, _callee3);
217
217
  })));
218
218
 
219
+ _defineProperty(_assertThisInitialized(_this), "getPath", function (sketchesHost, relativePath) {
220
+ try {
221
+ var _URL = new URL(sketchesHost),
222
+ pathname = _URL.pathname;
223
+
224
+ if (pathname && pathname !== '/') {
225
+ return "".concat(sketchesHost).concat(relativePath);
226
+ }
227
+
228
+ return relativePath;
229
+ } catch (err) {
230
+ console.log('Sketches host path error ---> ', err);
231
+ return relativePath;
232
+ }
233
+ });
234
+
219
235
  _defineProperty(_assertThisInitialized(_this), "getSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
220
236
  var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions;
221
237
 
@@ -223,8 +239,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
223
239
  while (1) {
224
240
  switch (_context4.prev = _context4.next) {
225
241
  case 0:
226
- accessTypeKey = get(_this.props, ["accessTypeKey"]);
227
- isStaging = get(_this.props, ["isStaging"]);
242
+ accessTypeKey = get(_this.props, ['accessTypeKey']);
243
+ isStaging = get(_this.props, ['isStaging']);
228
244
  HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
229
245
 
230
246
  accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
@@ -248,11 +264,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
248
264
  }
249
265
 
250
266
  return _context4.abrupt("return", {
251
- error: "subscriptions fetch failed"
267
+ error: 'subscriptions fetch failed'
252
268
  });
253
269
 
254
270
  case 15:
255
- return _context4.abrupt("return", subscriptions["subscription_groups"] || []);
271
+ return _context4.abrupt("return", subscriptions['subscription_groups'] || []);
256
272
 
257
273
  case 16:
258
274
  case "end":
@@ -291,7 +307,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
291
307
  }
292
308
 
293
309
  return _context5.abrupt("return", {
294
- error: "payment options fetch failed"
310
+ error: 'payment options fetch failed'
295
311
  });
296
312
 
297
313
  case 9:
@@ -317,7 +333,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
317
333
  while (1) {
318
334
  switch (_context6.prev = _context6.next) {
319
335
  case 0:
320
- storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "";
336
+ storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '';
321
337
 
322
338
  if (global.AccessType) {
323
339
  _context6.next = 3;
@@ -330,7 +346,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
330
346
  _context6.next = 5;
331
347
  return awaitHelper(global.AccessType.getAssetPlans({
332
348
  id: storyId,
333
- type: "story"
349
+ type: 'story'
334
350
  }));
335
351
 
336
352
  case 5:
@@ -345,7 +361,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
345
361
  }
346
362
 
347
363
  return _context6.abrupt("return", {
348
- error: "asset plan fetch failed"
364
+ error: 'asset plan fetch failed'
349
365
  });
350
366
 
351
367
  case 11:
@@ -366,15 +382,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
366
382
  while (1) {
367
383
  switch (_context7.prev = _context7.next) {
368
384
  case 0:
369
- isAccessTypeCampaignEnabled = get(_this.props, ["isAccessTypeCampaignEnabled"], false);
385
+ isAccessTypeCampaignEnabled = get(_this.props, ['isAccessTypeCampaignEnabled'], false);
370
386
 
371
387
  if (!isAccessTypeCampaignEnabled) {
372
388
  _context7.next = 18;
373
389
  break;
374
390
  }
375
391
 
376
- accessTypeKey = get(_this.props, ["accessTypeKey"]);
377
- isStaging = get(_this.props, ["isStaging"]);
392
+ accessTypeKey = get(_this.props, ['accessTypeKey']);
393
+ isStaging = get(_this.props, ['isStaging']);
378
394
  HOST = isStaging ? _this.stagingHost : _this.prodHost;
379
395
  accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
380
396
  _context7.t0 = awaitHelper;
@@ -397,11 +413,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
397
413
  }
398
414
 
399
415
  return _context7.abrupt("return", {
400
- error: "subscriptions fetch failed"
416
+ error: 'subscriptions fetch failed'
401
417
  });
402
418
 
403
419
  case 17:
404
- return _context7.abrupt("return", campaignSubscriptions["subscription_groups"] || []);
420
+ return _context7.abrupt("return", campaignSubscriptions['subscription_groups'] || []);
405
421
 
406
422
  case 18:
407
423
  return _context7.abrupt("return", []);
@@ -415,7 +431,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
415
431
  })));
416
432
 
417
433
  _defineProperty(_assertThisInitialized(_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
434
+ var _this$props;
435
+
418
436
  var callback,
437
+ url,
419
438
  jwtResponse,
420
439
  _yield$awaitHelper7,
421
440
  error,
@@ -428,15 +447,16 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
428
447
  callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
429
448
  return null;
430
449
  };
431
- _context8.next = 3;
432
- return fetch("/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
450
+ url = _this.getPath((_this$props = _this.props) === null || _this$props === void 0 ? void 0 : _this$props.sketchesHost, "/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
451
+ _context8.next = 4;
452
+ return fetch(url);
433
453
 
434
- case 3:
454
+ case 4:
435
455
  jwtResponse = _context8.sent;
436
- _context8.next = 6;
437
- return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get("x-integration-token"), !!jwtResponse.headers.get("x-integration-token")));
456
+ _context8.next = 7;
457
+ return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get('x-integration-token'), !!jwtResponse.headers.get('x-integration-token')));
438
458
 
439
- case 6:
459
+ case 7:
440
460
  _yield$awaitHelper7 = _context8.sent;
441
461
  error = _yield$awaitHelper7.error;
442
462
 
@@ -465,7 +485,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
465
485
  }
466
486
  }
467
487
 
468
- case 9:
488
+ case 10:
469
489
  case "end":
470
490
  return _context8.stop();
471
491
  }
@@ -536,11 +556,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
536
556
  break;
537
557
  }
538
558
 
539
- throw new Error("planId is mandatory");
559
+ throw new Error('planId is mandatory');
540
560
 
541
561
  case 4:
542
562
  _context10.next = 6;
543
- return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, "switch"));
563
+ return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, 'switch'));
544
564
 
545
565
  case 6:
546
566
  _yield$awaitHelper9 = _context10.sent;
@@ -578,7 +598,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
578
598
  _this.loadScript(function () {
579
599
  // dont try to initialize accessType if integration id is not available
580
600
  if (accessTypeBkIntegrationId === undefined) {
581
- console.warn("AccessType: Integration Id is undefined");
601
+ console.warn('AccessType: Integration Id is undefined');
582
602
  return false;
583
603
  }
584
604
 
@@ -617,11 +637,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
617
637
  switch (_context11.prev = _context11.next) {
618
638
  case 0:
619
639
  selectedPlanObj = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
620
- planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
621
- storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : "";
622
- storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : "";
623
- storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : "";
624
- paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : "";
640
+ planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : '';
641
+ storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : '';
642
+ storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : '';
643
+ storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : '';
644
+ paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : '';
625
645
  opts = _args11.length > 6 ? _args11[6] : undefined;
626
646
 
627
647
  if (selectedPlanObj) {
@@ -629,15 +649,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
629
649
  break;
630
650
  }
631
651
 
632
- console.warn("Razor pay needs a plan");
652
+ console.warn('Razor pay needs a plan');
633
653
  return _context11.abrupt("return", false);
634
654
 
635
655
  case 10:
636
- intent = get(opts, ["intent"], "default");
637
- switchType = get(opts, ["switchType"]);
656
+ intent = get(opts, ['intent'], 'default');
657
+ switchType = get(opts, ['switchType']);
638
658
  planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
639
659
 
640
- planObject["paymentType"] = paymentType || (get(planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
660
+ planObject['paymentType'] = paymentType || (get(planObject, ['selectedPlan', 'recurring']) ? 'razorpay_recurring' : 'razorpay');
641
661
  paymentOptions = _this.props.paymentOptions;
642
662
  _planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
643
663
  paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
@@ -668,13 +688,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
668
688
  }));
669
689
 
670
690
  case 25:
671
- if (!(intent === "switch")) {
691
+ if (!(intent === 'switch')) {
672
692
  _context11.next = 34;
673
693
  break;
674
694
  }
675
695
 
676
696
  _context11.next = 28;
677
- return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
697
+ return awaitHelper(global.AccessType.getPaymentOptions(null, null, 'switch'));
678
698
 
679
699
  case 28:
680
700
  _yield$awaitHelper11 = _context11.sent;
@@ -686,7 +706,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
686
706
  break;
687
707
  }
688
708
 
689
- throw new Error("payment options fetch failed");
709
+ throw new Error('payment options fetch failed');
690
710
 
691
711
  case 33:
692
712
  return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
@@ -710,19 +730,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
710
730
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
711
731
 
712
732
  if (!options.selectedPlan) {
713
- console.warn("Stripe pay needs a plan");
733
+ console.warn('Stripe pay needs a plan');
714
734
  return false;
715
735
  }
716
736
 
717
737
  var paymentOptions = _this.props.paymentOptions;
718
- var paymentType = get(options.selectedPlan, ["recurring"]) ? "stripe_recurring" : "stripe";
738
+ var paymentType = get(options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
719
739
 
720
740
  var paymentObject = _this.makePaymentObject(_objectSpread({
721
741
  paymentType: paymentType
722
742
  }, options));
723
743
 
724
744
  return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
725
- message: "Payment option is loading..."
745
+ message: 'Payment option is loading...'
726
746
  });
727
747
  });
728
748
 
@@ -730,12 +750,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
730
750
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
731
751
 
732
752
  if (!options.selectedPlan) {
733
- console.warn("Paypal pay needs a plan");
753
+ console.warn('Paypal pay needs a plan');
734
754
  return false;
735
755
  }
736
756
 
737
757
  var paymentOptions = _this.props.paymentOptions;
738
- var paymentType = get(options.selectedPlan, ["recurring"]) ? "paypal_recurring" : "paypal";
758
+ var paymentType = get(options.selectedPlan, ['recurring']) ? 'paypal_recurring' : 'paypal';
739
759
 
740
760
  var paymentObject = _this.makePaymentObject(_objectSpread({
741
761
  paymentType: paymentType
@@ -744,30 +764,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
744
764
  return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
745
765
  return response.proceed(paymentObject);
746
766
  }) : Promise.reject({
747
- message: "Payment option is loading..."
767
+ message: 'Payment option is loading...'
748
768
  });
749
769
  });
750
770
 
751
771
  _defineProperty(_assertThisInitialized(_this), "initOmisePayment", function () {
752
772
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
753
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
773
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
754
774
 
755
775
  if (!selectedPlanObj) {
756
- console.warn("Omise pay needs a plan");
776
+ console.warn('Omise pay needs a plan');
757
777
  return false;
758
778
  }
759
779
 
760
780
  var planObject = _this.makePlanObject(selectedPlanObj, planType);
761
781
 
762
- planObject["paymentType"] = get(planObject, ["selectedPlan", "recurring"]) ? "omise_recurring" : "omise";
782
+ planObject['paymentType'] = get(planObject, ['selectedPlan', 'recurring']) ? 'omise_recurring' : 'omise';
763
783
 
764
784
  var paymentObject = _this.makePaymentObject(planObject);
765
785
 
766
- var omise = get(_this.props, ["paymentOptions", "omise"]);
786
+ var omise = get(_this.props, ['paymentOptions', 'omise']);
767
787
 
768
788
  if (!omise) {
769
789
  return Promise.reject({
770
- message: "Payment option is loading..."
790
+ message: 'Payment option is loading...'
771
791
  });
772
792
  }
773
793
 
@@ -778,31 +798,31 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
778
798
 
779
799
  _defineProperty(_assertThisInitialized(_this), "initAdyenPayment", function () {
780
800
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
781
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
801
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
782
802
  var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
783
803
  var locale = arguments.length > 3 ? arguments[3] : undefined;
784
804
 
785
805
  var adyenExecutor = function adyenExecutor(resolve, reject) {
786
- if (!document.getElementById("adyen-modal")) {
787
- var modalElement = document.createElement("div");
788
- modalElement.setAttribute("id", "adyen-modal");
806
+ if (!document.getElementById('adyen-modal')) {
807
+ var modalElement = document.createElement('div');
808
+ modalElement.setAttribute('id', 'adyen-modal');
789
809
  document.body.appendChild(modalElement);
790
810
  }
791
811
 
792
812
  var afterOpen = function afterOpen() {
793
813
  var planObject = _this.makePlanObject(selectedPlanObj, planType);
794
814
 
795
- var isRecurring = get(planObject, ["selectedPlan", "recurring"]);
796
- var paymentType = isRecurring ? "adyen_recurring" : "adyen";
815
+ var isRecurring = get(planObject, ['selectedPlan', 'recurring']);
816
+ var paymentType = isRecurring ? 'adyen_recurring' : 'adyen';
797
817
 
798
818
  var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
799
819
  paymentType: paymentType
800
820
  }));
801
821
 
802
- var adyen = get(_this.props, ["paymentOptions", "adyen"]);
822
+ var adyen = get(_this.props, ['paymentOptions', 'adyen']);
803
823
  paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
804
- options: _objectSpread(_objectSpread({}, paymentObject["options"]), {}, {
805
- dropin_container_id: "dropin-adyen",
824
+ options: _objectSpread(_objectSpread({}, paymentObject['options']), {}, {
825
+ dropin_container_id: 'dropin-adyen',
806
826
  locale: locale
807
827
  }),
808
828
  additional_data: {
@@ -817,7 +837,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
817
837
  ReactDOM.render( /*#__PURE__*/React.createElement(AdyenModal, {
818
838
  afterOpen: afterOpen,
819
839
  afterClose: reject
820
- }), document.getElementById("adyen-modal"));
840
+ }), document.getElementById('adyen-modal'));
821
841
  };
822
842
 
823
843
  return new Promise(adyenExecutor);
@@ -827,12 +847,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
827
847
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
828
848
 
829
849
  if (!options.selectedPlan) {
830
- console.warn("Paytrail needs a plan");
850
+ console.warn('Paytrail needs a plan');
831
851
  return false;
832
852
  }
833
853
 
834
854
  var paymentOptions = _this.props.paymentOptions;
835
- var paymentType = get(options.selectedPlan, ["recurring"]) ? "paytrail_recurring" : "paytrail";
855
+ var paymentType = get(options.selectedPlan, ['recurring']) ? 'paytrail_recurring' : 'paytrail';
836
856
 
837
857
  var paymentObject = _this.makePaymentObject(_objectSpread({
838
858
  paymentType: paymentType
@@ -841,7 +861,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
841
861
  return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
842
862
  return response.proceed(paymentObject);
843
863
  }) : Promise.reject({
844
- message: "Payment option is loading..."
864
+ message: 'Payment option is loading...'
845
865
  });
846
866
  });
847
867
 
@@ -854,7 +874,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
854
874
  try {
855
875
  global.AccessType.pingbackAssetAccess(asset, accessData);
856
876
  } catch (e) {
857
- console.log("error in pingbackAssetAccess", e);
877
+ console.log('error in pingbackAssetAccess', e);
858
878
  }
859
879
 
860
880
  return _context12.abrupt("return", true);
@@ -885,7 +905,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
885
905
  break;
886
906
  }
887
907
 
888
- console.warn("AssetId is required");
908
+ console.warn('AssetId is required');
889
909
  return _context13.abrupt("return", false);
890
910
 
891
911
  case 3:
@@ -893,7 +913,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
893
913
 
894
914
  asset = {
895
915
  id: assetId,
896
- type: "story"
916
+ type: 'story'
897
917
  };
898
918
  _context13.next = 7;
899
919
  return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
@@ -919,7 +939,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
919
939
 
920
940
  _ref16 = accessData || {}, granted = _ref16.granted, grantReason = _ref16.grantReason, _ref16$data = _ref16.data, data = _ref16$data === void 0 ? {} : _ref16$data;
921
941
 
922
- if (!_this.props.disableMetering && granted && grantReason === "METERING") {
942
+ if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
923
943
  _this.pingBackMeteredStory(asset, accessData);
924
944
 
925
945
  _this.props.meterUpdated(data.numberRemaining || -1);
@@ -1004,8 +1024,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
1004
1024
  };
1005
1025
  }());
1006
1026
 
1007
- _this.prodHost = props.prodHost || "https://www.accesstype.com";
1008
- _this.stagingHost = props.stagingHost || "https://staging.accesstype.com";
1027
+ _this.prodHost = props.prodHost || 'https://www.accesstype.com';
1028
+ _this.stagingHost = props.stagingHost || 'https://staging.accesstype.com';
1009
1029
  return _this;
1010
1030
  }
1011
1031
 
@@ -1020,25 +1040,25 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
1020
1040
  var _ref19$selectedPlan = _ref19.selectedPlan,
1021
1041
  selectedPlan = _ref19$selectedPlan === void 0 ? {} : _ref19$selectedPlan,
1022
1042
  _ref19$couponCode = _ref19.couponCode,
1023
- couponCode = _ref19$couponCode === void 0 ? "" : _ref19$couponCode,
1043
+ couponCode = _ref19$couponCode === void 0 ? '' : _ref19$couponCode,
1024
1044
  _ref19$recipientSubsc = _ref19.recipientSubscriber,
1025
1045
  recipientSubscriber = _ref19$recipientSubsc === void 0 ? {} : _ref19$recipientSubsc,
1026
1046
  _ref19$planType = _ref19.planType,
1027
- planType = _ref19$planType === void 0 ? "" : _ref19$planType,
1047
+ planType = _ref19$planType === void 0 ? '' : _ref19$planType,
1028
1048
  _ref19$storyId = _ref19.storyId,
1029
- storyId = _ref19$storyId === void 0 ? "" : _ref19$storyId,
1049
+ storyId = _ref19$storyId === void 0 ? '' : _ref19$storyId,
1030
1050
  _ref19$storyHeadline = _ref19.storyHeadline,
1031
- storyHeadline = _ref19$storyHeadline === void 0 ? "" : _ref19$storyHeadline,
1051
+ storyHeadline = _ref19$storyHeadline === void 0 ? '' : _ref19$storyHeadline,
1032
1052
  _ref19$storySlug = _ref19.storySlug,
1033
- storySlug = _ref19$storySlug === void 0 ? "" : _ref19$storySlug,
1053
+ storySlug = _ref19$storySlug === void 0 ? '' : _ref19$storySlug,
1034
1054
  _ref19$paymentType = _ref19.paymentType,
1035
- paymentType = _ref19$paymentType === void 0 ? "" : _ref19$paymentType,
1055
+ paymentType = _ref19$paymentType === void 0 ? '' : _ref19$paymentType,
1036
1056
  _ref19$successUrl = _ref19.successUrl,
1037
- successUrl = _ref19$successUrl === void 0 ? "" : _ref19$successUrl,
1057
+ successUrl = _ref19$successUrl === void 0 ? '' : _ref19$successUrl,
1038
1058
  _ref19$returnUrl = _ref19.returnUrl,
1039
- returnUrl = _ref19$returnUrl === void 0 ? "" : _ref19$returnUrl,
1059
+ returnUrl = _ref19$returnUrl === void 0 ? '' : _ref19$returnUrl,
1040
1060
  _ref19$cancelUrl = _ref19.cancelUrl,
1041
- cancelUrl = _ref19$cancelUrl === void 0 ? "" : _ref19$cancelUrl;
1061
+ cancelUrl = _ref19$cancelUrl === void 0 ? '' : _ref19$cancelUrl;
1042
1062
  var id = selectedPlan.id,
1043
1063
  title = selectedPlan.title,
1044
1064
  description = selectedPlan.description,
@@ -1083,9 +1103,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
1083
1103
  };
1084
1104
 
1085
1105
  if (returnUrl) {
1086
- paymentObject.options.urls["return_url"] = returnUrl;
1106
+ paymentObject.options.urls['return_url'] = returnUrl;
1087
1107
  } else {
1088
- paymentObject.options.urls["success_url"] = successUrl;
1108
+ paymentObject.options.urls['success_url'] = successUrl;
1089
1109
  }
1090
1110
  }
1091
1111
 
@@ -1095,11 +1115,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
1095
1115
  key: "makePlanObject",
1096
1116
  value: function makePlanObject() {
1097
1117
  var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1098
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
1099
- var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
1100
- var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
1101
- var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
1102
- return selectedPlanObj.argType && selectedPlanObj.argType === "options" ? {
1118
+ var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1119
+ var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
1120
+ var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
1121
+ var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
1122
+ return selectedPlanObj.argType && selectedPlanObj.argType === 'options' ? {
1103
1123
  selectedPlan: selectedPlanObj.selectedPlan,
1104
1124
  planType: selectedPlanObj.planType,
1105
1125
  storyId: selectedPlanObj.storyId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "Components to help build Quintype Node.js apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",