@quintype/components 3.8.8-only-react-v19.4 → 3.8.9-razorpay-log.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 +2124 -1156
- package/dist/es/components/access-type.js +823 -574
- package/dist/es/components/adbutler-ad.js +14 -10
- package/dist/es/components/api-client.js +6 -4
- package/dist/es/components/breaking-news-item.js +3 -2
- package/dist/es/components/breaking-news.js +23 -7
- package/dist/es/components/client-side-only.js +19 -6
- package/dist/es/components/collection.js +5 -5
- package/dist/es/components/dfp-ad.js +30 -23
- package/dist/es/components/eager-load-images.js +29 -21
- package/dist/es/components/hamburger-button.js +5 -2
- package/dist/es/components/image-gallery.js +13 -10
- package/dist/es/components/impl/collection-impl.js +10 -3
- package/dist/es/components/impl/gumlet-image.js +19 -10
- package/dist/es/components/impl/image-utils.js +4 -3
- package/dist/es/components/impl/load-more-stories-manager.js +19 -6
- package/dist/es/components/impl/thumbor-image.js +97 -52
- package/dist/es/components/infinite-scroll.js +85 -29
- package/dist/es/components/infinite-story-base.js +24 -7
- package/dist/es/components/lazy-collection.js +8 -8
- package/dist/es/components/lazy-load-images.js +58 -24
- package/dist/es/components/link-base.js +19 -11
- package/dist/es/components/link.js +4 -1
- package/dist/es/components/load-more-collection-stories.js +18 -7
- package/dist/es/components/load-more-stories-base.js +20 -6
- package/dist/es/components/loading-indicator.js +5 -1
- package/dist/es/components/menu-item.js +10 -6
- package/dist/es/components/menu.js +9 -6
- package/dist/es/components/responsive-hero-image.js +3 -1
- package/dist/es/components/responsive-image.js +5 -0
- package/dist/es/components/responsive-source.js +1 -1
- package/dist/es/components/review-rating/review-rating.js +27 -21
- package/dist/es/components/review-rating/star-icon.js +5 -3
- package/dist/es/components/search-box.js +23 -7
- package/dist/es/components/search-page-base.js +18 -7
- package/dist/es/components/social-logins/with-facebook-login.js +20 -10
- package/dist/es/components/social-logins/with-google-login.js +18 -8
- package/dist/es/components/social-logins/with-linkedin-login.js +12 -7
- package/dist/es/components/social-logins/with-social-login.js +21 -7
- package/dist/es/components/social-logins/with-twitter-login.js +7 -7
- package/dist/es/components/social-share.js +24 -8
- package/dist/es/components/story-element.js +88 -43
- package/dist/es/components/story-elements/brightcove.js +94 -54
- package/dist/es/components/story-elements/dailymotion-embed-script.js +39 -13
- package/dist/es/components/story-elements/dailymotion.js +61 -19
- package/dist/es/components/story-elements/jsembed.js +30 -10
- package/dist/es/components/story-elements/jwPlayer.js +24 -9
- package/dist/es/components/story-elements/polltype.js +20 -6
- package/dist/es/components/story-elements/table.js +34 -16
- package/dist/es/components/story-elements/youtube.js +73 -24
- package/dist/es/components/update-on-interval.js +52 -31
- package/dist/es/components/with-client-side-only.js +4 -3
- package/dist/es/components/with-error.js +20 -7
- package/dist/es/components/with-host-url.js +9 -4
- package/dist/es/components/with-lazy.js +21 -7
- package/dist/es/components/with-member.js +33 -14
- package/dist/es/components/with-preview.js +20 -7
- package/dist/es/components/wrap-collection-layout.js +16 -4
- package/dist/es/store/reducers.js +45 -1
- package/dist/es/utils.js +12 -7
- package/package.json +7 -16
|
@@ -2,15 +2,22 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
function
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
11
15
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
|
-
|
|
13
|
-
function
|
|
16
|
+
|
|
17
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
+
|
|
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
|
+
|
|
14
21
|
import get from 'lodash/get';
|
|
15
22
|
import { bool, func, number, string } from 'prop-types';
|
|
16
23
|
import React from 'react';
|
|
@@ -18,28 +25,41 @@ import ReactDOM from 'react-dom';
|
|
|
18
25
|
import { batch, connect } from 'react-redux';
|
|
19
26
|
import { ACCESS_BEING_LOADED, ACCESS_UPDATED, ASSET_PLANS, CAMPAIGN_SUBSCRIPTION_GROUP_UPDATED, METER_UPDATED, PAYMENT_OPTIONS_UPDATED, SUBSCRIPTION_GROUP_UPDATED } from '../store/actions';
|
|
20
27
|
import { awaitHelper } from '../utils';
|
|
28
|
+
|
|
21
29
|
var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
30
|
+
_inherits(AccessTypeBase, _React$Component);
|
|
31
|
+
|
|
32
|
+
var _super = /*#__PURE__*/_createSuper(AccessTypeBase);
|
|
33
|
+
|
|
22
34
|
function AccessTypeBase(props) {
|
|
23
35
|
var _this;
|
|
36
|
+
|
|
24
37
|
_classCallCheck(this, AccessTypeBase);
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
|
|
39
|
+
_this = _super.call(this, props);
|
|
40
|
+
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "loadScript", function (callback) {
|
|
27
42
|
var accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
28
43
|
var isStaging = get(_this.props, ['isStaging']);
|
|
29
44
|
var enableAccesstype = get(_this.props, ['enableAccesstype']);
|
|
45
|
+
|
|
30
46
|
if (!enableAccesstype) {
|
|
31
47
|
return false;
|
|
32
48
|
}
|
|
49
|
+
|
|
33
50
|
var HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
34
51
|
var environment = isStaging ? '&env=sandbox' : '';
|
|
35
52
|
var accessTypeHost = "".concat(HOST, "/frontend/v2/accesstype.js?key=").concat(accessTypeKey).concat(environment);
|
|
36
53
|
var isATScriptAlreadyPresent = document.querySelector("script[src=\"".concat(accessTypeHost, "\"]"));
|
|
54
|
+
|
|
37
55
|
if (accessTypeKey && !isATScriptAlreadyPresent && !global.AccessType && global.document) {
|
|
38
56
|
var accessTypeScript = document.createElement('script');
|
|
57
|
+
|
|
39
58
|
accessTypeScript.onload = function () {
|
|
40
59
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
41
60
|
callback();
|
|
42
61
|
};
|
|
62
|
+
|
|
43
63
|
accessTypeScript.setAttribute('src', accessTypeHost);
|
|
44
64
|
accessTypeScript.setAttribute('id', 'AccessTypeScript');
|
|
45
65
|
accessTypeScript.setAttribute('data-accessType-script', '1');
|
|
@@ -47,416 +67,541 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
47
67
|
document.body.appendChild(accessTypeScript);
|
|
48
68
|
return true;
|
|
49
69
|
}
|
|
70
|
+
|
|
50
71
|
if (global.AccessType) {
|
|
51
72
|
_this.props.onATGlobalSet && _this.props.onATGlobalSet();
|
|
52
73
|
callback();
|
|
53
74
|
}
|
|
75
|
+
|
|
54
76
|
return true;
|
|
55
77
|
});
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "setUser", /*#__PURE__*/function () {
|
|
80
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(emailAddress, mobileNumber, accesstypeJwt) {
|
|
58
81
|
var isLoggedIn,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
isLoggedIn
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
userObj,
|
|
83
|
+
_yield$awaitHelper,
|
|
84
|
+
error,
|
|
85
|
+
user,
|
|
86
|
+
_args = arguments;
|
|
87
|
+
|
|
88
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
isLoggedIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
|
|
93
|
+
|
|
94
|
+
if (global.AccessType) {
|
|
95
|
+
_context.next = 3;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return _context.abrupt("return", null);
|
|
100
|
+
|
|
101
|
+
case 3:
|
|
102
|
+
userObj = isLoggedIn ? {
|
|
103
|
+
emailAddress: emailAddress,
|
|
104
|
+
mobileNumber: mobileNumber,
|
|
105
|
+
accesstypeJwt: accesstypeJwt
|
|
106
|
+
} : {
|
|
107
|
+
isLoggedIn: false
|
|
108
|
+
};
|
|
109
|
+
_context.next = 6;
|
|
110
|
+
return awaitHelper(global.AccessType.setUser(userObj));
|
|
111
|
+
|
|
112
|
+
case 6:
|
|
113
|
+
_yield$awaitHelper = _context.sent;
|
|
114
|
+
error = _yield$awaitHelper.error;
|
|
115
|
+
user = _yield$awaitHelper.data;
|
|
116
|
+
|
|
117
|
+
if (!error) {
|
|
118
|
+
_context.next = 12;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
console.warn("User context setting failed --> ", error);
|
|
123
|
+
return _context.abrupt("return", error);
|
|
124
|
+
|
|
125
|
+
case 12:
|
|
126
|
+
_this.props.onUserSet && _this.props.onUserSet();
|
|
127
|
+
return _context.abrupt("return", user);
|
|
128
|
+
|
|
129
|
+
case 14:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
99
133
|
}
|
|
100
134
|
}, _callee);
|
|
101
135
|
}));
|
|
136
|
+
|
|
102
137
|
return function (_x, _x2, _x3) {
|
|
103
138
|
return _ref.apply(this, arguments);
|
|
104
139
|
};
|
|
105
140
|
}());
|
|
106
|
-
|
|
107
|
-
|
|
141
|
+
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "validateCoupon", /*#__PURE__*/function () {
|
|
143
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(selectedPlanId, couponCode) {
|
|
108
144
|
var _yield$awaitHelper2, error, data;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
|
|
146
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) {
|
|
148
|
+
switch (_context2.prev = _context2.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
if (global.AccessType) {
|
|
151
|
+
_context2.next = 2;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return _context2.abrupt("return", {});
|
|
156
|
+
|
|
157
|
+
case 2:
|
|
158
|
+
_context2.next = 4;
|
|
159
|
+
return awaitHelper(global.AccessType.validateCoupon({
|
|
160
|
+
subscriptionPlanId: selectedPlanId,
|
|
161
|
+
couponCode: couponCode
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
case 4:
|
|
165
|
+
_yield$awaitHelper2 = _context2.sent;
|
|
166
|
+
error = _yield$awaitHelper2.error;
|
|
167
|
+
data = _yield$awaitHelper2.data;
|
|
168
|
+
|
|
169
|
+
if (!error) {
|
|
170
|
+
_context2.next = 10;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
console.warn("Error --> ", error);
|
|
175
|
+
return _context2.abrupt("return", error);
|
|
176
|
+
|
|
177
|
+
case 10:
|
|
178
|
+
return _context2.abrupt("return", data);
|
|
179
|
+
|
|
180
|
+
case 11:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context2.stop();
|
|
183
|
+
}
|
|
138
184
|
}
|
|
139
185
|
}, _callee2);
|
|
140
186
|
}));
|
|
187
|
+
|
|
141
188
|
return function (_x4, _x5) {
|
|
142
189
|
return _ref2.apply(this, arguments);
|
|
143
190
|
};
|
|
144
191
|
}());
|
|
145
|
-
|
|
192
|
+
|
|
193
|
+
_defineProperty(_assertThisInitialized(_this), "cancelSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
146
194
|
var subscriptionId,
|
|
147
|
-
|
|
148
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
149
|
-
while (1)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
195
|
+
_args3 = arguments;
|
|
196
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
197
|
+
while (1) {
|
|
198
|
+
switch (_context3.prev = _context3.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
subscriptionId = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : null;
|
|
201
|
+
|
|
202
|
+
if (subscriptionId) {
|
|
203
|
+
_context3.next = 3;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return _context3.abrupt("return", Promise.reject('Subscription id is not defined'));
|
|
208
|
+
|
|
209
|
+
case 3:
|
|
210
|
+
return _context3.abrupt("return", global.AccessType.cancelSubscription(subscriptionId));
|
|
211
|
+
|
|
212
|
+
case 4:
|
|
213
|
+
case "end":
|
|
214
|
+
return _context3.stop();
|
|
215
|
+
}
|
|
162
216
|
}
|
|
163
217
|
}, _callee3);
|
|
164
218
|
})));
|
|
165
|
-
|
|
219
|
+
|
|
220
|
+
_defineProperty(_assertThisInitialized(_this), "getPath", function (sketchesHost, relativePath) {
|
|
166
221
|
try {
|
|
167
222
|
var _URL = new URL(sketchesHost),
|
|
168
|
-
|
|
223
|
+
pathname = _URL.pathname;
|
|
224
|
+
|
|
169
225
|
if (pathname && pathname !== '/') {
|
|
170
226
|
return "".concat(sketchesHost).concat(relativePath);
|
|
171
227
|
}
|
|
228
|
+
|
|
172
229
|
return relativePath;
|
|
173
230
|
} catch (err) {
|
|
174
231
|
console.log('Sketches host path error ---> ', err);
|
|
175
232
|
return relativePath;
|
|
176
233
|
}
|
|
177
234
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_context4.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
error
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
235
|
+
|
|
236
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
237
|
+
var accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper3, error, subscriptions;
|
|
238
|
+
|
|
239
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
240
|
+
while (1) {
|
|
241
|
+
switch (_context4.prev = _context4.next) {
|
|
242
|
+
case 0:
|
|
243
|
+
accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
244
|
+
isStaging = get(_this.props, ['isStaging']);
|
|
245
|
+
HOST = isStaging ? _this.stagingHost : _this.prodHost; // TODO: use AccesstypeJS method insead of direct api call
|
|
246
|
+
|
|
247
|
+
accessTypeHost = "".concat(HOST, "/api/v1/subscription_groups.json?key=").concat(accessTypeKey);
|
|
248
|
+
_context4.t0 = awaitHelper;
|
|
249
|
+
_context4.next = 7;
|
|
250
|
+
return global.fetch(accessTypeHost);
|
|
251
|
+
|
|
252
|
+
case 7:
|
|
253
|
+
_context4.t1 = _context4.sent.json();
|
|
254
|
+
_context4.next = 10;
|
|
255
|
+
return (0, _context4.t0)(_context4.t1);
|
|
256
|
+
|
|
257
|
+
case 10:
|
|
258
|
+
_yield$awaitHelper3 = _context4.sent;
|
|
259
|
+
error = _yield$awaitHelper3.error;
|
|
260
|
+
subscriptions = _yield$awaitHelper3.data;
|
|
261
|
+
|
|
262
|
+
if (!error) {
|
|
263
|
+
_context4.next = 15;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return _context4.abrupt("return", {
|
|
268
|
+
error: 'subscriptions fetch failed'
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
case 15:
|
|
272
|
+
return _context4.abrupt("return", subscriptions['subscription_groups'] || []);
|
|
273
|
+
|
|
274
|
+
case 16:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context4.stop();
|
|
277
|
+
}
|
|
209
278
|
}
|
|
210
279
|
}, _callee4);
|
|
211
280
|
})));
|
|
212
|
-
|
|
281
|
+
|
|
282
|
+
_defineProperty(_assertThisInitialized(_this), "getPaymentOptions", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
213
283
|
var _yield$awaitHelper4, error, paymentOptions;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
284
|
+
|
|
285
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
286
|
+
while (1) {
|
|
287
|
+
switch (_context5.prev = _context5.next) {
|
|
288
|
+
case 0:
|
|
289
|
+
if (global.AccessType) {
|
|
290
|
+
_context5.next = 2;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return _context5.abrupt("return", []);
|
|
295
|
+
|
|
296
|
+
case 2:
|
|
297
|
+
_context5.next = 4;
|
|
298
|
+
return awaitHelper(global.AccessType.getPaymentOptions());
|
|
299
|
+
|
|
300
|
+
case 4:
|
|
301
|
+
_yield$awaitHelper4 = _context5.sent;
|
|
302
|
+
error = _yield$awaitHelper4.error;
|
|
303
|
+
paymentOptions = _yield$awaitHelper4.data;
|
|
304
|
+
|
|
305
|
+
if (!error) {
|
|
306
|
+
_context5.next = 9;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return _context5.abrupt("return", {
|
|
311
|
+
error: 'payment options fetch failed'
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
case 9:
|
|
315
|
+
return _context5.abrupt("return", paymentOptions);
|
|
316
|
+
|
|
317
|
+
case 10:
|
|
318
|
+
case "end":
|
|
319
|
+
return _context5.stop();
|
|
320
|
+
}
|
|
241
321
|
}
|
|
242
322
|
}, _callee5);
|
|
243
323
|
})));
|
|
244
|
-
|
|
324
|
+
|
|
325
|
+
_defineProperty(_assertThisInitialized(_this), "getAssetPlans", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
245
326
|
var storyId,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
327
|
+
_yield$awaitHelper5,
|
|
328
|
+
error,
|
|
329
|
+
_yield$awaitHelper5$d,
|
|
330
|
+
assetPlans,
|
|
331
|
+
_args6 = arguments;
|
|
332
|
+
|
|
333
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
334
|
+
while (1) {
|
|
335
|
+
switch (_context6.prev = _context6.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
storyId = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '';
|
|
338
|
+
|
|
339
|
+
if (global.AccessType) {
|
|
340
|
+
_context6.next = 3;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return _context6.abrupt("return", []);
|
|
345
|
+
|
|
346
|
+
case 3:
|
|
347
|
+
_context6.next = 5;
|
|
348
|
+
return awaitHelper(global.AccessType.getAssetPlans({
|
|
349
|
+
id: storyId,
|
|
350
|
+
type: 'story'
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
case 5:
|
|
354
|
+
_yield$awaitHelper5 = _context6.sent;
|
|
355
|
+
error = _yield$awaitHelper5.error;
|
|
356
|
+
_yield$awaitHelper5$d = _yield$awaitHelper5.data;
|
|
357
|
+
assetPlans = _yield$awaitHelper5$d === void 0 ? {} : _yield$awaitHelper5$d;
|
|
358
|
+
|
|
359
|
+
if (!error) {
|
|
360
|
+
_context6.next = 11;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return _context6.abrupt("return", {
|
|
365
|
+
error: 'asset plan fetch failed'
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
case 11:
|
|
369
|
+
return _context6.abrupt("return", assetPlans);
|
|
370
|
+
|
|
371
|
+
case 12:
|
|
372
|
+
case "end":
|
|
373
|
+
return _context6.stop();
|
|
374
|
+
}
|
|
283
375
|
}
|
|
284
376
|
}, _callee6);
|
|
285
377
|
})));
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
_context7.next =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
378
|
+
|
|
379
|
+
_defineProperty(_assertThisInitialized(_this), "getCampaignSubscription", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
380
|
+
var isAccessTypeCampaignEnabled, accessTypeKey, isStaging, HOST, accessTypeHost, _yield$awaitHelper6, error, campaignSubscriptions;
|
|
381
|
+
|
|
382
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
383
|
+
while (1) {
|
|
384
|
+
switch (_context7.prev = _context7.next) {
|
|
385
|
+
case 0:
|
|
386
|
+
isAccessTypeCampaignEnabled = get(_this.props, ['isAccessTypeCampaignEnabled'], false);
|
|
387
|
+
|
|
388
|
+
if (!isAccessTypeCampaignEnabled) {
|
|
389
|
+
_context7.next = 18;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
accessTypeKey = get(_this.props, ['accessTypeKey']);
|
|
394
|
+
isStaging = get(_this.props, ['isStaging']);
|
|
395
|
+
HOST = isStaging ? _this.stagingHost : _this.prodHost;
|
|
396
|
+
accessTypeHost = "".concat(HOST, "/api/v1/campaigns.json?key=").concat(accessTypeKey);
|
|
397
|
+
_context7.t0 = awaitHelper;
|
|
398
|
+
_context7.next = 9;
|
|
399
|
+
return global.fetch(accessTypeHost);
|
|
400
|
+
|
|
401
|
+
case 9:
|
|
402
|
+
_context7.t1 = _context7.sent.json();
|
|
403
|
+
_context7.next = 12;
|
|
404
|
+
return (0, _context7.t0)(_context7.t1);
|
|
405
|
+
|
|
406
|
+
case 12:
|
|
407
|
+
_yield$awaitHelper6 = _context7.sent;
|
|
408
|
+
error = _yield$awaitHelper6.error;
|
|
409
|
+
campaignSubscriptions = _yield$awaitHelper6.data;
|
|
410
|
+
|
|
411
|
+
if (!error) {
|
|
412
|
+
_context7.next = 17;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return _context7.abrupt("return", {
|
|
417
|
+
error: 'subscriptions fetch failed'
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
case 17:
|
|
421
|
+
return _context7.abrupt("return", campaignSubscriptions['subscription_groups'] || []);
|
|
422
|
+
|
|
423
|
+
case 18:
|
|
424
|
+
return _context7.abrupt("return", []);
|
|
425
|
+
|
|
426
|
+
case 19:
|
|
427
|
+
case "end":
|
|
428
|
+
return _context7.stop();
|
|
429
|
+
}
|
|
324
430
|
}
|
|
325
431
|
}, _callee7);
|
|
326
432
|
})));
|
|
327
|
-
|
|
433
|
+
|
|
434
|
+
_defineProperty(_assertThisInitialized(_this), "runSequentialCalls", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
328
435
|
var callback,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
436
|
+
_ref9,
|
|
437
|
+
email,
|
|
438
|
+
phone,
|
|
439
|
+
accessTypeBkIntegrationId,
|
|
440
|
+
_ref9$executeSequenti,
|
|
441
|
+
executeSequentialCalls,
|
|
442
|
+
jwtResponse,
|
|
443
|
+
_yield$awaitHelper7,
|
|
444
|
+
error,
|
|
445
|
+
_args8 = arguments;
|
|
446
|
+
|
|
447
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
448
|
+
while (1) {
|
|
449
|
+
switch (_context8.prev = _context8.next) {
|
|
450
|
+
case 0:
|
|
451
|
+
callback = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : function () {
|
|
452
|
+
return null;
|
|
453
|
+
};
|
|
454
|
+
_ref9 = _this.props || {}, email = _ref9.email, phone = _ref9.phone, accessTypeBkIntegrationId = _ref9.accessTypeBkIntegrationId, _ref9$executeSequenti = _ref9.executeSequentialCalls, executeSequentialCalls = _ref9$executeSequenti === void 0 ? true : _ref9$executeSequenti;
|
|
455
|
+
_context8.next = 4;
|
|
456
|
+
return fetch("/api/auth/v1/access-token/integrations/".concat(accessTypeBkIntegrationId));
|
|
457
|
+
|
|
458
|
+
case 4:
|
|
459
|
+
jwtResponse = _context8.sent;
|
|
460
|
+
_context8.next = 7;
|
|
461
|
+
return awaitHelper(_this.setUser(email, phone, jwtResponse.headers.get('x-integration-token'), !!jwtResponse.headers.get('x-integration-token')));
|
|
462
|
+
|
|
463
|
+
case 7:
|
|
464
|
+
_yield$awaitHelper7 = _context8.sent;
|
|
465
|
+
error = _yield$awaitHelper7.error;
|
|
466
|
+
|
|
467
|
+
if (!error) {
|
|
468
|
+
try {
|
|
469
|
+
if (executeSequentialCalls) {
|
|
470
|
+
Promise.all([_this.getSubscription(), _this.getPaymentOptions(), _this.getAssetPlans(), _this.getCampaignSubscription()]).then(function (_ref10) {
|
|
471
|
+
var _ref11 = _slicedToArray(_ref10, 4),
|
|
472
|
+
subscriptionGroups = _ref11[0],
|
|
473
|
+
paymentOptions = _ref11[1],
|
|
474
|
+
assetPlans = _ref11[2],
|
|
475
|
+
campaignSubscriptionGroups = _ref11[3];
|
|
476
|
+
|
|
477
|
+
batch(function () {
|
|
478
|
+
_this.props.subscriptionGroupLoaded(subscriptionGroups);
|
|
479
|
+
|
|
480
|
+
_this.props.paymentOptionsLoaded(paymentOptions);
|
|
481
|
+
|
|
482
|
+
_this.props.assetPlanLoaded(assetPlans);
|
|
483
|
+
|
|
484
|
+
_this.props.campaignSubscriptionGroupLoaded(campaignSubscriptionGroups);
|
|
485
|
+
});
|
|
486
|
+
callback();
|
|
369
487
|
});
|
|
488
|
+
} else {
|
|
370
489
|
callback();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
490
|
+
}
|
|
491
|
+
} catch (e) {
|
|
492
|
+
console.log("Subscription / payments failed", e);
|
|
374
493
|
}
|
|
375
|
-
} catch (e) {
|
|
376
|
-
console.log("Subscription / payments failed", e);
|
|
377
494
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
495
|
+
|
|
496
|
+
case 10:
|
|
497
|
+
case "end":
|
|
498
|
+
return _context8.stop();
|
|
499
|
+
}
|
|
382
500
|
}
|
|
383
501
|
}, _callee8);
|
|
384
502
|
})));
|
|
385
|
-
|
|
503
|
+
|
|
504
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscriptionForUser", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
386
505
|
var _yield$awaitHelper8, error, _yield$awaitHelper8$d, subscriptions;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
_context9.next = 1;
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
return _context9.abrupt("return", {});
|
|
395
|
-
case 1:
|
|
396
|
-
_context9.next = 2;
|
|
397
|
-
return awaitHelper(global.AccessType.getSubscriptions());
|
|
398
|
-
case 2:
|
|
399
|
-
_yield$awaitHelper8 = _context9.sent;
|
|
400
|
-
error = _yield$awaitHelper8.error;
|
|
401
|
-
_yield$awaitHelper8$d = _yield$awaitHelper8.data;
|
|
402
|
-
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
403
|
-
if (!error) {
|
|
404
|
-
_context9.next = 3;
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
return _context9.abrupt("return", error);
|
|
408
|
-
case 3:
|
|
409
|
-
return _context9.abrupt("return", subscriptions);
|
|
410
|
-
case 4:
|
|
411
|
-
case "end":
|
|
412
|
-
return _context9.stop();
|
|
413
|
-
}
|
|
414
|
-
}, _callee9);
|
|
415
|
-
})));
|
|
416
|
-
_defineProperty(_this, "getSubscriptionsWithSwitchablePlans", /*#__PURE__*/function () {
|
|
417
|
-
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(planId) {
|
|
418
|
-
var _yield$awaitHelper9, error, _yield$awaitHelper9$d, subscription;
|
|
419
|
-
return _regeneratorRuntime.wrap(function (_context0) {
|
|
420
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
506
|
+
|
|
507
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
508
|
+
while (1) {
|
|
509
|
+
switch (_context9.prev = _context9.next) {
|
|
421
510
|
case 0:
|
|
422
511
|
if (global.AccessType) {
|
|
423
|
-
|
|
512
|
+
_context9.next = 2;
|
|
424
513
|
break;
|
|
425
514
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
_context0.next = 2;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
throw new Error('planId is mandatory');
|
|
515
|
+
|
|
516
|
+
return _context9.abrupt("return", {});
|
|
517
|
+
|
|
433
518
|
case 2:
|
|
434
|
-
|
|
435
|
-
return awaitHelper(global.AccessType.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
519
|
+
_context9.next = 4;
|
|
520
|
+
return awaitHelper(global.AccessType.getSubscriptions());
|
|
521
|
+
|
|
522
|
+
case 4:
|
|
523
|
+
_yield$awaitHelper8 = _context9.sent;
|
|
524
|
+
error = _yield$awaitHelper8.error;
|
|
525
|
+
_yield$awaitHelper8$d = _yield$awaitHelper8.data;
|
|
526
|
+
subscriptions = _yield$awaitHelper8$d === void 0 ? [] : _yield$awaitHelper8$d;
|
|
527
|
+
|
|
441
528
|
if (!error) {
|
|
442
|
-
|
|
529
|
+
_context9.next = 10;
|
|
443
530
|
break;
|
|
444
531
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
case
|
|
532
|
+
|
|
533
|
+
return _context9.abrupt("return", error);
|
|
534
|
+
|
|
535
|
+
case 10:
|
|
536
|
+
return _context9.abrupt("return", subscriptions);
|
|
537
|
+
|
|
538
|
+
case 11:
|
|
449
539
|
case "end":
|
|
450
|
-
return
|
|
540
|
+
return _context9.stop();
|
|
451
541
|
}
|
|
452
|
-
}
|
|
542
|
+
}
|
|
543
|
+
}, _callee9);
|
|
544
|
+
})));
|
|
545
|
+
|
|
546
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscriptionsWithSwitchablePlans", /*#__PURE__*/function () {
|
|
547
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(planId) {
|
|
548
|
+
var _yield$awaitHelper9, error, _yield$awaitHelper9$d, subscription;
|
|
549
|
+
|
|
550
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
551
|
+
while (1) {
|
|
552
|
+
switch (_context10.prev = _context10.next) {
|
|
553
|
+
case 0:
|
|
554
|
+
if (global.AccessType) {
|
|
555
|
+
_context10.next = 2;
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return _context10.abrupt("return", {});
|
|
560
|
+
|
|
561
|
+
case 2:
|
|
562
|
+
if (planId) {
|
|
563
|
+
_context10.next = 4;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
throw new Error('planId is mandatory');
|
|
568
|
+
|
|
569
|
+
case 4:
|
|
570
|
+
_context10.next = 6;
|
|
571
|
+
return awaitHelper(global.AccessType.getSubscriptionWithSwitchablePlans(planId, 'switch'));
|
|
572
|
+
|
|
573
|
+
case 6:
|
|
574
|
+
_yield$awaitHelper9 = _context10.sent;
|
|
575
|
+
error = _yield$awaitHelper9.error;
|
|
576
|
+
_yield$awaitHelper9$d = _yield$awaitHelper9.data;
|
|
577
|
+
subscription = _yield$awaitHelper9$d === void 0 ? {} : _yield$awaitHelper9$d;
|
|
578
|
+
|
|
579
|
+
if (!error) {
|
|
580
|
+
_context10.next = 12;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
return _context10.abrupt("return", error);
|
|
585
|
+
|
|
586
|
+
case 12:
|
|
587
|
+
return _context10.abrupt("return", subscription);
|
|
588
|
+
|
|
589
|
+
case 13:
|
|
590
|
+
case "end":
|
|
591
|
+
return _context10.stop();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}, _callee10);
|
|
453
595
|
}));
|
|
596
|
+
|
|
454
597
|
return function (_x6) {
|
|
455
|
-
return
|
|
598
|
+
return _ref13.apply(this, arguments);
|
|
456
599
|
};
|
|
457
600
|
}());
|
|
458
|
-
|
|
601
|
+
|
|
602
|
+
_defineProperty(_assertThisInitialized(_this), "initAccessType", function (callback) {
|
|
459
603
|
var accessTypeBkIntegrationId = _this.props.accessTypeBkIntegrationId;
|
|
604
|
+
|
|
460
605
|
try {
|
|
461
606
|
_this.loadScript(function () {
|
|
462
607
|
// dont try to initialize accessType if integration id is not available
|
|
@@ -464,178 +609,225 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
464
609
|
console.warn('AccessType: Integration Id is undefined');
|
|
465
610
|
return false;
|
|
466
611
|
}
|
|
612
|
+
|
|
467
613
|
_this.runSequentialCalls(callback);
|
|
468
614
|
});
|
|
469
615
|
} catch (e) {
|
|
470
616
|
console.warn("Accesstype load fail", e);
|
|
471
617
|
}
|
|
472
618
|
});
|
|
473
|
-
|
|
619
|
+
|
|
620
|
+
_defineProperty(_assertThisInitialized(_this), "initRazorPayPayment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
474
621
|
var selectedPlanObj,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
622
|
+
planType,
|
|
623
|
+
storyId,
|
|
624
|
+
storyHeadline,
|
|
625
|
+
storySlug,
|
|
626
|
+
paymentType,
|
|
627
|
+
opts,
|
|
628
|
+
intent,
|
|
629
|
+
switchType,
|
|
630
|
+
planObject,
|
|
631
|
+
paymentOptions,
|
|
632
|
+
_planObject$selectedP,
|
|
633
|
+
discounted_price_cents,
|
|
634
|
+
price_cents,
|
|
635
|
+
paymentObject,
|
|
636
|
+
_yield$awaitHelper10,
|
|
637
|
+
data,
|
|
638
|
+
_yield$awaitHelper11,
|
|
639
|
+
error,
|
|
640
|
+
switchPaymentOptions,
|
|
641
|
+
_args11 = arguments;
|
|
642
|
+
|
|
643
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
644
|
+
while (1) {
|
|
645
|
+
switch (_context11.prev = _context11.next) {
|
|
646
|
+
case 0:
|
|
647
|
+
selectedPlanObj = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
648
|
+
planType = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : '';
|
|
649
|
+
storyId = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : '';
|
|
650
|
+
storyHeadline = _args11.length > 3 && _args11[3] !== undefined ? _args11[3] : '';
|
|
651
|
+
storySlug = _args11.length > 4 && _args11[4] !== undefined ? _args11[4] : '';
|
|
652
|
+
paymentType = _args11.length > 5 && _args11[5] !== undefined ? _args11[5] : '';
|
|
653
|
+
opts = _args11.length > 6 ? _args11[6] : undefined;
|
|
654
|
+
|
|
655
|
+
if (selectedPlanObj) {
|
|
656
|
+
_context11.next = 10;
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
console.warn('Razor pay needs a plan');
|
|
661
|
+
return _context11.abrupt("return", false);
|
|
662
|
+
|
|
663
|
+
case 10:
|
|
664
|
+
intent = get(opts, ['intent'], 'default');
|
|
665
|
+
switchType = get(opts, ['switchType']);
|
|
666
|
+
planObject = _this.makePlanObject(selectedPlanObj, planType, storyId, storyHeadline, storySlug); //we are doing this to sake of backward compatibility and will be refactored later.
|
|
667
|
+
|
|
668
|
+
planObject['paymentType'] = paymentType || (get(planObject, ['selectedPlan', 'recurring']) ? 'razorpay_recurring' : 'razorpay');
|
|
669
|
+
paymentOptions = _this.props.paymentOptions;
|
|
670
|
+
_planObject$selectedP = planObject.selectedPlan, discounted_price_cents = _planObject$selectedP.discounted_price_cents, price_cents = _planObject$selectedP.price_cents;
|
|
671
|
+
paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
672
|
+
couponCode: selectedPlanObj.coupon_code
|
|
673
|
+
}));
|
|
674
|
+
|
|
675
|
+
if (!(discounted_price_cents === 0 || price_cents === 0)) {
|
|
676
|
+
_context11.next = 23;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
_context11.next = 20;
|
|
681
|
+
return awaitHelper(global.AccessType.getPaymentOptions(0));
|
|
682
|
+
|
|
683
|
+
case 20:
|
|
684
|
+
_yield$awaitHelper10 = _context11.sent;
|
|
685
|
+
data = _yield$awaitHelper10.data;
|
|
686
|
+
paymentOptions = data;
|
|
687
|
+
|
|
688
|
+
case 23:
|
|
689
|
+
if (!(paymentObject.payment.amount_cents === 0)) {
|
|
690
|
+
_context11.next = 25;
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
return _context11.abrupt("return", global.AccessType.getPaymentOptions(0).then(function (provider) {
|
|
695
|
+
return provider.razorpay.proceed(paymentObject);
|
|
696
|
+
}));
|
|
697
|
+
|
|
698
|
+
case 25:
|
|
699
|
+
if (!(intent === 'switch')) {
|
|
700
|
+
_context11.next = 34;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
_context11.next = 28;
|
|
705
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, 'switch'));
|
|
706
|
+
|
|
707
|
+
case 28:
|
|
708
|
+
_yield$awaitHelper11 = _context11.sent;
|
|
709
|
+
error = _yield$awaitHelper11.error;
|
|
710
|
+
switchPaymentOptions = _yield$awaitHelper11.data;
|
|
711
|
+
|
|
712
|
+
if (!error) {
|
|
713
|
+
_context11.next = 33;
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
throw new Error('payment options fetch failed');
|
|
718
|
+
|
|
719
|
+
case 33:
|
|
720
|
+
return _context11.abrupt("return", switchPaymentOptions.razorpay.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
721
|
+
switch_type: switchType,
|
|
722
|
+
subscription_plan_id: selectedPlanObj.id,
|
|
723
|
+
subscriptionId: selectedPlanObj.subscriptionId
|
|
724
|
+
})));
|
|
725
|
+
|
|
726
|
+
case 34:
|
|
727
|
+
console.log('paymentOptions', paymentOptions.razorpay.proceed(paymentObject));
|
|
728
|
+
return _context11.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
|
|
729
|
+
|
|
730
|
+
case 36:
|
|
731
|
+
case "end":
|
|
732
|
+
return _context11.stop();
|
|
733
|
+
}
|
|
566
734
|
}
|
|
567
|
-
},
|
|
735
|
+
}, _callee11);
|
|
568
736
|
})));
|
|
569
|
-
|
|
737
|
+
|
|
738
|
+
_defineProperty(_assertThisInitialized(_this), "initStripePayment", function () {
|
|
570
739
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
740
|
+
|
|
571
741
|
if (!options.selectedPlan) {
|
|
572
742
|
console.warn('Stripe pay needs a plan');
|
|
573
743
|
return false;
|
|
574
744
|
}
|
|
745
|
+
|
|
575
746
|
var paymentOptions = _this.props.paymentOptions;
|
|
576
747
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
|
|
748
|
+
|
|
577
749
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
578
750
|
paymentType: paymentType
|
|
579
751
|
}, options));
|
|
752
|
+
|
|
580
753
|
return paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
581
754
|
message: 'Payment option is loading...'
|
|
582
755
|
});
|
|
583
756
|
});
|
|
584
|
-
|
|
757
|
+
|
|
758
|
+
_defineProperty(_assertThisInitialized(_this), "initPaypalPayment", function () {
|
|
585
759
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
760
|
+
|
|
586
761
|
if (!options.selectedPlan) {
|
|
587
762
|
console.warn('Paypal pay needs a plan');
|
|
588
763
|
return false;
|
|
589
764
|
}
|
|
765
|
+
|
|
590
766
|
var paymentOptions = _this.props.paymentOptions;
|
|
591
767
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'paypal_recurring' : 'paypal';
|
|
768
|
+
|
|
592
769
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
593
770
|
paymentType: paymentType
|
|
594
771
|
}, options));
|
|
772
|
+
|
|
595
773
|
return paymentOptions.paypal ? paymentOptions.paypal.proceed(paymentObject).then(function (response) {
|
|
596
774
|
return response.proceed(paymentObject);
|
|
597
775
|
}) : Promise.reject({
|
|
598
776
|
message: 'Payment option is loading...'
|
|
599
777
|
});
|
|
600
778
|
});
|
|
601
|
-
|
|
779
|
+
|
|
780
|
+
_defineProperty(_assertThisInitialized(_this), "initOmisePayment", function () {
|
|
602
781
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
603
782
|
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
783
|
+
|
|
604
784
|
if (!selectedPlanObj) {
|
|
605
785
|
console.warn('Omise pay needs a plan');
|
|
606
786
|
return false;
|
|
607
787
|
}
|
|
788
|
+
|
|
608
789
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
790
|
+
|
|
609
791
|
planObject['paymentType'] = get(planObject, ['selectedPlan', 'recurring']) ? 'omise_recurring' : 'omise';
|
|
792
|
+
|
|
610
793
|
var paymentObject = _this.makePaymentObject(planObject);
|
|
794
|
+
|
|
611
795
|
var omise = get(_this.props, ['paymentOptions', 'omise']);
|
|
796
|
+
|
|
612
797
|
if (!omise) {
|
|
613
798
|
return Promise.reject({
|
|
614
799
|
message: 'Payment option is loading...'
|
|
615
800
|
});
|
|
616
801
|
}
|
|
802
|
+
|
|
617
803
|
return omise.proceed(paymentObject).then(function (response) {
|
|
618
804
|
return response;
|
|
619
805
|
});
|
|
620
806
|
});
|
|
621
|
-
|
|
807
|
+
|
|
808
|
+
_defineProperty(_assertThisInitialized(_this), "initAdyenPayment", function () {
|
|
622
809
|
var selectedPlanObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
623
810
|
var planType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
624
811
|
var AdyenModal = arguments.length > 2 ? arguments[2] : undefined;
|
|
625
812
|
var locale = arguments.length > 3 ? arguments[3] : undefined;
|
|
813
|
+
|
|
626
814
|
var adyenExecutor = function adyenExecutor(resolve, reject) {
|
|
627
815
|
if (!document.getElementById('adyen-modal')) {
|
|
628
816
|
var modalElement = document.createElement('div');
|
|
629
817
|
modalElement.setAttribute('id', 'adyen-modal');
|
|
630
818
|
document.body.appendChild(modalElement);
|
|
631
819
|
}
|
|
820
|
+
|
|
632
821
|
var afterOpen = function afterOpen() {
|
|
633
822
|
var planObject = _this.makePlanObject(selectedPlanObj, planType);
|
|
823
|
+
|
|
634
824
|
var isRecurring = get(planObject, ['selectedPlan', 'recurring']);
|
|
635
825
|
var paymentType = isRecurring ? 'adyen_recurring' : 'adyen';
|
|
826
|
+
|
|
636
827
|
var paymentObject = _this.makePaymentObject(_objectSpread(_objectSpread({}, planObject), {}, {
|
|
637
828
|
paymentType: paymentType
|
|
638
829
|
}));
|
|
830
|
+
|
|
639
831
|
var adyen = get(_this.props, ['paymentOptions', 'adyen']);
|
|
640
832
|
paymentObject = _objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
641
833
|
options: _objectSpread(_objectSpread({}, paymentObject['options']), {}, {
|
|
@@ -650,193 +842,241 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
650
842
|
return response.proceed(paymentObject);
|
|
651
843
|
}));
|
|
652
844
|
};
|
|
653
|
-
|
|
845
|
+
|
|
846
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(AdyenModal, {
|
|
654
847
|
afterOpen: afterOpen,
|
|
655
848
|
afterClose: reject
|
|
656
849
|
}), document.getElementById('adyen-modal'));
|
|
657
850
|
};
|
|
851
|
+
|
|
658
852
|
return new Promise(adyenExecutor);
|
|
659
853
|
});
|
|
660
|
-
|
|
854
|
+
|
|
855
|
+
_defineProperty(_assertThisInitialized(_this), "initPaytrailPayment", function () {
|
|
661
856
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
857
|
+
|
|
662
858
|
if (!options.selectedPlan) {
|
|
663
859
|
console.warn('Paytrail needs a plan');
|
|
664
860
|
return false;
|
|
665
861
|
}
|
|
862
|
+
|
|
666
863
|
var paymentOptions = _this.props.paymentOptions;
|
|
667
864
|
var paymentType = get(options.selectedPlan, ['recurring']) ? 'paytrail_recurring' : 'paytrail';
|
|
865
|
+
|
|
668
866
|
var paymentObject = _this.makePaymentObject(_objectSpread({
|
|
669
867
|
paymentType: paymentType
|
|
670
868
|
}, options));
|
|
869
|
+
|
|
671
870
|
return paymentOptions.paytrail ? paymentOptions.paytrail.proceed(paymentObject).then(function (response) {
|
|
672
871
|
return response.proceed(paymentObject);
|
|
673
872
|
}) : Promise.reject({
|
|
674
873
|
message: 'Payment option is loading...'
|
|
675
874
|
});
|
|
676
875
|
});
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
876
|
+
|
|
877
|
+
_defineProperty(_assertThisInitialized(_this), "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
878
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(asset, accessData) {
|
|
879
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
880
|
+
while (1) {
|
|
881
|
+
switch (_context12.prev = _context12.next) {
|
|
882
|
+
case 0:
|
|
883
|
+
try {
|
|
884
|
+
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
885
|
+
} catch (e) {
|
|
886
|
+
console.log('error in pingbackAssetAccess', e);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return _context12.abrupt("return", true);
|
|
890
|
+
|
|
891
|
+
case 2:
|
|
892
|
+
case "end":
|
|
893
|
+
return _context12.stop();
|
|
894
|
+
}
|
|
691
895
|
}
|
|
692
|
-
},
|
|
896
|
+
}, _callee12);
|
|
693
897
|
}));
|
|
898
|
+
|
|
694
899
|
return function (_x7, _x8) {
|
|
695
|
-
return
|
|
900
|
+
return _ref15.apply(this, arguments);
|
|
696
901
|
};
|
|
697
902
|
}());
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
903
|
+
|
|
904
|
+
_defineProperty(_assertThisInitialized(_this), "checkAccess", /*#__PURE__*/function () {
|
|
905
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(assetId) {
|
|
906
|
+
var asset, _yield$awaitHelper12, error, accessData, accessById, _ref17, granted, grantReason, _ref17$data, data;
|
|
907
|
+
|
|
908
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
909
|
+
while (1) {
|
|
910
|
+
switch (_context13.prev = _context13.next) {
|
|
911
|
+
case 0:
|
|
912
|
+
if (assetId) {
|
|
913
|
+
_context13.next = 3;
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
console.warn('AssetId is required');
|
|
918
|
+
return _context13.abrupt("return", false);
|
|
919
|
+
|
|
920
|
+
case 3:
|
|
921
|
+
_this.props.accessIsLoading(true);
|
|
922
|
+
|
|
923
|
+
asset = {
|
|
924
|
+
id: assetId,
|
|
925
|
+
type: 'story'
|
|
926
|
+
};
|
|
927
|
+
_context13.next = 7;
|
|
928
|
+
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
929
|
+
|
|
930
|
+
case 7:
|
|
931
|
+
_yield$awaitHelper12 = _context13.sent;
|
|
932
|
+
error = _yield$awaitHelper12.error;
|
|
933
|
+
accessData = _yield$awaitHelper12.data;
|
|
934
|
+
|
|
935
|
+
if (!error) {
|
|
936
|
+
_context13.next = 12;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
return _context13.abrupt("return", error);
|
|
941
|
+
|
|
942
|
+
case 12:
|
|
943
|
+
accessById = _defineProperty({}, assetId, accessData);
|
|
944
|
+
|
|
945
|
+
_this.props.accessUpdated(accessById);
|
|
946
|
+
|
|
947
|
+
_this.props.accessIsLoading(false);
|
|
948
|
+
|
|
949
|
+
_ref17 = accessData || {}, granted = _ref17.granted, grantReason = _ref17.grantReason, _ref17$data = _ref17.data, data = _ref17$data === void 0 ? {} : _ref17$data;
|
|
950
|
+
|
|
951
|
+
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
952
|
+
_this.pingBackMeteredStory(asset, accessData);
|
|
953
|
+
|
|
954
|
+
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return _context13.abrupt("return", accessById);
|
|
958
|
+
|
|
959
|
+
case 18:
|
|
960
|
+
case "end":
|
|
961
|
+
return _context13.stop();
|
|
962
|
+
}
|
|
740
963
|
}
|
|
741
|
-
},
|
|
964
|
+
}, _callee13);
|
|
742
965
|
}));
|
|
966
|
+
|
|
743
967
|
return function (_x9) {
|
|
744
|
-
return
|
|
968
|
+
return _ref16.apply(this, arguments);
|
|
745
969
|
};
|
|
746
970
|
}());
|
|
747
|
-
|
|
971
|
+
|
|
972
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
748
973
|
var metadata;
|
|
749
|
-
return _regeneratorRuntime.wrap(function (
|
|
750
|
-
while (1)
|
|
751
|
-
|
|
752
|
-
if (global.AccessType) {
|
|
753
|
-
_context12.next = 1;
|
|
754
|
-
break;
|
|
755
|
-
}
|
|
756
|
-
return _context12.abrupt("return", {});
|
|
757
|
-
case 1:
|
|
758
|
-
_context12.next = 2;
|
|
759
|
-
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
760
|
-
case 2:
|
|
761
|
-
metadata = _context12.sent;
|
|
762
|
-
return _context12.abrupt("return", metadata);
|
|
763
|
-
case 3:
|
|
764
|
-
case "end":
|
|
765
|
-
return _context12.stop();
|
|
766
|
-
}
|
|
767
|
-
}, _callee12);
|
|
768
|
-
})));
|
|
769
|
-
_defineProperty(_this, "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
770
|
-
var _ref17 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13(subscriberMetadata) {
|
|
771
|
-
var response;
|
|
772
|
-
return _regeneratorRuntime.wrap(function (_context13) {
|
|
773
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
974
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
975
|
+
while (1) {
|
|
976
|
+
switch (_context14.prev = _context14.next) {
|
|
774
977
|
case 0:
|
|
775
|
-
if (
|
|
776
|
-
|
|
978
|
+
if (global.AccessType) {
|
|
979
|
+
_context14.next = 2;
|
|
777
980
|
break;
|
|
778
981
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
982
|
+
|
|
983
|
+
return _context14.abrupt("return", {});
|
|
984
|
+
|
|
783
985
|
case 2:
|
|
784
|
-
|
|
785
|
-
return
|
|
786
|
-
|
|
986
|
+
_context14.next = 4;
|
|
987
|
+
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
988
|
+
|
|
989
|
+
case 4:
|
|
990
|
+
metadata = _context14.sent;
|
|
991
|
+
return _context14.abrupt("return", metadata);
|
|
992
|
+
|
|
993
|
+
case 6:
|
|
787
994
|
case "end":
|
|
788
|
-
return
|
|
995
|
+
return _context14.stop();
|
|
789
996
|
}
|
|
790
|
-
}
|
|
997
|
+
}
|
|
998
|
+
}, _callee14);
|
|
999
|
+
})));
|
|
1000
|
+
|
|
1001
|
+
_defineProperty(_assertThisInitialized(_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
1002
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(subscriberMetadata) {
|
|
1003
|
+
var response;
|
|
1004
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1005
|
+
while (1) {
|
|
1006
|
+
switch (_context15.prev = _context15.next) {
|
|
1007
|
+
case 0:
|
|
1008
|
+
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
1009
|
+
_context15.next = 2;
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return _context15.abrupt("return", {});
|
|
1014
|
+
|
|
1015
|
+
case 2:
|
|
1016
|
+
_context15.next = 4;
|
|
1017
|
+
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
1018
|
+
|
|
1019
|
+
case 4:
|
|
1020
|
+
response = _context15.sent;
|
|
1021
|
+
return _context15.abrupt("return", response);
|
|
1022
|
+
|
|
1023
|
+
case 6:
|
|
1024
|
+
case "end":
|
|
1025
|
+
return _context15.stop();
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}, _callee15);
|
|
791
1029
|
}));
|
|
792
|
-
|
|
793
|
-
|
|
1030
|
+
|
|
1031
|
+
return function (_x10) {
|
|
1032
|
+
return _ref19.apply(this, arguments);
|
|
794
1033
|
};
|
|
795
1034
|
}());
|
|
1035
|
+
|
|
796
1036
|
_this.prodHost = props.prodHost || 'https://www.accesstype.com';
|
|
797
1037
|
_this.stagingHost = props.stagingHost || 'https://staging.accesstype.com';
|
|
798
1038
|
return _this;
|
|
799
1039
|
}
|
|
800
|
-
|
|
801
|
-
|
|
1040
|
+
|
|
1041
|
+
_createClass(AccessTypeBase, [{
|
|
802
1042
|
key: "componentDidMount",
|
|
803
1043
|
value: function componentDidMount() {
|
|
804
1044
|
this.initAccessType();
|
|
805
1045
|
}
|
|
806
1046
|
}, {
|
|
807
1047
|
key: "makePaymentObject",
|
|
808
|
-
value: function makePaymentObject(
|
|
809
|
-
var
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
1048
|
+
value: function makePaymentObject(_ref20) {
|
|
1049
|
+
var _ref20$selectedPlan = _ref20.selectedPlan,
|
|
1050
|
+
selectedPlan = _ref20$selectedPlan === void 0 ? {} : _ref20$selectedPlan,
|
|
1051
|
+
_ref20$couponCode = _ref20.couponCode,
|
|
1052
|
+
couponCode = _ref20$couponCode === void 0 ? '' : _ref20$couponCode,
|
|
1053
|
+
_ref20$recipientSubsc = _ref20.recipientSubscriber,
|
|
1054
|
+
recipientSubscriber = _ref20$recipientSubsc === void 0 ? {} : _ref20$recipientSubsc,
|
|
1055
|
+
_ref20$planType = _ref20.planType,
|
|
1056
|
+
planType = _ref20$planType === void 0 ? '' : _ref20$planType,
|
|
1057
|
+
_ref20$storyId = _ref20.storyId,
|
|
1058
|
+
storyId = _ref20$storyId === void 0 ? '' : _ref20$storyId,
|
|
1059
|
+
_ref20$storyHeadline = _ref20.storyHeadline,
|
|
1060
|
+
storyHeadline = _ref20$storyHeadline === void 0 ? '' : _ref20$storyHeadline,
|
|
1061
|
+
_ref20$storySlug = _ref20.storySlug,
|
|
1062
|
+
storySlug = _ref20$storySlug === void 0 ? '' : _ref20$storySlug,
|
|
1063
|
+
_ref20$paymentType = _ref20.paymentType,
|
|
1064
|
+
paymentType = _ref20$paymentType === void 0 ? '' : _ref20$paymentType,
|
|
1065
|
+
_ref20$successUrl = _ref20.successUrl,
|
|
1066
|
+
successUrl = _ref20$successUrl === void 0 ? '' : _ref20$successUrl,
|
|
1067
|
+
_ref20$returnUrl = _ref20.returnUrl,
|
|
1068
|
+
returnUrl = _ref20$returnUrl === void 0 ? '' : _ref20$returnUrl,
|
|
1069
|
+
_ref20$cancelUrl = _ref20.cancelUrl,
|
|
1070
|
+
cancelUrl = _ref20$cancelUrl === void 0 ? '' : _ref20$cancelUrl;
|
|
831
1071
|
var id = selectedPlan.id,
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1072
|
+
title = selectedPlan.title,
|
|
1073
|
+
description = selectedPlan.description,
|
|
1074
|
+
price_cents = selectedPlan.price_cents,
|
|
1075
|
+
price_currency = selectedPlan.price_currency,
|
|
1076
|
+
duration_length = selectedPlan.duration_length,
|
|
1077
|
+
duration_unit = selectedPlan.duration_unit,
|
|
1078
|
+
discounted_price_cents = selectedPlan.discounted_price_cents,
|
|
1079
|
+
metadata = selectedPlan.metadata;
|
|
840
1080
|
var paymentObject = {
|
|
841
1081
|
type: planType,
|
|
842
1082
|
plan: {
|
|
@@ -862,18 +1102,22 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
862
1102
|
slug: storySlug
|
|
863
1103
|
}],
|
|
864
1104
|
recipient_subscriber: recipientSubscriber //for gift subscription
|
|
1105
|
+
|
|
865
1106
|
};
|
|
1107
|
+
|
|
866
1108
|
if ((successUrl || returnUrl) && cancelUrl) {
|
|
867
1109
|
paymentObject.options = {};
|
|
868
1110
|
paymentObject.options.urls = {
|
|
869
1111
|
cancel_url: cancelUrl
|
|
870
1112
|
};
|
|
1113
|
+
|
|
871
1114
|
if (returnUrl) {
|
|
872
1115
|
paymentObject.options.urls['return_url'] = returnUrl;
|
|
873
1116
|
} else {
|
|
874
1117
|
paymentObject.options.urls['success_url'] = successUrl;
|
|
875
1118
|
}
|
|
876
1119
|
}
|
|
1120
|
+
|
|
877
1121
|
return paymentObject;
|
|
878
1122
|
}
|
|
879
1123
|
}, {
|
|
@@ -926,7 +1170,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
926
1170
|
});
|
|
927
1171
|
}
|
|
928
1172
|
}]);
|
|
1173
|
+
|
|
1174
|
+
return AccessTypeBase;
|
|
929
1175
|
}(React.Component);
|
|
1176
|
+
|
|
930
1177
|
var mapStateToProps = function mapStateToProps(state) {
|
|
931
1178
|
return {
|
|
932
1179
|
subscriptions: state.subscriptions || null,
|
|
@@ -934,6 +1181,7 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
934
1181
|
assetPlans: state.assetPlans || null
|
|
935
1182
|
};
|
|
936
1183
|
};
|
|
1184
|
+
|
|
937
1185
|
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
938
1186
|
return {
|
|
939
1187
|
subscriptionGroupLoaded: function subscriptionGroupLoaded(subscriptions) {
|
|
@@ -980,7 +1228,6 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
|
980
1228
|
}
|
|
981
1229
|
};
|
|
982
1230
|
};
|
|
983
|
-
|
|
984
1231
|
/**
|
|
985
1232
|
* `AccessType` is a generic connected render prop which exposes methods to handle access to stories / assets and initialize AccessTypeJS.
|
|
986
1233
|
|
|
@@ -1147,4 +1394,6 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
|
1147
1394
|
* @component
|
|
1148
1395
|
* @category Subscription
|
|
1149
1396
|
*/
|
|
1397
|
+
|
|
1398
|
+
|
|
1150
1399
|
export var AccessType = /*#__PURE__*/connect(mapStateToProps, mapDispatchToProps)(AccessTypeBase);
|