@pelcro/react-pelcro-js 3.22.0-beta.4 → 3.22.0-beta.6
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 +28 -12
- package/dist/index.esm.js +28 -12
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -14079,7 +14079,6 @@ class SelectModal extends React.Component {
|
|
|
14079
14079
|
});
|
|
14080
14080
|
});
|
|
14081
14081
|
});
|
|
14082
|
-
console.log("bugsnag Triggered");
|
|
14083
14082
|
}
|
|
14084
14083
|
});
|
|
14085
14084
|
_defineProperty$3(this, "componentWillUnmount", () => {
|
|
@@ -16355,6 +16354,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16355
16354
|
onFailure = () => {},
|
|
16356
16355
|
...props
|
|
16357
16356
|
} = _ref;
|
|
16357
|
+
const [vantivPaymentRequest, setVantivPaymentRequest] = React.useState(null);
|
|
16358
|
+
const [updatedCouponCode, setUpdatedCouponCode] = React.useState("");
|
|
16358
16359
|
const {
|
|
16359
16360
|
t
|
|
16360
16361
|
} = useTranslation("payment");
|
|
@@ -16397,7 +16398,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16397
16398
|
}, []);
|
|
16398
16399
|
|
|
16399
16400
|
/*====== Start Tap integration ========*/
|
|
16400
|
-
const submitUsingTap =
|
|
16401
|
+
const submitUsingTap = state => {
|
|
16401
16402
|
var _ref2, _ref3, _ref4, _state$updatedPrice;
|
|
16402
16403
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16403
16404
|
if (isUsingExistingPaymentMethod) {
|
|
@@ -16492,7 +16493,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16492
16493
|
content: null
|
|
16493
16494
|
}
|
|
16494
16495
|
});
|
|
16495
|
-
handleTapPayment(tapID);
|
|
16496
|
+
handleTapPayment(tapID, state);
|
|
16496
16497
|
}
|
|
16497
16498
|
};
|
|
16498
16499
|
|
|
@@ -16505,7 +16506,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16505
16506
|
}
|
|
16506
16507
|
});
|
|
16507
16508
|
};
|
|
16508
|
-
function handleTapPayment(paymentRequest) {
|
|
16509
|
+
function handleTapPayment(paymentRequest, state) {
|
|
16509
16510
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16510
16511
|
if (type === "createPayment") {
|
|
16511
16512
|
handleTapSubscription();
|
|
@@ -16683,7 +16684,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16683
16684
|
};
|
|
16684
16685
|
/*====== End Tap integration ========*/
|
|
16685
16686
|
|
|
16686
|
-
const submitUsingVantiv =
|
|
16687
|
+
const submitUsingVantiv = state => {
|
|
16687
16688
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16688
16689
|
if (isUsingExistingPaymentMethod) {
|
|
16689
16690
|
// no need to create a new source using vantiv
|
|
@@ -16696,12 +16697,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16696
16697
|
/*
|
|
16697
16698
|
calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
|
|
16698
16699
|
*/
|
|
16699
|
-
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
16700
|
+
handleVantivPayment(vantivInstanceRef.current.getPaypageRegistrationId({
|
|
16700
16701
|
id: orderId,
|
|
16701
16702
|
orderId: orderId
|
|
16702
|
-
});
|
|
16703
|
+
}), state);
|
|
16703
16704
|
};
|
|
16704
|
-
function handleVantivPayment(paymentRequest) {
|
|
16705
|
+
function handleVantivPayment(paymentRequest, couponCode) {
|
|
16705
16706
|
if (paymentRequest) {
|
|
16706
16707
|
const SUCCESS_STATUS = "870";
|
|
16707
16708
|
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
@@ -16767,7 +16768,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16767
16768
|
const renewSubscription = !isGift && subscriptionIdToRenew;
|
|
16768
16769
|
const giftSubscriprition = isGift && !subscriptionIdToRenew;
|
|
16769
16770
|
const renewGift = isRenewingGift;
|
|
16770
|
-
const couponCode = state.couponCode || window.Pelcro.coupon.getFromUrl() || "";
|
|
16771
16771
|
if (renewGift) {
|
|
16772
16772
|
return payment.execute({
|
|
16773
16773
|
type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
|
|
@@ -16853,7 +16853,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16853
16853
|
height: "245",
|
|
16854
16854
|
timeout: 50000,
|
|
16855
16855
|
div: "eProtectiframe",
|
|
16856
|
-
callback:
|
|
16856
|
+
callback: paymentRequest => setVantivPaymentRequest(paymentRequest),
|
|
16857
16857
|
showCvv: true,
|
|
16858
16858
|
numYears: 8,
|
|
16859
16859
|
placeholderText: {
|
|
@@ -16868,6 +16868,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16868
16868
|
});
|
|
16869
16869
|
}
|
|
16870
16870
|
}, [selectedPaymentMethodId]);
|
|
16871
|
+
|
|
16872
|
+
//Trigger the handleVantivPayment method when a vantivePaymentRequest is present
|
|
16873
|
+
React.useEffect(() => {
|
|
16874
|
+
if (vantivPaymentRequest) {
|
|
16875
|
+
handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
|
|
16876
|
+
}
|
|
16877
|
+
}, [vantivPaymentRequest]);
|
|
16871
16878
|
React.useEffect(() => {
|
|
16872
16879
|
whenUserReady(() => {
|
|
16873
16880
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
|
|
@@ -16996,6 +17003,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16996
17003
|
});
|
|
16997
17004
|
if (err) {
|
|
16998
17005
|
onFailure(err);
|
|
17006
|
+
|
|
17007
|
+
//reset the coupon code in local state
|
|
17008
|
+
setUpdatedCouponCode("");
|
|
16999
17009
|
dispatch({
|
|
17000
17010
|
type: SET_COUPON_ERROR,
|
|
17001
17011
|
payload: getErrorMessages(err)
|
|
@@ -17054,6 +17064,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17054
17064
|
type: SET_COUPON,
|
|
17055
17065
|
payload: res.data.coupon
|
|
17056
17066
|
});
|
|
17067
|
+
|
|
17068
|
+
//set the coupon code in local state to be able to use with Vantiv
|
|
17069
|
+
setUpdatedCouponCode(res.data.coupon.code);
|
|
17057
17070
|
dispatch({
|
|
17058
17071
|
type: SET_PERCENT_OFF,
|
|
17059
17072
|
payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
|
|
@@ -17124,6 +17137,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17124
17137
|
const debouncedApplyCouponCode = React.useRef(debounce(onApplyCouponCode, 1000)).current;
|
|
17125
17138
|
const removeAppliedCoupon = state => {
|
|
17126
17139
|
state.couponCode = "";
|
|
17140
|
+
|
|
17141
|
+
//reset the coupon code in local state
|
|
17142
|
+
setUpdatedCouponCode("");
|
|
17127
17143
|
dispatch({
|
|
17128
17144
|
type: SET_COUPON_ERROR,
|
|
17129
17145
|
payload: ""
|
|
@@ -17808,10 +17824,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17808
17824
|
return submitPayment(state);
|
|
17809
17825
|
}
|
|
17810
17826
|
if (getSiteCardProcessor() === "vantiv") {
|
|
17811
|
-
return submitUsingVantiv();
|
|
17827
|
+
return submitUsingVantiv(state);
|
|
17812
17828
|
}
|
|
17813
17829
|
if (getSiteCardProcessor() === "tap") {
|
|
17814
|
-
return submitUsingTap();
|
|
17830
|
+
return submitUsingTap(state);
|
|
17815
17831
|
}
|
|
17816
17832
|
if (selectedPaymentMethodId) {
|
|
17817
17833
|
// pay with selected method (source) if exists already
|
package/dist/index.esm.js
CHANGED
|
@@ -14049,7 +14049,6 @@ class SelectModal extends Component {
|
|
|
14049
14049
|
});
|
|
14050
14050
|
});
|
|
14051
14051
|
});
|
|
14052
|
-
console.log("bugsnag Triggered");
|
|
14053
14052
|
}
|
|
14054
14053
|
});
|
|
14055
14054
|
_defineProperty$3(this, "componentWillUnmount", () => {
|
|
@@ -16325,6 +16324,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16325
16324
|
onFailure = () => {},
|
|
16326
16325
|
...props
|
|
16327
16326
|
} = _ref;
|
|
16327
|
+
const [vantivPaymentRequest, setVantivPaymentRequest] = useState(null);
|
|
16328
|
+
const [updatedCouponCode, setUpdatedCouponCode] = useState("");
|
|
16328
16329
|
const {
|
|
16329
16330
|
t
|
|
16330
16331
|
} = useTranslation("payment");
|
|
@@ -16367,7 +16368,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16367
16368
|
}, []);
|
|
16368
16369
|
|
|
16369
16370
|
/*====== Start Tap integration ========*/
|
|
16370
|
-
const submitUsingTap =
|
|
16371
|
+
const submitUsingTap = state => {
|
|
16371
16372
|
var _ref2, _ref3, _ref4, _state$updatedPrice;
|
|
16372
16373
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16373
16374
|
if (isUsingExistingPaymentMethod) {
|
|
@@ -16462,7 +16463,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16462
16463
|
content: null
|
|
16463
16464
|
}
|
|
16464
16465
|
});
|
|
16465
|
-
handleTapPayment(tapID);
|
|
16466
|
+
handleTapPayment(tapID, state);
|
|
16466
16467
|
}
|
|
16467
16468
|
};
|
|
16468
16469
|
|
|
@@ -16475,7 +16476,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16475
16476
|
}
|
|
16476
16477
|
});
|
|
16477
16478
|
};
|
|
16478
|
-
function handleTapPayment(paymentRequest) {
|
|
16479
|
+
function handleTapPayment(paymentRequest, state) {
|
|
16479
16480
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16480
16481
|
if (type === "createPayment") {
|
|
16481
16482
|
handleTapSubscription();
|
|
@@ -16653,7 +16654,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16653
16654
|
};
|
|
16654
16655
|
/*====== End Tap integration ========*/
|
|
16655
16656
|
|
|
16656
|
-
const submitUsingVantiv =
|
|
16657
|
+
const submitUsingVantiv = state => {
|
|
16657
16658
|
const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
|
|
16658
16659
|
if (isUsingExistingPaymentMethod) {
|
|
16659
16660
|
// no need to create a new source using vantiv
|
|
@@ -16666,12 +16667,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16666
16667
|
/*
|
|
16667
16668
|
calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
|
|
16668
16669
|
*/
|
|
16669
|
-
vantivInstanceRef.current.getPaypageRegistrationId({
|
|
16670
|
+
handleVantivPayment(vantivInstanceRef.current.getPaypageRegistrationId({
|
|
16670
16671
|
id: orderId,
|
|
16671
16672
|
orderId: orderId
|
|
16672
|
-
});
|
|
16673
|
+
}), state);
|
|
16673
16674
|
};
|
|
16674
|
-
function handleVantivPayment(paymentRequest) {
|
|
16675
|
+
function handleVantivPayment(paymentRequest, couponCode) {
|
|
16675
16676
|
if (paymentRequest) {
|
|
16676
16677
|
const SUCCESS_STATUS = "870";
|
|
16677
16678
|
if (paymentRequest.response !== SUCCESS_STATUS) {
|
|
@@ -16737,7 +16738,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16737
16738
|
const renewSubscription = !isGift && subscriptionIdToRenew;
|
|
16738
16739
|
const giftSubscriprition = isGift && !subscriptionIdToRenew;
|
|
16739
16740
|
const renewGift = isRenewingGift;
|
|
16740
|
-
const couponCode = state.couponCode || window.Pelcro.coupon.getFromUrl() || "";
|
|
16741
16741
|
if (renewGift) {
|
|
16742
16742
|
return payment.execute({
|
|
16743
16743
|
type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
|
|
@@ -16823,7 +16823,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16823
16823
|
height: "245",
|
|
16824
16824
|
timeout: 50000,
|
|
16825
16825
|
div: "eProtectiframe",
|
|
16826
|
-
callback:
|
|
16826
|
+
callback: paymentRequest => setVantivPaymentRequest(paymentRequest),
|
|
16827
16827
|
showCvv: true,
|
|
16828
16828
|
numYears: 8,
|
|
16829
16829
|
placeholderText: {
|
|
@@ -16838,6 +16838,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16838
16838
|
});
|
|
16839
16839
|
}
|
|
16840
16840
|
}, [selectedPaymentMethodId]);
|
|
16841
|
+
|
|
16842
|
+
//Trigger the handleVantivPayment method when a vantivePaymentRequest is present
|
|
16843
|
+
useEffect(() => {
|
|
16844
|
+
if (vantivPaymentRequest) {
|
|
16845
|
+
handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
|
|
16846
|
+
}
|
|
16847
|
+
}, [vantivPaymentRequest]);
|
|
16841
16848
|
useEffect(() => {
|
|
16842
16849
|
whenUserReady(() => {
|
|
16843
16850
|
if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
|
|
@@ -16966,6 +16973,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
16966
16973
|
});
|
|
16967
16974
|
if (err) {
|
|
16968
16975
|
onFailure(err);
|
|
16976
|
+
|
|
16977
|
+
//reset the coupon code in local state
|
|
16978
|
+
setUpdatedCouponCode("");
|
|
16969
16979
|
dispatch({
|
|
16970
16980
|
type: SET_COUPON_ERROR,
|
|
16971
16981
|
payload: getErrorMessages(err)
|
|
@@ -17024,6 +17034,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17024
17034
|
type: SET_COUPON,
|
|
17025
17035
|
payload: res.data.coupon
|
|
17026
17036
|
});
|
|
17037
|
+
|
|
17038
|
+
//set the coupon code in local state to be able to use with Vantiv
|
|
17039
|
+
setUpdatedCouponCode(res.data.coupon.code);
|
|
17027
17040
|
dispatch({
|
|
17028
17041
|
type: SET_PERCENT_OFF,
|
|
17029
17042
|
payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
|
|
@@ -17094,6 +17107,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17094
17107
|
const debouncedApplyCouponCode = useRef(debounce(onApplyCouponCode, 1000)).current;
|
|
17095
17108
|
const removeAppliedCoupon = state => {
|
|
17096
17109
|
state.couponCode = "";
|
|
17110
|
+
|
|
17111
|
+
//reset the coupon code in local state
|
|
17112
|
+
setUpdatedCouponCode("");
|
|
17097
17113
|
dispatch({
|
|
17098
17114
|
type: SET_COUPON_ERROR,
|
|
17099
17115
|
payload: ""
|
|
@@ -17778,10 +17794,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
|
|
|
17778
17794
|
return submitPayment(state);
|
|
17779
17795
|
}
|
|
17780
17796
|
if (getSiteCardProcessor() === "vantiv") {
|
|
17781
|
-
return submitUsingVantiv();
|
|
17797
|
+
return submitUsingVantiv(state);
|
|
17782
17798
|
}
|
|
17783
17799
|
if (getSiteCardProcessor() === "tap") {
|
|
17784
|
-
return submitUsingTap();
|
|
17800
|
+
return submitUsingTap(state);
|
|
17785
17801
|
}
|
|
17786
17802
|
if (selectedPaymentMethodId) {
|
|
17787
17803
|
// pay with selected method (source) if exists already
|