@quintype/components 3.4.1 → 3.4.2

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
@@ -5263,28 +5263,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5263
5263
  }
5264
5264
  });
5265
5265
 
5266
- _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initRazorPayPayment", function () {
5267
- var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5268
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
5269
- var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
5270
- var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
5271
- var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
5266
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initRazorPayPayment", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10() {
5267
+ var selectedPlanObj,
5268
+ planType,
5269
+ storyId,
5270
+ storyHeadline,
5271
+ storySlug,
5272
+ paymentType,
5273
+ planObject,
5274
+ paymentOptions,
5275
+ _planObject$selectedP,
5276
+ discounted_price_cents,
5277
+ price_cents,
5278
+ _yield$awaitHelper9,
5279
+ data,
5280
+ paymentObject,
5281
+ _args10 = arguments;
5282
+
5283
+ return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
5284
+ while (1) {
5285
+ switch (_context10.prev = _context10.next) {
5286
+ case 0:
5287
+ selectedPlanObj = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
5288
+ planType = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : "";
5289
+ storyId = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : "";
5290
+ storyHeadline = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : "";
5291
+ storySlug = _args10.length > 4 && _args10[4] !== undefined ? _args10[4] : "";
5292
+ paymentType = _args10.length > 5 && _args10[5] !== undefined ? _args10[5] : "";
5293
+
5294
+ if (selectedPlanObj) {
5295
+ _context10.next = 9;
5296
+ break;
5297
+ }
5272
5298
 
5273
- if (!selectedPlanObj) {
5274
- console.warn("Razor pay needs a plan");
5275
- return false;
5276
- }
5299
+ console.warn("Razor pay needs a plan");
5300
+ return _context10.abrupt("return", false);
5277
5301
 
5278
- var planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
5302
+ case 9:
5303
+ planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
5279
5304
 
5305
+ paymentOptions = _this.props.paymentOptions;
5306
+ _planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
5280
5307
 
5281
- var paymentOptions = _this.props.paymentOptions;
5282
- planObject["paymentType"] = get__default["default"](planObject.selectedPlan, ["recurring"]) ? "razorpay_recurring" : "razorpay";
5308
+ if (!(discounted_price_cents === 0 || price_cents === 0)) {
5309
+ _context10.next = 18;
5310
+ break;
5311
+ }
5283
5312
 
5284
- var paymentObject = _this.makePaymentObject(planObject);
5313
+ _context10.next = 15;
5314
+ return awaitHelper(global.AccessType.getPaymentOptions(0));
5285
5315
 
5286
- return paymentOptions.razorpay.proceed(paymentObject);
5287
- });
5316
+ case 15:
5317
+ _yield$awaitHelper9 = _context10.sent;
5318
+ data = _yield$awaitHelper9.data;
5319
+ paymentOptions = data;
5320
+
5321
+ case 18:
5322
+ planObject["paymentType"] = paymentType || (get__default["default"](planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
5323
+ paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
5324
+ couponCode: selectedPlanObj.coupon_code
5325
+ }));
5326
+
5327
+ if (!(paymentObject.payment.amount_cents === 0)) {
5328
+ _context10.next = 22;
5329
+ break;
5330
+ }
5331
+
5332
+ return _context10.abrupt("return", global.AccessType.getPaymentOptions(0).then(function (provider) {
5333
+ return provider.razorpay.proceed(paymentObject);
5334
+ }));
5335
+
5336
+ case 22:
5337
+ return _context10.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
5338
+
5339
+ case 23:
5340
+ case "end":
5341
+ return _context10.stop();
5342
+ }
5343
+ }
5344
+ }, _callee10);
5345
+ })));
5288
5346
 
5289
5347
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initStripePayment", function () {
5290
5348
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -5426,10 +5484,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5426
5484
  });
5427
5485
 
