@pelcro/react-pelcro-js 3.10.0 → 3.10.1-beta.10
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 +52 -29
- package/dist/index.esm.js +52 -29
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -10530,6 +10530,7 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10530
10530
|
const {
|
|
10531
10531
|
isAuthenticated,
|
|
10532
10532
|
setInvoice,
|
|
10533
|
+
whenUserReady,
|
|
10533
10534
|
whenSiteReady,
|
|
10534
10535
|
switchView
|
|
10535
10536
|
} = usePelcro.getStore();
|
|
@@ -10538,28 +10539,30 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10538
10539
|
return switchView("login");
|
|
10539
10540
|
}
|
|
10540
10541
|
|
|
10541
|
-
|
|
10542
|
-
|
|
10542
|
+
whenUserReady(() => {
|
|
10543
|
+
const invoiceId = window.Pelcro.helpers.getURLParameter("id");
|
|
10544
|
+
const wasSetSuccessfully = setInvoice(invoiceId);
|
|
10543
10545
|
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10546
|
+
if (!wasSetSuccessfully) {
|
|
10547
|
+
const errorMessage = i18next.t("messages:invalidInvoice", {
|
|
10548
|
+
returnObjects: true
|
|
10549
|
+
});
|
|
10550
|
+
return notify.error(errorMessage);
|
|
10551
|
+
}
|
|
10550
10552
|
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10553
|
+
const {
|
|
10554
|
+
invoice
|
|
10555
|
+
} = usePelcro.getStore();
|
|
10554
10556
|
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10557
|
+
if (invoice.total === 0) {
|
|
10558
|
+
const errorMessage = i18next.t("messages:zeroTotalInvoice", {
|
|
10559
|
+
returnObjects: true
|
|
10560
|
+
});
|
|
10561
|
+
return notify.error(errorMessage);
|
|
10562
|
+
}
|
|
10561
10563
|
|
|
10562
|
-
|
|
10564
|
+
return switchView("invoice-details");
|
|
10565
|
+
});
|
|
10563
10566
|
});
|
|
10564
10567
|
};
|
|
10565
10568
|
|
|
@@ -12232,18 +12235,25 @@ function LoginModal({
|
|
|
12232
12235
|
} = useTranslation("login");
|
|
12233
12236
|
const {
|
|
12234
12237
|
switchView,
|
|
12235
|
-
resetView
|
|
12238
|
+
resetView,
|
|
12239
|
+
invoice
|
|
12236
12240
|
} = usePelcro();
|
|
12237
12241
|
|
|
12238
12242
|
const onSuccess = res => {
|
|
12239
12243
|
var _props$onSuccess;
|
|
12240
12244
|
|
|
12241
12245
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
12242
|
-
resetView();
|
|
12243
12246
|
|
|
12244
12247
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
12245
12248
|
initPaywalls();
|
|
12246
12249
|
}
|
|
12250
|
+
|
|
12251
|
+
resetView();
|
|
12252
|
+
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
12253
|
+
|
|
12254
|
+
if (viewFromURL === "invoice-details") {
|
|
12255
|
+
initViewFromURL();
|
|
12256
|
+
}
|
|
12247
12257
|
};
|
|
12248
12258
|
|
|
12249
12259
|
const onCreateAccountClick = () => {
|
|
@@ -15403,6 +15413,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15403
15413
|
const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
|
|
15404
15414
|
const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
|
|
15405
15415
|
const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
|
|
15416
|
+
const [isTapLoaded, setIsTapLoaded] = React.useState(Boolean(window.Tapjsli));
|
|
15406
15417
|
React.useEffect(() => {
|
|
15407
15418
|
if (window.Pelcro.coupon.getFromUrl()) {
|
|
15408
15419
|
dispatch({
|
|
@@ -15857,9 +15868,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15857
15868
|
const vantivInstanceRef = React__default['default'].useRef(null);
|
|
15858
15869
|
const tapInstanceRef = React__default['default'].useRef(null);
|
|
15859
15870
|
const tapInstanceCard = React__default['default'].useRef(null);
|
|
15871
|
+
const cardProcessor = getSiteCardProcessor();
|
|
15860
15872
|
React.useEffect(() => {
|
|
15861
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15862
|
-
|
|
15863
15873
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
15864
15874
|
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
15865
15875
|
|
|
@@ -15886,10 +15896,18 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15886
15896
|
}
|
|
15887
15897
|
});
|
|
15888
15898
|
}
|
|
15899
|
+
}, [selectedPaymentMethodId]);
|
|
15900
|
+
React.useEffect(() => {
|
|
15901
|
+
if (cardProcessor === "tap" && !isTapLoaded) {
|
|
15902
|
+
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
15903
|
+
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
15904
|
+
setIsTapLoaded(true);
|
|
15905
|
+
}
|
|
15889
15906
|
|
|
15890
|
-
if (cardProcessor === "tap" && !selectedPaymentMethodId) {
|
|
15907
|
+
if (cardProcessor === "tap" && !selectedPaymentMethodId && isTapLoaded) {
|
|
15891
15908
|
var _window$Pelcro$site$r3;
|
|
15892
15909
|
|
|
15910
|
+
console.log("Yes Tap JSLI is enabled and activated");
|
|
15893
15911
|
const tapKey = Tapjsli((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.tap_gateway_settings.publishable_key);
|
|
15894
15912
|
let elements = tapKey.elements({});
|
|
15895
15913
|
let style = {
|
|
@@ -15952,7 +15970,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15952
15970
|
tapInstanceRef.current = tapKey;
|
|
15953
15971
|
tapInstanceCard.current = card;
|
|
15954
15972
|
}
|
|
15955
|
-
}, [selectedPaymentMethodId]);
|
|
15973
|
+
}, [selectedPaymentMethodId, isTapLoaded]);
|
|
15956
15974
|
|
|
15957
15975
|
const initPaymentRequest = (state, dispatch) => {
|
|
15958
15976
|
try {
|
|
@@ -17074,12 +17092,17 @@ const UnwrappedForm = es_12(PaymentMethodContainerWithoutStripe);
|
|
|
17074
17092
|
|
|
17075
17093
|
const PaymentMethodContainer = props => {
|
|
17076
17094
|
const [isStripeLoaded, setIsStripeLoaded] = React.useState(Boolean(window.Stripe));
|
|
17095
|
+
const {
|
|
17096
|
+
whenUserReady
|
|
17097
|
+
} = usePelcro.getStore();
|
|
17077
17098
|
React.useEffect(() => {
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
|
|
17099
|
+
whenUserReady(() => {
|
|
17100
|
+
if (!window.Stripe) {
|
|
17101
|
+
document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
|
|
17102
|
+
setIsStripeLoaded(true);
|
|
17103
|
+
});
|
|
17104
|
+
}
|
|
17105
|
+
});
|
|
17083
17106
|
}, []);
|
|
17084
17107
|
|
|
17085
17108
|
if (isStripeLoaded) {
|
package/dist/index.esm.js
CHANGED
|
@@ -10500,6 +10500,7 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10500
10500
|
const {
|
|
10501
10501
|
isAuthenticated,
|
|
10502
10502
|
setInvoice,
|
|
10503
|
+
whenUserReady,
|
|
10503
10504
|
whenSiteReady,
|
|
10504
10505
|
switchView
|
|
10505
10506
|
} = usePelcro.getStore();
|
|
@@ -10508,28 +10509,30 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10508
10509
|
return switchView("login");
|
|
10509
10510
|
}
|
|
10510
10511
|
|
|
10511
|
-
|
|
10512
|
-
|
|
10512
|
+
whenUserReady(() => {
|
|
10513
|
+
const invoiceId = window.Pelcro.helpers.getURLParameter("id");
|
|
10514
|
+
const wasSetSuccessfully = setInvoice(invoiceId);
|
|
10513
10515
|
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10516
|
+
if (!wasSetSuccessfully) {
|
|
10517
|
+
const errorMessage = i18next.t("messages:invalidInvoice", {
|
|
10518
|
+
returnObjects: true
|
|
10519
|
+
});
|
|
10520
|
+
return notify.error(errorMessage);
|
|
10521
|
+
}
|
|
10520
10522
|
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10523
|
+
const {
|
|
10524
|
+
invoice
|
|
10525
|
+
} = usePelcro.getStore();
|
|
10524
10526
|
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10527
|
+
if (invoice.total === 0) {
|
|
10528
|
+
const errorMessage = i18next.t("messages:zeroTotalInvoice", {
|
|
10529
|
+
returnObjects: true
|
|
10530
|
+
});
|
|
10531
|
+
return notify.error(errorMessage);
|
|
10532
|
+
}
|
|
10531
10533
|
|
|
10532
|
-
|
|
10534
|
+
return switchView("invoice-details");
|
|
10535
|
+
});
|
|
10533
10536
|
});
|
|
10534
10537
|
};
|
|
10535
10538
|
|
|
@@ -12202,18 +12205,25 @@ function LoginModal({
|
|
|
12202
12205
|
} = useTranslation("login");
|
|
12203
12206
|
const {
|
|
12204
12207
|
switchView,
|
|
12205
|
-
resetView
|
|
12208
|
+
resetView,
|
|
12209
|
+
invoice
|
|
12206
12210
|
} = usePelcro();
|
|
12207
12211
|
|
|
12208
12212
|
const onSuccess = res => {
|
|
12209
12213
|
var _props$onSuccess;
|
|
12210
12214
|
|
|
12211
12215
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
12212
|
-
resetView();
|
|
12213
12216
|
|
|
12214
12217
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
12215
12218
|
initPaywalls();
|
|
12216
12219
|
}
|
|
12220
|
+
|
|
12221
|
+
resetView();
|
|
12222
|
+
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
12223
|
+
|
|
12224
|
+
if (viewFromURL === "invoice-details") {
|
|
12225
|
+
initViewFromURL();
|
|
12226
|
+
}
|
|
12217
12227
|
};
|
|
12218
12228
|
|
|
12219
12229
|
const onCreateAccountClick = () => {
|
|
@@ -15373,6 +15383,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15373
15383
|
const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
|
|
15374
15384
|
const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
|
|
15375
15385
|
const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
|
|
15386
|
+
const [isTapLoaded, setIsTapLoaded] = useState(Boolean(window.Tapjsli));
|
|
15376
15387
|
useEffect(() => {
|
|
15377
15388
|
if (window.Pelcro.coupon.getFromUrl()) {
|
|
15378
15389
|
dispatch({
|
|
@@ -15827,9 +15838,8 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15827
15838
|
const vantivInstanceRef = React__default.useRef(null);
|
|
15828
15839
|
const tapInstanceRef = React__default.useRef(null);
|
|
15829
15840
|
const tapInstanceCard = React__default.useRef(null);
|
|
15841
|
+
const cardProcessor = getSiteCardProcessor();
|
|
15830
15842
|
useEffect(() => {
|
|
15831
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15832
|
-
|
|
15833
15843
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
15834
15844
|
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
15835
15845
|
|
|
@@ -15856,10 +15866,18 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15856
15866
|
}
|
|
15857
15867
|
});
|
|
15858
15868
|
}
|
|
15869
|
+
}, [selectedPaymentMethodId]);
|
|
15870
|
+
useEffect(() => {
|
|
15871
|
+
if (cardProcessor === "tap" && !isTapLoaded) {
|
|
15872
|
+
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
15873
|
+
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
15874
|
+
setIsTapLoaded(true);
|
|
15875
|
+
}
|
|
15859
15876
|
|
|
15860
|
-
if (cardProcessor === "tap" && !selectedPaymentMethodId) {
|
|
15877
|
+
if (cardProcessor === "tap" && !selectedPaymentMethodId && isTapLoaded) {
|
|
15861
15878
|
var _window$Pelcro$site$r3;
|
|
15862
15879
|
|
|
15880
|
+
console.log("Yes Tap JSLI is enabled and activated");
|
|
15863
15881
|
const tapKey = Tapjsli((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.tap_gateway_settings.publishable_key);
|
|
15864
15882
|
let elements = tapKey.elements({});
|
|
15865
15883
|
let style = {
|
|
@@ -15922,7 +15940,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15922
15940
|
tapInstanceRef.current = tapKey;
|
|
15923
15941
|
tapInstanceCard.current = card;
|
|
15924
15942
|
}
|
|
15925
|
-
}, [selectedPaymentMethodId]);
|
|
15943
|
+
}, [selectedPaymentMethodId, isTapLoaded]);
|
|
15926
15944
|
|
|
15927
15945
|
const initPaymentRequest = (state, dispatch) => {
|
|
15928
15946
|
try {
|
|
@@ -17044,12 +17062,17 @@ const UnwrappedForm = es_12(PaymentMethodContainerWithoutStripe);
|
|
|
17044
17062
|
|
|
17045
17063
|
const PaymentMethodContainer = props => {
|
|
17046
17064
|
const [isStripeLoaded, setIsStripeLoaded] = useState(Boolean(window.Stripe));
|
|
17065
|
+
const {
|
|
17066
|
+
whenUserReady
|
|
17067
|
+
} = usePelcro.getStore();
|
|
17047
17068
|
useEffect(() => {
|
|
17048
|
-
|
|
17049
|
-
|
|
17050
|
-
|
|
17051
|
-
|
|
17052
|
-
|
|
17069
|
+
whenUserReady(() => {
|
|
17070
|
+
if (!window.Stripe) {
|
|
17071
|
+
document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
|
|
17072
|
+
setIsStripeLoaded(true);
|
|
17073
|
+
});
|
|
17074
|
+
}
|
|
17075
|
+
});
|
|
17053
17076
|
}, []);
|
|
17054
17077
|
|
|
17055
17078
|
if (isStripeLoaded) {
|