@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
|
@@ -18,13 +18,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
18
18
|
|
|
19
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
20
|
|
|
21
|
-
import get from
|
|
22
|
-
import { bool, func, number, string } from
|
|
23
|
-
import React from
|
|
24
|
-
import ReactDOM from
|
|
25
|
-
import { batch, connect } from
|
|
26
|
-
import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from
|
|
27
|
-
import { awaitHelper } from
|
|
21
|
+
import get from "lodash/get";
|
|
22
|
+
import { bool, func, number, string } from "prop-types";
|
|
23
|
+
import React from "react";
|
|
24
|
+
import ReactDOM from "react-dom";
|
|
25
|
+
import { batch, connect } from "react-redux";
|
|
26
|
+
import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from "../store/actions";
|
|
27
|
+
import { awaitHelper } from "../utils";
|
|
28
28
|
|
|
29
29
|
var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
30
30
|
_inherits(AccessTypeBase, _React$Component);
|
|
@@ -39,30 +39,32 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
39
39
|
_this = _super.call(this, props);
|
|
40
40
|
|
|
41
41
|
_defineProperty(_assertThisInitialized(_this), "loadScript", function (callback) {
|
|
42
|
-
var accessTypeKey = get(_this.props, [
|
|
43
|
-
var isStaging = get(_this.props, [
|
|
44
|
-
var enableAccesstype = get(_this.props, [
|
|
42
|
+
var accessTypeKey = get(_this.props, ["accessTypeKey"]);
|
|
43
|
+
var isStaging = get(_this.props, ["isStaging"]);
|
|
44
|
+
var enableAccesstype = get(_this.props, ["enableAccesstype"]);
|
|
45
|
+
console.log("loadscript===============", _this.props);
|
|
45
46
|
|
|
46
47
|
if (!enableAccesstype) {
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
var HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
51
|
-
var environment = isStaging ?
|
|
52
|
+
var environment = isStaging ? "&env=sandbox" : "";
|
|
52
53
|
var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
|
|
53
54
|
var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
|
|
54
55
|
|
|
55
56
|
if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
|
|
56
|
-
|
|
57
|
+
console.log("coming in creating the script---------");
|
|
58
|
+
var accessTypeScript = document.createElement("script");
|
|
57
59
|
|
|
58
60
|
accessTypeScript.onload = function () {
|
|
59
61
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
60
62
|
callback();
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
accessTypeScript.setAttribute(
|
|
64
|
-
accessTypeScript.setAttribute(
|
|
65
|
-
accessTypeScript.setAttribute(
|
|
65
|
+
accessTypeScript.setAttribute("src", accessTypeHost);
|
|
66
|
+
accessTypeScript.setAttribute("id", "AccessTypeScript");
|
|
67
|
+
accessTypeScript.setAttribute("data-accessType-script", "1");
|
|
66
68
|
accessTypeScript.async = 1;
|
|
67
69
|
document.body.appendChild(accessTypeScript);
|
|
68
70
|
return true;
|
|
@@ -90,15 +92,17 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
90
92
|
switch (_context.prev = _context.next) {
|
|
91
93
|
case 0:
|
|
92
94
|
isLoggedIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
|
|
95
|
+
console.log("set user global.AccessType--", global.AccessType);
|
|
96
|
+
console.log("set user props-------", emailAddress, mobileNumber, accesstypeJwt, isLoggedIn);
|
|
93
97
|
|
|
94
98
|
if (global.AccessType) {
|
|
95
|
-
_context.next =
|
|
99
|
+
_context.next = 5;
|
|
96
100
|
break;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
return _context.abrupt("return", null);
|
|
100
104
|
|
|
101
|
-
case
|
|
105
|
+
case 5:
|
|
102
106
|
userObj = isLoggedIn ? {
|
|
103
107
|
emailAddress: emailAddress,
|
|
104
108
|
mobileNumber: mobileNumber,
|
|
@@ -106,26 +110,28 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
106
110
|
} : {
|
|
107
111
|
isLoggedIn: false
|
|
108
112
|
};
|
|
109
|
-
_context.next =
|
|
113
|
+
_context.next = 8;
|
|
110
114
|
return awaitHelper(global.AccessType.setUser(userObj));
|
|
111
115
|
|
|
112
|
-
case
|
|
116
|
+
case 8:
|
|
113
117
|
_yield$awaitHelper = _context.sent;
|
|
114
118
|
error = _yield$awaitHelper.error;
|
|
115
119
|
user = _yield$awaitHelper.data;
|
|
120
|
+
console.log("set user error-------", error);
|
|
121
|
+
console.log("set user user-------", user);
|
|
116
122
|
|
|
117
123
|
if (!error) {
|
|
118
|
-
_context.next =
|
|
124
|
+
_context.next = 16;
|
|
119
125
|
break;
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
console.warn("User context setting failed --> ", error);
|
|
123
129
|
return _context.abrupt("return", error);
|
|
124
130
|
|
|
125
|
-
case
|
|
131
|
+
case 16:
|
|
126
132
|
return _context.abrupt("return", user);
|
|
127
133
|
|
|
128
|
-
case
|
|
134
|
+
case 17:
|
|
129
135
|
case "end":
|
|
130
136
|
return _context.stop();
|
|
131
137
|
}
|
|
@@ -203,7 +209,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
203
209
|
break;
|
|
204
210
|
}
|
|
205
211
|
|
|
206
|
-
return _context3.abrupt("return", Promise.reject(
|
|
212
|
+
return _context3.abrupt("return", Promise.reject("Subscription id is not defined"));
|
|
207
213
|
|
|
208
214
|
case 3:
|
|
209
215
|
return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
|
|
@@ -216,22 +222,6 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
216
222
|
}, _callee3);
|
|
217
223
|
})));
|
|
218
224
|
|
|
219
|
-
_defineProperty(_assertThisInitialized(_this), "getPath", function (sketchesHost, relativePath) {
|
|
220
|
-
try {
|
|
221
|
-
var _URL = new URL(sketchesHost),
|
|
222
|
-
pathname = _URL.pathname;
|
|
223
|
-
|
|
224
|
-
if (pathname && pathname !== '/') {
|
|
225
|
-
return "".concat(sketchesHost).concat(relativePath);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return relativePath;
|
|
229
|
-
} catch (err) {
|
|
230
|
-
console.log('Sketches host path error ---> ', err);
|
|
231
|
-
return relativePath;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
225
|
_defineProperty(_assertThisInitialized(_this), "getSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
236
226
|
var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions;
|
|
237
227
|
|
|
@@ -239,8 +229,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
239
229
|
while (1) {
|
|
240
230
|
switch (_context4.prev = _context4.next) {
|
|
241
231
|
case 0:
|
|
242
|
-
accessTypeKey = get(_this.props, [
|
|
243
|
-
isStaging = get(_this.props, [
|
|
232
|
+
accessTypeKey = get(_this.props, ["accessTypeKey"]);
|
|
233
|
+
isStaging = get(_this.props, ["isStaging"]);
|
|
244
234
|
HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
|
|
245
235
|
|
|
246
236
|
accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
|
|
@@ -264,11 +254,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
264
254
|
}
|
|
265
255
|
|
|
266
256
|
return _context4.abrupt("return", {
|
|
267
|
-
error:
|
|
257
|
+
error: "subscriptions fetch failed"
|
|
268
258
|
});
|
|
269
259
|
|
|
270
260
|
case 15:
|
|
271
|
-
return _context4.abrupt("return", subscriptions[
|
|
261
|
+
return _context4.abrupt("return", subscriptions["subscription_groups"] || []);
|
|
272
262
|
|
|
273
263
|
case 16:
|
|
274
264
|
case "end":
|
|
@@ -307,7 +297,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
307
297
|
}
|
|
308
298
|
|
|
309
299
|
return _context5.abrupt("return", {
|
|
310
|
-
error:
|
|
300
|
+
error: "payment options fetch failed"
|
|
311
301
|
});
|
|
312
302
|
|
|
313
303
|
case 9:
|
|
@@ -333,7 +323,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
333
323
|
while (1) {
|
|
334
324
|
switch (_context6.prev = _context6.next) {
|
|
335
325
|
case 0:
|
|
336
|
-
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] :
|
|
326
|
+
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : "";
|
|
337
327
|
|
|
338
328
|
if (global.AccessType) {
|
|
339
329
|
_context6.next = 3;
|
|
@@ -346,7 +336,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
346
336
|
_context6.next = 5;
|
|
347
337
|
return awaitHelper(global.AccessType.getAssetPlans({
|
|
348
338
|
id: storyId,
|
|
349
|
-
type:
|
|
339
|
+
type: "story"
|
|
350
340
|
}));
|
|
351
341
|
|
|
352
342
|
case 5:
|
|
@@ -361,7 +351,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
361
351
|
}
|
|
362
352
|
|
|
363
353
|
return _context6.abrupt("return", {
|
|
364
|
-
error:
|
|
354
|
+
error: "asset plan fetch failed"
|
|
365
355
|
});
|
|
366
356
|
|
|
367
357
|
case 11:
|
|
@@ -382,15 +372,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
382
372
|
while (1) {
|
|
383
373
|
switch (_context7.prev = _context7.next) {
|
|
384
374
|
case 0:
|
|
385
|
-
isAccessTypeCampaignEnabled = get(_this.props, [
|
|
375
|
+
isAccessTypeCampaignEnabled = get(_this.props, ["isAccessTypeCampaignEnabled"], false);
|
|
386
376
|
|
|
387
377
|
if (!isAccessTypeCampaignEnabled) {
|
|
388
378
|
_context7.next = 18;
|
|
389
379
|
break;
|
|
390
380
|
}
|
|
391
381
|
|
|
392
|
-
accessTypeKey = get(_this.props, [
|
|
393
|
-
isStaging = get(_this.props, [
|
|
382
|
+
accessTypeKey = get(_this.props, ["accessTypeKey"]);
|
|
383
|
+
isStaging = get(_this.props, ["isStaging"]);
|
|
394
384
|
HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
395
385
|
accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
|
|
396
386
|
_context7.t0 = awaitHelper;
|
|
@@ -413,11 +403,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
413
403
|
}
|
|
414
404
|
|
|
415
405
|
return _context7.abrupt("return", {
|
|
416
|
-
error:
|
|
406
|
+
error: "subscriptions fetch failed"
|
|
417
407
|
});
|
|
418
408
|
|
|
419
409
|
case 17:
|
|
420
|
-
return _context7.abrupt("return", campaignSubscriptions[
|
|
410
|
+
return _context7.abrupt("return", campaignSubscriptions["subscription_groups"] || []);
|
|
421
411
|
|
|
422
412
|
case 18:
|
|
423
413
|
return _context7.abrupt("return", []);
|
|
@@ -431,10 +421,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
431
421
|
})));
|
|
432
422
|
|
|
433
423
|
_defineProperty(_assertThisInitialized(_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
434
|
-
var _this$props;
|
|
435
|
-
|
|
436
424
|
var callback,
|
|
437
|
-
url,
|
|
438
425
|
jwtResponse,
|
|
439
426
|
_yield$awaitHelper7,
|
|
440
427
|
error,
|
|
@@ -447,18 +434,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
447
434
|
callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
|
|
448
435
|
return null;
|
|
449
436
|
};
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return fetch(url);
|
|
437
|
+
_context8.next = 3;
|
|
438
|
+
return fetch("/api/auth/v1/access-token/integrations/".concat(_this.props.accessTypeBkIntegrationId));
|
|
453
439
|
|
|
454
|
-
case
|
|
440
|
+
case 3:
|
|
455
441
|
jwtResponse = _context8.sent;
|
|
442
|
+
console.log("jwtresponse--------", jwtResponse);
|
|
456
443
|
_context8.next = 7;
|
|
457
|
-
return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get(
|
|
444
|
+
return awaitHelper(_this.setUser(_this.props.email, _this.props.phone, jwtResponse.headers.get("x-integration-token"), !!jwtResponse.headers.get("x-integration-token")));
|
|
458
445
|
|
|
459
446
|
case 7:
|
|
460
447
|
_yield$awaitHelper7 = _context8.sent;
|
|
461
448
|
error = _yield$awaitHelper7.error;
|
|
449
|
+
console.log("error run sequencial calls------ ", error);
|
|
462
450
|
|
|
463
451
|
if (!error) {
|
|
464
452
|
try {
|
|
@@ -485,7 +473,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
485
473
|
}
|
|
486
474
|
}
|
|
487
475
|
|
|
488
|
-
case
|
|
476
|
+
case 11:
|
|
489
477
|
case "end":
|
|
490
478
|
return _context8.stop();
|
|
491
479
|
}
|
|
@@ -494,40 +482,57 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
494
482
|
})));
|
|
495
483
|
|
|
496
484
|
_defineProperty(_assertThisInitialized(_this), "getSubscriptionForUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
485
|
+
var _global, _window, _global2, _global2$get;
|
|
486
|
+
|
|
497
487
|
var _yield$awaitHelper8, error, _yield$awaitHelper8$d, subscriptions;
|
|
498
488
|
|
|
499
489
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
500
490
|
while (1) {
|
|
501
491
|
switch (_context9.prev = _context9.next) {
|
|
502
492
|
case 0:
|
|
493
|
+
console.log(typeof global !== 'undefined' ? 'Node.js' : 'Browser');
|
|
494
|
+
console.log("global.Accesstype---------", (_global = global) === null || _global === void 0 ? void 0 : _global.AccessType);
|
|
495
|
+
console.log("window.Accesstype---------", (_window = window) === null || _window === void 0 ? void 0 : _window.AccessType);
|
|
496
|
+
console.log("global---------", global);
|
|
497
|
+
console.log("object keys----", Object.keys(global));
|
|
498
|
+
console.log("object keys global.window----", Object.keys(global.window));
|
|
499
|
+
console.log("global window enumerable", Object.getOwnPropertyDescriptor(global.window, 'Accesstype'));
|
|
500
|
+
console.log("window----------", window);
|
|
501
|
+
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'));
|
|
502
|
+
setTimeout(function () {
|
|
503
|
+
console.log("settimeout---------", global.Accesstype); // Check if it exists after some time
|
|
504
|
+
}, 1000);
|
|
505
|
+
|
|
503
506
|
if (global.AccessType) {
|
|
504
|
-
_context9.next =
|
|
507
|
+
_context9.next = 12;
|
|
505
508
|
break;
|
|
506
509
|
}
|
|
507
510
|
|
|
508
511
|
return _context9.abrupt("return", {});
|
|
509
512
|
|
|
510
|
-
case
|
|
511
|
-
_context9.next =
|
|
513
|
+
case 12:
|
|
514
|
+
_context9.next = 14;
|
|
512
515
|
return awaitHelper(global.AccessType.getSubscriptions());
|
|
513
516
|
|
|
514
|
-
case
|
|
517
|
+
case 14:
|
|
515
518
|
_yield$awaitHelper8 = _context9.sent;
|
|
516
519
|
error = _yield$awaitHelper8.error;
|
|
517
520
|
_yield$awaitHelper8$d = _yield$awaitHelper8.data;
|
|
518
521
|
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
519
522
|
|
|
520
523
|
if (!error) {
|
|
521
|
-
_context9.next =
|
|
524
|
+
_context9.next = 21;
|
|
522
525
|
break;
|
|
523
526
|
}
|
|
524
527
|
|
|
528
|
+
console.log("user subscription error-------", error);
|
|
525
529
|
return _context9.abrupt("return", error);
|
|
526
530
|
|
|
527
|
-
case
|
|
531
|
+
case 21:
|
|
532
|
+
console.log("subscription----------", subscriptions);
|
|
528
533
|
return _context9.abrupt("return", subscriptions);
|
|
529
534
|
|
|
530
|
-
case
|
|
535
|
+
case 23:
|
|
531
536
|
case "end":
|
|
532
537
|
return _context9.stop();
|
|
533
538
|
}
|
|
@@ -556,11 +561,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
556
561
|
break;
|
|
557
562
|
}
|
|
558
563
|
|
|
559
|
-
throw new Error(
|
|
564
|
+
throw new Error("planId is mandatory");
|
|
560
565
|
|
|
561
566
|
case 4:
|
|
562
567
|
_context10.next = 6;
|
|
563
|
-
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId,
|
|
568
|
+
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, "switch"));
|
|
564
569
|
|
|
565
570
|
case 6:
|
|
566
571
|
_yield$awaitHelper9 = _context10.sent;
|
|
@@ -593,12 +598,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
593
598
|
|
|
594
599
|
_defineProperty(_assertThisInitialized(_this), "initAccessType", function (callback) {
|
|
595
600
|
var accessTypeBkIntegrationId = _this.props.accessTypeBkIntegrationId;
|
|
601
|
+
console.log("init accesstype-----");
|
|
596
602
|
|
|
597
603
|
try {
|
|
598
604
|
_this.loadScript(function () {
|
|
599
605
|
// dont try to initialize accessType if integration id is not available
|
|
600
606
|
if (accessTypeBkIntegrationId === undefined) {
|
|
601
|
-
console.warn(
|
|
607
|
+
console.warn("AccessType: Integration Id is undefined");
|
|
602
608
|
return false;
|
|
603
609
|
}
|
|
604
610
|
|
|
@@ -637,11 +643,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
637
643
|
switch (_context11.prev = _context11.next) {
|
|
638
644
|
case 0:
|
|
639
645
|
selectedPlanObj = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
640
|
-
planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] :
|
|
641
|
-
storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] :
|
|
642
|
-
storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] :
|
|
643
|
-
storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] :
|
|
644
|
-
paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] :
|
|
646
|
+
planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
|
|
647
|
+
storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : "";
|
|
648
|
+
storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : "";
|
|
649
|
+
storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : "";
|
|
650
|
+
paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : "";
|
|
645
651
|
opts = _args11.length > 6 ? _args11[6] : undefined;
|
|
646
652
|
|
|
647
653
|
if (selectedPlanObj) {
|
|
@@ -649,15 +655,15 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
649
655
|
break;
|
|
650
656
|
}
|
|
651
657
|
|
|
652
|
-
console.warn(
|
|
658
|
+
console.warn("Razor pay needs a plan");
|
|
653
659
|
return _context11.abrupt("return", false);
|
|
654
660
|
|
|
655
661
|
case 10:
|
|
656
|
-
intent = get(opts, [
|
|
657
|
-
switchType = get(opts, [
|
|
662
|
+
intent = get(opts, ["intent"], "default");
|
|
663
|
+
switchType = get(opts, ["switchType"]);
|
|
658
664
|
planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
|
|
659
665
|
|
|
660
|
-
planObject[
|
|
666
|
+
planObject["paymentType"] = paymentType || (get(planObject, ["selectedPlan", "recurring"]) ? "razorpay_recurring" : "razorpay");
|
|
661
667
|
paymentOptions = _this.props.paymentOptions;
|
|
662
668
|
_planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
|
|
663
669
|
paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
@@ -688,13 +694,13 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
688
694
|
}));
|
|
689
695
|
|
|
690
696
|
case 25:
|
|
691
|
-
if (!(intent ===
|
|
697
|
+
if (!(intent === "switch")) {
|
|
692
698
|
_context11.next = 34;
|
|
693
699
|
break;
|
|
694
700
|
}
|
|
695
701
|
|
|
696
702
|
_context11.next = 28;
|
|
697
|
-
return awaitHelper(global.AccessType.getPaymentOptions(null, null,
|
|
703
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
|
|
698
704
|
|
|
699
705
|
case 28:
|
|
700
706
|
_yield$awaitHelper11 = _context11.sent;
|
|
@@ -706,7 +712,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
706
712
|
break;
|
|
707
713
|
}
|
|
708
714
|
|
|
709
|
-
throw new Error(
|
|
715
|
+
throw new Error("payment options fetch failed");
|
|
710
716
|
|
|
711
717
|
case 33:
|
|
712
718
|
return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
@@ -730,19 +736,19 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
730
736
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
731
737
|
|
|
732
738
|
if (!options.selectedPlan) {
|
|
733
|
-
console.warn(
|
|
739
|
+
console.warn("Stripe pay needs a plan");
|
|
734
740
|
return false;
|
|
735
741
|
}
|
|
736
742
|
|
|
737
743
|
var paymentOptions = _this.props.paymentOptions;
|
|
738
|
-
var paymentType = get(options.selectedPlan, [
|
|
744
|
+
var paymentType = get(options.selectedPlan, ["recurring"]) ? "stripe_recurring" : "stripe";
|
|
739
745
|
|
|
740
746
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
741
747
|
paymentType: paymentType
|
|
742
748
|
}, options));
|
|
743
749
|
|
|
744
750
|
return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
745
|
-
message:
|
|
751
|
+
message: "Payment option is loading..."
|
|
746
752
|
});
|
|
747
753
|
});
|
|
748
754
|
|
|
@@ -750,12 +756,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
750
756
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
751
757
|
|
|
752
758
|
if (!options.selectedPlan) {
|
|
753
|
-
console.warn(
|
|
759
|
+
console.warn("Paypal pay needs a plan");
|
|
754
760
|
return false;
|
|
755
761
|
}
|
|
756
762
|
|
|
757
763
|
var paymentOptions = _this.props.paymentOptions;
|
|
758
|
-
var paymentType = get(options.selectedPlan, [
|
|
764
|
+
var paymentType = get(options.selectedPlan, ["recurring"]) ? "paypal_recurring" : "paypal";
|
|
759
765
|
|
|
760
766
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
761
767
|
paymentType: paymentType
|
|
@@ -764,30 +770,30 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
764
770
|
return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
|
|
765
771
|
return response.proceed(paymentObject);
|
|
766
772
|
}) : Promise.reject({
|
|
767
|
-
message:
|
|
773
|
+
message: "Payment option is loading..."
|
|
768
774
|
});
|
|
769
775
|
});
|
|
770
776
|
|
|
771
777
|
_defineProperty(_assertThisInitialized(_this), "initOmisePayment", function () {
|
|
772
778
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
773
|
-
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
779
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
774
780
|
|
|
775
781
|
if (!selectedPlanObj) {
|
|
776
|
-
console.warn(
|
|
782
|
+
console.warn("Omise pay needs a plan");
|
|
777
783
|
return false;
|
|
778
784
|
}
|
|
779
785
|
|
|
780
786
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
781
787
|
|
|
782
|
-
planObject[
|
|
788
|
+
planObject["paymentType"] = get(planObject, ["selectedPlan", "recurring"]) ? "omise_recurring" : "omise";
|
|
783
789
|
|
|
784
790
|
var paymentObject = _this.makePaymentObject(planObject);
|
|
785
791
|
|
|
786
|
-
var omise = get(_this.props, [
|
|
792
|
+
var omise = get(_this.props, ["paymentOptions", "omise"]);
|
|
787
793
|
|
|
788
794
|
if (!omise) {
|
|
789
795
|
return Promise.reject({
|
|
790
|
-
message:
|
|
796
|
+
message: "Payment option is loading..."
|
|
791
797
|
});
|
|
792
798
|
}
|
|
793
799
|
|
|
@@ -798,31 +804,31 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
798
804
|
|
|
799
805
|
_defineProperty(_assertThisInitialized(_this), "initAdyenPayment", function () {
|
|
800
806
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
801
|
-
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
807
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
802
808
|
var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
|
|
803
809
|
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
804
810
|
|
|
805
811
|
var adyenExecutor = function adyenExecutor(resolve, reject) {
|
|
806
|
-
if (!document.getElementById(
|
|
807
|
-
var modalElement = document.createElement(
|
|
808
|
-
modalElement.setAttribute(
|
|
812
|
+
if (!document.getElementById("adyen-modal")) {
|
|
813
|
+
var modalElement = document.createElement("div");
|
|
814
|
+
modalElement.setAttribute("id", "adyen-modal");
|
|
809
815
|
document.body.appendChild(modalElement);
|
|
810
816
|
}
|
|
811
817
|
|
|
812
818
|
var afterOpen = function afterOpen() {
|
|
813
819
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
814
820
|
|
|
815
|
-
var isRecurring = get(planObject, [
|
|
816
|
-
var paymentType = isRecurring ?
|
|
821
|
+
var isRecurring = get(planObject, ["selectedPlan", "recurring"]);
|
|
822
|
+
var paymentType = isRecurring ? "adyen_recurring" : "adyen";
|
|
817
823
|
|
|
818
824
|
var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
819
825
|
paymentType: paymentType
|
|
820
826
|
}));
|
|
821
827
|
|
|
822
|
-
var adyen = get(_this.props, [
|
|
828
|
+
var adyen = get(_this.props, ["paymentOptions", "adyen"]);
|
|
823
829
|
paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
824
|
-
options: _objectSpread(_objectSpread({}, paymentObject[
|
|
825
|
-
dropin_container_id:
|
|
830
|
+
options: _objectSpread(_objectSpread({}, paymentObject["options"]), {}, {
|
|
831
|
+
dropin_container_id: "dropin-adyen",
|
|
826
832
|
locale: locale
|
|
827
833
|
}),
|
|
828
834
|
additional_data: {
|
|
@@ -837,7 +843,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
837
843
|
ReactDOM.render( /*#__PURE__*/React.createElement(AdyenModal, {
|
|
838
844
|
afterOpen: afterOpen,
|
|
839
845
|
afterClose: reject
|
|
840
|
-
}), document.getElementById(
|
|
846
|
+
}), document.getElementById("adyen-modal"));
|
|
841
847
|
};
|
|
842
848
|
|
|
843
849
|
return new Promise(adyenExecutor);
|
|
@@ -847,12 +853,12 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
847
853
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
848
854
|
|
|
849
855
|
if (!options.selectedPlan) {
|
|
850
|
-
console.warn(
|
|
856
|
+
console.warn("Paytrail needs a plan");
|
|
851
857
|
return false;
|
|
852
858
|
}
|
|
853
859
|
|
|
854
860
|
var paymentOptions = _this.props.paymentOptions;
|
|
855
|
-
var paymentType = get(options.selectedPlan, [
|
|
861
|
+
var paymentType = get(options.selectedPlan, ["recurring"]) ? "paytrail_recurring" : "paytrail";
|
|
856
862
|
|
|
857
863
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
858
864
|
paymentType: paymentType
|
|
@@ -861,7 +867,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
861
867
|
return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
|
|
862
868
|
return response.proceed(paymentObject);
|
|
863
869
|
}) : Promise.reject({
|
|
864
|
-
message:
|
|
870
|
+
message: "Payment option is loading..."
|
|
865
871
|
});
|
|
866
872
|
});
|
|
867
873
|
|
|
@@ -874,7 +880,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
874
880
|
try {
|
|
875
881
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
876
882
|
} catch (e) {
|
|
877
|
-
console.log(
|
|
883
|
+
console.log("error in pingbackAssetAccess", e);
|
|
878
884
|
}
|
|
879
885
|
|
|
880
886
|
return _context12.abrupt("return", true);
|
|
@@ -905,7 +911,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
905
911
|
break;
|
|
906
912
|
}
|
|
907
913
|
|
|
908
|
-
console.warn(
|
|
914
|
+
console.warn("AssetId is required");
|
|
909
915
|
return _context13.abrupt("return", false);
|
|
910
916
|
|
|
911
917
|
case 3:
|
|
@@ -913,7 +919,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
913
919
|
|
|
914
920
|
asset = {
|
|
915
921
|
id: assetId,
|
|
916
|
-
type:
|
|
922
|
+
type: "story"
|
|
917
923
|
};
|
|
918
924
|
_context13.next = 7;
|
|
919
925
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
@@ -939,7 +945,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
939
945
|
|
|
940
946
|
_ref16 = accessData || {}, granted = _ref16.granted, grantReason = _ref16.grantReason, _ref16$data = _ref16.data, data = _ref16$data === void 0 ? {} : _ref16$data;
|
|
941
947
|
|
|
942
|
-
if (!_this.props.disableMetering && granted && grantReason ===
|
|
948
|
+
if (!_this.props.disableMetering && granted && grantReason === "METERING") {
|
|
943
949
|
_this.pingBackMeteredStory(asset, accessData);
|
|
944
950
|
|
|
945
951
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
@@ -1024,8 +1030,8 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1024
1030
|
};
|
|
1025
1031
|
}());
|
|
1026
1032
|
|
|
1027
|
-
_this.prodHost = props.prodHost ||
|
|
1028
|
-
_this.stagingHost = props.stagingHost ||
|
|
1033
|
+
_this.prodHost = props.prodHost || "https://www.accesstype.com";
|
|
1034
|
+
_this.stagingHost = props.stagingHost || "https://staging.accesstype.com";
|
|
1029
1035
|
return _this;
|
|
1030
1036
|
}
|
|
1031
1037
|
|
|
@@ -1040,25 +1046,25 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1040
1046
|
var _ref19$selectedPlan = _ref19.selectedPlan,
|
|
1041
1047
|
selectedPlan = _ref19$selectedPlan === void 0 ? {} : _ref19$selectedPlan,
|
|
1042
1048
|
_ref19$couponCode = _ref19.couponCode,
|
|
1043
|
-
couponCode = _ref19$couponCode === void 0 ?
|
|
1049
|
+
couponCode = _ref19$couponCode === void 0 ? "" : _ref19$couponCode,
|
|
1044
1050
|
_ref19$recipientSubsc = _ref19.recipientSubscriber,
|
|
1045
1051
|
recipientSubscriber = _ref19$recipientSubsc === void 0 ? {} : _ref19$recipientSubsc,
|
|
1046
1052
|
_ref19$planType = _ref19.planType,
|
|
1047
|
-
planType = _ref19$planType === void 0 ?
|
|
1053
|
+
planType = _ref19$planType === void 0 ? "" : _ref19$planType,
|
|
1048
1054
|
_ref19$storyId = _ref19.storyId,
|
|
1049
|
-
storyId = _ref19$storyId === void 0 ?
|
|
1055
|
+
storyId = _ref19$storyId === void 0 ? "" : _ref19$storyId,
|
|
1050
1056
|
_ref19$storyHeadline = _ref19.storyHeadline,
|
|
1051
|
-
storyHeadline = _ref19$storyHeadline === void 0 ?
|
|
1057
|
+
storyHeadline = _ref19$storyHeadline === void 0 ? "" : _ref19$storyHeadline,
|
|
1052
1058
|
_ref19$storySlug = _ref19.storySlug,
|
|
1053
|
-
storySlug = _ref19$storySlug === void 0 ?
|
|
1059
|
+
storySlug = _ref19$storySlug === void 0 ? "" : _ref19$storySlug,
|
|
1054
1060
|
_ref19$paymentType = _ref19.paymentType,
|
|
1055
|
-
paymentType = _ref19$paymentType === void 0 ?
|
|
1061
|
+
paymentType = _ref19$paymentType === void 0 ? "" : _ref19$paymentType,
|
|
1056
1062
|
_ref19$successUrl = _ref19.successUrl,
|
|
1057
|
-
successUrl = _ref19$successUrl === void 0 ?
|
|
1063
|
+
successUrl = _ref19$successUrl === void 0 ? "" : _ref19$successUrl,
|
|
1058
1064
|
_ref19$returnUrl = _ref19.returnUrl,
|
|
1059
|
-
returnUrl = _ref19$returnUrl === void 0 ?
|
|
1065
|
+
returnUrl = _ref19$returnUrl === void 0 ? "" : _ref19$returnUrl,
|
|
1060
1066
|
_ref19$cancelUrl = _ref19.cancelUrl,
|
|
1061
|
-
cancelUrl = _ref19$cancelUrl === void 0 ?
|
|
1067
|
+
cancelUrl = _ref19$cancelUrl === void 0 ? "" : _ref19$cancelUrl;
|
|
1062
1068
|
var id = selectedPlan.id,
|
|
1063
1069
|
title = selectedPlan.title,
|
|
1064
1070
|
description = selectedPlan.description,
|
|
@@ -1103,9 +1109,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1103
1109
|
};
|
|
1104
1110
|
|
|
1105
1111
|
if (returnUrl) {
|
|
1106
|
-
paymentObject.options.urls[
|
|
1112
|
+
paymentObject.options.urls["return_url"] = returnUrl;
|
|
1107
1113
|
} else {
|
|
1108
|
-
paymentObject.options.urls[
|
|
1114
|
+
paymentObject.options.urls["success_url"] = successUrl;
|
|
1109
1115
|
}
|
|
1110
1116
|
}
|
|
1111
1117
|
|
|
@@ -1115,11 +1121,11 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1115
1121
|
key: "makePlanObject",
|
|
1116
1122
|
value: function makePlanObject() {
|
|
1117
1123
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1118
|
-
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
1119
|
-
var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
1120
|
-
var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] :
|
|
1121
|
-
var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] :
|
|
1122
|
-
return selectedPlanObj.argType && selectedPlanObj.argType ===
|
|
1124
|
+
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
1125
|
+
var storyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
1126
|
+
var storyHeadline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
1127
|
+
var storySlug = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
1128
|
+
return selectedPlanObj.argType && selectedPlanObj.argType === "options" ? {
|
|
1123
1129
|
selectedPlan: selectedPlanObj.selectedPlan,
|
|
1124
1130
|
planType: selectedPlanObj.planType,
|
|
1125
1131
|
storyId: selectedPlanObj.storyId,
|