5428
5486
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "pingBackMeteredStory", /*#__PURE__*/function () {
5429
- var _ref12 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee10(asset, accessData) {
5430
- return _regeneratorRuntime__default["default"].wrap(function _callee10$(_context10) {
5487
+ var _ref13 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(asset, accessData) {
5488
+ return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
5431
5489
  while (1) {
5432
- switch (_context10.prev = _context10.next) {
5490
+ switch (_context11.prev = _context11.next) {
5433
5491
  case 0:
5434
5492
  try {
5435
5493
  global.AccessType.pingbackAssetAccess(asset, accessData);
@@ -5437,36 +5495,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5437
5495
  console.log("error in pingbackAssetAccess", e);
5438
5496
  }
5439
5497
 
5440
- return _context10.abrupt("return", true);
5498
+ return _context11.abrupt("return", true);
5441
5499
 
5442
5500
  case 2:
5443
5501
  case "end":
5444
- return _context10.stop();
5502
+ return _context11.stop();
5445
5503
  }
5446
5504
  }
5447
- }, _callee10);
5505
+ }, _callee11);
5448
5506
  }));
5449
5507
 
5450
5508
  return function (_x6, _x7) {
5451
- return _ref12.apply(this, arguments);
5509
+ return _ref13.apply(this, arguments);
5452
5510
  };
5453
5511
  }());
5454
5512
 
5455
5513
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "checkAccess", /*#__PURE__*/function () {
5456
- var _ref13 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee11(assetId) {
5457
- var asset, _yield$awaitHelper9, error, accessData, accessById, granted, grantReason, _accessData$data, data;
5514
+ var _ref14 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12(assetId) {
5515
+ var asset, _yield$awaitHelper10, error, accessData, accessById, granted, grantReason, _accessData$data, data;
5458
5516
 
5459
- return _regeneratorRuntime__default["default"].wrap(function _callee11$(_context11) {
5517
+ return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context12) {
5460
5518
  while (1) {
5461
- switch (_context11.prev = _context11.next) {
5519
+ switch (_context12.prev = _context12.next) {
5462
5520
  case 0:
5463
5521
  if (assetId) {
5464
- _context11.next = 3;
5522
+ _context12.next = 3;
5465
5523
  break;
5466
5524
  }
5467
5525
 
5468
5526
  console.warn("AssetId is required");
5469
- return _context11.abrupt("return", false);
5527
+ return _context12.abrupt("return", false);
5470
5528
 
5471
5529
  case 3:
5472
5530
  _this.props.accessIsLoading(true);
@@ -5475,13 +5533,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5475
5533
  id: assetId,
5476
5534
  type: "story"
5477
5535
  };
5478
- _context11.next = 7;
5536
+ _context12.next = 7;
5479
5537
  return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
5480
5538
 
5481
5539
  case 7:
5482
- _yield$awaitHelper9 = _context11.sent;
5483
- error = _yield$awaitHelper9.error;
5484
- accessData = _yield$awaitHelper9.data;
5540
+ _yield$awaitHelper10 = _context12.sent;
5541
+ error = _yield$awaitHelper10.error;
5542
+ accessData = _yield$awaitHelper10.data;
5485
5543
  accessById = _defineProperty__default["default"]({}, assetId, accessData);
5486
5544
 
5487
5545
  _this.props.accessUpdated(accessById);
@@ -5497,89 +5555,89 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5497
5555
  }
5498
5556
 
5499
5557
  if (!error) {
5500
- _context11.next = 17;
5558
+ _context12.next = 17;
5501
5559
  break;
5502
5560
  }
5503
5561
 
5504
- return _context11.abrupt("return", error);
5562
+ return _context12.abrupt("return", error);
5505
5563
 
5506
5564
  case 17:
5507
- return _context11.abrupt("return", accessById);
5565
+ return _context12.abrupt("return", accessById);
5508
5566
 
5509
5567
  case 18:
5510
5568
  case "end":
5511
- return _context11.stop();
5569
+ return _context12.stop();
5512
5570
  }
5513
5571
  }
5514
- }, _callee11);
5572
+ }, _callee12);
5515
5573
  }));
5516
5574
 
5517
5575
  return function (_x8) {
5518
- return _ref13.apply(this, arguments);
5576
+ return _ref14.apply(this, arguments);
5519
5577
  };
5520
5578
  }());
5521
5579
 
