@quintype/components 3.8.1 → 3.8.2-logs.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 +128 -122
- package/dist/es/components/access-type.js +135 -129
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -5050,30 +5050,32 @@ 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, [
|
|
5054
|
-
var isStaging = get__default["default"](_this.props, [
|
|
5055
|
-
var enableAccesstype = get__default["default"](_this.props, [
|
|
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
|
+
console.log("loadscript===============", _this.props);
|
|
5056
5057
|
|
|
5057
5058
|
if (!enableAccesstype) {
|
|
5058
5059
|
return false;
|
|
5059
5060
|
}
|
|
5060
5061
|
|
|
5061
5062
|
var HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
5062
|
-
var environment = isStaging ?
|
|
5063
|
+
var environment = isStaging ? "&env=sandbox" : "";
|
|
5063
5064
|
var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
|
|
5064
5065
|
var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
|
|
5065
5066
|
|
|
5066
5067
|
if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
|
|
5067
|
-
|
|
5068
|
+
console.log("coming in creating the script---------");
|
|
5069
|
+
var accessTypeScript = document.createElement("script");
|
|
5068
5070
|
|
|
5069
5071
|
accessTypeScript.onload = function () {
|
|
5070
5072
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
5071
5073
|
callback();
|
|
5072
5074
|
};
|
|
5073
5075
|
|
|
5074
|
-
accessTypeScript.setAttribute(
|
|
5075
|
-
accessTypeScript.setAttribute(
|
|
5076
|
-
accessTypeScript.setAttribute(
|
|
5076
|
+
accessTypeScript.setAttribute("src", accessTypeHost);
|
|
5077
|
+
accessTypeScript.setAttribute("id", "AccessTypeScript");
|
|
5078
|
+
accessTypeScript.setAttribute("data-accessType-script", "1");
|
|
5077
5079
|
accessTypeScript.async = 1;
|
|
5078
5080
|
document.body.appendChild(accessTypeScript);
|
|
5079
5081
|
return true;
|
|
@@ -5101,15 +5103,17 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5101
5103
|
switch (_context.prev = _context.next) {
|
|
5102
5104
|
case 0:
|
|
5103
5105
|
isLoggedIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
|
|
5106
|
+
console.log("set user global.AccessType--", global.AccessType);
|
|
5107
|
+
console.log("set user props-------", emailAddress, mobileNumber, accesstypeJwt, isLoggedIn);
|
|
5104
5108
|
|
|
5105
5109
|
if (global.AccessType) {
|
|
5106
|
-
_context.next =
|
|
5110
|
+
_context.next = 5;
|
|
5107
5111
|
break;
|
|
5108
5112
|
}
|
|
5109
5113
|
|
|
5110
5114
|
return _context.abrupt("return", null);
|
|
5111
5115
|
|
|
5112
|
-
case
|
|
5116
|
+
case 5:
|
|
5113
5117
|
userObj = isLoggedIn ? {
|
|
5114
5118
|
emailAddress: emailAddress,
|
|
5115
5119
|
mobileNumber: mobileNumber,
|
|
@@ -5117,26 +5121,28 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5117
5121
|
} : {
|
|
5118
5122
|
isLoggedIn: false
|
|
5119
5123
|
};
|
|
5120
|
-
_context.next =
|
|
5124
|
+
_context.next = 8;
|
|
5121
5125
|
return awaitHelper(global.AccessType.setUser(userObj));
|
|
5122
5126
|
|
|
5123
|
-
case
|
|
5127
|
+
case 8:
|
|
5124
5128
|
_yield$awaitHelper = _context.sent;
|
|
5125
5129
|
error = _yield$awaitHelper.error;
|
|
5126
5130
|
user = _yield$awaitHelper.data;
|
|
5131
|
+
console.log("set user error-------", error);
|
|
5132
|
+
console.log("set user user-------", user);
|
|
5127
5133
|
|
|
5128
5134
|
if (!error) {
|
|
5129
|
-
_context.next =
|
|
5135
|
+
_context.next = 16;
|
|
5130
5136
|
break;
|
|
5131
5137
|
}
|
|
5132
5138
|
|
|
5133
5139
|
console.warn("User context setting failed --> ", error);
|
|
5134
5140
|
return _context.abrupt("return", error);
|
|
5135
5141
|
|
|
5136
|
-
case
|
|
5142
|
+
case 16:
|
|
5137
5143
|
return _context.abrupt("return", user);
|
|
5138
5144
|
|
|
5139
|
-
case
|
|
5145
|
+
case 17:
|
|
5140
5146
|
case "end":
|
|
5141
5147
|
return _context.stop();
|
|
5142
5148
|
}
|
|
@@ -5214,7 +5220,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5214
5220
|
break;
|
|
5215
5221
|
}
|
|
5216
5222
|
|
|
5217
|
-
return _context3.abrupt("return", Promise.reject(
|
|
5223
|
+
return _context3.abrupt("return", Promise.reject("Subscription id is not defined"));
|
|
5218
5224
|
|
|
5219
5225
|
case 3:
|
|
5220
5226
|
return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
|
|
@@ -5227,22 +5233,6 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5227
5233
|
}, _callee3);
|
|
5228
5234
|
})));
|
|
5229
5235
|
|
|
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
|
-
|
|
5246
5236
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscription", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4() {
|
|
5247
5237
|
var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions;
|
|
5248
5238
|
|
|
@@ -5250,8 +5240,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5250
5240
|
while (1) {
|
|
5251
5241
|
switch (_context4.prev = _context4.next) {
|
|
5252
5242
|
case 0:
|
|
5253
|
-
accessTypeKey = get__default["default"](_this.props, [
|
|
5254
|
-
isStaging = get__default["default"](_this.props, [
|
|
5243
|
+
accessTypeKey = get__default["default"](_this.props, ["accessTypeKey"]);
|
|
5244
|
+
isStaging = get__default["default"](_this.props, ["isStaging"]);
|
|
5255
5245
|
HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
|
|
5256
5246
|
|
|
5257
5247
|
accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
|
|
@@ -5275,11 +5265,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5275
5265
|
}
|
|
5276
5266
|
|
|
5277
5267
|
return _context4.abrupt("return", {
|
|
5278
|
-
error:
|
|
5268
|
+
error: "subscriptions fetch failed"
|
|
5279
5269
|
});
|
|
5280
5270
|
|
|
5281
5271
|
case 15:
|
|
5282
|
-
return _context4.abrupt("return", subscriptions[
|
|
5272
|
+
return _context4.abrupt("return", subscriptions["subscription_groups"] || []);
|
|
5283
5273
|
|
|
5284
5274
|
case 16:
|
|
5285
5275
|
case "end":
|
|
@@ -5318,7 +5308,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5318
5308
|
}
|
|
5319
5309
|
|
|
5320
5310
|
return _context5.abrupt("return", {
|
|
5321
|
-
error:
|
|
5311
|
+
error: "payment options fetch failed"
|
|
5322
5312
|
});
|
|
5323
5313
|
|
|
5324
5314
|
case 9:
|
|
@@ -5344,7 +5334,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5344
5334
|
while (1) {
|
|
5345
5335
|
switch (_context6.prev = _context6.next) {
|
|
5346
5336
|
case 0:
|
|
5347
|
-
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] :
|
|
5337
|
+
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "";
|
|
5348
5338
|
|
|
5349
5339
|
if (global.AccessType) {
|
|
5350
5340
|
_context6.next = 3;
|
|
@@ -5357,7 +5347,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5357
5347
|
_context6.next = 5;
|
|
5358
5348
|
return awaitHelper(global.AccessType.getAssetPlans({
|
|
5359
5349
|
id: storyId,
|
|
5360
|
-
type:
|
|
5350
|
+
type: "story"
|
|
5361
5351
|
}));
|
|
5362
5352
|
|
|
5363
5353
|
case 5:
|
|
@@ -5372,7 +5362,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5372
5362
|
}
|
|
5373
5363
|
|
|
5374
5364
|
return _context6.abrupt("return", {
|
|
5375
|
-
error:
|
|
5365
|
+
error: "asset plan fetch failed"
|
|
5376
5366
|
});
|
|
5377
5367
|
|
|
5378
5368
|
case 11:
|
|
@@ -5393,15 +5383,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5393
5383
|
while (1) {
|
|
5394
5384
|
switch (_context7.prev = _context7.next) {
|
|
5395
5385
|
case 0:
|
|
5396
|
-
isAccessTypeCampaignEnabled = get__default["default"](_this.props, [
|
|
5386
|
+
isAccessTypeCampaignEnabled = get__default["default"](_this.props, ["isAccessTypeCampaignEnabled"], false);
|
|
5397
5387
|
|
|
5398
5388
|
if (!isAccessTypeCampaignEnabled) {
|
|
5399
5389
|
_context7.next = 18;
|
|
5400
5390
|
break;
|
|
5401
5391
|
}
|
|
5402
5392
|
|
|
5403
|
-
accessTypeKey = get__default["default"](_this.props, [
|
|
5404
|
-
isStaging = get__default["default"](_this.props, [
|
|
5393
|
+
accessTypeKey = get__default["default"](_this.props, ["accessTypeKey"]);
|
|
5394
|
+
isStaging = get__default["default"](_this.props, ["isStaging"]);
|
|
5405
5395
|
HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
5406
5396
|
accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
|
|
5407
5397
|
_context7.t0 = awaitHelper;
|
|
@@ -5424,11 +5414,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5424
5414
|
}
|
|
5425
5415
|
|
|
5426
5416
|
return _context7.abrupt("return", {
|
|
5427
|
-
error:
|
|
5417
|
+
error: "subscriptions fetch failed"
|
|
5428
5418
|
});
|
|
5429
5419
|
|
|
5430
5420
|
case 17:
|
|
5431
|
-
return _context7.abrupt("return", campaignSubscriptions[
|
|
5421
|
+
return _context7.abrupt("return", campaignSubscriptions["subscription_groups"] || []);
|
|
5432
5422
|
|
|
5433
5423
|
case 18:
|
|
5434
5424
|
return _context7.abrupt("return", []);
|
|
@@ -5442,10 +5432,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5442
5432
|
})));
|
|
5443
5433
|
|
|
5444
5434
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee8() {
|
|
5445
|
-
var _this$props;
|
|
5446
|
-
|
|
5447
5435
|
var callback,
|
|
5448
|
-
url,
|
|
5449
5436
|
jwtResponse,
|
|
5450
5437
|
_yield$awaitHelper7,
|
|
5451
5438
|
error,
|
|
@@ -5458,18 +5445,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5458
5445
|
callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
|
|
5459
5446
|
return null;
|
|
5460
5447
|
};
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
return fetch(url);
|
|
5448
|
+
_context8.next = 3;
|
|
5449
|
+
return fetch("/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
|
|
5464
5450
|
|
|
5465
|
-
case
|
|
5451
|
+
case 3:
|
|
5466
5452
|
jwtResponse = _context8.sent;
|
|
5453
|
+
console.log("jwtresponse--------", jwtResponse);
|
|
5467
5454
|
_context8.next = 7;
|
|
5468
|
-
return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get(
|
|
5455
|
+
return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get("x-integration-token"), !!jwtResponse.headers.get("x-integration-token")));
|
|
5469
5456
|
|
|
5470
5457
|
case 7:
|
|
5471
5458
|
_yield$awaitHelper7 = _context8.sent;
|
|
5472
5459
|
error = _yield$awaitHelper7.error;
|
|
5460
|
+
console.log("error run sequencial calls------ ", error);
|
|
5473
5461
|
|
|
5474
5462
|
if (!error) {
|
|
5475
5463
|
try {
|
|
@@ -5496,7 +5484,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5496
5484
|
}
|
|
5497
5485
|
}
|
|
5498
5486
|
|
|
5499
|
-
case
|
|
5487
|
+
case 11:
|
|
5500
5488
|
case "end":
|
|
5501
5489
|
return _context8.stop();
|
|
5502
5490
|
}
|
|
@@ -5505,40 +5493,57 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5505
5493
|
})));
|
|
5506
5494
|
|
|
5507
5495
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscriptionForUser", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee9() {
|
|
5496
|
+
var _global, _window, _global2, _global2$get;
|
|
5497
|
+
|
|
5508
5498
|
var _yield$awaitHelper8, error, _yield$awaitHelper8$d, subscriptions;
|
|
5509
5499
|
|
|
5510
5500
|
return _regeneratorRuntime__default["default"].wrap(function _callee9$(_context9) {
|
|
5511
5501
|
while (1) {
|
|
5512
5502
|
switch (_context9.prev = _context9.next) {
|
|
5513
5503
|
case 0:
|
|
5504
|
+
console.log(typeof global !== 'undefined' ? 'Node.js' : 'Browser');
|
|
5505
|
+
console.log("global.Accesstype---------", (_global = global) === null || _global === void 0 ? void 0 : _global.AccessType);
|
|
5506
|
+
console.log("window.Accesstype---------", (_window = window) === null || _window === void 0 ? void 0 : _window.AccessType);
|
|
5507
|
+
console.log("global---------", global);
|
|
5508
|
+
console.log("object keys----", Object.keys(global));
|
|
5509
|
+
console.log("object keys global.window----", Object.keys(global.window));
|
|
5510
|
+
console.log("global window enumerable", Object.getOwnPropertyDescriptor(global.window, 'Accesstype'));
|
|
5511
|
+
console.log("window----------", window);
|
|
5512
|
+
console.log("global?.get?.('Accesstype')----", (_global2 = global) === null || _global2 === void 0 ? void 0 : (_global2$get = _global2.get) === null || _global2$get === void 0 ? void 0 : _global2$get.call(_global2, 'Accesstype'));
|
|
5513
|
+
setTimeout(function () {
|
|
5514
|
+
console.log("settimeout---------", global.Accesstype); // Check if it exists after some time
|
|
5515
|
+
}, 1000);
|
|
5516
|
+
|
|
5514
5517
|
if (global.AccessType) {
|
|
5515
|
-
_context9.next =
|
|
5518
|
+
_context9.next = 12;
|
|
5516
5519
|
break;
|
|
5517
5520
|
}
|
|
5518
5521
|
|
|
5519
5522
|
return _context9.abrupt("return", {});
|
|
5520
5523
|
|
|
5521
|
-
case
|
|
5522
|
-
_context9.next =
|
|
5524
|
+
case 12:
|
|
5525
|
+
_context9.next = 14;
|
|
5523
5526
|
return awaitHelper(global.AccessType.getSubscriptions());
|
|
5524
5527
|
|
|
5525
|
-
case
|
|
5528
|
+
case 14:
|
|
5526
5529
|
_yield$awaitHelper8 = _context9.sent;
|
|
5527
5530
|
error = _yield$awaitHelper8.error;
|
|
5528
5531
|
_yield$awaitHelper8$d = _yield$awaitHelper8.data;
|
|
5529
5532
|
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
5530
5533
|
|
|
5531
5534
|
if (!error) {
|
|
5532
|
-
_context9.next =
|
|
5535
|
+
_context9.next = 21;
|
|
5533
5536
|
break;
|
|
5534
5537
|
}
|
|
5535
5538
|
|
|
5539
|
+
console.log("user subscription error-------", error);
|
|
5536
5540
|
return _context9.abrupt("return", error);
|
|
5537
5541
|
|
|
5538
|
-
case
|
|
5542
|
+
case 21:
|
|
5543
|
+
console.log("subscription----------", subscriptions);
|
|
5539
5544
|
return _context9.abrupt("return", subscriptions);
|
|
5540
5545
|
|
|
5541
|
-
case
|
|
5546
|
+
case 23:
|
|
5542
5547
|
case "end":
|
|
5543
5548
|
return _context9.stop();
|
|
5544
5549
|
}
|
|
@@ -5567,11 +5572,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5567
5572
|
break;
|
|
5568
5573
|
}
|
|
5569
5574
|
|
|
5570
|
-
throw new Error(
|
|
5575
|
+
throw new Error("planId is mandatory");
|
|
5571
5576
|
|
|
5572
5577
|
case 4:
|
|
5573
5578
|
_context10.next = 6;
|
|
5574
|
-
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId,
|
|
5579
|
+
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, "switch"));
|
|
5575
5580
|
|
|
5576
5581
|
case 6:
|
|
5577
5582
|
_yield$awaitHelper9 = _context10.sent;
|
|
@@ -5604,12 +5609,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5604
5609
|
|
|
5605
5610
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initAccessType", function (callback) {
|
|
5606
5611
|
var accessTypeBkIntegrationId = _this.props.accessTypeBkIntegrationId;
|
|
5612
|
+
console.log("init accesstype-----");
|
|
5607
5613
|
|
|
5608
5614
|
try {
|
|
5609
5615
|
_this.loadScript(function () {
|
|
5610
5616
|
// dont try to initialize accessType if integration id is not available
|
|
5611
5617
|
if (accessTypeBkIntegrationId === undefined) {
|
|
5612
|
-
console.warn(
|
|
5618
|
+
console.warn("AccessType: Integration Id is undefined");
|
|
5613
5619
|
return false;
|
|
5614
5620
|
}
|
|
5615
5621
|
|
|
@@ -5648,11 +5654,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5648
5654
|
switch (_context11.prev = _context11.next) {
|
|
5649
5655
|
case 0:
|
|
5650
5656
|
selectedPlanObj = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
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] :
|
|
5657
|
+
planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
|
|
5658
|
+
storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : "";
|
|
5659
|
+
storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : "";
|
|
5660
|
+
storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : "";
|
|
5661
|
+
paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : "";
|
|
5656
5662
|
opts = _args11.length > 6 ? _args11[6] : undefined;
|
|
5657
5663
|
|
|
5658
5664
|
if (selectedPlanObj) {
|
|
@@ -5660,15 +5666,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5660
5666
|
break;
|
|
5661
5667
|
}
|
|
5662
5668
|
|
|
5663
|
-
console.warn(
|
|
5669
|
+
console.warn("Razor pay needs a plan");
|
|
5664
5670
|
return _context11.abrupt("return", false);
|
|
5665
5671
|
|
|
5666
5672
|
case 10:
|
|
5667
|
-
intent = get__default["default"](opts, [
|
|
5668
|
-
switchType = get__default["default"](opts, [
|
|
5673
|
+
intent = get__default["default"](opts, ["intent"], "default");
|
|
5674
|
+
switchType = get__default["default"](opts, ["switchType"]);
|
|
5669
5675
|
planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
|
|
5670
5676
|
|
|
5671
|
-
planObject[
|
|
5677
|
+
planObject["paymentType"] = paymentType || (get__default["default"](planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
|
|
5672
5678
|
paymentOptions = _this.props.paymentOptions;
|
|
5673
5679
|
_planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
|
|
5674
5680
|
paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
@@ -5699,13 +5705,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5699
5705
|
}));
|
|
5700
5706
|
|
|
5701
5707
|
case 25:
|
|
5702
|
-
if (!(intent ===
|
|
5708
|
+
if (!(intent === "switch")) {
|
|
5703
5709
|
_context11.next = 34;
|
|
5704
5710
|
break;
|
|
5705
5711
|
}
|
|
5706
5712
|
|
|
5707
5713
|
_context11.next = 28;
|
|
5708
|
-
return awaitHelper(global.AccessType.getPaymentOptions(null, null,
|
|
5714
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
|
|
5709
5715
|
|
|
5710
5716
|
case 28:
|
|
5711
5717
|
_yield$awaitHelper11 = _context11.sent;
|
|
@@ -5717,7 +5723,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5717
5723
|
break;
|
|
5718
5724
|
}
|
|
5719
5725
|
|
|
5720
|
-
throw new Error(
|
|
5726
|
+
throw new Error("payment options fetch failed");
|
|
5721
5727
|
|
|
5722
5728
|
case 33:
|
|
5723
5729
|
return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
@@ -5741,19 +5747,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5741
5747
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5742
5748
|
|
|
5743
5749
|
if (!options.selectedPlan) {
|
|
5744
|
-
console.warn(
|
|
5750
|
+
console.warn("Stripe pay needs a plan");
|
|
5745
5751
|
return false;
|
|
5746
5752
|
}
|
|
5747
5753
|
|
|
5748
5754
|
var paymentOptions = _this.props.paymentOptions;
|
|
5749
|
-
var paymentType = get__default["default"](options.selectedPlan, [
|
|
5755
|
+
var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "stripe_recurring" : "stripe";
|
|
5750
5756
|
|
|
5751
5757
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
5752
5758
|
paymentType: paymentType
|
|
5753
5759
|
}, options));
|
|
5754
5760
|
|
|
5755
5761
|
return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
5756
|
-
message:
|
|
5762
|
+
message: "Payment option is loading..."
|
|
5757
5763
|
});
|
|
5758
5764
|
});
|
|
5759
5765
|
|
|
@@ -5761,12 +5767,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5761
5767
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5762
5768
|
|
|
5763
5769
|
if (!options.selectedPlan) {
|
|
5764
|
-
console.warn(
|
|
5770
|
+
console.warn("Paypal pay needs a plan");
|
|
5765
5771
|
return false;
|
|
5766
5772
|
}
|
|
5767
5773
|
|
|
5768
5774
|
var paymentOptions = _this.props.paymentOptions;
|
|
5769
|
-
var paymentType = get__default["default"](options.selectedPlan, [
|
|
5775
|
+
var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "paypal_recurring" : "paypal";
|
|
5770
5776
|
|
|
5771
5777
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
5772
5778
|
paymentType: paymentType
|
|
@@ -5775,30 +5781,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5775
5781
|
return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
|
|
5776
5782
|
return response.proceed(paymentObject);
|
|
5777
5783
|
}) : Promise.reject({
|
|
5778
|
-
message:
|
|
5784
|
+
message: "Payment option is loading..."
|
|
5779
5785
|
});
|
|
5780
5786
|
});
|
|
5781
5787
|
|
|
5782
5788
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initOmisePayment", function () {
|
|
5783
5789
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5784
|
-
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
5790
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
5785
5791
|
|
|
5786
5792
|
if (!selectedPlanObj) {
|
|
5787
|
-
console.warn(
|
|
5793
|
+
console.warn("Omise pay needs a plan");
|
|
5788
5794
|
return false;
|
|
5789
5795
|
}
|
|
5790
5796
|
|
|
5791
5797
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
5792
5798
|
|
|
5793
|
-
planObject[
|
|
5799
|
+
planObject["paymentType"] = get__default["default"](planObject, ["selectedPlan", "recurring"]) ? "omise_recurring" : "omise";
|
|
5794
5800
|
|
|
5795
5801
|
var paymentObject = _this.makePaymentObject(planObject);
|
|
5796
5802
|
|
|
5797
|
-
var omise = get__default["default"](_this.props, [
|
|
5803
|
+
var omise = get__default["default"](_this.props, ["paymentOptions", "omise"]);
|
|
5798
5804
|
|
|
5799
5805
|
if (!omise) {
|
|
5800
5806
|
return Promise.reject({
|
|
5801
|
-
message:
|
|
5807
|
+
message: "Payment option is loading..."
|
|
5802
5808
|
});
|
|
5803
5809
|
}
|
|
5804
5810
|
|
|
@@ -5809,31 +5815,31 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5809
5815
|
|
|
5810
5816
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initAdyenPayment", function () {
|
|
5811
5817
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5812
|
-
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
5818
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
5813
5819
|
var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
|
|
5814
5820
|
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
5815
5821
|
|
|
5816
5822
|
var adyenExecutor = function adyenExecutor(resolve, reject) {
|
|
5817
|
-
if (!document.getElementById(
|
|
5818
|
-
var modalElement = document.createElement(
|
|
5819
|
-
modalElement.setAttribute(
|
|
5823
|
+
if (!document.getElementById("adyen-modal")) {
|
|
5824
|
+
var modalElement = document.createElement("div");
|
|
5825
|
+
modalElement.setAttribute("id", "adyen-modal");
|
|
5820
5826
|
document.body.appendChild(modalElement);
|
|
5821
5827
|
}
|
|
5822
5828
|
|
|
5823
5829
|
var afterOpen = function afterOpen() {
|
|
5824
5830
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
5825
5831
|
|
|
5826
|
-
var isRecurring = get__default["default"](planObject, [
|
|
5827
|
-
var paymentType = isRecurring ?
|
|
5832
|
+
var isRecurring = get__default["default"](planObject, ["selectedPlan", "recurring"]);
|
|
5833
|
+
var paymentType = isRecurring ? "adyen_recurring" : "adyen";
|
|
5828
5834
|
|
|
5829
5835
|
var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
5830
5836
|
paymentType: paymentType
|
|
5831
5837
|
}));
|
|
5832
5838
|
|
|
5833
|
-
var adyen = get__default["default"](_this.props, [
|
|
5839
|
+
var adyen = get__default["default"](_this.props, ["paymentOptions", "adyen"]);
|
|
5834
5840
|
paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
5835
|
-
options: _objectSpread(_objectSpread({}, paymentObject[
|
|
5836
|
-
dropin_container_id:
|
|
5841
|
+
options: _objectSpread(_objectSpread({}, paymentObject["options"]), {}, {
|
|
5842
|
+
dropin_container_id: "dropin-adyen",
|
|
5837
5843
|
locale: locale
|
|
5838
5844
|
}),
|
|
5839
5845
|
additional_data: {
|
|
@@ -5848,7 +5854,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5848
5854
|
ReactDOM__default["default"].render( /*#__PURE__*/React__default["default"].createElement(AdyenModal, {
|
|
5849
5855
|
afterOpen: afterOpen,
|
|
5850
5856
|
afterClose: reject
|
|
5851
|
-
}), document.getElementById(
|
|
5857
|
+
}), document.getElementById("adyen-modal"));
|
|
5852
5858
|
};
|
|
5853
5859
|
|
|
5854
5860
|
return new Promise(adyenExecutor);
|
|
@@ -5858,12 +5864,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5858
5864
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
5859
5865
|
|
|
5860
5866
|
if (!options.selectedPlan) {
|
|
5861
|
-
console.warn(
|
|
5867
|
+
console.warn("Paytrail needs a plan");
|
|
5862
5868
|
return false;
|
|
5863
5869
|
}
|
|
5864
5870
|
|
|
5865
5871
|
var paymentOptions = _this.props.paymentOptions;
|
|
5866
|
-
var paymentType = get__default["default"](options.selectedPlan, [
|
|
5872
|
+
var paymentType = get__default["default"](options.selectedPlan, ["recurring"]) ? "paytrail_recurring" : "paytrail";
|
|
5867
5873
|
|
|
5868
5874
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
5869
5875
|
paymentType: paymentType
|
|
@@ -5872,7 +5878,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5872
5878
|
return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
|
|
5873
5879
|
return response.proceed(paymentObject);
|
|
5874
5880
|
}) : Promise.reject({
|
|
5875
|
-
message:
|
|
5881
|
+
message: "Payment option is loading..."
|
|
5876
5882
|
});
|
|
5877
5883
|
});
|
|
5878
5884
|
|
|
@@ -5885,7 +5891,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5885
5891
|
try {
|
|
5886
5892
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
5887
5893
|
} catch (e) {
|
|
5888
|
-
console.log(
|
|
5894
|
+
console.log("error in pingbackAssetAccess", e);
|
|
5889
5895
|
}
|
|
5890
5896
|
|
|
5891
5897
|
return _context12.abrupt("return", true);
|
|
@@ -5916,7 +5922,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5916
5922
|
break;
|
|
5917
5923
|
}
|
|
5918
5924
|
|
|
5919
|
-
console.warn(
|
|
5925
|
+
console.warn("AssetId is required");
|
|
5920
5926
|
return _context13.abrupt("return", false);
|
|
5921
5927
|
|
|
5922
5928
|
case 3:
|
|
@@ -5924,7 +5930,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5924
5930
|
|
|
5925
5931
|
asset = {
|
|
5926
5932
|
id: assetId,
|
|
5927
|
-
type:
|
|
5933
|
+
type: "story"
|
|
5928
5934
|
};
|
|
5929
5935
|
_context13.next = 7;
|
|
5930
5936
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
@@ -5950,7 +5956,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5950
5956
|
|
|
5951
5957
|
_ref16 = accessData || {}, granted = _ref16.granted, grantReason = _ref16.grantReason, _ref16$data = _ref16.data, data = _ref16$data === void 0 ? {} : _ref16$data;
|
|
5952
5958
|
|
|
5953
|
-
if (!_this.props.disableMetering && granted && grantReason ===
|
|
5959
|
+
if (!_this.props.disableMetering && granted && grantReason === "METERING") {
|
|
5954
5960
|
_this.pingBackMeteredStory(asset, accessData);
|
|
5955
5961
|
|
|
5956
5962
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
@@ -6035,8 +6041,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6035
6041
|
};
|
|
6036
6042
|
}());
|
|
6037
6043
|
|
|
6038
|
-
_this.prodHost = props.prodHost ||
|
|
6039
|
-
_this.stagingHost = props.stagingHost ||
|
|
6044
|
+
_this.prodHost = props.prodHost || "https://www.accesstype.com";
|
|
6045
|
+
_this.stagingHost = props.stagingHost || "https://staging.accesstype.com";
|
|
6040
6046
|
return _this;
|
|
6041
6047
|
}
|
|
6042
6048
|
|
|
@@ -6051,25 +6057,25 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6051
6057
|
var _ref19$selectedPlan = _ref19.selectedPlan,
|
|
6052
6058
|
selectedPlan = _ref19$selectedPlan === void 0 ? {} : _ref19$selectedPlan,
|
|
6053
6059
|
_ref19$couponCode = _ref19.couponCode,
|
|
6054
|
-
couponCode = _ref19$couponCode === void 0 ?
|
|
6060
|
+
couponCode = _ref19$couponCode === void 0 ? "" : _ref19$couponCode,
|
|
6055
6061
|
_ref19$recipientSubsc = _ref19.recipientSubscriber,
|
|
6056
6062
|
recipientSubscriber = _ref19$recipientSubsc === void 0 ? {} : _ref19$recipientSubsc,
|
|
6057
6063
|
_ref19$planType = _ref19.planType,
|
|
6058
|
-
planType = _ref19$planType === void 0 ?
|
|
6064
|
+
planType = _ref19$planType === void 0 ? "" : _ref19$planType,
|
|
6059
6065
|
_ref19$storyId = _ref19.storyId,
|
|
6060
|
-
storyId = _ref19$storyId === void 0 ?
|
|
6066
|
+
storyId = _ref19$storyId === void 0 ? "" : _ref19$storyId,
|
|
6061
6067
|
_ref19$storyHeadline = _ref19.storyHeadline,
|
|
6062
|
-
storyHeadline = _ref19$storyHeadline === void 0 ?
|
|
6068
|
+
storyHeadline = _ref19$storyHeadline === void 0 ? "" : _ref19$storyHeadline,
|
|
6063
6069
|
_ref19$storySlug = _ref19.storySlug,
|
|
6064
|
-
storySlug = _ref19$storySlug === void 0 ?
|
|
6070
|
+
storySlug = _ref19$storySlug === void 0 ? "" : _ref19$storySlug,
|
|
6065
6071
|
_ref19$paymentType = _ref19.paymentType,
|
|
6066
|
-
paymentType = _ref19$paymentType === void 0 ?
|
|
6072
|
+
paymentType = _ref19$paymentType === void 0 ? "" : _ref19$paymentType,
|
|
6067
6073
|
_ref19$successUrl = _ref19.successUrl,
|
|
6068
|
-
successUrl = _ref19$successUrl === void 0 ?
|
|
6074
|
+
successUrl = _ref19$successUrl === void 0 ? "" : _ref19$successUrl,
|
|
6069
6075
|
_ref19$returnUrl = _ref19.returnUrl,
|
|
6070
|
-
returnUrl = _ref19$returnUrl === void 0 ?
|
|
6076
|
+
returnUrl = _ref19$returnUrl === void 0 ? "" : _ref19$returnUrl,
|
|
6071
6077
|
_ref19$cancelUrl = _ref19.cancelUrl,
|
|
6072
|
-
cancelUrl = _ref19$cancelUrl === void 0 ?
|
|
6078
|
+
cancelUrl = _ref19$cancelUrl === void 0 ? "" : _ref19$cancelUrl;
|
|
6073
6079
|
var id = selectedPlan.id,
|
|
6074
6080
|
title = selectedPlan.title,
|
|
6075
6081
|
description = selectedPlan.description,
|
|
@@ -6114,9 +6120,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6114
6120
|
};
|
|
6115
6121
|
|
|
6116
6122
|
if (returnUrl) {
|
|
6117
|
-
paymentObject.options.urls[
|
|
6123
|
+
paymentObject.options.urls["return_url"] = returnUrl;
|
|
6118
6124
|
} else {
|
|
6119
|
-
paymentObject.options.urls[
|
|
6125
|
+
paymentObject.options.urls["success_url"] = successUrl;
|
|
6120
6126
|
}
|
|
6121
6127
|
}
|
|
6122
6128
|
|
|
@@ -6126,11 +6132,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6126
6132
|
key: "makePlanObject",
|
|
6127
6133
|
value: function makePlanObject() {
|
|
6128
6134
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
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 ===
|
|
6135
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
6136
|
+
var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
6137
|
+
var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
6138
|
+
var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
6139
|
+
return selectedPlanObj.argType && selectedPlanObj.argType === "options" ? {
|
|
6134
6140
|
selectedPlan: selectedPlanObj.selectedPlan,
|
|
6135
6141
|
planType: selectedPlanObj.planType,
|
|
6136
6142
|
storyId: selectedPlanObj.storyId,
|