@pelcro/react-pelcro-js 3.33.2 → 3.35.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 +157 -44
- package/dist/index.esm.js +157 -44
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -18762,6 +18762,102 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18762
18762
|
onSuccess(response);
|
|
18763
18763
|
}
|
|
18764
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: DISABLE_SUBMIT,
|
|
18777
|
+
payload: false
|
|
18778
|
+
});
|
|
18779
|
+
dispatch({
|
|
18780
|
+
type: LOADING,
|
|
18781
|
+
payload: false
|
|
18782
|
+
});
|
|
18783
|
+
onFailure(res.error);
|
|
18784
|
+
return dispatch({
|
|
18785
|
+
type: SHOW_ALERT,
|
|
18786
|
+
payload: {
|
|
18787
|
+
type: "error",
|
|
18788
|
+
content: getErrorMessages(res.error)
|
|
18789
|
+
}
|
|
18790
|
+
});
|
|
18791
|
+
}
|
|
18792
|
+
if (flow === "create") {
|
|
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
|
+
};
|
|
18765
18861
|
const subscribe = (stripeSource, state, dispatch) => {
|
|
18766
18862
|
const {
|
|
18767
18863
|
couponCode
|
|
@@ -19024,7 +19120,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19024
19120
|
return stripe.createSource({
|
|
19025
19121
|
type: "card"
|
|
19026
19122
|
}).then(_ref8 => {
|
|
19027
|
-
var _source$card2;
|
|
19028
19123
|
let {
|
|
19029
19124
|
source,
|
|
19030
19125
|
error
|
|
@@ -19034,26 +19129,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19034
19129
|
}
|
|
19035
19130
|
|
|
19036
19131
|
// We don't support source creation for 3D secure yet
|
|
19037
|
-
if (
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
}
|
|
19132
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19133
|
+
// return handlePaymentError({
|
|
19134
|
+
// error: {
|
|
19135
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19136
|
+
// }
|
|
19137
|
+
// });
|
|
19138
|
+
// }
|
|
19139
|
+
|
|
19044
19140
|
window.Pelcro.paymentMethods.create({
|
|
19045
19141
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19046
19142
|
token: source.id
|
|
19047
19143
|
}, (err, res) => {
|
|
19048
|
-
|
|
19049
|
-
type: DISABLE_SUBMIT,
|
|
19050
|
-
payload: false
|
|
19051
|
-
});
|
|
19052
|
-
dispatch({
|
|
19053
|
-
type: LOADING,
|
|
19054
|
-
payload: false
|
|
19055
|
-
});
|
|
19144
|
+
var _res$data, _res$data$setup_inten, _res$data2, _res$data2$setup_inte;
|
|
19056
19145
|
if (err) {
|
|
19146
|
+
dispatch({
|
|
19147
|
+
type: DISABLE_SUBMIT,
|
|
19148
|
+
payload: false
|
|
19149
|
+
});
|
|
19150
|
+
dispatch({
|
|
19151
|
+
type: LOADING,
|
|
19152
|
+
payload: false
|
|
19153
|
+
});
|
|
19057
19154
|
onFailure(err);
|
|
19058
19155
|
return dispatch({
|
|
19059
19156
|
type: SHOW_ALERT,
|
|
@@ -19063,14 +19160,22 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19063
19160
|
}
|
|
19064
19161
|
});
|
|
19065
19162
|
}
|
|
19066
|
-
|
|
19067
|
-
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
|
|
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: LOADING,
|
|
19168
|
+
payload: false
|
|
19169
|
+
});
|
|
19170
|
+
dispatch({
|
|
19171
|
+
type: SHOW_ALERT,
|
|
19172
|
+
payload: {
|
|
19173
|
+
type: "success",
|
|
19174
|
+
content: t("messages.sourceCreated")
|
|
19175
|
+
}
|
|
19176
|
+
});
|
|
19177
|
+
onSuccess(res);
|
|
19178
|
+
}
|
|
19074
19179
|
});
|
|
19075
19180
|
});
|
|
19076
19181
|
};
|
|
@@ -19091,6 +19196,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19091
19196
|
exp_year: year,
|
|
19092
19197
|
is_default: isDefault
|
|
19093
19198
|
}, (err, res) => {
|
|
19199
|
+
var _res$data3, _res$data3$setup_inte, _res$data4, _res$data4$setup_inte;
|
|
19094
19200
|
dispatch({
|
|
19095
19201
|
type: DISABLE_SUBMIT,
|
|
19096
19202
|
payload: false
|
|
@@ -19109,14 +19215,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19109
19215
|
}
|
|
19110
19216
|
});
|
|
19111
19217
|
}
|
|
19112
|
-
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
|
|
19118
|
-
|
|
19119
|
-
|
|
19218
|
+
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") {
|
|
19219
|
+
confirmStripeIntentSetup(res, "update");
|
|
19220
|
+
} else {
|
|
19221
|
+
dispatch({
|
|
19222
|
+
type: SHOW_ALERT,
|
|
19223
|
+
payload: {
|
|
19224
|
+
type: "success",
|
|
19225
|
+
content: t("messages.sourceUpdated")
|
|
19226
|
+
}
|
|
19227
|
+
});
|
|
19228
|
+
onSuccess(res);
|
|
19229
|
+
}
|
|
19120
19230
|
});
|
|
19121
19231
|
};
|
|
19122
19232
|
const replacePaymentSource = (state, dispatch) => {
|
|
@@ -19126,7 +19236,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19126
19236
|
return stripe.createSource({
|
|
19127
19237
|
type: "card"
|
|
19128
19238
|
}).then(_ref9 => {
|
|
19129
|
-
var _source$card3;
|
|
19130
19239
|
let {
|
|
19131
19240
|
source,
|
|
19132
19241
|
error
|
|
@@ -19136,17 +19245,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19136
19245
|
}
|
|
19137
19246
|
|
|
19138
19247
|
// We don't support source creation for 3D secure yet
|
|
19139
|
-
if (
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
}
|
|
19248
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19249
|
+
// return handlePaymentError({
|
|
19250
|
+
// error: {
|
|
19251
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19252
|
+
// }
|
|
19253
|
+
// });
|
|
19254
|
+
// }
|
|
19255
|
+
|
|
19146
19256
|
window.Pelcro.paymentMethods.create({
|
|
19147
19257
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19148
19258
|
token: source.id
|
|
19149
19259
|
}, (err, res) => {
|
|
19260
|
+
var _res$data5, _res$data5$setup_inte, _res$data6, _res$data6$setup_inte;
|
|
19150
19261
|
if (err) {
|
|
19151
19262
|
onFailure(err);
|
|
19152
19263
|
return dispatch({
|
|
@@ -19157,7 +19268,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19157
19268
|
}
|
|
19158
19269
|
});
|
|
19159
19270
|
}
|
|
19160
|
-
if (res) {
|
|
19271
|
+
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") {
|
|
19272
|
+
confirmStripeIntentSetup(res, "replace", paymentMethodId);
|
|
19273
|
+
} else {
|
|
19161
19274
|
setTimeout(() => {
|
|
19162
19275
|
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
19163
19276
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -19276,12 +19389,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19276
19389
|
coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
|
|
19277
19390
|
address_id: selectedAddressId
|
|
19278
19391
|
}, (error, res) => {
|
|
19279
|
-
var _res$
|
|
19392
|
+
var _res$data7, _res$data8;
|
|
19280
19393
|
if (error) {
|
|
19281
19394
|
return reject(error);
|
|
19282
19395
|
}
|
|
19283
|
-
const taxAmount = (_res$
|
|
19284
|
-
const totalAmountWithTax = (_res$
|
|
19396
|
+
const taxAmount = (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.taxes;
|
|
19397
|
+
const totalAmountWithTax = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.total;
|
|
19285
19398
|
resolve({
|
|
19286
19399
|
totalAmountWithTax,
|
|
19287
19400
|
taxAmount
|
package/dist/index.esm.js
CHANGED
|
@@ -18732,6 +18732,102 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18732
18732
|
onSuccess(response);
|
|
18733
18733
|
}
|
|
18734
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: DISABLE_SUBMIT,
|
|
18747
|
+
payload: false
|
|
18748
|
+
});
|
|
18749
|
+
dispatch({
|
|
18750
|
+
type: LOADING,
|
|
18751
|
+
payload: false
|
|
18752
|
+
});
|
|
18753
|
+
onFailure(res.error);
|
|
18754
|
+
return dispatch({
|
|
18755
|
+
type: SHOW_ALERT,
|
|
18756
|
+
payload: {
|
|
18757
|
+
type: "error",
|
|
18758
|
+
content: getErrorMessages(res.error)
|
|
18759
|
+
}
|
|
18760
|
+
});
|
|
18761
|
+
}
|
|
18762
|
+
if (flow === "create") {
|
|
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
|
+
};
|
|
18735
18831
|
const subscribe = (stripeSource, state, dispatch) => {
|
|
18736
18832
|
const {
|
|
18737
18833
|
couponCode
|
|
@@ -18994,7 +19090,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
18994
19090
|
return stripe.createSource({
|
|
18995
19091
|
type: "card"
|
|
18996
19092
|
}).then(_ref8 => {
|
|
18997
|
-
var _source$card2;
|
|
18998
19093
|
let {
|
|
18999
19094
|
source,
|
|
19000
19095
|
error
|
|
@@ -19004,26 +19099,28 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19004
19099
|
}
|
|
19005
19100
|
|
|
19006
19101
|
// We don't support source creation for 3D secure yet
|
|
19007
|
-
if (
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
}
|
|
19102
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19103
|
+
// return handlePaymentError({
|
|
19104
|
+
// error: {
|
|
19105
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19106
|
+
// }
|
|
19107
|
+
// });
|
|
19108
|
+
// }
|
|
19109
|
+
|
|
19014
19110
|
window.Pelcro.paymentMethods.create({
|
|
19015
19111
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19016
19112
|
token: source.id
|
|
19017
19113
|
}, (err, res) => {
|
|
19018
|
-
|
|
19019
|
-
type: DISABLE_SUBMIT,
|
|
19020
|
-
payload: false
|
|
19021
|
-
});
|
|
19022
|
-
dispatch({
|
|
19023
|
-
type: LOADING,
|
|
19024
|
-
payload: false
|
|
19025
|
-
});
|
|
19114
|
+
var _res$data, _res$data$setup_inten, _res$data2, _res$data2$setup_inte;
|
|
19026
19115
|
if (err) {
|
|
19116
|
+
dispatch({
|
|
19117
|
+
type: DISABLE_SUBMIT,
|
|
19118
|
+
payload: false
|
|
19119
|
+
});
|
|
19120
|
+
dispatch({
|
|
19121
|
+
type: LOADING,
|
|
19122
|
+
payload: false
|
|
19123
|
+
});
|
|
19027
19124
|
onFailure(err);
|
|
19028
19125
|
return dispatch({
|
|
19029
19126
|
type: SHOW_ALERT,
|
|
@@ -19033,14 +19130,22 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19033
19130
|
}
|
|
19034
19131
|
});
|
|
19035
19132
|
}
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
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: LOADING,
|
|
19138
|
+
payload: false
|
|
19139
|
+
});
|
|
19140
|
+
dispatch({
|
|
19141
|
+
type: SHOW_ALERT,
|
|
19142
|
+
payload: {
|
|
19143
|
+
type: "success",
|
|
19144
|
+
content: t("messages.sourceCreated")
|
|
19145
|
+
}
|
|
19146
|
+
});
|
|
19147
|
+
onSuccess(res);
|
|
19148
|
+
}
|
|
19044
19149
|
});
|
|
19045
19150
|
});
|
|
19046
19151
|
};
|
|
@@ -19061,6 +19166,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19061
19166
|
exp_year: year,
|
|
19062
19167
|
is_default: isDefault
|
|
19063
19168
|
}, (err, res) => {
|
|
19169
|
+
var _res$data3, _res$data3$setup_inte, _res$data4, _res$data4$setup_inte;
|
|
19064
19170
|
dispatch({
|
|
19065
19171
|
type: DISABLE_SUBMIT,
|
|
19066
19172
|
payload: false
|
|
@@ -19079,14 +19185,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19079
19185
|
}
|
|
19080
19186
|
});
|
|
19081
19187
|
}
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19086
|
-
|
|
19087
|
-
|
|
19088
|
-
|
|
19089
|
-
|
|
19188
|
+
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") {
|
|
19189
|
+
confirmStripeIntentSetup(res, "update");
|
|
19190
|
+
} else {
|
|
19191
|
+
dispatch({
|
|
19192
|
+
type: SHOW_ALERT,
|
|
19193
|
+
payload: {
|
|
19194
|
+
type: "success",
|
|
19195
|
+
content: t("messages.sourceUpdated")
|
|
19196
|
+
}
|
|
19197
|
+
});
|
|
19198
|
+
onSuccess(res);
|
|
19199
|
+
}
|
|
19090
19200
|
});
|
|
19091
19201
|
};
|
|
19092
19202
|
const replacePaymentSource = (state, dispatch) => {
|
|
@@ -19096,7 +19206,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19096
19206
|
return stripe.createSource({
|
|
19097
19207
|
type: "card"
|
|
19098
19208
|
}).then(_ref9 => {
|
|
19099
|
-
var _source$card3;
|
|
19100
19209
|
let {
|
|
19101
19210
|
source,
|
|
19102
19211
|
error
|
|
@@ -19106,17 +19215,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19106
19215
|
}
|
|
19107
19216
|
|
|
19108
19217
|
// We don't support source creation for 3D secure yet
|
|
19109
|
-
if (
|
|
19110
|
-
|
|
19111
|
-
|
|
19112
|
-
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
}
|
|
19218
|
+
// if (source?.card?.three_d_secure === "required") {
|
|
19219
|
+
// return handlePaymentError({
|
|
19220
|
+
// error: {
|
|
19221
|
+
// message: t("messages.cardAuthNotSupported")
|
|
19222
|
+
// }
|
|
19223
|
+
// });
|
|
19224
|
+
// }
|
|
19225
|
+
|
|
19116
19226
|
window.Pelcro.paymentMethods.create({
|
|
19117
19227
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
19118
19228
|
token: source.id
|
|
19119
19229
|
}, (err, res) => {
|
|
19230
|
+
var _res$data5, _res$data5$setup_inte, _res$data6, _res$data6$setup_inte;
|
|
19120
19231
|
if (err) {
|
|
19121
19232
|
onFailure(err);
|
|
19122
19233
|
return dispatch({
|
|
@@ -19127,7 +19238,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19127
19238
|
}
|
|
19128
19239
|
});
|
|
19129
19240
|
}
|
|
19130
|
-
if (res) {
|
|
19241
|
+
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") {
|
|
19242
|
+
confirmStripeIntentSetup(res, "replace", paymentMethodId);
|
|
19243
|
+
} else {
|
|
19131
19244
|
setTimeout(() => {
|
|
19132
19245
|
window.Pelcro.paymentMethods.deletePaymentMethod({
|
|
19133
19246
|
auth_token: window.Pelcro.user.read().auth_token,
|
|
@@ -19246,12 +19359,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
19246
19359
|
coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
|
|
19247
19360
|
address_id: selectedAddressId
|
|
19248
19361
|
}, (error, res) => {
|
|
19249
|
-
var _res$
|
|
19362
|
+
var _res$data7, _res$data8;
|
|
19250
19363
|
if (error) {
|
|
19251
19364
|
return reject(error);
|
|
19252
19365
|
}
|
|
19253
|
-
const taxAmount = (_res$
|
|
19254
|
-
const totalAmountWithTax = (_res$
|
|
19366
|
+
const taxAmount = (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.taxes;
|
|
19367
|
+
const totalAmountWithTax = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.total;
|
|
19255
19368
|
resolve({
|
|
19256
19369
|
totalAmountWithTax,
|
|
19257
19370
|
taxAmount
|