5522
- _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12() {
5580
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13() {
5523
5581
  var metadata;
5524
- return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context12) {
5582
+ return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context13) {
5525
5583
  while (1) {
5526
- switch (_context12.prev = _context12.next) {
5584
+ switch (_context13.prev = _context13.next) {
5527
5585
  case 0:
5528
5586
  if (global.AccessType) {
5529
- _context12.next = 2;
5587
+ _context13.next = 2;
5530
5588
  break;
5531
5589
  }
5532
5590
 
5533
- return _context12.abrupt("return", {});
5591
+ return _context13.abrupt("return", {});
5534
5592
 
5535
5593
  case 2:
5536
- _context12.next = 4;
5594
+ _context13.next = 4;
5537
5595
  return awaitHelper(global.AccessType.getSubscriberMetadata());
5538
5596
 
5539
5597
  case 4:
5540
- metadata = _context12.sent;
5541
- return _context12.abrupt("return", metadata);
5598
+ metadata = _context13.sent;
5599
+ return _context13.abrupt("return", metadata);
5542
5600
 
5543
5601
  case 6:
5544
5602
  case "end":
5545
- return _context12.stop();
5603
+ return _context13.stop();
5546
5604
  }
5547
5605
  }
5548
- }, _callee12);
5606
+ }, _callee13);
5549
5607
  })));
5550
5608
 
5551
5609
  _defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "setSubscriberMetadata", /*#__PURE__*/function () {
5552
- var _ref15 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(subscriberMetadata) {
5610
+ var _ref16 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(subscriberMetadata) {
5553
5611
  var response;
5554
- return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context13) {
5612
+ return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context14) {
5555
5613
  while (1) {
5556
- switch (_context13.prev = _context13.next) {
5614
+ switch (_context14.prev = _context14.next) {
5557
5615
  case 0:
5558
5616
  if (!(!global.AccessType || !subscriberMetadata)) {
5559
- _context13.next = 2;
5617
+ _context14.next = 2;
5560
5618
  break;
5561
5619
  }
5562
5620
 
5563
- return _context13.abrupt("return", {});
5621
+ return _context14.abrupt("return", {});
5564
5622
 
5565
5623
  case 2:
5566
- _context13.next = 4;
5624
+ _context14.next = 4;
5567
5625
  return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
5568
5626
 
5569
5627
  case 4:
5570
- response = _context13.sent;
5571
- return _context13.abrupt("return", response);
5628
+ response = _context14.sent;
5629
+ return _context14.abrupt("return", response);
5572
5630
 
5573
5631
  case 6:
5574
5632
  case "end":
5575
- return _context13.stop();
5633
+ return _context14.stop();
5576
5634
  }
5577
5635
  }
5578
- }, _callee13);
5636
+ }, _callee14);
5579
5637
  }));
5580
5638
 
5581
5639
  return function (_x9) {
5582
- return _ref15.apply(this, arguments);
5640
+ return _ref16.apply(this, arguments);
5583
5641
  };
5584
5642
  }());
5585
5643
 
@@ -5595,29 +5653,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5595
5653
  }
