@pelcro/react-pelcro-js 3.10.1-beta.1 → 3.10.1-beta.11
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 +60 -31
- package/dist/index.esm.js +60 -31
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -10531,35 +10531,38 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10531
10531
|
isAuthenticated,
|
|
10532
10532
|
setInvoice,
|
|
10533
10533
|
whenUserReady,
|
|
10534
|
+
whenSiteReady,
|
|
10534
10535
|
switchView
|
|
10535
10536
|
} = usePelcro.getStore();
|
|
10536
|
-
|
|
10537
|
+
whenSiteReady(() => {
|
|
10537
10538
|
if (!isAuthenticated()) {
|
|
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 = () => {
|
|
@@ -15395,6 +15405,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15395
15405
|
selectedPaymentMethodId,
|
|
15396
15406
|
couponCode
|
|
15397
15407
|
} = usePelcro();
|
|
15408
|
+
const {
|
|
15409
|
+
whenUserReady
|
|
15410
|
+
} = usePelcro.getStore();
|
|
15398
15411
|
const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
|
|
15399
15412
|
const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
|
|
15400
15413
|
const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
|
|
@@ -15403,6 +15416,17 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15403
15416
|
const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
|
|
15404
15417
|
const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
|
|
15405
15418
|
const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
|
|
15419
|
+
const cardProcessor = getSiteCardProcessor();
|
|
15420
|
+
const [isTapLoaded, setIsTapLoaded] = React.useState(Boolean(window.Tapjsli));
|
|
15421
|
+
React.useEffect(() => {
|
|
15422
|
+
whenUserReady(() => {
|
|
15423
|
+
if (cardProcessor === "tap" && !window.Tapjsli) {
|
|
15424
|
+
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
15425
|
+
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
15426
|
+
setIsTapLoaded(true);
|
|
15427
|
+
}
|
|
15428
|
+
});
|
|
15429
|
+
}, []);
|
|
15406
15430
|
React.useEffect(() => {
|
|
15407
15431
|
if (window.Pelcro.coupon.getFromUrl()) {
|
|
15408
15432
|
dispatch({
|
|
@@ -15858,8 +15882,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15858
15882
|
const tapInstanceRef = React__default['default'].useRef(null);
|
|
15859
15883
|
const tapInstanceCard = React__default['default'].useRef(null);
|
|
15860
15884
|
React.useEffect(() => {
|
|
15861
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15862
|
-
|
|
15863
15885
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
15864
15886
|
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
15865
15887
|
|
|
@@ -15886,10 +15908,12 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15886
15908
|
}
|
|
15887
15909
|
});
|
|
15888
15910
|
}
|
|
15889
|
-
|
|
15890
|
-
|
|
15911
|
+
}, [selectedPaymentMethodId]);
|
|
15912
|
+
React.useEffect(() => {
|
|
15913
|
+
if (cardProcessor === "tap" && !selectedPaymentMethodId && isTapLoaded) {
|
|
15891
15914
|
var _window$Pelcro$site$r3;
|
|
15892
15915
|
|
|
15916
|
+
console.log("Yes Tap JSLI is enabled and activated");
|
|
15893
15917
|
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
15918
|
let elements = tapKey.elements({});
|
|
15895
15919
|
let style = {
|
|
@@ -15952,7 +15976,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15952
15976
|
tapInstanceRef.current = tapKey;
|
|
15953
15977
|
tapInstanceCard.current = card;
|
|
15954
15978
|
}
|
|
15955
|
-
}, [selectedPaymentMethodId]);
|
|
15979
|
+
}, [selectedPaymentMethodId, isTapLoaded]);
|
|
15956
15980
|
|
|
15957
15981
|
const initPaymentRequest = (state, dispatch) => {
|
|
15958
15982
|
try {
|
|
@@ -17074,12 +17098,17 @@ const UnwrappedForm = es_12(PaymentMethodContainerWithoutStripe);
|
|
|
17074
17098
|
|
|
17075
17099
|
const PaymentMethodContainer = props => {
|
|
17076
17100
|
const [isStripeLoaded, setIsStripeLoaded] = React.useState(Boolean(window.Stripe));
|
|
17101
|
+
const {
|
|
17102
|
+
whenUserReady
|
|
17103
|
+
} = usePelcro.getStore();
|
|
17077
17104
|
React.useEffect(() => {
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
|
|
17105
|
+
whenUserReady(() => {
|
|
17106
|
+
if (!window.Stripe) {
|
|
17107
|
+
document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
|
|
17108
|
+
setIsStripeLoaded(true);
|
|
17109
|
+
});
|
|
17110
|
+
}
|
|
17111
|
+
});
|
|
17083
17112
|
}, []);
|
|
17084
17113
|
|
|
17085
17114
|
if (isStripeLoaded) {
|
package/dist/index.esm.js
CHANGED
|
@@ -10501,35 +10501,38 @@ const showInvoiceDetailsFromUrl = () => {
|
|
|
10501
10501
|
isAuthenticated,
|
|
10502
10502
|
setInvoice,
|
|
10503
10503
|
whenUserReady,
|
|
10504
|
+
whenSiteReady,
|
|
10504
10505
|
switchView
|
|
10505
10506
|
} = usePelcro.getStore();
|
|
10506
|
-
|
|
10507
|
+
whenSiteReady(() => {
|
|
10507
10508
|
if (!isAuthenticated()) {
|
|
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 = () => {
|
|
@@ -15365,6 +15375,9 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15365
15375
|
selectedPaymentMethodId,
|
|
15366
15376
|
couponCode
|
|
15367
15377
|
} = usePelcro();
|
|
15378
|
+
const {
|
|
15379
|
+
whenUserReady
|
|
15380
|
+
} = usePelcro.getStore();
|
|
15368
15381
|
const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
|
|
15369
15382
|
const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
|
|
15370
15383
|
const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
|
|
@@ -15373,6 +15386,17 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15373
15386
|
const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
|
|
15374
15387
|
const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
|
|
15375
15388
|
const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
|
|
15389
|
+
const cardProcessor = getSiteCardProcessor();
|
|
15390
|
+
const [isTapLoaded, setIsTapLoaded] = useState(Boolean(window.Tapjsli));
|
|
15391
|
+
useEffect(() => {
|
|
15392
|
+
whenUserReady(() => {
|
|
15393
|
+
if (cardProcessor === "tap" && !window.Tapjsli) {
|
|
15394
|
+
window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
|
|
15395
|
+
window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
|
|
15396
|
+
setIsTapLoaded(true);
|
|
15397
|
+
}
|
|
15398
|
+
});
|
|
15399
|
+
}, []);
|
|
15376
15400
|
useEffect(() => {
|
|
15377
15401
|
if (window.Pelcro.coupon.getFromUrl()) {
|
|
15378
15402
|
dispatch({
|
|
@@ -15828,8 +15852,6 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15828
15852
|
const tapInstanceRef = React__default.useRef(null);
|
|
15829
15853
|
const tapInstanceCard = React__default.useRef(null);
|
|
15830
15854
|
useEffect(() => {
|
|
15831
|
-
const cardProcessor = getSiteCardProcessor();
|
|
15832
|
-
|
|
15833
15855
|
if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
|
|
15834
15856
|
var _window$Pelcro$site$r, _window$Pelcro$site$r2;
|
|
15835
15857
|
|
|
@@ -15856,10 +15878,12 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15856
15878
|
}
|
|
15857
15879
|
});
|
|
15858
15880
|
}
|
|
15859
|
-
|
|
15860
|
-
|
|
15881
|
+
}, [selectedPaymentMethodId]);
|
|
15882
|
+
useEffect(() => {
|
|
15883
|
+
if (cardProcessor === "tap" && !selectedPaymentMethodId && isTapLoaded) {
|
|
15861
15884
|
var _window$Pelcro$site$r3;
|
|
15862
15885
|
|
|
15886
|
+
console.log("Yes Tap JSLI is enabled and activated");
|
|
15863
15887
|
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
15888
|
let elements = tapKey.elements({});
|
|
15865
15889
|
let style = {
|
|
@@ -15922,7 +15946,7 @@ const PaymentMethodContainerWithoutStripe = ({
|
|
|
15922
15946
|
tapInstanceRef.current = tapKey;
|
|
15923
15947
|
tapInstanceCard.current = card;
|
|
15924
15948
|
}
|
|
15925
|
-
}, [selectedPaymentMethodId]);
|
|
15949
|
+
}, [selectedPaymentMethodId, isTapLoaded]);
|
|
15926
15950
|
|
|
15927
15951
|
const initPaymentRequest = (state, dispatch) => {
|
|
15928
15952
|
try {
|
|
@@ -17044,12 +17068,17 @@ const UnwrappedForm = es_12(PaymentMethodContainerWithoutStripe);
|
|
|
17044
17068
|
|
|
17045
17069
|
const PaymentMethodContainer = props => {
|
|
17046
17070
|
const [isStripeLoaded, setIsStripeLoaded] = useState(Boolean(window.Stripe));
|
|
17071
|
+
const {
|
|
17072
|
+
whenUserReady
|
|
17073
|
+
} = usePelcro.getStore();
|
|
17047
17074
|
useEffect(() => {
|
|
17048
|
-
|
|
17049
|
-
|
|
17050
|
-
|
|
17051
|
-
|
|
17052
|
-
|
|
17075
|
+
whenUserReady(() => {
|
|
17076
|
+
if (!window.Stripe) {
|
|
17077
|
+
document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
|
|
17078
|
+
setIsStripeLoaded(true);
|
|
17079
|
+
});
|
|
17080
|
+
}
|
|
17081
|
+
});
|
|
17053
17082
|
}, []);
|
|
17054
17083
|
|
|
17055
17084
|
if (isStripeLoaded) {
|