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