5596
5654
  }, {
5597
5655
  key: "makePaymentObject",
5598
- value: function makePaymentObject(_ref16) {
5599
- var _ref16$selectedPlan = _ref16.selectedPlan,
5600
- selectedPlan = _ref16$selectedPlan === void 0 ? {} : _ref16$selectedPlan,
5601
- _ref16$couponCode = _ref16.couponCode,
5602
- couponCode = _ref16$couponCode === void 0 ? "" : _ref16$couponCode,
5603
- _ref16$recipientSubsc = _ref16.recipientSubscriber,
5604
- recipientSubscriber = _ref16$recipientSubsc === void 0 ? {} : _ref16$recipientSubsc,
5605
- _ref16$planType = _ref16.planType,
5606
- planType = _ref16$planType === void 0 ? "" : _ref16$planType,
5607
- _ref16$storyId = _ref16.storyId,
5608
- storyId = _ref16$storyId === void 0 ? "" : _ref16$storyId,
5609
- _ref16$storyHeadline = _ref16.storyHeadline,
5610
- storyHeadline = _ref16$storyHeadline === void 0 ? "" : _ref16$storyHeadline,
5611
- _ref16$storySlug = _ref16.storySlug,
5612
- storySlug = _ref16$storySlug === void 0 ? "" : _ref16$storySlug,
5613
- _ref16$paymentType = _ref16.paymentType,
5614
- paymentType = _ref16$paymentType === void 0 ? "" : _ref16$paymentType,
5615
- _ref16$successUrl = _ref16.successUrl,
5616
- successUrl = _ref16$successUrl === void 0 ? "" : _ref16$successUrl,
5617
- _ref16$returnUrl = _ref16.returnUrl,
5618
- returnUrl = _ref16$returnUrl === void 0 ? "" : _ref16$returnUrl,
5619
- _ref16$cancelUrl = _ref16.cancelUrl,
5620
- cancelUrl = _ref16$cancelUrl === void 0 ? "" : _ref16$cancelUrl;
5656
+ value: function makePaymentObject(_ref17) {
5657
+ var _ref17$selectedPlan = _ref17.selectedPlan,
5658
+ selectedPlan = _ref17$selectedPlan === void 0 ? {} : _ref17$selectedPlan,
5659
+ _ref17$couponCode = _ref17.couponCode,
5660
+ couponCode = _ref17$couponCode === void 0 ? "" : _ref17$couponCode,
5661
+ _ref17$recipientSubsc = _ref17.recipientSubscriber,
5662
+ recipientSubscriber = _ref17$recipientSubsc === void 0 ? {} : _ref17$recipientSubsc,
5663
+ _ref17$planType = _ref17.planType,
5664
+ planType = _ref17$planType === void 0 ? "" : _ref17$planType,
5665
+ _ref17$storyId = _ref17.storyId,
5666
+ storyId = _ref17$storyId === void 0 ? "" : _ref17$storyId,
5667
+ _ref17$storyHeadline = _ref17.storyHeadline,
5668
+ storyHeadline = _ref17$storyHeadline === void 0 ? "" : _ref17$storyHeadline,
5669
+ _ref17$storySlug = _ref17.storySlug,
5670
+ storySlug = _ref17$storySlug === void 0 ? "" : _ref17$storySlug,
5671
+ _ref17$paymentType = _ref17.paymentType,
5672
+ paymentType = _ref17$paymentType === void 0 ? "" : _ref17$paymentType,
5673
+ _ref17$successUrl = _ref17.successUrl,
5674
+ successUrl = _ref17$successUrl === void 0 ? "" : _ref17$successUrl,
5675
+ _ref17$returnUrl = _ref17.returnUrl,
5676
+ returnUrl = _ref17$returnUrl === void 0 ? "" : _ref17$returnUrl,
5677
+ _ref17$cancelUrl = _ref17.cancelUrl,
5678
+ cancelUrl = _ref17$cancelUrl === void 0 ? "" : _ref17$cancelUrl;
5621
5679
  var id = selectedPlan.id,
5622
5680
  title = selectedPlan.title,
5623
5681
  description = selectedPlan.description,
@@ -5625,6 +5683,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5625
5683
  price_currency = selectedPlan.price_currency,
5626
5684
  duration_length = selectedPlan.duration_length,
5627
5685
  duration_unit = selectedPlan.duration_unit,
5686
+ discounted_price_cents = selectedPlan.discounted_price_cents,
5628
5687
  metadata = selectedPlan.metadata;
5629
5688
  var paymentObject = {
5630
5689
  type: planType,
@@ -5635,13 +5694,14 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5635
5694
  price_cents: price_cents,
5636
5695
  price_currency: price_currency,
5637
5696
  duration_length: duration_length,
5638
- duration_unit: duration_unit
5697
+ duration_unit: duration_unit,
5698
+ discounted_price_cents: discounted_price_cents
5639
5699
  },
5640
5700
  metadata: metadata,
5641
5701
  coupon_code: couponCode,
5642
5702
  payment: {
5643
5703
  payment_type: paymentType,
5644
- amount_cents: price_cents,
5704
+ amount_cents: discounted_price_cents === undefined ? price_cents : discounted_price_cents,
5645
5705
  amount_currency: price_currency
5646
5706
  },
5647
5707
  assets: [{
@@ -5706,6 +5766,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
5706
5766
  initAdyenPayment: this.initAdyenPayment,
5707
5767
  initPaytrailPayment: this.initPaytrailPayment,
5708
5768
  checkAccess: this.checkAccess,
5769
+ getSubscription: this.getSubscription,
5709
5770
  getSubscriptionForUser: this.getSubscriptionForUser,
5710
5771
  accessUpdated: this.props.accessUpdated,
5711
5772
  accessIsLoading: this.props.accessIsLoading,
@@ -5799,6 +5860,7 @@ var mapDispatchToProps$1 = function mapDispatchToProps(dispatch) {
5799
5860
  "phone_number": "007"}} | Update the Subscriber Metadata
5800
5861
  * validateCoupon| selectedPlan(object), couponCode (string) | Validate coupon with plan
5801
5862
  * cancelSubscription| subscriptionId(number) | Cancel a subscription
5863
+ * getSubscription | -NA- | Gets the subscription groups provided by the publisher
5802
5864
  * getSubscriptionForUser | -NA- | Gets the subscriptions of the current logged in user
5803
5865
  * accessUpdated| accessObject(object) | Sets the current story access to redux store
5804
5866
  * accessIsLoading| loading(boolean) | A boolean which holds true between the request for access of a story and its response
@@ -533,28 +533,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
533
533
  }
534
534
  });
535
535
 
536
- _defineProperty(_assertThisInitialized(_this), "initRazorPayPayment", function () {
537
- var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
538
- var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
539
- var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
540
- var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
541
- var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
536
+ _defineProperty(_assertThisInitialized(_this), "initRazorPayPayment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
537
+ var selectedPlanObj,
538
+ planType,
539
+ storyId,
540
+ storyHeadline,
541
+ storySlug,
542
+ paymentType,
543
+ planObject,
544
+ paymentOptions,
545
+ _planObject$selectedP,
546
+ discounted_price_cents,
547
+ price_cents,
548
+ _yield$awaitHelper9,
549
+ data,
550
+ paymentObject,
551
+ _args10 = arguments;
552
+
553
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
554
+ while (1) {
555
+ switch (_context10.prev = _context10.next) {
556
+ case 0:
557
+ selectedPlanObj = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
558
+ planType = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : "";
559
+ storyId = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : "";
560
+ storyHeadline = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : "";
561
+ storySlug = _args10.length > 4 && _args10[4] !== undefined ? _args10[4] : "";
562
+ paymentType = _args10.length > 5 && _args10[5] !== undefined ? _args10[5] : "";
563
+
564
+ if (selectedPlanObj) {
565
+ _context10.next = 9;
566
+ break;
567
+ }
542
568
 
543
- if (!selectedPlanObj) {
544
- console.warn("Razor pay needs a plan");
545
- return false;
546
- }
569
+ console.warn("Razor pay needs a plan");
570
+ return _context10.abrupt("return", false);
547
571
 
548
- var planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
572
+ case 9:
573
+ planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
549
574
 
575
+ paymentOptions = _this.props.paymentOptions;
576
+ _planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
550
577
 
551
- var paymentOptions = _this.props.paymentOptions;
552
- planObject["paymentType"] = get(planObject.selectedPlan, ["recurring"]) ? "razorpay_recurring" : "razorpay";
578
+ if (!(discounted_price_cents === 0 || price_cents === 0)) {
579
+ _context10.next = 18;
580
+ break;
581
+ }
553
582
 
554
- var paymentObject = _this.makePaymentObject(planObject);
583
+ _context10.next = 15;
584
+ return awaitHelper(global.AccessType.getPaymentOptions(0));
555
585
 
556
- return paymentOptions.razorpay.proceed(paymentObject);
557
- });
586
+ case 15:
587
+ _yield$awaitHelper9 = _context10.sent;
588
+ data = _yield$awaitHelper9.data;
589
+ paymentOptions = data;
590
+
591
+ case 18:
592
+ planObject["paymentType"] = paymentType || (get(planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
593
+ paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
594
+ couponCode: selectedPlanObj.coupon_code
595
+ }));
596
+
597
+ if (!(paymentObject.payment.amount_cents === 0)) {
598
+ _context10.next = 22;
599
+ break;
600
+ }
601
+
602
+ return _context10.abrupt("return", global.AccessType.getPaymentOptions(0).then(function (provider) {
603
+ return provider.razorpay.proceed(paymentObject);
604
+ }));
605
+
606
+ case 22:
607
+ return _context10.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
608
+
609
+ case 23:
610
+ case "end":
611
+ return _context10.stop();
612
+ }
613
+ }
614
+ }, _callee10);
615
+ })));
558
616
 
