@pelcro/react-pelcro-js 3.33.1 → 3.34.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/index.cjs.js +178 -49
- package/dist/index.esm.js +178 -49
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -14100,14 +14100,37 @@ function LoginModal(_ref) {
|
|
|
14100
14100
|
plan,
|
|
14101
14101
|
order,
|
|
14102
14102
|
switchToAddressView,
|
|
14103
|
-
switchToPaymentView
|
|
14103
|
+
switchToPaymentView,
|
|
14104
|
+
giftCode,
|
|
14105
|
+
isGift
|
|
14104
14106
|
} = usePelcro();
|
|
14105
14107
|
const onSuccess = res => {
|
|
14106
14108
|
var _props$onSuccess;
|
|
14107
14109
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
14110
|
+
handleAfterLoginLogic();
|
|
14111
|
+
};
|
|
14112
|
+
const handleAfterLoginLogic = () => {
|
|
14108
14113
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
14109
14114
|
initPaywalls();
|
|
14110
14115
|
}
|
|
14116
|
+
if (!product && !order && !giftCode) {
|
|
14117
|
+
// If product and plan are not selected
|
|
14118
|
+
return resetView();
|
|
14119
|
+
}
|
|
14120
|
+
|
|
14121
|
+
// If this is a redeem gift
|
|
14122
|
+
if (giftCode) {
|
|
14123
|
+
return switchView("gift-redeem");
|
|
14124
|
+
// return switchToAddressView();
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
// Check if the subscription is meant as a gift (if so, gather recipients info)
|
|
14128
|
+
if (isGift) {
|
|
14129
|
+
return switchView("gift-create");
|
|
14130
|
+
}
|
|
14131
|
+
if (order) {
|
|
14132
|
+
return switchToAddressView();
|
|
14133
|
+
}
|
|
14111
14134
|
if (product && plan) {
|
|
14112
14135
|
if (product.address_required) {
|
|
14113
14136
|
return switchToAddressView();
|
|
@@ -14118,15 +14141,12 @@ function LoginModal(_ref) {
|
|
|
14118
14141
|
if (product && !plan) {
|
|
14119
14142
|
return switchView("plan-select");
|
|
14120
14143
|
}
|
|
14121
|
-
if (order) {
|
|
14122
|
-
return switchToAddressView();
|
|
14123
|
-
}
|
|
14124
|
-
resetView();
|
|
14125
14144
|
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
14126
14145
|
const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
|
|
14127
14146
|
if (viewsURLs.includes(viewFromURL)) {
|
|
14128
|
-
initViewFromURL();
|
|
14147
|
+
return initViewFromURL();
|
|
14129
14148
|
}
|
|
14149
|
+
return resetView();
|
|
14130
14150
|
};
|
|
14131
14151
|
const onCreateAccountClick = () => {
|
|
14132
14152
|
switchView("plan-select");
|
|
@@ -18742,6 +18762,102 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18742
18762
|
onSuccess(response);
|
|
18743
18763
|
}
|
|
18744
18764
|
};
|
|
18765
|
+
const confirmStripeIntentSetup = (response, flow, paymentMethodId) => {
|
|
18766
|
+
var _response$data2;
|
|
18767
|
+
const setupIntent = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.setup_intent;
|
|
18768
|
+
if (setupIntent !== null && setupIntent !== void 0 && setupIntent.client_secret) {
|
|
18769
|
+
var _response$data3, _response$data3$sourc;
|
|
18770
|
+
stripe.confirmCardSetup(setupIntent.client_secret, {
|
|
18771
|
+
payment_method: (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : (_response$data3$sourc = _response$data3.source) === null || _response$data3$sourc === void 0 ? void 0 : _response$data3$sourc.object_id
|
|
18772
|
+
}).then(res => {
|
|
18773
|
+
var _response$data4;
|
|
18774
|
+
if (res.error) {
|
|
18775
|
+
dispatch({
|
|
18776
|
+
type: LOADING,
|
|
18777
|
+
payload: false
|
|
18778
|
+
});
|
|
18779
|
+
onFailure(res.error);
|
|
18780
|
+
return dispatch({
|
|
18781
|
+
type: SHOW_ALERT,
|
|
18782
|
+
payload: {
|
|
18783
|
+
type: "error",
|
|
18784
|
+
content: getErrorMessages(res.error)
|
|
18785
|
+
}
|
|
18786
|
+
});
|
|
18787
|
+
}
|
|
18788
|
+
if (flow === "create") {
|
|
18789
|
+
dispatch({
|
|
18790
|
+
type: DISABLE_SUBMIT,
|
|
18791
|
+
payload: false
|
|
18792
|
+
});
|
|
18793
|
+
dispatch({
|
|
18794
|
+
type: LOADING,
|
|
18795
|
+
payload: false
|
|
18796
|
+
});
|
|
18797
|
+
dispatch({
|
|
18798
|
+
type: SHOW_ALERT,
|
|
18799
|
+
payload: {
|
|
18800
|
+
type: "success",
|
|
18801
|
+
content: t("messages.sourceCreated")
|
|
18802
|
+
}
|
|
18803
|
+
});
|
|
18804
|
+
onSuccess(res);
|
|
18805
|
+
return;
|
|
18806
|
+
}
|
|
18807
|
+
if (flow === "update") {
|
|
18808
|
+
dispatch({
|
|
18809
|
+
type: DISABLE_SUBMIT,
|
|
18810
|
+
payload: false
|
|
18811
|
+
});
|
|
18812
|
+
dispatch({
|
|
18813
|
+
type: LOADING,
|
|
18814
|
+
payload: false
|
|
18815
|
+
});
|
|
18816
|
+
dispatch({
|
|
18817
|
+
type: SHOW_ALERT,
|
|
18818
|
+
payload: {
|
|
18819
|
+
type: "success",
|
|
18820
|
+
content: t("messages.sourceUpdated")
|
|
18821
|
+
}
|
|
18822
|
+
});
|
|
18823
|
+
onSuccess(res);
|
|
18824
|
+
return;
|
|
18825
|
+
}
|
|
18826
|
+
if (flow === "replace") {
|
|
18827
|
+
setTimeout(() => {
|
|
18828
|
+
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
18829
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18830
|
+
payment_method_id: paymentMethodId
|
|
18831
|
+
}, (err, res) => {
|
|
18832
|
+
dispatch({
|
|
18833
|
+
type: DISABLE_SUBMIT,
|
|
18834
|
+
payload: false
|
|
18835
|
+
});
|
|
18836
|
+
dispatch({
|
|
18837
|
+
type: LOADING,
|
|
18838
|
+
payload: false
|
|
18839
|
+
});
|
|
18840
|
+
if (err) {
|
|
18841
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
18842
|
+
return dispatch({
|
|
18843
|
+
type: SHOW_ALERT,
|
|
18844
|
+
payload: {
|
|
18845
|
+
type: "error",
|
|
18846
|
+
content: getErrorMessages(err)
|
|
18847
|
+
}
|
|
18848
|
+
});
|
|
18849
|
+
}
|
|
18850
|
+
onSuccess(res);
|
|
18851
|
+
});
|
|
18852
|
+
}, 2000);
|
|
18853
|
+
return;
|
|
18854
|
+
}
|
|
18855
|
+
return handlePayment(response === null || response === void 0 ? void 0 : (_response$data4 = response.data) === null || _response$data4 === void 0 ? void 0 : _response$data4.source);
|
|
18856
|
+
});
|
|
18857
|
+
} else {
|
|
18858
|
+
onSuccess(response);
|
|
18859
|
+
}
|
|
18860
|
+
};
|
|
18745
18861
|
const subscribe = (stripeSource, state, dispatch) => {
|
|
18746
18862
|
const {
|
|
18747
18863
|
couponCode
|
|
@@ -19004,7 +19120,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19004
19120
|
return stripe.createSource({
|
|
19005
19121
|
type: "card"
|
|
19006
19122
|
}).then(_ref8 => {
|
|
19007
|
-
var _source$card2;
|
|
19008
19123
|
let {
|
|
19009
19124
|
source,
|
|
19010
19125
|
error
|
|
@@ -19014,17 +19129,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19014
19129
|
}
|
|
19015
19130
|
|
|
19016
19131
|
// We don't support source creation for 3D secure yet
|
|
19017
|
-
if (
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
}
|
|
19132
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19133
|
+
// return handlePaymentError({
|
|
19134
|
+
// error: {
|
|
19135
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19136
|
+
// }
|
|
19137
|
+
// });
|
|
19138
|
+
// }
|
|
19139
|
+
|
|
19024
19140
|
window.Pelcro.paymentMethods.create({
|
|
19025
19141
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19026
19142
|
token: source.id
|
|
19027
19143
|
}, (err, res) => {
|
|
19144
|
+
var _res$data, _res$data$setup_inten, _res$data2, _res$data2$setup_inte;
|
|
19028
19145
|
dispatch({
|
|
19029
19146
|
type: DISABLE_SUBMIT,
|
|
19030
19147
|
payload: false
|
|
@@ -19043,14 +19160,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19043
19160
|
}
|
|
19044
19161
|
});
|
|
19045
19162
|
}
|
|
19046
|
-
|
|
19047
|
-
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19163
|
+
if (((_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$setup_inten = _res$data.setup_intent) === null || _res$data$setup_inten === void 0 ? void 0 : _res$data$setup_inten.status) === "requires_action" || ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$setup_inte = _res$data2.setup_intent) === null || _res$data2$setup_inte === void 0 ? void 0 : _res$data2$setup_inte.status) === "requires_confirmation") {
|
|
19164
|
+
confirmStripeIntentSetup(res, "create");
|
|
19165
|
+
} else {
|
|
19166
|
+
dispatch({
|
|
19167
|
+
type: SHOW_ALERT,
|
|
19168
|
+
payload: {
|
|
19169
|
+
type: "success",
|
|
19170
|
+
content: t("messages.sourceCreated")
|
|
19171
|
+
}
|
|
19172
|
+
});
|
|
19173
|
+
onSuccess(res);
|
|
19174
|
+
}
|
|
19054
19175
|
});
|
|
19055
19176
|
});
|
|
19056
19177
|
};
|
|
@@ -19071,6 +19192,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19071
19192
|
exp_year: year,
|
|
19072
19193
|
is_default: isDefault
|
|
19073
19194
|
}, (err, res) => {
|
|
19195
|
+
var _res$data3, _res$data3$setup_inte, _res$data4, _res$data4$setup_inte;
|
|
19074
19196
|
dispatch({
|
|
19075
19197
|
type: DISABLE_SUBMIT,
|
|
19076
19198
|
payload: false
|
|
@@ -19089,14 +19211,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19089
19211
|
}
|
|
19090
19212
|
});
|
|
19091
19213
|
}
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19095
|
-
|
|
19096
|
-
|
|
19097
|
-
|
|
19098
|
-
|
|
19099
|
-
|
|
19214
|
+
if (((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$setup_inte = _res$data3.setup_intent) === null || _res$data3$setup_inte === void 0 ? void 0 : _res$data3$setup_inte.status) === "requires_action" || ((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$setup_inte = _res$data4.setup_intent) === null || _res$data4$setup_inte === void 0 ? void 0 : _res$data4$setup_inte.status) === "requires_confirmation") {
|
|
19215
|
+
confirmStripeIntentSetup(res, "update");
|
|
19216
|
+
} else {
|
|
19217
|
+
dispatch({
|
|
19218
|
+
type: SHOW_ALERT,
|
|
19219
|
+
payload: {
|
|
19220
|
+
type: "success",
|
|
19221
|
+
content: t("messages.sourceUpdated")
|
|
19222
|
+
}
|
|
19223
|
+
});
|
|
19224
|
+
onSuccess(res);
|
|
19225
|
+
}
|
|
19100
19226
|
});
|
|
19101
19227
|
};
|
|
19102
19228
|
const replacePaymentSource = (state, dispatch) => {
|
|
@@ -19106,7 +19232,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19106
19232
|
return stripe.createSource({
|
|
19107
19233
|
type: "card"
|
|
19108
19234
|
}).then(_ref9 => {
|
|
19109
|
-
var _source$card3;
|
|
19110
19235
|
let {
|
|
19111
19236
|
source,
|
|
19112
19237
|
error
|
|
@@ -19116,17 +19241,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19116
19241
|
}
|
|
19117
19242
|
|
|
19118
19243
|
// We don't support source creation for 3D secure yet
|
|
19119
|
-
if (
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19123
|
-
|
|
19124
|
-
|
|
19125
|
-
}
|
|
19244
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19245
|
+
// return handlePaymentError({
|
|
19246
|
+
// error: {
|
|
19247
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19248
|
+
// }
|
|
19249
|
+
// });
|
|
19250
|
+
// }
|
|
19251
|
+
|
|
19126
19252
|
window.Pelcro.paymentMethods.create({
|
|
19127
19253
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19128
19254
|
token: source.id
|
|
19129
19255
|
}, (err, res) => {
|
|
19256
|
+
var _res$data5, _res$data5$setup_inte, _res$data6, _res$data6$setup_inte;
|
|
19130
19257
|
if (err) {
|
|
19131
19258
|
onFailure(err);
|
|
19132
19259
|
return dispatch({
|
|
@@ -19137,7 +19264,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19137
19264
|
}
|
|
19138
19265
|
});
|
|
19139
19266
|
}
|
|
19140
|
-
if (res) {
|
|
19267
|
+
if (((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$setup_inte = _res$data5.setup_intent) === null || _res$data5$setup_inte === void 0 ? void 0 : _res$data5$setup_inte.status) === "requires_action" || ((_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : (_res$data6$setup_inte = _res$data6.setup_intent) === null || _res$data6$setup_inte === void 0 ? void 0 : _res$data6$setup_inte.status) === "requires_confirmation") {
|
|
19268
|
+
confirmStripeIntentSetup(res, "replace", paymentMethodId);
|
|
19269
|
+
} else {
|
|
19141
19270
|
setTimeout(() => {
|
|
19142
19271
|
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
19143
19272
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -19256,12 +19385,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19256
19385
|
coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
|
|
19257
19386
|
address_id: selectedAddressId
|
|
19258
19387
|
}, (error, res) => {
|
|
19259
|
-
var _res$
|
|
19388
|
+
var _res$data7, _res$data8;
|
|
19260
19389
|
if (error) {
|
|
19261
19390
|
return reject(error);
|
|
19262
19391
|
}
|
|
19263
|
-
const taxAmount = (_res$
|
|
19264
|
-
const totalAmountWithTax = (_res$
|
|
19392
|
+
const taxAmount = (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.taxes;
|
|
19393
|
+
const totalAmountWithTax = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.total;
|
|
19265
19394
|
resolve({
|
|
19266
19395
|
totalAmountWithTax,
|
|
19267
19396
|
taxAmount
|
|
@@ -20083,7 +20212,7 @@ const CouponCodeField = props => {
|
|
|
20083
20212
|
};
|
|
20084
20213
|
return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
|
|
20085
20214
|
className: "plc-h-12",
|
|
20086
|
-
wrapperClassName: "plc-mb-
|
|
20215
|
+
wrapperClassName: "plc-mb-6",
|
|
20087
20216
|
errorClassName: "plc-h-12 sm:plc-h-8",
|
|
20088
20217
|
error: couponError,
|
|
20089
20218
|
"aria-label": t("labels.code"),
|
|
@@ -30436,9 +30565,7 @@ const MembershipsItems = () => {
|
|
|
30436
30565
|
};
|
|
30437
30566
|
if (memberships.length === 0) return null;
|
|
30438
30567
|
return memberships.sort((a, b) => a.created_at - b.created_at).map(membership => {
|
|
30439
|
-
|
|
30440
|
-
(_window$Pelcro$addres = window.Pelcro.address.list()) === null || _window$Pelcro$addres === void 0 ? void 0 : _window$Pelcro$addres.find(address => address.id === membership.address_id);
|
|
30441
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, membership.subscription.ended_at === null && /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
30568
|
+
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
30442
30569
|
key: membership.id,
|
|
30443
30570
|
className: `plc-w-full plc-align-top pelcro-membership-row`
|
|
30444
30571
|
}, /*#__PURE__*/React__default['default'].createElement("td", {
|
|
@@ -30454,12 +30581,13 @@ const MembershipsItems = () => {
|
|
|
30454
30581
|
}),
|
|
30455
30582
|
className: "plc-text-blue-400 focus:plc-ring-blue-500 pelcro-dashboard-membership-address-button",
|
|
30456
30583
|
onClick: () => onChangeAddressClick(membership.id)
|
|
30457
|
-
}, `${t("labels.editAddress")}`)))
|
|
30584
|
+
}, `${t("labels.editAddress")}`)));
|
|
30458
30585
|
});
|
|
30459
30586
|
};
|
|
30460
30587
|
function getActiveMemberships() {
|
|
30461
30588
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
30462
|
-
|
|
30589
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
30590
|
+
return (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
30463
30591
|
}
|
|
30464
30592
|
function getMemberShipStatus(status) {
|
|
30465
30593
|
return {
|
|
@@ -31184,7 +31312,8 @@ function hasDonationSubs() {
|
|
|
31184
31312
|
}
|
|
31185
31313
|
function hasActiveMemberships() {
|
|
31186
31314
|
var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
|
|
31187
|
-
|
|
31315
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
31316
|
+
return (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.some(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : false;
|
|
31188
31317
|
}
|
|
31189
31318
|
const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
|
|
31190
31319
|
|
package/dist/index.esm.js
CHANGED
|
@@ -14070,14 +14070,37 @@ function LoginModal(_ref) {
|
|
|
14070
14070
|
plan,
|
|
14071
14071
|
order,
|
|
14072
14072
|
switchToAddressView,
|
|
14073
|
-
switchToPaymentView
|
|
14073
|
+
switchToPaymentView,
|
|
14074
|
+
giftCode,
|
|
14075
|
+
isGift
|
|
14074
14076
|
} = usePelcro();
|
|
14075
14077
|
const onSuccess = res => {
|
|
14076
14078
|
var _props$onSuccess;
|
|
14077
14079
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
14080
|
+
handleAfterLoginLogic();
|
|
14081
|
+
};
|
|
14082
|
+
const handleAfterLoginLogic = () => {
|
|
14078
14083
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
14079
14084
|
initPaywalls();
|
|
14080
14085
|
}
|
|
14086
|
+
if (!product && !order && !giftCode) {
|
|
14087
|
+
// If product and plan are not selected
|
|
14088
|
+
return resetView();
|
|
14089
|
+
}
|
|
14090
|
+
|
|
14091
|
+
// If this is a redeem gift
|
|
14092
|
+
if (giftCode) {
|
|
14093
|
+
return switchView("gift-redeem");
|
|
14094
|
+
// return switchToAddressView();
|
|
14095
|
+
}
|
|
14096
|
+
|
|
14097
|
+
// Check if the subscription is meant as a gift (if so, gather recipients info)
|
|
14098
|
+
if (isGift) {
|
|
14099
|
+
return switchView("gift-create");
|
|
14100
|
+
}
|
|
14101
|
+
if (order) {
|
|
14102
|
+
return switchToAddressView();
|
|
14103
|
+
}
|
|
14081
14104
|
if (product && plan) {
|
|
14082
14105
|
if (product.address_required) {
|
|
14083
14106
|
return switchToAddressView();
|
|
@@ -14088,15 +14111,12 @@ function LoginModal(_ref) {
|
|
|
14088
14111
|
if (product && !plan) {
|
|
14089
14112
|
return switchView("plan-select");
|
|
14090
14113
|
}
|
|
14091
|
-
if (order) {
|
|
14092
|
-
return switchToAddressView();
|
|
14093
|
-
}
|
|
14094
|
-
resetView();
|
|
14095
14114
|
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
14096
14115
|
const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
|
|
14097
14116
|
if (viewsURLs.includes(viewFromURL)) {
|
|
14098
|
-
initViewFromURL();
|
|
14117
|
+
return initViewFromURL();
|
|
14099
14118
|
}
|
|
14119
|
+
return resetView();
|
|
14100
14120
|
};
|
|
14101
14121
|
const onCreateAccountClick = () => {
|
|
14102
14122
|
switchView("plan-select");
|
|
@@ -18712,6 +18732,102 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18712
18732
|
onSuccess(response);
|
|
18713
18733
|
}
|
|
18714
18734
|
};
|
|
18735
|
+
const confirmStripeIntentSetup = (response, flow, paymentMethodId) => {
|
|
18736
|
+
var _response$data2;
|
|
18737
|
+
const setupIntent = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.setup_intent;
|
|
18738
|
+
if (setupIntent !== null && setupIntent !== void 0 && setupIntent.client_secret) {
|
|
18739
|
+
var _response$data3, _response$data3$sourc;
|
|
18740
|
+
stripe.confirmCardSetup(setupIntent.client_secret, {
|
|
18741
|
+
payment_method: (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : (_response$data3$sourc = _response$data3.source) === null || _response$data3$sourc === void 0 ? void 0 : _response$data3$sourc.object_id
|
|
18742
|
+
}).then(res => {
|
|
18743
|
+
var _response$data4;
|
|
18744
|
+
if (res.error) {
|
|
18745
|
+
dispatch({
|
|
18746
|
+
type: LOADING,
|
|
18747
|
+
payload: false
|
|
18748
|
+
});
|
|
18749
|
+
onFailure(res.error);
|
|
18750
|
+
return dispatch({
|
|
18751
|
+
type: SHOW_ALERT,
|
|
18752
|
+
payload: {
|
|
18753
|
+
type: "error",
|
|
18754
|
+
content: getErrorMessages(res.error)
|
|
18755
|
+
}
|
|
18756
|
+
});
|
|
18757
|
+
}
|
|
18758
|
+
if (flow === "create") {
|
|
18759
|
+
dispatch({
|
|
18760
|
+
type: DISABLE_SUBMIT,
|
|
18761
|
+
payload: false
|
|
18762
|
+
});
|
|
18763
|
+
dispatch({
|
|
18764
|
+
type: LOADING,
|
|
18765
|
+
payload: false
|
|
18766
|
+
});
|
|
18767
|
+
dispatch({
|
|
18768
|
+
type: SHOW_ALERT,
|
|
18769
|
+
payload: {
|
|
18770
|
+
type: "success",
|
|
18771
|
+
content: t("messages.sourceCreated")
|
|
18772
|
+
}
|
|
18773
|
+
});
|
|
18774
|
+
onSuccess(res);
|
|
18775
|
+
return;
|
|
18776
|
+
}
|
|
18777
|
+
if (flow === "update") {
|
|
18778
|
+
dispatch({
|
|
18779
|
+
type: DISABLE_SUBMIT,
|
|
18780
|
+
payload: false
|
|
18781
|
+
});
|
|
18782
|
+
dispatch({
|
|
18783
|
+
type: LOADING,
|
|
18784
|
+
payload: false
|
|
18785
|
+
});
|
|
18786
|
+
dispatch({
|
|
18787
|
+
type: SHOW_ALERT,
|
|
18788
|
+
payload: {
|
|
18789
|
+
type: "success",
|
|
18790
|
+
content: t("messages.sourceUpdated")
|
|
18791
|
+
}
|
|
18792
|
+
});
|
|
18793
|
+
onSuccess(res);
|
|
18794
|
+
return;
|
|
18795
|
+
}
|
|
18796
|
+
if (flow === "replace") {
|
|
18797
|
+
setTimeout(() => {
|
|
18798
|
+
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
18799
|
+
auth_token: window.Pelcro.user.read().auth_token,
|
|
18800
|
+
payment_method_id: paymentMethodId
|
|
18801
|
+
}, (err, res) => {
|
|
18802
|
+
dispatch({
|
|
18803
|
+
type: DISABLE_SUBMIT,
|
|
18804
|
+
payload: false
|
|
18805
|
+
});
|
|
18806
|
+
dispatch({
|
|
18807
|
+
type: LOADING,
|
|
18808
|
+
payload: false
|
|
18809
|
+
});
|
|
18810
|
+
if (err) {
|
|
18811
|
+
onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
|
|
18812
|
+
return dispatch({
|
|
18813
|
+
type: SHOW_ALERT,
|
|
18814
|
+
payload: {
|
|
18815
|
+
type: "error",
|
|
18816
|
+
content: getErrorMessages(err)
|
|
18817
|
+
}
|
|
18818
|
+
});
|
|
18819
|
+
}
|
|
18820
|
+
onSuccess(res);
|
|
18821
|
+
});
|
|
18822
|
+
}, 2000);
|
|
18823
|
+
return;
|
|
18824
|
+
}
|
|
18825
|
+
return handlePayment(response === null || response === void 0 ? void 0 : (_response$data4 = response.data) === null || _response$data4 === void 0 ? void 0 : _response$data4.source);
|
|
18826
|
+
});
|
|
18827
|
+
} else {
|
|
18828
|
+
onSuccess(response);
|
|
18829
|
+
}
|
|
18830
|
+
};
|
|
18715
18831
|
const subscribe = (stripeSource, state, dispatch) => {
|
|
18716
18832
|
const {
|
|
18717
18833
|
couponCode
|
|
@@ -18974,7 +19090,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18974
19090
|
return stripe.createSource({
|
|
18975
19091
|
type: "card"
|
|
18976
19092
|
}).then(_ref8 => {
|
|
18977
|
-
var _source$card2;
|
|
18978
19093
|
let {
|
|
18979
19094
|
source,
|
|
18980
19095
|
error
|
|
@@ -18984,17 +19099,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18984
19099
|
}
|
|
18985
19100
|
|
|
18986
19101
|
// We don't support source creation for 3D secure yet
|
|
18987
|
-
if (
|
|
18988
|
-
|
|
18989
|
-
|
|
18990
|
-
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
}
|
|
19102
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19103
|
+
// return handlePaymentError({
|
|
19104
|
+
// error: {
|
|
19105
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19106
|
+
// }
|
|
19107
|
+
// });
|
|
19108
|
+
// }
|
|
19109
|
+
|
|
18994
19110
|
window.Pelcro.paymentMethods.create({
|
|
18995
19111
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
18996
19112
|
token: source.id
|
|
18997
19113
|
}, (err, res) => {
|
|
19114
|
+
var _res$data, _res$data$setup_inten, _res$data2, _res$data2$setup_inte;
|
|
18998
19115
|
dispatch({
|
|
18999
19116
|
type: DISABLE_SUBMIT,
|
|
19000
19117
|
payload: false
|
|
@@ -19013,14 +19130,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19013
19130
|
}
|
|
19014
19131
|
});
|
|
19015
19132
|
}
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19133
|
+
if (((_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$setup_inten = _res$data.setup_intent) === null || _res$data$setup_inten === void 0 ? void 0 : _res$data$setup_inten.status) === "requires_action" || ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$setup_inte = _res$data2.setup_intent) === null || _res$data2$setup_inte === void 0 ? void 0 : _res$data2$setup_inte.status) === "requires_confirmation") {
|
|
19134
|
+
confirmStripeIntentSetup(res, "create");
|
|
19135
|
+
} else {
|
|
19136
|
+
dispatch({
|
|
19137
|
+
type: SHOW_ALERT,
|
|
19138
|
+
payload: {
|
|
19139
|
+
type: "success",
|
|
19140
|
+
content: t("messages.sourceCreated")
|
|
19141
|
+
}
|
|
19142
|
+
});
|
|
19143
|
+
onSuccess(res);
|
|
19144
|
+
}
|
|
19024
19145
|
});
|
|
19025
19146
|
});
|
|
19026
19147
|
};
|
|
@@ -19041,6 +19162,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19041
19162
|
exp_year: year,
|
|
19042
19163
|
is_default: isDefault
|
|
19043
19164
|
}, (err, res) => {
|
|
19165
|
+
var _res$data3, _res$data3$setup_inte, _res$data4, _res$data4$setup_inte;
|
|
19044
19166
|
dispatch({
|
|
19045
19167
|
type: DISABLE_SUBMIT,
|
|
19046
19168
|
payload: false
|
|
@@ -19059,14 +19181,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19059
19181
|
}
|
|
19060
19182
|
});
|
|
19061
19183
|
}
|
|
19062
|
-
|
|
19063
|
-
|
|
19064
|
-
|
|
19065
|
-
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19184
|
+
if (((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$setup_inte = _res$data3.setup_intent) === null || _res$data3$setup_inte === void 0 ? void 0 : _res$data3$setup_inte.status) === "requires_action" || ((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$setup_inte = _res$data4.setup_intent) === null || _res$data4$setup_inte === void 0 ? void 0 : _res$data4$setup_inte.status) === "requires_confirmation") {
|
|
19185
|
+
confirmStripeIntentSetup(res, "update");
|
|
19186
|
+
} else {
|
|
19187
|
+
dispatch({
|
|
19188
|
+
type: SHOW_ALERT,
|
|
19189
|
+
payload: {
|
|
19190
|
+
type: "success",
|
|
19191
|
+
content: t("messages.sourceUpdated")
|
|
19192
|
+
}
|
|
19193
|
+
});
|
|
19194
|
+
onSuccess(res);
|
|
19195
|
+
}
|
|
19070
19196
|
});
|
|
19071
19197
|
};
|
|
19072
19198
|
const replacePaymentSource = (state, dispatch) => {
|
|
@@ -19076,7 +19202,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19076
19202
|
return stripe.createSource({
|
|
19077
19203
|
type: "card"
|
|
19078
19204
|
}).then(_ref9 => {
|
|
19079
|
-
var _source$card3;
|
|
19080
19205
|
let {
|
|
19081
19206
|
source,
|
|
19082
19207
|
error
|
|
@@ -19086,17 +19211,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19086
19211
|
}
|
|
19087
19212
|
|
|
19088
19213
|
// We don't support source creation for 3D secure yet
|
|
19089
|
-
if (
|
|
19090
|
-
|
|
19091
|
-
|
|
19092
|
-
|
|
19093
|
-
|
|
19094
|
-
|
|
19095
|
-
}
|
|
19214
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19215
|
+
// return handlePaymentError({
|
|
19216
|
+
// error: {
|
|
19217
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19218
|
+
// }
|
|
19219
|
+
// });
|
|
19220
|
+
// }
|
|
19221
|
+
|
|
19096
19222
|
window.Pelcro.paymentMethods.create({
|
|
19097
19223
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19098
19224
|
token: source.id
|
|
19099
19225
|
}, (err, res) => {
|
|
19226
|
+
var _res$data5, _res$data5$setup_inte, _res$data6, _res$data6$setup_inte;
|
|
19100
19227
|
if (err) {
|
|
19101
19228
|
onFailure(err);
|
|
19102
19229
|
return dispatch({
|
|
@@ -19107,7 +19234,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19107
19234
|
}
|
|
19108
19235
|
});
|
|
19109
19236
|
}
|
|
19110
|
-
if (res) {
|
|
19237
|
+
if (((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$setup_inte = _res$data5.setup_intent) === null || _res$data5$setup_inte === void 0 ? void 0 : _res$data5$setup_inte.status) === "requires_action" || ((_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : (_res$data6$setup_inte = _res$data6.setup_intent) === null || _res$data6$setup_inte === void 0 ? void 0 : _res$data6$setup_inte.status) === "requires_confirmation") {
|
|
19238
|
+
confirmStripeIntentSetup(res, "replace", paymentMethodId);
|
|
19239
|
+
} else {
|
|
19111
19240
|
setTimeout(() => {
|
|
19112
19241
|
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
19113
19242
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -19226,12 +19355,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19226
19355
|
coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
|
|
19227
19356
|
address_id: selectedAddressId
|
|
19228
19357
|
}, (error, res) => {
|
|
19229
|
-
var _res$
|
|
19358
|
+
var _res$data7, _res$data8;
|
|
19230
19359
|
if (error) {
|
|
19231
19360
|
return reject(error);
|
|
19232
19361
|
}
|
|
19233
|
-
const taxAmount = (_res$
|
|
19234
|
-
const totalAmountWithTax = (_res$
|
|
19362
|
+
const taxAmount = (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.taxes;
|
|
19363
|
+
const totalAmountWithTax = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.total;
|
|
19235
19364
|
resolve({
|
|
19236
19365
|
totalAmountWithTax,
|
|
19237
19366
|
taxAmount
|
|
@@ -20053,7 +20182,7 @@ const CouponCodeField = props => {
|
|
|
20053
20182
|
};
|
|
20054
20183
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({
|
|
20055
20184
|
className: "plc-h-12",
|
|
20056
|
-
wrapperClassName: "plc-mb-
|
|
20185
|
+
wrapperClassName: "plc-mb-6",
|
|
20057
20186
|
errorClassName: "plc-h-12 sm:plc-h-8",
|
|
20058
20187
|
error: couponError,
|
|
20059
20188
|
"aria-label": t("labels.code"),
|
|
@@ -30406,9 +30535,7 @@ const MembershipsItems = () => {
|
|
|
30406
30535
|
};
|
|
30407
30536
|
if (memberships.length === 0) return null;
|
|
30408
30537
|
return memberships.sort((a, b) => a.created_at - b.created_at).map(membership => {
|
|
30409
|
-
|
|
30410
|
-
(_window$Pelcro$addres = window.Pelcro.address.list()) === null || _window$Pelcro$addres === void 0 ? void 0 : _window$Pelcro$addres.find(address => address.id === membership.address_id);
|
|
30411
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, membership.subscription.ended_at === null && /*#__PURE__*/React__default.createElement("tr", {
|
|
30538
|
+
return /*#__PURE__*/React__default.createElement("tr", {
|
|
30412
30539
|
key: membership.id,
|
|
30413
30540
|
className: `plc-w-full plc-align-top pelcro-membership-row`
|
|
30414
30541
|
}, /*#__PURE__*/React__default.createElement("td", {
|
|
@@ -30424,12 +30551,13 @@ const MembershipsItems = () => {
|
|
|
30424
30551
|
}),
|
|
30425
30552
|
className: "plc-text-blue-400 focus:plc-ring-blue-500 pelcro-dashboard-membership-address-button",
|
|
30426
30553
|
onClick: () => onChangeAddressClick(membership.id)
|
|
30427
|
-
}, `${t("labels.editAddress")}`)))
|
|
30554
|
+
}, `${t("labels.editAddress")}`)));
|
|
30428
30555
|
});
|
|
30429
30556
|
};
|
|
30430
30557
|
function getActiveMemberships() {
|
|
30431
30558
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
30432
|
-
|
|
30559
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
30560
|
+
return (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
30433
30561
|
}
|
|
30434
30562
|
function getMemberShipStatus(status) {
|
|
30435
30563
|
return {
|
|
@@ -31154,7 +31282,8 @@ function hasDonationSubs() {
|
|
|
31154
31282
|
}
|
|
31155
31283
|
function hasActiveMemberships() {
|
|
31156
31284
|
var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
|
|
31157
|
-
|
|
31285
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
31286
|
+
return (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.some(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : false;
|
|
31158
31287
|
}
|
|
31159
31288
|
const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
|
|
31160
31289
|
|