@quintype/components 3.8.9-razorpay-log.0 → 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 +145 -85
- package/dist/es/components/access-type.js +145 -85
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -5798,10 +5798,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5798
5798
|
})));
|
|
5799
5799
|
|
|
5800
5800
|
case 34:
|
|
5801
|
-
console.log('paymentOptions', paymentOptions.razorpay.proceed(paymentObject));
|
|
5802
5801
|
return _context11.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
|
|
5803
5802
|
|
|
5804
|
-
case
|
|
5803
|
+
case 35:
|
|
5805
5804
|
case "end":
|
|
5806
5805
|
return _context11.stop();
|
|
5807
5806
|
}
|
|
@@ -5809,25 +5808,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5809
5808
|
}, _callee11);
|
|
5810
5809
|
})));
|
|
5811
5810
|
|
|
5812
|
-
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initStripePayment", function () {
|
|
5813
|
-
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;
|
|
5814
5824
|
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
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] : {};
|
|
5819
5830
|
|
|
5820
|
-
|
|
5821
|
-
|
|
5831
|
+
if (options.selectedPlan) {
|
|
5832
|
+
_context12.next = 4;
|
|
5833
|
+
break;
|
|
5834
|
+
}
|
|
5822
5835
|
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
}, options));
|
|
5836
|
+
console.warn('Stripe pay needs a plan');
|
|
5837
|
+
return _context12.abrupt("return", false);
|
|
5826
5838
|
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
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
|
+
})));
|
|
5831
5891
|
|
|
5832
5892
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "initPaypalPayment", function () {
|
|
5833
5893
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5949,10 +6009,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5949
6009
|
});
|
|
5950
6010
|
|
|
5951
6011
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
5952
|
-
var
|
|
5953
|
-
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) {
|
|
5954
6014
|
while (1) {
|
|
5955
|
-
switch (
|
|
6015
|
+
switch (_context13.prev = _context13.next) {
|
|
5956
6016
|
case 0:
|
|
5957
6017
|
try {
|
|
5958
6018
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
@@ -5960,36 +6020,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5960
6020
|
console.log('error in pingbackAssetAccess', e);
|
|
5961
6021
|
}
|
|
5962
6022
|
|
|
5963
|
-
return
|
|
6023
|
+
return _context13.abrupt("return", true);
|
|
5964
6024
|
|
|
5965
6025
|
case 2:
|
|
5966
6026
|
case "end":
|
|
5967
|
-
return
|
|
6027
|
+
return _context13.stop();
|
|
5968
6028
|
}
|
|
5969
6029
|
}
|
|
5970
|
-
},
|
|
6030
|
+
}, _callee13);
|
|
5971
6031
|
}));
|
|
5972
6032
|
|
|
5973
6033
|
return function (_x7, _x8) {
|
|
5974
|
-
return
|
|
6034
|
+
return _ref16.apply(this, arguments);
|
|
5975
6035
|
};
|
|
5976
6036
|
}());
|
|
5977
6037
|
|
|
5978
6038
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "checkAccess", /*#__PURE__*/function () {
|
|
5979
|
-
var
|
|
5980
|
-
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;
|
|
5981
6041
|
|
|
5982
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6042
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee14$(_context14) {
|
|
5983
6043
|
while (1) {
|
|
5984
|
-
switch (
|
|
6044
|
+
switch (_context14.prev = _context14.next) {
|
|
5985
6045
|
case 0:
|
|
5986
6046
|
if (assetId) {
|
|
5987
|
-
|
|
6047
|
+
_context14.next = 3;
|
|
5988
6048
|
break;
|
|
5989
6049
|
}
|
|
5990
6050
|
|
|
5991
6051
|
console.warn('AssetId is required');
|
|
5992
|
-
return
|
|
6052
|
+
return _context14.abrupt("return", false);
|
|
5993
6053
|
|
|
5994
6054
|
case 3:
|
|
5995
6055
|
_this.props.accessIsLoading(true);
|
|
@@ -5998,20 +6058,20 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
5998
6058
|
id: assetId,
|
|
5999
6059
|
type: 'story'
|
|
6000
6060
|
};
|
|
6001
|
-
|
|
6061
|
+
_context14.next = 7;
|
|
6002
6062
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
6003
6063
|
|
|
6004
6064
|
case 7:
|
|
6005
|
-
_yield$
|
|
6006
|
-
error = _yield$
|
|
6007
|
-
accessData = _yield$
|
|
6065
|
+
_yield$awaitHelper13 = _context14.sent;
|
|
6066
|
+
error = _yield$awaitHelper13.error;
|
|
6067
|
+
accessData = _yield$awaitHelper13.data;
|
|
6008
6068
|
|
|
6009
6069
|
if (!error) {
|
|
6010
|
-
|
|
6070
|
+
_context14.next = 12;
|
|
6011
6071
|
break;
|
|
6012
6072
|
}
|
|
6013
6073
|
|
|
6014
|
-
return
|
|
6074
|
+
return _context14.abrupt("return", error);
|
|
6015
6075
|
|
|
6016
6076
|
case 12:
|
|
6017
6077
|
accessById = _defineProperty__default["default"]({}, assetId, accessData);
|
|
@@ -6020,7 +6080,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6020
6080
|
|
|
6021
6081
|
_this.props.accessIsLoading(false);
|
|
6022
6082
|
|
|
6023
|
-
|
|
6083
|
+
_ref18 = accessData || {}, granted = _ref18.granted, grantReason = _ref18.grantReason, _ref18$data = _ref18.data, data = _ref18$data === void 0 ? {} : _ref18$data;
|
|
6024
6084
|
|
|
6025
6085
|
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
6026
6086
|
_this.pingBackMeteredStory(asset, accessData);
|
|
@@ -6028,82 +6088,82 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6028
6088
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
6029
6089
|
}
|
|
6030
6090
|
|
|
6031
|
-
return
|
|
6091
|
+
return _context14.abrupt("return", accessById);
|
|
6032
6092
|
|
|
6033
6093
|
case 18:
|
|
6034
6094
|
case "end":
|
|
6035
|
-
return
|
|
6095
|
+
return _context14.stop();
|
|
6036
6096
|
}
|
|
6037
6097
|
}
|
|
6038
|
-
},
|
|
6098
|
+
}, _callee14);
|
|
6039
6099
|
}));
|
|
6040
6100
|
|
|
6041
6101
|
return function (_x9) {
|
|
6042
|
-
return
|
|
6102
|
+
return _ref17.apply(this, arguments);
|
|
6043
6103
|
};
|
|
6044
6104
|
}());
|
|
6045
6105
|
|
|
6046
|
-
_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() {
|
|
6047
6107
|
var metadata;
|
|
6048
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6108
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee15$(_context15) {
|
|
6049
6109
|
while (1) {
|
|
6050
|
-
switch (
|
|
6110
|
+
switch (_context15.prev = _context15.next) {
|
|
6051
6111
|
case 0:
|
|
6052
6112
|
if (global.AccessType) {
|
|
6053
|
-
|
|
6113
|
+
_context15.next = 2;
|
|
6054
6114
|
break;
|
|
6055
6115
|
}
|
|
6056
6116
|
|
|
6057
|
-
return
|
|
6117
|
+
return _context15.abrupt("return", {});
|
|
6058
6118
|
|
|
6059
6119
|
case 2:
|
|
6060
|
-
|
|
6120
|
+
_context15.next = 4;
|
|
6061
6121
|
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
6062
6122
|
|
|
6063
6123
|
case 4:
|
|
6064
|
-
metadata =
|
|
6065
|
-
return
|
|
6124
|
+
metadata = _context15.sent;
|
|
6125
|
+
return _context15.abrupt("return", metadata);
|
|
6066
6126
|
|
|
6067
6127
|
case 6:
|
|
6068
6128
|
case "end":
|
|
6069
|
-
return
|
|
6129
|
+
return _context15.stop();
|
|
6070
6130
|
}
|
|
6071
6131
|
}
|
|
6072
|
-
},
|
|
6132
|
+
}, _callee15);
|
|
6073
6133
|
})));
|
|
6074
6134
|
|
|
6075
6135
|
_defineProperty__default["default"](_assertThisInitialized__default["default"](_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
6076
|
-
var
|
|
6136
|
+
var _ref20 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee16(subscriberMetadata) {
|
|
6077
6137
|
var response;
|
|
6078
|
-
return _regeneratorRuntime__default["default"].wrap(function
|
|
6138
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee16$(_context16) {
|
|
6079
6139
|
while (1) {
|
|
6080
|
-
switch (
|
|
6140
|
+
switch (_context16.prev = _context16.next) {
|
|
6081
6141
|
case 0:
|
|
6082
6142
|
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
6083
|
-
|
|
6143
|
+
_context16.next = 2;
|
|
6084
6144
|
break;
|
|
6085
6145
|
}
|
|
6086
6146
|
|
|
6087
|
-
return
|
|
6147
|
+
return _context16.abrupt("return", {});
|
|
6088
6148
|
|
|
6089
6149
|
case 2:
|
|
6090
|
-
|
|
6150
|
+
_context16.next = 4;
|
|
6091
6151
|
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
6092
6152
|
|
|
6093
6153
|
case 4:
|
|
6094
|
-
response =
|
|
6095
|
-
return
|
|
6154
|
+
response = _context16.sent;
|
|
6155
|
+
return _context16.abrupt("return", response);
|
|
6096
6156
|
|
|
6097
6157
|
case 6:
|
|
6098
6158
|
case "end":
|
|
6099
|
-
return
|
|
6159
|
+
return _context16.stop();
|
|
6100
6160
|
}
|
|
6101
6161
|
}
|
|
6102
|
-
},
|
|
6162
|
+
}, _callee16);
|
|
6103
6163
|
}));
|
|
6104
6164
|
|
|
6105
6165
|
return function (_x10) {
|
|
6106
|
-
return
|
|
6166
|
+
return _ref20.apply(this, arguments);
|
|
6107
6167
|
};
|
|
6108
6168
|
}());
|
|
6109
6169
|
|
|
@@ -6119,29 +6179,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
6119
6179
|
}
|
|
6120
6180
|
}, {
|
|
6121
6181
|
key: "makePaymentObject",
|
|
6122
|
-
value: function makePaymentObject(
|
|
6123
|
-
var
|
|
6124
|
-
selectedPlan =
|
|
6125
|
-
|
|
6126
|
-
couponCode =
|
|
6127
|
-
|
|
6128
|
-
recipientSubscriber =
|
|
6129
|
-
|
|
6130
|
-
planType =
|
|
6131
|
-
|
|
6132
|
-
storyId =
|
|
6133
|
-
|
|
6134
|
-
storyHeadline =
|
|
6135
|
-
|
|
6136
|
-
storySlug =
|
|
6137
|
-
|
|
6138
|
-
paymentType =
|
|
6139
|
-
|
|
6140
|
-
successUrl =
|
|
6141
|
-
|
|
6142
|
-
returnUrl =
|
|
6143
|
-
|
|
6144
|
-
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;
|
|
6145
6205
|
var id = selectedPlan.id,
|
|
6146
6206
|
title = selectedPlan.title,
|
|
6147
6207
|
description = selectedPlan.description,
|
|
@@ -724,10 +724,9 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
724
724
|
})));
|
|
725
725
|
|
|
726
726
|
case 34:
|
|
727
|
-
console.log('paymentOptions', paymentOptions.razorpay.proceed(paymentObject));
|
|
728
727
|
return _context11.abrupt("return", paymentOptions.razorpay.proceed(paymentObject));
|
|
729
728
|
|
|
730
|
-
case
|
|
729
|
+
case 35:
|
|
731
730
|
case "end":
|
|
732
731
|
return _context11.stop();
|
|
733
732
|
}
|
|
@@ -735,25 +734,86 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
735
734
|
}, _callee11);
|
|
736
735
|
})));
|
|
737
736
|
|
|
738
|
-
_defineProperty(_assertThisInitialized(_this), "initStripePayment", function () {
|
|
739
|
-
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;
|
|
740
750
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
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] : {};
|
|
745
756
|
|
|
746
|
-
|
|
747
|
-
|
|
757
|
+
if (options.selectedPlan) {
|
|
758
|
+
_context12.next = 4;
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
748
761
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}, options));
|
|
762
|
+
console.warn('Stripe pay needs a plan');
|
|
763
|
+
return _context12.abrupt("return", false);
|
|
752
764
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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
|
+
})));
|
|
757
817
|
|
|
758
818
|
_defineProperty(_assertThisInitialized(_this), "initPaypalPayment", function () {
|
|
759
819
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -875,10 +935,10 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
875
935
|
});
|
|
876
936
|
|
|
877
937
|
_defineProperty(_assertThisInitialized(_this), "pingBackMeteredStory", /*#__PURE__*/function () {
|
|
878
|
-
var
|
|
879
|
-
return _regeneratorRuntime.wrap(function
|
|
938
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(asset, accessData) {
|
|
939
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
880
940
|
while (1) {
|
|
881
|
-
switch (
|
|
941
|
+
switch (_context13.prev = _context13.next) {
|
|
882
942
|
case 0:
|
|
883
943
|
try {
|
|
884
944
|
global.AccessType.pingbackAssetAccess(asset, accessData);
|
|
@@ -886,36 +946,36 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
886
946
|
console.log('error in pingbackAssetAccess', e);
|
|
887
947
|
}
|
|
888
948
|
|
|
889
|
-
return
|
|
949
|
+
return _context13.abrupt("return", true);
|
|
890
950
|
|
|
891
951
|
case 2:
|
|
892
952
|
case "end":
|
|
893
|
-
return
|
|
953
|
+
return _context13.stop();
|
|
894
954
|
}
|
|
895
955
|
}
|
|
896
|
-
},
|
|
956
|
+
}, _callee13);
|
|
897
957
|
}));
|
|
898
958
|
|
|
899
959
|
return function (_x7, _x8) {
|
|
900
|
-
return
|
|
960
|
+
return _ref16.apply(this, arguments);
|
|
901
961
|
};
|
|
902
962
|
}());
|
|
903
963
|
|
|
904
964
|
_defineProperty(_assertThisInitialized(_this), "checkAccess", /*#__PURE__*/function () {
|
|
905
|
-
var
|
|
906
|
-
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;
|
|
907
967
|
|
|
908
|
-
return _regeneratorRuntime.wrap(function
|
|
968
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
909
969
|
while (1) {
|
|
910
|
-
switch (
|
|
970
|
+
switch (_context14.prev = _context14.next) {
|
|
911
971
|
case 0:
|
|
912
972
|
if (assetId) {
|
|
913
|
-
|
|
973
|
+
_context14.next = 3;
|
|
914
974
|
break;
|
|
915
975
|
}
|
|
916
976
|
|
|
917
977
|
console.warn('AssetId is required');
|
|
918
|
-
return
|
|
978
|
+
return _context14.abrupt("return", false);
|
|
919
979
|
|
|
920
980
|
case 3:
|
|
921
981
|
_this.props.accessIsLoading(true);
|
|
@@ -924,20 +984,20 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
924
984
|
id: assetId,
|
|
925
985
|
type: 'story'
|
|
926
986
|
};
|
|
927
|
-
|
|
987
|
+
_context14.next = 7;
|
|
928
988
|
return awaitHelper(global.AccessType.isAssetAccessible(asset, _this.props.disableMetering));
|
|
929
989
|
|
|
930
990
|
case 7:
|
|
931
|
-
_yield$
|
|
932
|
-
error = _yield$
|
|
933
|
-
accessData = _yield$
|
|
991
|
+
_yield$awaitHelper13 = _context14.sent;
|
|
992
|
+
error = _yield$awaitHelper13.error;
|
|
993
|
+
accessData = _yield$awaitHelper13.data;
|
|
934
994
|
|
|
935
995
|
if (!error) {
|
|
936
|
-
|
|
996
|
+
_context14.next = 12;
|
|
937
997
|
break;
|
|
938
998
|
}
|
|
939
999
|
|
|
940
|
-
return
|
|
1000
|
+
return _context14.abrupt("return", error);
|
|
941
1001
|
|
|
942
1002
|
case 12:
|
|
943
1003
|
accessById = _defineProperty({}, assetId, accessData);
|
|
@@ -946,7 +1006,7 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
946
1006
|
|
|
947
1007
|
_this.props.accessIsLoading(false);
|
|
948
1008
|
|
|
949
|
-
|
|
1009
|
+
_ref18 = accessData || {}, granted = _ref18.granted, grantReason = _ref18.grantReason, _ref18$data = _ref18.data, data = _ref18$data === void 0 ? {} : _ref18$data;
|
|
950
1010
|
|
|
951
1011
|
if (!_this.props.disableMetering && granted && grantReason === 'METERING') {
|
|
952
1012
|
_this.pingBackMeteredStory(asset, accessData);
|
|
@@ -954,82 +1014,82 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
954
1014
|
_this.props.meterUpdated(data.numberRemaining || -1);
|
|
955
1015
|
}
|
|
956
1016
|
|
|
957
|
-
return
|
|
1017
|
+
return _context14.abrupt("return", accessById);
|
|
958
1018
|
|
|
959
1019
|
case 18:
|
|
960
1020
|
case "end":
|
|
961
|
-
return
|
|
1021
|
+
return _context14.stop();
|
|
962
1022
|
}
|
|
963
1023
|
}
|
|
964
|
-
},
|
|
1024
|
+
}, _callee14);
|
|
965
1025
|
}));
|
|
966
1026
|
|
|
967
1027
|
return function (_x9) {
|
|
968
|
-
return
|
|
1028
|
+
return _ref17.apply(this, arguments);
|
|
969
1029
|
};
|
|
970
1030
|
}());
|
|
971
1031
|
|
|
972
|
-
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1032
|
+
_defineProperty(_assertThisInitialized(_this), "getSubscriberMetadata", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
973
1033
|
var metadata;
|
|
974
|
-
return _regeneratorRuntime.wrap(function
|
|
1034
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
975
1035
|
while (1) {
|
|
976
|
-
switch (
|
|
1036
|
+
switch (_context15.prev = _context15.next) {
|
|
977
1037
|
case 0:
|
|
978
1038
|
if (global.AccessType) {
|
|
979
|
-
|
|
1039
|
+
_context15.next = 2;
|
|
980
1040
|
break;
|
|
981
1041
|
}
|
|
982
1042
|
|
|
983
|
-
return
|
|
1043
|
+
return _context15.abrupt("return", {});
|
|
984
1044
|
|
|
985
1045
|
case 2:
|
|
986
|
-
|
|
1046
|
+
_context15.next = 4;
|
|
987
1047
|
return awaitHelper(global.AccessType.getSubscriberMetadata());
|
|
988
1048
|
|
|
989
1049
|
case 4:
|
|
990
|
-
metadata =
|
|
991
|
-
return
|
|
1050
|
+
metadata = _context15.sent;
|
|
1051
|
+
return _context15.abrupt("return", metadata);
|
|
992
1052
|
|
|
993
1053
|
case 6:
|
|
994
1054
|
case "end":
|
|
995
|
-
return
|
|
1055
|
+
return _context15.stop();
|
|
996
1056
|
}
|
|
997
1057
|
}
|
|
998
|
-
},
|
|
1058
|
+
}, _callee15);
|
|
999
1059
|
})));
|
|
1000
1060
|
|
|
1001
1061
|
_defineProperty(_assertThisInitialized(_this), "setSubscriberMetadata", /*#__PURE__*/function () {
|
|
1002
|
-
var
|
|
1062
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(subscriberMetadata) {
|
|
1003
1063
|
var response;
|
|
1004
|
-
return _regeneratorRuntime.wrap(function
|
|
1064
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1005
1065
|
while (1) {
|
|
1006
|
-
switch (
|
|
1066
|
+
switch (_context16.prev = _context16.next) {
|
|
1007
1067
|
case 0:
|
|
1008
1068
|
if (!(!global.AccessType || !subscriberMetadata)) {
|
|
1009
|
-
|
|
1069
|
+
_context16.next = 2;
|
|
1010
1070
|
break;
|
|
1011
1071
|
}
|
|
1012
1072
|
|
|
1013
|
-
return
|
|
1073
|
+
return _context16.abrupt("return", {});
|
|
1014
1074
|
|
|
1015
1075
|
case 2:
|
|
1016
|
-
|
|
1076
|
+
_context16.next = 4;
|
|
1017
1077
|
return awaitHelper(global.AccessType.setSubscriberMetadata(subscriberMetadata));
|
|
1018
1078
|
|
|
1019
1079
|
case 4:
|
|
1020
|
-
response =
|
|
1021
|
-
return
|
|
1080
|
+
response = _context16.sent;
|
|
1081
|
+
return _context16.abrupt("return", response);
|
|
1022
1082
|
|
|
1023
1083
|
case 6:
|
|
1024
1084
|
case "end":
|
|
1025
|
-
return
|
|
1085
|
+
return _context16.stop();
|
|
1026
1086
|
}
|
|
1027
1087
|
}
|
|
1028
|
-
},
|
|
1088
|
+
}, _callee16);
|
|
1029
1089
|
}));
|
|
1030
1090
|
|
|
1031
1091
|
return function (_x10) {
|
|
1032
|
-
return
|
|
1092
|
+
return _ref20.apply(this, arguments);
|
|
1033
1093
|
};
|
|
1034
1094
|
}());
|
|
1035
1095
|
|
|
@@ -1045,29 +1105,29 @@ var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
|
|
|
1045
1105
|
}
|
|
1046
1106
|
}, {
|
|
1047
1107
|
key: "makePaymentObject",
|
|
1048
|
-
value: function makePaymentObject(
|
|
1049
|
-
var
|
|
1050
|
-
selectedPlan =
|
|
1051
|
-
|
|
1052
|
-
couponCode =
|
|
1053
|
-
|
|
1054
|
-
recipientSubscriber =
|
|
1055
|
-
|
|
1056
|
-
planType =
|
|
1057
|
-
|
|
1058
|
-
storyId =
|
|
1059
|
-
|
|
1060
|
-
storyHeadline =
|
|
1061
|
-
|
|
1062
|
-
storySlug =
|
|
1063
|
-
|
|
1064
|
-
paymentType =
|
|
1065
|
-
|
|
1066
|
-
successUrl =
|
|
1067
|
-
|
|
1068
|
-
returnUrl =
|
|
1069
|
-
|
|
1070
|
-
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;
|
|
1071
1131
|
var id = selectedPlan.id,
|
|
1072
1132
|
title = selectedPlan.title,
|
|
1073
1133
|
description = selectedPlan.description,
|
package/package.json
CHANGED