559
617
  _defineProperty(_assertThisInitialized(_this), "initStripePayment", function () {
560
618
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -696,10 +754,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
696
754
  });
697
755
 
698
756
  _defineProperty(_assertThisInitialized(_this), "pingBackMeteredStory", /*#__PURE__*/function () {
699
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(asset, accessData) {
700
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
757
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(asset, accessData) {
758
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
701
759
  while (1) {
702
- switch (_context10.prev = _context10.next) {
760
+ switch (_context11.prev = _context11.next) {
703
761
  case 0:
704
762
  try {
705
763
  global.AccessType.pingbackAssetAccess(asset, accessData);
@@ -707,36 +765,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
707
765
  console.log("error in pingbackAssetAccess", e);
708
766
  }
709
767
 
710
- return _context10.abrupt("return", true);
768
+ return _context11.abrupt("return", true);
711
769
 
712
770
  case 2:
713
771
  case "end":
714
- return _context10.stop();
772
+ return _context11.stop();
715
773
  }
716
774
  }
717
- }, _callee10);
775
+ }, _callee11);
718
776
  }));
719
777
 
720
778
  return function (_x6, _x7) {
721
- return _ref12.apply(this, arguments);
779
+ return _ref13.apply(this, arguments);
722
780
  };
723
781
  }());
