@pelcro/react-pelcro-js 3.22.0-beta.5 → 3.22.0-beta.7

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 CHANGED
@@ -16354,6 +16354,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16354
16354
  onFailure = () => {},
16355
16355
  ...props
16356
16356
  } = _ref;
16357
+ const [vantivPaymentRequest, setVantivPaymentRequest] = React.useState(null);
16358
+ const [updatedCouponCode, setUpdatedCouponCode] = React.useState("");
16357
16359
  const {
16358
16360
  t
16359
16361
  } = useTranslation("payment");
@@ -16695,12 +16697,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16695
16697
  /*
16696
16698
  calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
16697
16699
  */
16698
- handleVantivPayment(vantivInstanceRef.current.getPaypageRegistrationId({
16700
+ vantivInstanceRef.current.getPaypageRegistrationId({
16699
16701
  id: orderId,
16700
16702
  orderId: orderId
16701
- }), state);
16703
+ });
16702
16704
  };
16703
- function handleVantivPayment(paymentRequest, state) {
16705
+ function handleVantivPayment(paymentRequest, couponCode) {
16704
16706
  if (paymentRequest) {
16705
16707
  const SUCCESS_STATUS = "870";
16706
16708
  if (paymentRequest.response !== SUCCESS_STATUS) {
@@ -16766,9 +16768,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16766
16768
  const renewSubscription = !isGift && subscriptionIdToRenew;
16767
16769
  const giftSubscriprition = isGift && !subscriptionIdToRenew;
16768
16770
  const renewGift = isRenewingGift;
16769
- const {
16770
- couponCode
16771
- } = state;
16772
16771
  if (renewGift) {
16773
16772
  return payment.execute({
16774
16773
  type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
@@ -16854,7 +16853,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16854
16853
  height: "245",
16855
16854
  timeout: 50000,
16856
16855
  div: "eProtectiframe",
16857
- callback: handleVantivPayment,
16856
+ callback: paymentRequest => setVantivPaymentRequest(paymentRequest),
16858
16857
  showCvv: true,
16859
16858
  numYears: 8,
16860
16859
  placeholderText: {
@@ -16869,6 +16868,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16869
16868
  });
16870
16869
  }
16871
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]);
16872
16878
  React.useEffect(() => {
16873
16879
  whenUserReady(() => {
16874
16880
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
@@ -16997,6 +17003,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16997
17003
  });
16998
17004
  if (err) {
16999
17005
  onFailure(err);
17006
+
17007
+ //reset the coupon code in local state
17008
+ setUpdatedCouponCode("");
17000
17009
  dispatch({
17001
17010
  type: SET_COUPON_ERROR,
17002
17011
  payload: getErrorMessages(err)
@@ -17055,6 +17064,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17055
17064
  type: SET_COUPON,
17056
17065
  payload: res.data.coupon
17057
17066
  });
17067
+
17068
+ //set the coupon code in local state to be able to use with Vantiv
17069
+ setUpdatedCouponCode(res.data.coupon.code);
17058
17070
  dispatch({
17059
17071
  type: SET_PERCENT_OFF,
17060
17072
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
@@ -17125,6 +17137,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17125
17137
  const debouncedApplyCouponCode = React.useRef(debounce(onApplyCouponCode, 1000)).current;
17126
17138
  const removeAppliedCoupon = state => {
17127
17139
  state.couponCode = "";
17140
+
17141
+ //reset the coupon code in local state
17142
+ setUpdatedCouponCode("");
17128
17143
  dispatch({
17129
17144
  type: SET_COUPON_ERROR,
17130
17145
  payload: ""
@@ -17809,7 +17824,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17809
17824
  return submitPayment(state);
17810
17825
  }
17811
17826
  if (getSiteCardProcessor() === "vantiv") {
17812
- return submitUsingVantiv(state);
17827
+ return submitUsingVantiv();
17813
17828
  }
17814
17829
  if (getSiteCardProcessor() === "tap") {
17815
17830
  return submitUsingTap(state);
package/dist/index.esm.js CHANGED
@@ -16324,6 +16324,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16324
16324
  onFailure = () => {},
16325
16325
  ...props
16326
16326
  } = _ref;
16327
+ const [vantivPaymentRequest, setVantivPaymentRequest] = useState(null);
16328
+ const [updatedCouponCode, setUpdatedCouponCode] = useState("");
16327
16329
  const {
16328
16330
  t
16329
16331
  } = useTranslation("payment");
@@ -16665,12 +16667,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16665
16667
  /*
16666
16668
  calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
16667
16669
  */
16668
- handleVantivPayment(vantivInstanceRef.current.getPaypageRegistrationId({
16670
+ vantivInstanceRef.current.getPaypageRegistrationId({
16669
16671
  id: orderId,
16670
16672
  orderId: orderId
16671
- }), state);
16673
+ });
16672
16674
  };
16673
- function handleVantivPayment(paymentRequest, state) {
16675
+ function handleVantivPayment(paymentRequest, couponCode) {
16674
16676
  if (paymentRequest) {
16675
16677
  const SUCCESS_STATUS = "870";
16676
16678
  if (paymentRequest.response !== SUCCESS_STATUS) {
@@ -16736,9 +16738,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16736
16738
  const renewSubscription = !isGift && subscriptionIdToRenew;
16737
16739
  const giftSubscriprition = isGift && !subscriptionIdToRenew;
16738
16740
  const renewGift = isRenewingGift;
16739
- const {
16740
- couponCode
16741
- } = state;
16742
16741
  if (renewGift) {
16743
16742
  return payment.execute({
16744
16743
  type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
@@ -16824,7 +16823,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16824
16823
  height: "245",
16825
16824
  timeout: 50000,
16826
16825
  div: "eProtectiframe",
16827
- callback: handleVantivPayment,
16826
+ callback: paymentRequest => setVantivPaymentRequest(paymentRequest),
16828
16827
  showCvv: true,
16829
16828
  numYears: 8,
16830
16829
  placeholderText: {
@@ -16839,6 +16838,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16839
16838
  });
16840
16839
  }
16841
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]);
16842
16848
  useEffect(() => {
16843
16849
  whenUserReady(() => {
16844
16850
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
@@ -16967,6 +16973,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16967
16973
  });
16968
16974
  if (err) {
16969
16975
  onFailure(err);
16976
+
16977
+ //reset the coupon code in local state
16978
+ setUpdatedCouponCode("");
16970
16979
  dispatch({
16971
16980
  type: SET_COUPON_ERROR,
16972
16981
  payload: getErrorMessages(err)
@@ -17025,6 +17034,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17025
17034
  type: SET_COUPON,
17026
17035
  payload: res.data.coupon
17027
17036
  });
17037
+
17038
+ //set the coupon code in local state to be able to use with Vantiv
17039
+ setUpdatedCouponCode(res.data.coupon.code);
17028
17040
  dispatch({
17029
17041
  type: SET_PERCENT_OFF,
17030
17042
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
@@ -17095,6 +17107,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17095
17107
  const debouncedApplyCouponCode = useRef(debounce(onApplyCouponCode, 1000)).current;
17096
17108
  const removeAppliedCoupon = state => {
17097
17109
  state.couponCode = "";
17110
+
17111
+ //reset the coupon code in local state
17112
+ setUpdatedCouponCode("");
17098
17113
  dispatch({
17099
17114
  type: SET_COUPON_ERROR,
17100
17115
  payload: ""
@@ -17779,7 +17794,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17779
17794
  return submitPayment(state);
17780
17795
  }
17781
17796
  if (getSiteCardProcessor() === "vantiv") {
17782
- return submitUsingVantiv(state);
17797
+ return submitUsingVantiv();
17783
17798
  }
17784
17799
  if (getSiteCardProcessor() === "tap") {
17785
17800
  return submitUsingTap(state);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.22.0-beta.5",
4
+ "version": "3.22.0-beta.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",