@quintype/components 3.8.8 → 3.8.9-stripe-up-downgrade.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 +144 -83
- package/dist/es/components/access-type.js +144 -83
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -5808,25 +5808,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5808
5808
|
}, _callee11);
|
|
5809
5809
|
})));
|
|
5810
5810
|
|
|
5811
|
-
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initStripePayment", function () {
|
|
5812
|
-
var options
|
|
5811
|
+
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initStripePayment", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee12() {
|
|
5812
|
+
var options,
|
|
5813
|
+
paymentOptions,
|
|
5814
|
+
paymentType,
|
|
5815
|
+
paymentObject,
|
|
5816
|
+
intent,
|
|
5817
|
+
switchType,
|
|
5818
|
+
_options$selectedPlan,
|
|
5819
|
+
_options$selectedPlan2,
|
|
5820
|
+
_yield$awaitHelper12,
|
|
5821
|
+
error,
|
|
5822
|
+
switchPaymentOptions,
|
|
5823
|
+
_args12 = arguments;
|
|
5813
5824
|
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5825
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee12$(_context12) {
|
|
5826
|
+
while (1) {
|
|
5827
|
+
switch (_context12.prev = _context12.next) {
|
|
5828
|
+
case 0:
|
|
5829
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
5818
5830
|
|
|
5819
|
-
|
|
5820
|
-
|
|
5831
|
+
if (options.selectedPlan) {
|
|
5832
|
+
_context12.next = 4;
|
|
5833
|
+
break;
|
|
5834
|
+
}
|
|
5821
5835
|
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
}, options));
|
|
5836
|
+
console.warn('Stripe pay needs a plan');
|
|
5837
|
+
return _context12.abrupt("return", false);
|
|
5825
5838
|
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5839
|
+
case 4:
|
|
5840
|
+
paymentOptions = _this.props.paymentOptions;
|
|
5841
|
+
paymentType = get__default["default"](options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
|
|
5842
|
+
paymentObject = _this.makePaymentObject(_objectSpread({
|
|
5843
|
+
paymentType: paymentType
|
|
5844
|
+
}, options));
|
|
5845
|
+
intent = get__default["default"](options, ['intent'], 'default');
|
|
5846
|
+
switchType = get__default["default"](options, ['switchType']);
|
|
5847
|
+
console.log("------- initStripePayment PROPS--------->", _this.props, {
|
|
5848
|
+
intent: intent,
|
|
5849
|
+
switchType: switchType
|
|
5850
|
+
});
|
|
5851
|
+
|
|
5852
|
+
if (!(intent === "switch")) {
|
|
5853
|
+
_context12.next = 19;
|
|
5854
|
+
break;
|
|
5855
|
+
}
|
|
5856
|
+
|
|
5857
|
+
_context12.next = 13;
|
|
5858
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
|
|
5859
|
+
|
|
5860
|
+
case 13:
|
|
5861
|
+
_yield$awaitHelper12 = _context12.sent;
|
|
5862
|
+
error = _yield$awaitHelper12.error;
|
|
5863
|
+
switchPaymentOptions = _yield$awaitHelper12.data;
|
|
5864
|
+
|
|
5865
|
+
if (!error) {
|
|
5866
|
+
_context12.next = 18;
|
|
5867
|
+
break;
|
|
5868
|
+
}
|
|
5869
|
+
|
|
5870
|
+
throw new Error("payment options fetch failed");
|
|
5871
|
+
|
|
5872
|
+
case 18:
|
|
5873
|
+
return _context12.abrupt("return", switchPaymentOptions.stripe.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
5874
|
+
switch_type: switchType,
|
|
5875
|
+
subscription_plan_id: options === null || options === void 0 ? void 0 : (_options$selectedPlan = options.selectedPlan) === null || _options$selectedPlan === void 0 ? void 0 : _options$selectedPlan.id,
|
|
5876
|
+
subscriptionId: options === null || options === void 0 ? void 0 : (_options$selectedPlan2 = options.selectedPlan) === null || _options$selectedPlan2 === void 0 ? void 0 : _options$selectedPlan2.subscriptionId
|
|
5877
|
+
})));
|
|
5878
|
+
|
|
5879
|
+
case 19:
|
|
5880
|
+
return _context12.abrupt("return", paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
5881
|
+
message: 'Payment option is loading...'
|
|
5882
|
+
}));
|
|
5883
|
+
|
|
5884
|
+
case 20:
|
|
5885
|
+
case "end":
|
|
5886
|
+
return _context12.stop();
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
}, _callee12);
|
|
5890
|
+
})));
|
|
5830
5891
|
|
|
5831
5892
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initPaypalPayment", function () {
|
|
5832
5893
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5948,10 +6009,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5948
6009
|
});
|
|
5949
6010
|
|
|
5950
6011
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
5951
|
-
var
|
|
5952
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6012
|
+
var _ref16 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee13(asset, accessData) {
|
|
6013
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee13$(_context13) {
|
|
5953
6014
|
while (1) {
|
|
5954
|
-
switch (
|
|
6015
|
+
switch (_context13.prev = _context13.next) {
|
|
5955
6016
|
case 0:
|
|
5956
6017
|
try {
|
|
5957
6018
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
@@ -5959,36 +6020,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5959
6020
|
console.log('error in pingbackAssetAccess', e);
|
|
5960
6021
|
}
|
|
5961
6022
|
|
|
5962
|
-
return
|
|
6023
|
+
return _context13.abrupt("return", true);
|
|
5963
6024
|
|
|
5964
6025
|
case 2:
|
|
5965
6026
|
case "end":
|
|
5966
|
-
return
|
|
6027
|
+
return _context13.stop();
|
|
5967
6028
|
}
|
|
5968
6029
|
}
|
|
5969
|
-
},
|
|
6030
|
+
}, _callee13);
|
|
5970
6031
|
}));
|
|
5971
6032
|
|
|
5972
6033
|
return function (_x7, _x8) {
|
|
5973
|
-
return
|
|
6034
|
+
return _ref16.apply(this, arguments);
|
|
5974
6035
|
};
|
|
5975
6036
|
}());
|
|
5976
6037
|
|
|
5977
6038
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "checkAccess", /*#__PURE__*/function () {
|
|
5978
|
-
var
|
|
5979
|
-
var asset, _yield$
|
|
6039
|
+
var _ref17 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee14(assetId) {
|
|
6040
|
+
var asset, _yield$awaitHelper13, error, accessData, accessById, _ref18, granted, grantReason, _ref18$data, data;
|
|
5980
6041
|
|
|
5981
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6042
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context14) {
|
|
5982
6043
|
while (1) {
|
|
5983
|
-
switch (
|
|
6044
|
+
switch (_context14.prev = _context14.next) {
|
|
5984
6045
|
case 0:
|
|
5985
6046
|
if (assetId) {
|
|
5986
|
-
|
|
6047
|
+
_context14.next = 3;
|
|
5987
6048
|
break;
|
|
5988
6049
|
}
|
|
5989
6050
|
|
|
5990
6051
|
console.warn('AssetId is required');
|
|
5991
|
-
return
|
|
6052
|
+
return _context14.abrupt("return", false);
|
|
5992
6053
|
|
|
5993
6054
|
case 3:
|
|
5994
6055
|
_this.props.accessIsLoading(true);
|
|
@@ -5997,20 +6058,20 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5997
6058
|
id: assetId,
|
|
5998
6059
|
type: 'story'
|
|
5999
6060
|
};
|
|
6000
|
-
|
|
6061
|
+
_context14.next = 7;
|
|
6001
6062
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
6002
6063
|
|
|
6003
6064
|
case 7:
|
|
6004
|
-
_yield$
|
|
6005
|
-
error = _yield$
|
|
6006
|
-
accessData = _yield$
|
|
6065
|
+
_yield$awaitHelper13 = _context14.sent;
|
|
6066
|
+
error = _yield$awaitHelper13.error;
|
|
6067
|
+
accessData = _yield$awaitHelper13.data;
|
|
6007
6068
|
|
|
6008
6069
|
if (!error) {
|
|
6009
|
-
|
|
6070
|
+
_context14.next = 12;
|
|
6010
6071
|
break;
|
|
6011
6072
|
}
|
|
6012
6073
|
|
|
6013
|
-
return
|
|
6074
|
+
return _context14.abrupt("return", error);
|
|
6014
6075
|
|
|
6015
6076
|
case 12:
|
|
6016
6077
|
accessById = _defineProperty__default["default"]({}, assetId, accessData);
|
|
@@ -6019,7 +6080,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6019
6080
|
|
|
6020
6081
|
_this.props.accessIsLoading(false);
|
|
6021
6082
|
|
|
6022
|
-
|
|
6083
|
+
_ref18 = accessData || {}, granted = _ref18.granted, grantReason = _ref18.grantReason, _ref18$data = _ref18.data, data = _ref18$data === void 0 ? {} : _ref18$data;
|
|
6023
6084
|
|
|
6024
6085
|
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
6025
6086
|
_this.pingBackMeteredStory(asset, accessData);
|
|
@@ -6027,82 +6088,82 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6027
6088
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
6028
6089
|
}
|
|
6029
6090
|
|
|
6030
|
-
return
|
|
6091
|
+
return _context14.abrupt("return", accessById);
|
|
6031
6092
|
|
|
6032
6093
|
case 18:
|
|
6033
6094
|
case "end":
|
|
6034
|
-
return
|
|
6095
|
+
return _context14.stop();
|
|
6035
6096
|
}
|
|
6036
6097
|
}
|
|
6037
|
-
},
|
|
6098
|
+
}, _callee14);
|
|
6038
6099
|
}));
|
|
6039
6100
|
|
|
6040
6101
|
return function (_x9) {
|
|
6041
|
-
return
|
|
6102
|
+
return _ref17.apply(this, arguments);
|
|
6042
6103
|
};
|
|
6043
6104
|
}());
|
|
6044
6105
|
|
|
6045
|
-
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function
|
|
6106
|
+
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee15() {
|
|
6046
6107
|
var metadata;
|
|
6047
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6108
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context15) {
|
|
6048
6109
|
while (1) {
|
|
6049
|
-
switch (
|
|
6110
|
+
switch (_context15.prev = _context15.next) {
|
|
6050
6111
|
case 0:
|
|
6051
6112
|
if (global.AccessType) {
|
|
6052
|
-
|
|
6113
|
+
_context15.next = 2;
|
|
6053
6114
|
break;
|
|
6054
6115
|
}
|
|
6055
6116
|
|
|
6056
|
-
return
|
|
6117
|
+
return _context15.abrupt("return", {});
|
|
6057
6118
|
|
|
6058
6119
|
case 2:
|
|
6059
|
-
|
|
6120
|
+
_context15.next = 4;
|
|
6060
6121
|
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
6061
6122
|
|
|
6062
6123
|
case 4:
|
|
6063
|
-
metadata =
|
|
6064
|
-
return
|
|
6124
|
+
metadata = _context15.sent;
|
|
6125
|
+
return _context15.abrupt("return", metadata);
|
|
6065
6126
|
|
|
6066
6127
|
case 6:
|
|
6067
6128
|
case "end":
|
|
6068
|
-
return
|
|
6129
|
+
return _context15.stop();
|
|
6069
6130
|
}
|
|
6070
6131
|
}
|
|
6071
|
-
},
|
|
6132
|
+
}, _callee15);
|
|
6072
6133
|
})));
|
|
6073
6134
|
|
|
6074
6135
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
6075
|
-
var
|
|
6136
|
+
var _ref20 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16(subscriberMetadata) {
|
|
6076
6137
|
var response;
|
|
6077
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6138
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
|
6078
6139
|
while (1) {
|
|
6079
|
-
switch (
|
|
6140
|
+
switch (_context16.prev = _context16.next) {
|
|
6080
6141
|
case 0:
|
|
6081
6142
|
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
6082
|
-
|
|
6143
|
+
_context16.next = 2;
|
|
6083
6144
|
break;
|
|
6084
6145
|
}
|
|
6085
6146
|
|
|
6086
|
-
return
|
|
6147
|
+
return _context16.abrupt("return", {});
|
|
6087
6148
|
|
|
6088
6149
|
case 2:
|
|
6089
|
-
|
|
6150
|
+
_context16.next = 4;
|
|
6090
6151
|
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
6091
6152
|
|
|
6092
6153
|
case 4:
|
|
6093
|
-
response =
|
|
6094
|
-
return
|
|
6154
|
+
response = _context16.sent;
|
|
6155
|
+
return _context16.abrupt("return", response);
|
|
6095
6156
|
|
|
6096
6157
|
case 6:
|
|
6097
6158
|
case "end":
|
|
6098
|
-
return
|
|
6159
|
+
return _context16.stop();
|
|
6099
6160
|
}
|
|
6100
6161
|
}
|
|
6101
|
-
},
|
|
6162
|
+
}, _callee16);
|
|
6102
6163
|
}));
|
|
6103
6164
|
|
|
6104
6165
|
return function (_x10) {
|
|
6105
|
-
return
|
|
6166
|
+
return _ref20.apply(this, arguments);
|
|
6106
6167
|
};
|
|
6107
6168
|
}());
|
|
6108
6169
|
|
|
@@ -6118,29 +6179,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6118
6179
|
}
|
|
6119
6180
|
}, {
|
|
6120
6181
|
key: "makePaymentObject",
|
|
6121
|
-
value: function makePaymentObject(
|
|
6122
|
-
var
|
|
6123
|
-
selectedPlan =
|
|
6124
|
-
|
|
6125
|
-
couponCode =
|
|
6126
|
-
|
|
6127
|
-
recipientSubscriber =
|
|
6128
|
-
|
|
6129
|
-
planType =
|
|
6130
|
-
|
|
6131
|
-
storyId =
|
|
6132
|
-
|
|
6133
|
-
storyHeadline =
|
|
6134
|
-
|
|
6135
|
-
storySlug =
|
|
6136
|
-
|
|
6137
|
-
paymentType =
|
|
6138
|
-
|
|
6139
|
-
successUrl =
|
|
6140
|
-
|
|
6141
|
-
returnUrl =
|
|
6142
|
-
|
|
6143
|
-
cancelUrl =
|
|
6182
|
+
value: function makePaymentObject(_ref21) {
|
|
6183
|
+
var _ref21$selectedPlan = _ref21.selectedPlan,
|
|
6184
|
+
selectedPlan = _ref21$selectedPlan === void 0 ? {} : _ref21$selectedPlan,
|
|
6185
|
+
_ref21$couponCode = _ref21.couponCode,
|
|
6186
|
+
couponCode = _ref21$couponCode === void 0 ? '' : _ref21$couponCode,
|
|
6187
|
+
_ref21$recipientSubsc = _ref21.recipientSubscriber,
|
|
6188
|
+
recipientSubscriber = _ref21$recipientSubsc === void 0 ? {} : _ref21$recipientSubsc,
|
|
6189
|
+
_ref21$planType = _ref21.planType,
|
|
6190
|
+
planType = _ref21$planType === void 0 ? '' : _ref21$planType,
|
|
6191
|
+
_ref21$storyId = _ref21.storyId,
|
|
6192
|
+
storyId = _ref21$storyId === void 0 ? '' : _ref21$storyId,
|
|
6193
|
+
_ref21$storyHeadline = _ref21.storyHeadline,
|
|
6194
|
+
storyHeadline = _ref21$storyHeadline === void 0 ? '' : _ref21$storyHeadline,
|
|
6195
|
+
_ref21$storySlug = _ref21.storySlug,
|
|
6196
|
+
storySlug = _ref21$storySlug === void 0 ? '' : _ref21$storySlug,
|
|
6197
|
+
_ref21$paymentType = _ref21.paymentType,
|
|
6198
|
+
paymentType = _ref21$paymentType === void 0 ? '' : _ref21$paymentType,
|
|
6199
|
+
_ref21$successUrl = _ref21.successUrl,
|
|
6200
|
+
successUrl = _ref21$successUrl === void 0 ? '' : _ref21$successUrl,
|
|
6201
|
+
_ref21$returnUrl = _ref21.returnUrl,
|
|
6202
|
+
returnUrl = _ref21$returnUrl === void 0 ? '' : _ref21$returnUrl,
|
|
6203
|
+
_ref21$cancelUrl = _ref21.cancelUrl,
|
|
6204
|
+
cancelUrl = _ref21$cancelUrl === void 0 ? '' : _ref21$cancelUrl;
|
|
6144
6205
|
var id = selectedPlan.id,
|
|
6145
6206
|
title = selectedPlan.title,
|
|
6146
6207
|
description = selectedPlan.description,
|
|
@@ -734,25 +734,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
734
734
|
}, _callee11);
|
|
735
735
|
})));
|
|
736
736
|
|
|
737
|
-
_defineProperty(_assertThisInitialized(_this), "initStripePayment", function () {
|
|
738
|
-
var options
|
|
737
|
+
_defineProperty(_assertThisInitialized(_this), "initStripePayment", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
738
|
+
var options,
|
|
739
|
+
paymentOptions,
|
|
740
|
+
paymentType,
|
|
741
|
+
paymentObject,
|
|
742
|
+
intent,
|
|
743
|
+
switchType,
|
|
744
|
+
_options$selectedPlan,
|
|
745
|
+
_options$selectedPlan2,
|
|
746
|
+
_yield$awaitHelper12,
|
|
747
|
+
error,
|
|
748
|
+
switchPaymentOptions,
|
|
749
|
+
_args12 = arguments;
|
|
739
750
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
751
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
752
|
+
while (1) {
|
|
753
|
+
switch (_context12.prev = _context12.next) {
|
|
754
|
+
case 0:
|
|
755
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
744
756
|
|
|
745
|
-
|
|
746
|
-
|
|
757
|
+
if (options.selectedPlan) {
|
|
758
|
+
_context12.next = 4;
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
747
761
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}, options));
|
|
762
|
+
console.warn('Stripe pay needs a plan');
|
|
763
|
+
return _context12.abrupt("return", false);
|
|
751
764
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
765
|
+
case 4:
|
|
766
|
+
paymentOptions = _this.props.paymentOptions;
|
|
767
|
+
paymentType = get(options.selectedPlan, ['recurring']) ? 'stripe_recurring' : 'stripe';
|
|
768
|
+
paymentObject = _this.makePaymentObject(_objectSpread({
|
|
769
|
+
paymentType: paymentType
|
|
770
|
+
}, options));
|
|
771
|
+
intent = get(options, ['intent'], 'default');
|
|
772
|
+
switchType = get(options, ['switchType']);
|
|
773
|
+
console.log("------- initStripePayment PROPS--------->", _this.props, {
|
|
774
|
+
intent: intent,
|
|
775
|
+
switchType: switchType
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
if (!(intent === "switch")) {
|
|
779
|
+
_context12.next = 19;
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
_context12.next = 13;
|
|
784
|
+
return awaitHelper(global.AccessType.getPaymentOptions(null, null, "switch"));
|
|
785
|
+
|
|
786
|
+
case 13:
|
|
787
|
+
_yield$awaitHelper12 = _context12.sent;
|
|
788
|
+
error = _yield$awaitHelper12.error;
|
|
789
|
+
switchPaymentOptions = _yield$awaitHelper12.data;
|
|
790
|
+
|
|
791
|
+
if (!error) {
|
|
792
|
+
_context12.next = 18;
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
throw new Error("payment options fetch failed");
|
|
797
|
+
|
|
798
|
+
case 18:
|
|
799
|
+
return _context12.abrupt("return", switchPaymentOptions.stripe.proceed(_objectSpread(_objectSpread({}, paymentObject), {}, {
|
|
800
|
+
switch_type: switchType,
|
|
801
|
+
subscription_plan_id: options === null || options === void 0 ? void 0 : (_options$selectedPlan = options.selectedPlan) === null || _options$selectedPlan === void 0 ? void 0 : _options$selectedPlan.id,
|
|
802
|
+
subscriptionId: options === null || options === void 0 ? void 0 : (_options$selectedPlan2 = options.selectedPlan) === null || _options$selectedPlan2 === void 0 ? void 0 : _options$selectedPlan2.subscriptionId
|
|
803
|
+
})));
|
|
804
|
+
|
|
805
|
+
case 19:
|
|
806
|
+
return _context12.abrupt("return", paymentOptions.stripe ? paymentOptions.stripe.proceed(paymentObject) : Promise.reject({
|
|
807
|
+
message: 'Payment option is loading...'
|
|
808
|
+
}));
|
|
809
|
+
|
|
810
|
+
case 20:
|
|
811
|
+
case "end":
|
|
812
|
+
return _context12.stop();
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}, _callee12);
|
|
816
|
+
})));
|
|
756
817
|
|
|
757
818
|
_defineProperty(_assertThisInitialized(_this), "initPaypalPayment", function () {
|
|
758
819
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -874,10 +935,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
874
935
|
});
|
|
875
936
|
|
|
876
937
|
_defineProperty(_assertThisInitialized(_this), "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
877
|
-
var
|
|
878
|
-
return _regeneratorRuntime.wrap(function
|
|
938
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(asset, accessData) {
|
|
939
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
879
940
|
while (1) {
|
|
880
|
-
switch (
|
|
941
|
+
switch (_context13.prev = _context13.next) {
|
|
881
942
|
case 0:
|
|
882
943
|
try {
|
|
883
944
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
@@ -885,36 +946,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
885
946
|
console.log('error in pingbackAssetAccess', e);
|
|
886
947
|
}
|
|
887
948
|
|
|
888
|
-
return
|
|
949
|
+
return _context13.abrupt("return", true);
|
|
889
950
|
|
|
890
951
|
case 2:
|
|
891
952
|
case "end":
|
|
892
|
-
return
|
|
953
|
+
return _context13.stop();
|
|
893
954
|
}
|
|
894
955
|
}
|
|
895
|
-
},
|
|
956
|
+
}, _callee13);
|
|
896
957
|
}));
|
|
897
958
|
|
|
898
959
|
return function (_x7, _x8) {
|
|
899
|
-
return
|
|
960
|
+
return _ref16.apply(this, arguments);
|
|
900
961
|
};
|
|
901
962
|
}());
|
|
902
963
|
|
|
903
964
|
_defineProperty(_assertThisInitialized(_this), "checkAccess", /*#__PURE__*/function () {
|
|
904
|
-
var
|
|
905
|
-
var asset, _yield$
|
|
965
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(assetId) {
|
|
966
|
+
var asset, _yield$awaitHelper13, error, accessData, accessById, _ref18, granted, grantReason, _ref18$data, data;
|
|
906
967
|
|
|
907
|
-
return _regeneratorRuntime.wrap(function
|
|
968
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
908
969
|
while (1) {
|
|
909
|
-
switch (
|
|
970
|
+
switch (_context14.prev = _context14.next) {
|
|
910
971
|
case 0:
|
|
911
972
|
if (assetId) {
|
|
912
|
-
|
|
973
|
+
_context14.next = 3;
|
|
913
974
|
break;
|
|
914
975
|
}
|
|
915
976
|
|
|
916
977
|
console.warn('AssetId is required');
|
|
917
|
-
return
|
|
978
|
+
return _context14.abrupt("return", false);
|
|
918
979
|
|
|
919
980
|
case 3:
|
|
920
981
|
_this.props.accessIsLoading(true);
|
|
@@ -923,20 +984,20 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
923
984
|
id: assetId,
|
|
924
985
|
type: 'story'
|
|
925
986
|
};
|
|
926
|
-
|
|
987
|
+
_context14.next = 7;
|
|
927
988
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
928
989
|
|
|
929
990
|
case 7:
|
|
930
|
-
_yield$
|
|
931
|
-
error = _yield$
|
|
932
|
-
accessData = _yield$
|
|
991
|
+
_yield$awaitHelper13 = _context14.sent;
|
|
992
|
+
error = _yield$awaitHelper13.error;
|
|
993
|
+
accessData = _yield$awaitHelper13.data;
|
|
933
994
|
|
|
934
995
|
if (!error) {
|
|
935
|
-
|
|
996
|
+
_context14.next = 12;
|
|
936
997
|
break;
|
|
937
998
|
}
|
|
938
999
|
|
|
939
|
-
return
|
|
1000
|
+
return _context14.abrupt("return", error);
|
|
940
1001
|
|
|
941
1002
|
case 12:
|
|
942
1003
|
accessById = _defineProperty({}, assetId, accessData);
|
|
@@ -945,7 +1006,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
945
1006
|
|
|
946
1007
|
_this.props.accessIsLoading(false);
|
|
947
1008
|
|
|
948
|
-
|
|
1009
|
+
_ref18 = accessData || {}, granted = _ref18.granted, grantReason = _ref18.grantReason, _ref18$data = _ref18.data, data = _ref18$data === void 0 ? {} : _ref18$data;
|
|
949
1010
|
|
|
950
1011
|
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
951
1012
|
_this.pingBackMeteredStory(asset, accessData);
|
|
@@ -953,82 +1014,82 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
953
1014
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
954
1015
|
}
|
|
955
1016
|
|
|
956
|
-
return
|
|
1017
|
+
return _context14.abrupt("return", accessById);
|
|
957
1018
|
|
|
958
1019
|
case 18:
|
|
959
1020
|
case "end":
|
|
960
|
-
return
|
|
1021
|
+
return _context14.stop();
|
|
961
1022
|
}
|
|
962
1023
|
}
|
|
963
|
-
},
|
|
1024
|
+
}, _callee14);
|
|
964
1025
|
}));
|
|
965
1026
|
|
|
966
1027
|
return function (_x9) {
|
|
967
|
-
return
|
|
1028
|
+
return _ref17.apply(this, arguments);
|
|
968
1029
|
};
|
|
969
1030
|
}());
|
|
970
1031
|
|
|
971
|
-
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1032
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
972
1033
|
var metadata;
|
|
973
|
-
return _regeneratorRuntime.wrap(function
|
|
1034
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
974
1035
|
while (1) {
|
|
975
|
-
switch (
|
|
1036
|
+
switch (_context15.prev = _context15.next) {
|
|
976
1037
|
case 0:
|
|
977
1038
|
if (global.AccessType) {
|
|
978
|
-
|
|
1039
|
+
_context15.next = 2;
|
|
979
1040
|
break;
|
|
980
1041
|
}
|
|
981
1042
|
|
|
982
|
-
return
|
|
1043
|
+
return _context15.abrupt("return", {});
|
|
983
1044
|
|
|
984
1045
|
case 2:
|
|
985
|
-
|
|
1046
|
+
_context15.next = 4;
|
|
986
1047
|
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
987
1048
|
|
|
988
1049
|
case 4:
|
|
989
|
-
metadata =
|
|
990
|
-
return
|
|
1050
|
+
metadata = _context15.sent;
|
|
1051
|
+
return _context15.abrupt("return", metadata);
|
|
991
1052
|
|
|
992
1053
|
case 6:
|
|
993
1054
|
case "end":
|
|
994
|
-
return
|
|
1055
|
+
return _context15.stop();
|
|
995
1056
|
}
|
|
996
1057
|
}
|
|
997
|
-
},
|
|
1058
|
+
}, _callee15);
|
|
998
1059
|
})));
|
|
999
1060
|
|
|
1000
1061
|
_defineProperty(_assertThisInitialized(_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
1001
|
-
var
|
|
1062
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(subscriberMetadata) {
|
|
1002
1063
|
var response;
|
|
1003
|
-
return _regeneratorRuntime.wrap(function
|
|
1064
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1004
1065
|
while (1) {
|
|
1005
|
-
switch (
|
|
1066
|
+
switch (_context16.prev = _context16.next) {
|
|
1006
1067
|
case 0:
|
|
1007
1068
|
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
1008
|
-
|
|
1069
|
+
_context16.next = 2;
|
|
1009
1070
|
break;
|
|
1010
1071
|
}
|
|
1011
1072
|
|
|
1012
|
-
return
|
|
1073
|
+
return _context16.abrupt("return", {});
|
|
1013
1074
|
|
|
1014
1075
|
case 2:
|
|
1015
|
-
|
|
1076
|
+
_context16.next = 4;
|
|
1016
1077
|
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
1017
1078
|
|
|
1018
1079
|
case 4:
|
|
1019
|
-
response =
|
|
1020
|
-
return
|
|
1080
|
+
response = _context16.sent;
|
|
1081
|
+
return _context16.abrupt("return", response);
|
|
1021
1082
|
|
|
1022
1083
|
case 6:
|
|
1023
1084
|
case "end":
|
|
1024
|
-
return
|
|
1085
|
+
return _context16.stop();
|
|
1025
1086
|
}
|
|
1026
1087
|
}
|
|
1027
|
-
},
|
|
1088
|
+
}, _callee16);
|
|
1028
1089
|
}));
|
|
1029
1090
|
|
|
1030
1091
|
return function (_x10) {
|
|
1031
|
-
return
|
|
1092
|
+
return _ref20.apply(this, arguments);
|
|
1032
1093
|
};
|
|
1033
1094
|
}());
|
|
1034
1095
|
|
|
@@ -1044,29 +1105,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1044
1105
|
}
|
|
1045
1106
|
}, {
|
|
1046
1107
|
key: "makePaymentObject",
|
|
1047
|
-
value: function makePaymentObject(
|
|
1048
|
-
var
|
|
1049
|
-
selectedPlan =
|
|
1050
|
-
|
|
1051
|
-
couponCode =
|
|
1052
|
-
|
|
1053
|
-
recipientSubscriber =
|
|
1054
|
-
|
|
1055
|
-
planType =
|
|
1056
|
-
|
|
1057
|
-
storyId =
|
|
1058
|
-
|
|
1059
|
-
storyHeadline =
|
|
1060
|
-
|
|
1061
|
-
storySlug =
|
|
1062
|
-
|
|
1063
|
-
paymentType =
|
|
1064
|
-
|
|
1065
|
-
successUrl =
|
|
1066
|
-
|
|
1067
|
-
returnUrl =
|
|
1068
|
-
|
|
1069
|
-
cancelUrl =
|
|
1108
|
+
value: function makePaymentObject(_ref21) {
|
|
1109
|
+
var _ref21$selectedPlan = _ref21.selectedPlan,
|
|
1110
|
+
selectedPlan = _ref21$selectedPlan === void 0 ? {} : _ref21$selectedPlan,
|
|
1111
|
+
_ref21$couponCode = _ref21.couponCode,
|
|
1112
|
+
couponCode = _ref21$couponCode === void 0 ? '' : _ref21$couponCode,
|
|
1113
|
+
_ref21$recipientSubsc = _ref21.recipientSubscriber,
|
|
1114
|
+
recipientSubscriber = _ref21$recipientSubsc === void 0 ? {} : _ref21$recipientSubsc,
|
|
1115
|
+
_ref21$planType = _ref21.planType,
|
|
1116
|
+
planType = _ref21$planType === void 0 ? '' : _ref21$planType,
|
|
1117
|
+
_ref21$storyId = _ref21.storyId,
|
|
1118
|
+
storyId = _ref21$storyId === void 0 ? '' : _ref21$storyId,
|
|
1119
|
+
_ref21$storyHeadline = _ref21.storyHeadline,
|
|
1120
|
+
storyHeadline = _ref21$storyHeadline === void 0 ? '' : _ref21$storyHeadline,
|
|
1121
|
+
_ref21$storySlug = _ref21.storySlug,
|
|
1122
|
+
storySlug = _ref21$storySlug === void 0 ? '' : _ref21$storySlug,
|
|
1123
|
+
_ref21$paymentType = _ref21.paymentType,
|
|
1124
|
+
paymentType = _ref21$paymentType === void 0 ? '' : _ref21$paymentType,
|
|
1125
|
+
_ref21$successUrl = _ref21.successUrl,
|
|
1126
|
+
successUrl = _ref21$successUrl === void 0 ? '' : _ref21$successUrl,
|
|
1127
|
+
_ref21$returnUrl = _ref21.returnUrl,
|
|
1128
|
+
returnUrl = _ref21$returnUrl === void 0 ? '' : _ref21$returnUrl,
|
|
1129
|
+
_ref21$cancelUrl = _ref21.cancelUrl,
|
|
1130
|
+
cancelUrl = _ref21$cancelUrl === void 0 ? '' : _ref21$cancelUrl;
|
|
1070
1131
|
var id = selectedPlan.id,
|
|
1071
1132
|
title = selectedPlan.title,
|
|
1072
1133
|
description = selectedPlan.description,
|