724
782
 
725
783
  _defineProperty(_assertThisInitialized(_this), "checkAccess", /*#__PURE__*/function () {
726
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(assetId) {
727
- var asset, _yield$awaitHelper9, error, accessData, accessById, granted, grantReason, _accessData$data, data;
784
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(assetId) {
785
+ var asset, _yield$awaitHelper10, error, accessData, accessById, granted, grantReason, _accessData$data, data;
728
786
 
729
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
787
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
730
788
  while (1) {
731
- switch (_context11.prev = _context11.next) {
789
+ switch (_context12.prev = _context12.next) {
732
790
  case 0:
733
791
  if (assetId) {
734
- _context11.next = 3;
792
+ _context12.next = 3;
735
793
  break;
736
794
  }
737
795
 
738
796
  console.warn("AssetId is required");
739
- return _context11.abrupt("return", false);
797
+ return _context12.abrupt("return", false);
740
798
 
741
799
  case 3:
742
800
  _this.props.accessIsLoading(true);
@@ -745,13 +803,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
745
803
  id: assetId,
746
804
  type: "story"
747
805
  };
748
- _context11.next = 7;
806
+ _context12.next = 7;
749
807
  return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
750
808
 
751
809
  case 7:
752
- _yield$awaitHelper9 = _context11.sent;
753
- error = _yield$awaitHelper9.error;
754
- accessData = _yield$awaitHelper9.data;
810
+ _yield$awaitHelper10 = _context12.sent;
811
+ error = _yield$awaitHelper10.error;
812
+ accessData = _yield$awaitHelper10.data;
755
813
  accessById = _defineProperty({}, assetId, accessData);
756
814
 
757
815
  _this.props.accessUpdated(accessById);
@@ -767,89 +825,89 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
767
825
  }
768
826
 
769
827
  if (!error) {
770
- _context11.next = 17;
828
+ _context12.next = 17;
771
829
  break;
772
830
  }
773
831
 
774
- return _context11.abrupt("return", error);
832
+ return _context12.abrupt("return", error);
775
833
 
776
834
  case 17:
777
- return _context11.abrupt("return", accessById);
835
+ return _context12.abrupt("return", accessById);
778
836
 
779
837
  case 18:
780
838
  case "end":
781
- return _context11.stop();
839
+ return _context12.stop();
782
840
  }
783
841
  }
784
- }, _callee11);
842
+ }, _callee12);
785
843
  }));
786
844
 
787
845
  return function (_x8) {
788
- return _ref13.apply(this, arguments);
846
+ return _ref14.apply(this, arguments);
789
847
  };
790
848
  }());
791
849
 
792
- _defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
850
+ _defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
793
851
  var metadata;
794
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
852
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
795
853
  while (1) {
796
- switch (_context12.prev = _context12.next) {
854
+ switch (_context13.prev = _context13.next) {
797
855
  case 0:
798
856
  if (global.AccessType) {
799
- _context12.next = 2;
857
+ _context13.next = 2;
800
858
  break;
801
859
  }
802
860
 
803
- return _context12.abrupt("return", {});
861
+ return _context13.abrupt("return", {});
804
862
 
805
863
  case 2:
806
- _context12.next = 4;
864
+ _context13.next = 4;
807
865
  return awaitHelper(global.AccessType.getSubscriberMetadata());
808
866
 
809
867
  case 4:
810
- metadata = _context12.sent;
811
- return _context12.abrupt("return", metadata);
868
+ metadata = _context13.sent;
869
+ return _context13.abrupt("return", metadata);
812
870
 
813
871
  case 6:
814
872
  case "end":
815
- return _context12.stop();
873
+ return _context13.stop();
816
874
  }
817
875
  }
818
- }, _callee12);
876
+ }, _callee13);
819
877
  })));
820
878
 
821
879
  _defineProperty(_assertThisInitialized(_this), "setSubscriberMetadata", /*#__PURE__*/function () {
822
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(subscriberMetadata) {
880
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(subscriberMetadata) {
823
881
  var response;
824
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
882
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
825
883
  while (1) {
826
- switch (_context13.prev = _context13.next) {
884
+ switch (_context14.prev = _context14.next) {
827
885
  case 0:
828
886
  if (!(!global.AccessType || !subscriberMetadata)) {
829
- _context13.next = 2;
887
+ _context14.next = 2;
830
888
  break;
831
889
  }
832
890
 
833
- return _context13.abrupt("return", {});
891
+ return _context14.abrupt("return", {});
834
892
 
835
893
  case 2:
836
- _context13.next = 4;
894
+ _context14.next = 4;
837
895
  return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
838
896
 
839
897
  case 4:
840
- response = _context13.sent;
841
- return _context13.abrupt("return", response);
898
+ response = _context14.sent;
899
+ return _context14.abrupt("return", response);
842
900
 
843
901
  case 6:
844
902
  case "end":
845
- return _context13.stop();
903
+ return _context14.stop();
846
904
  }
847
905
  }
848
- }, _callee13);
906
+ }, _callee14);
849
907
  }));
850
908
 
851
909
  return function (_x9) {
852
- return _ref15.apply(this, arguments);
910
+ return _ref16.apply(this, arguments);
853
911
  };
854
912
  }());
855
913
 
@@ -865,29 +923,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
865
923
  }
866
924
  }, {
867
925
  key: "makePaymentObject",
868
- value: function makePaymentObject(_ref16) {
869
- var _ref16$selectedPlan = _ref16.selectedPlan,
870
- selectedPlan = _ref16$selectedPlan === void 0 ? {} : _ref16$selectedPlan,
871
- _ref16$couponCode = _ref16.couponCode,
872
- couponCode = _ref16$couponCode === void 0 ? "" : _ref16$couponCode,
873
- _ref16$recipientSubsc = _ref16.recipientSubscriber,
874
- recipientSubscriber = _ref16$recipientSubsc === void 0 ? {} : _ref16$recipientSubsc,
875
- _ref16$planType = _ref16.planType,
876
- planType = _ref16$planType === void 0 ? "" : _ref16$planType,
877
- _ref16$storyId = _ref16.storyId,
878
- storyId = _ref16$storyId === void 0 ? "" : _ref16$storyId,
879
- _ref16$storyHeadline = _ref16.storyHeadline,
880
- storyHeadline = _ref16$storyHeadline === void 0 ? "" : _ref16$storyHeadline,
881
- _ref16$storySlug = _ref16.storySlug,
882
- storySlug = _ref16$storySlug === void 0 ? "" : _ref16$storySlug,
883
- _ref16$paymentType = _ref16.paymentType,
884
- paymentType = _ref16$paymentType === void 0 ? "" : _ref16$paymentType,
885
- _ref16$successUrl = _ref16.successUrl,
886
- successUrl = _ref16$successUrl === void 0 ? "" : _ref16$successUrl,
887
- _ref16$returnUrl = _ref16.returnUrl,
888
- returnUrl = _ref16$returnUrl === void 0 ? "" : _ref16$returnUrl,
889
- _ref16$cancelUrl = _ref16.cancelUrl,
890
- cancelUrl = _ref16$cancelUrl === void 0 ? "" : _ref16$cancelUrl;
926
+ value: function makePaymentObject(_ref17) {
927
+ var _ref17$selectedPlan = _ref17.selectedPlan,
928
+ selectedPlan = _ref17$selectedPlan === void 0 ? {} : _ref17$selectedPlan,
929
+ _ref17$couponCode = _ref17.couponCode,
930
+ couponCode = _ref17$couponCode === void 0 ? "" : _ref17$couponCode,
931
+ _ref17$recipientSubsc = _ref17.recipientSubscriber,
932
+ recipientSubscriber = _ref17$recipientSubsc === void 0 ? {} : _ref17$recipientSubsc,
933
+ _ref17$planType = _ref17.planType,
934
+ planType = _ref17$planType === void 0 ? "" : _ref17$planType,
935
+ _ref17$storyId = _ref17.storyId,
936
+ storyId = _ref17$storyId === void 0 ? "" : _ref17$storyId,
937
+ _ref17$storyHeadline = _ref17.storyHeadline,
938
+ storyHeadline = _ref17$storyHeadline === void 0 ? "" : _ref17$storyHeadline,
939
+ _ref17$storySlug = _ref17.storySlug,
940
+ storySlug = _ref17$storySlug === void 0 ? "" : _ref17$storySlug,
941
+ _ref17$paymentType = _ref17.paymentType,
942
+ paymentType = _ref17$paymentType === void 0 ? "" : _ref17$paymentType,
943
+ _ref17$successUrl = _ref17.successUrl,
944
+ successUrl = _ref17$successUrl === void 0 ? "" : _ref17$successUrl,
945
+ _ref17$returnUrl = _ref17.returnUrl,
946
+ returnUrl = _ref17$returnUrl === void 0 ? "" : _ref17$returnUrl,
947
+ _ref17$cancelUrl = _ref17.cancelUrl,
948
+ cancelUrl = _ref17$cancelUrl === void 0 ? "" : _ref17$cancelUrl;
891
949
  var id = selectedPlan.id,
892
950
  title = selectedPlan.title,
893
951
  description = selectedPlan.description,
@@ -895,6 +953,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
895
953
  price_currency = selectedPlan.price_currency,
896
954
  duration_length = selectedPlan.duration_length,
897
955
  duration_unit = selectedPlan.duration_unit,
956
+ discounted_price_cents = selectedPlan.discounted_price_cents,
898
957
  metadata = selectedPlan.metadata;
899
958
  var paymentObject = {
900
959
  type: planType,
@@ -905,13 +964,14 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
905
964
  price_cents: price_cents,
906
965
  price_currency: price_currency,
907
966
  duration_length: duration_length,
908
- duration_unit: duration_unit
967
+ duration_unit: duration_unit,
968
+ discounted_price_cents: discounted_price_cents
909
969
  },
910
970
  metadata: metadata,
911
971
  coupon_code: couponCode,
912
972
  payment: {
913
973
  payment_type: paymentType,
914
- amount_cents: price_cents,
974
+ amount_cents: discounted_price_cents === undefined ? price_cents : discounted_price_cents,
915
975
  amount_currency: price_currency
916
976
  },
917
977
  assets: [{
@@ -976,6 +1036,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
976
1036
  initAdyenPayment: this.initAdyenPayment,
977
1037
  initPaytrailPayment: this.initPaytrailPayment,
978
1038
  checkAccess: this.checkAccess,
1039
+ getSubscription: this.getSubscription,
979
1040
  getSubscriptionForUser: this.getSubscriptionForUser,
980
1041
  accessUpdated: this.props.accessUpdated,
981
1042
  accessIsLoading: this.props.accessIsLoading,
@@ -1069,6 +1130,7 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
1069
1130
  "phone_number": "007"}} | Update the Subscriber Metadata
1070
1131
  * validateCoupon| selectedPlan(object), couponCode (string) | Validate coupon with plan
1071
1132
  * cancelSubscription| subscriptionId(number) | Cancel a subscription
1133
+ * getSubscription | -NA- | Gets the subscription groups provided by the publisher
1072
1134
  * getSubscriptionForUser | -NA- | Gets the subscriptions of the current logged in user
1073
1135
  * accessUpdated| accessObject(object) | Sets the current story access to redux store
1074
1136
  * accessIsLoading| loading(boolean) | A boolean which holds true between the request for access of a story and its response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
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",
@@ -103,7 +103,7 @@
103
103
  "docs": "rimraf docs && jsdoc -c jsdoc.json",
104
104
  "prepack": "npm run build",
105
105
  "prepublishOnly": "./bin-dev-scripts/standard-version-release.sh",
106
- "sync-files-to": "npx onchange --verbose --wait --await-write-finish 'src/**/*' -- ./bin-dev-scripts/sync-to.sh",
106
+ "sync-files-to": "npx onchange --verbose --await-write-finish=2000 'src/**/*' -- ./bin-dev-scripts/sync-to.sh",
107
107
  "test": "jest --config jest.config.js",
108
108
  "test:cover": "jest --coverage --watchAll; open coverage/index.html"
109
109
  }