@pelcro/react-pelcro-js 3.6.0-beta.26 → 3.6.0-beta.27

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
@@ -15325,7 +15325,7 @@ const PaymentMethodContainerWithoutStripe = ({
15325
15325
  } else if (type === "orderCreate") {
15326
15326
  purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15327
15327
  } else if (type === "invoicePayment") {
15328
- payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15328
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15329
15329
  } else if (type === "updatePaymentSource") {
15330
15330
  createNewTapCard();
15331
15331
  }
@@ -15502,7 +15502,7 @@ const PaymentMethodContainerWithoutStripe = ({
15502
15502
  } else if (type === "orderCreate") {
15503
15503
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15504
15504
  } else if (type === "invoicePayment") {
15505
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15505
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15506
15506
  } else if (type === "updatePaymentSource") {
15507
15507
  createNewVantivCard();
15508
15508
  }
@@ -16025,6 +16025,90 @@ const PaymentMethodContainerWithoutStripe = ({
16025
16025
  updateTotalAmountWithTax();
16026
16026
  }
16027
16027
  };
16028
+ /**
16029
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
16030
+ * Only trigger method if PaymentIntent status is `requires_action`.
16031
+ *
16032
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
16033
+ *
16034
+ * @param response
16035
+ * @param error
16036
+ * @returns {*}
16037
+ */
16038
+
16039
+
16040
+ const confirmStripeCardPayment = (response, error) => {
16041
+ if (response) {
16042
+ var _response$data;
16043
+
16044
+ const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
16045
+
16046
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16047
+ stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
16048
+ console.log("The validation response", res);
16049
+ dispatch({
16050
+ type: DISABLE_SUBMIT,
16051
+ payload: false
16052
+ });
16053
+ dispatch({
16054
+ type: LOADING,
16055
+ payload: false
16056
+ });
16057
+
16058
+ if (res.error) {
16059
+ onFailure(res.error);
16060
+ return dispatch({
16061
+ type: SHOW_ALERT,
16062
+ payload: {
16063
+ type: "error",
16064
+ content: getErrorMessages(res.error)
16065
+ }
16066
+ });
16067
+ }
16068
+
16069
+ onSuccess(res);
16070
+ });
16071
+ } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16072
+ dispatch({
16073
+ type: DISABLE_SUBMIT,
16074
+ payload: false
16075
+ });
16076
+ dispatch({
16077
+ type: LOADING,
16078
+ payload: false
16079
+ });
16080
+ return dispatch({
16081
+ type: SHOW_ALERT,
16082
+ payload: {
16083
+ type: "error",
16084
+ content: t("messages.cardAuthFailed")
16085
+ }
16086
+ });
16087
+ }
16088
+ } else {
16089
+ dispatch({
16090
+ type: DISABLE_SUBMIT,
16091
+ payload: false
16092
+ });
16093
+ dispatch({
16094
+ type: LOADING,
16095
+ payload: false
16096
+ });
16097
+
16098
+ if (error) {
16099
+ onFailure(error);
16100
+ return dispatch({
16101
+ type: SHOW_ALERT,
16102
+ payload: {
16103
+ type: "error",
16104
+ content: getErrorMessages(error)
16105
+ }
16106
+ });
16107
+ }
16108
+
16109
+ onSuccess(response);
16110
+ }
16111
+ };
16028
16112
 
16029
16113
  const subscribe = (stripeSource, state, dispatch) => {
16030
16114
  const {
@@ -16047,27 +16131,7 @@ const PaymentMethodContainerWithoutStripe = ({
16047
16131
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
16048
16132
  address_id: product.address_required ? selectedAddressId : null
16049
16133
  }, (err, res) => {
16050
- dispatch({
16051
- type: DISABLE_SUBMIT,
16052
- payload: false
16053
- });
16054
- dispatch({
16055
- type: LOADING,
16056
- payload: false
16057
- });
16058
-
16059
- if (err) {
16060
- onFailure(err);
16061
- return dispatch({
16062
- type: SHOW_ALERT,
16063
- payload: {
16064
- type: "error",
16065
- content: getErrorMessages(err)
16066
- }
16067
- });
16068
- }
16069
-
16070
- onSuccess(res);
16134
+ confirmStripeCardPayment(res, err);
16071
16135
  });
16072
16136
  } else {
16073
16137
  if (isRenewingGift) {
@@ -16291,27 +16355,7 @@ const PaymentMethodContainerWithoutStripe = ({
16291
16355
  isExistingSource: Boolean(selectedPaymentMethodId),
16292
16356
  invoiceId: invoice.id
16293
16357
  }, (err, res) => {
16294
- dispatch({
16295
- type: DISABLE_SUBMIT,
16296
- payload: false
16297
- });
16298
- dispatch({
16299
- type: LOADING,
16300
- payload: false
16301
- });
16302
-
16303
- if (err) {
16304
- onFailure(err);
16305
- return dispatch({
16306
- type: SHOW_ALERT,
16307
- payload: {
16308
- type: "error",
16309
- content: getErrorMessages(err)
16310
- }
16311
- });
16312
- }
16313
-
16314
- onSuccess(res);
16358
+ confirmStripeCardPayment(res, err);
16315
16359
  });
16316
16360
  };
16317
16361
 
@@ -16391,7 +16435,7 @@ const PaymentMethodContainerWithoutStripe = ({
16391
16435
  source,
16392
16436
  error
16393
16437
  }) => {
16394
- var _ref3, _ref4, _state$updatedPrice2, _source$card3;
16438
+ var _ref3, _ref4, _state$updatedPrice2;
16395
16439
 
16396
16440
  if (error) {
16397
16441
  return handlePaymentError(error);
@@ -16417,25 +16461,7 @@ const PaymentMethodContainerWithoutStripe = ({
16417
16461
  }, 0);
16418
16462
  };
16419
16463
 
16420
- const totalAmount = (_ref3 = (_ref4 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal();
16421
-
16422
- if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
16423
- return resolveTaxCalculation().then(res => {
16424
- var _res$totalAmountWithT;
16425
-
16426
- return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
16427
- source,
16428
- error
16429
- }) => {
16430
- if (error) {
16431
- return handlePaymentError(error);
16432
- }
16433
-
16434
- toggleAuthenticationPendingView(true, source);
16435
- });
16436
- });
16437
- }
16438
-
16464
+ (_ref3 = (_ref4 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal();
16439
16465
  return handlePayment(source);
16440
16466
  }).catch(error => {
16441
16467
  return handlePaymentError(error);
@@ -16529,7 +16555,7 @@ const PaymentMethodContainerWithoutStripe = ({
16529
16555
  } else if (stripeSource && type === "orderCreate") {
16530
16556
  purchase(new StripeGateway(), stripeSource.id, state, dispatch);
16531
16557
  } else if (stripeSource && type === "invoicePayment") {
16532
- payInvoice(new StripeGateway(), stripeSource.id, dispatch);
16558
+ payInvoice(new StripeGateway(), stripeSource.id);
16533
16559
  }
16534
16560
  };
16535
16561
 
@@ -16679,7 +16705,7 @@ const PaymentMethodContainerWithoutStripe = ({
16679
16705
  case HANDLE_PAYPAL_SUBSCRIPTION:
16680
16706
  return lib_5(state, (state, dispatch) => {
16681
16707
  if (type === "invoicePayment") {
16682
- payInvoice(new PaypalGateway(), action.payload, dispatch);
16708
+ payInvoice(new PaypalGateway(), action.payload);
16683
16709
  } else {
16684
16710
  handlePaypalSubscription(state, action.payload);
16685
16711
  }
package/dist/index.esm.js CHANGED
@@ -15295,7 +15295,7 @@ const PaymentMethodContainerWithoutStripe = ({
15295
15295
  } else if (type === "orderCreate") {
15296
15296
  purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15297
15297
  } else if (type === "invoicePayment") {
15298
- payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15298
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15299
15299
  } else if (type === "updatePaymentSource") {
15300
15300
  createNewTapCard();
15301
15301
  }
@@ -15472,7 +15472,7 @@ const PaymentMethodContainerWithoutStripe = ({
15472
15472
  } else if (type === "orderCreate") {
15473
15473
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15474
15474
  } else if (type === "invoicePayment") {
15475
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15475
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15476
15476
  } else if (type === "updatePaymentSource") {
15477
15477
  createNewVantivCard();
15478
15478
  }
@@ -15995,6 +15995,90 @@ const PaymentMethodContainerWithoutStripe = ({
15995
15995
  updateTotalAmountWithTax();
15996
15996
  }
15997
15997
  };
15998
+ /**
15999
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
16000
+ * Only trigger method if PaymentIntent status is `requires_action`.
16001
+ *
16002
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
16003
+ *
16004
+ * @param response
16005
+ * @param error
16006
+ * @returns {*}
16007
+ */
16008
+
16009
+
16010
+ const confirmStripeCardPayment = (response, error) => {
16011
+ if (response) {
16012
+ var _response$data;
16013
+
16014
+ const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
16015
+
16016
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16017
+ stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
16018
+ console.log("The validation response", res);
16019
+ dispatch({
16020
+ type: DISABLE_SUBMIT,
16021
+ payload: false
16022
+ });
16023
+ dispatch({
16024
+ type: LOADING,
16025
+ payload: false
16026
+ });
16027
+
16028
+ if (res.error) {
16029
+ onFailure(res.error);
16030
+ return dispatch({
16031
+ type: SHOW_ALERT,
16032
+ payload: {
16033
+ type: "error",
16034
+ content: getErrorMessages(res.error)
16035
+ }
16036
+ });
16037
+ }
16038
+
16039
+ onSuccess(res);
16040
+ });
16041
+ } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16042
+ dispatch({
16043
+ type: DISABLE_SUBMIT,
16044
+ payload: false
16045
+ });
16046
+ dispatch({
16047
+ type: LOADING,
16048
+ payload: false
16049
+ });
16050
+ return dispatch({
16051
+ type: SHOW_ALERT,
16052
+ payload: {
16053
+ type: "error",
16054
+ content: t("messages.cardAuthFailed")
16055
+ }
16056
+ });
16057
+ }
16058
+ } else {
16059
+ dispatch({
16060
+ type: DISABLE_SUBMIT,
16061
+ payload: false
16062
+ });
16063
+ dispatch({
16064
+ type: LOADING,
16065
+ payload: false
16066
+ });
16067
+
16068
+ if (error) {
16069
+ onFailure(error);
16070
+ return dispatch({
16071
+ type: SHOW_ALERT,
16072
+ payload: {
16073
+ type: "error",
16074
+ content: getErrorMessages(error)
16075
+ }
16076
+ });
16077
+ }
16078
+
16079
+ onSuccess(response);
16080
+ }
16081
+ };
15998
16082
 
15999
16083
  const subscribe = (stripeSource, state, dispatch) => {
16000
16084
  const {
@@ -16017,27 +16101,7 @@ const PaymentMethodContainerWithoutStripe = ({
16017
16101
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
16018
16102
  address_id: product.address_required ? selectedAddressId : null
16019
16103
  }, (err, res) => {
16020
- dispatch({
16021
- type: DISABLE_SUBMIT,
16022
- payload: false
16023
- });
16024
- dispatch({
16025
- type: LOADING,
16026
- payload: false
16027
- });
16028
-
16029
- if (err) {
16030
- onFailure(err);
16031
- return dispatch({
16032
- type: SHOW_ALERT,
16033
- payload: {
16034
- type: "error",
16035
- content: getErrorMessages(err)
16036
- }
16037
- });
16038
- }
16039
-
16040
- onSuccess(res);
16104
+ confirmStripeCardPayment(res, err);
16041
16105
  });
16042
16106
  } else {
16043
16107
  if (isRenewingGift) {
@@ -16261,27 +16325,7 @@ const PaymentMethodContainerWithoutStripe = ({
16261
16325
  isExistingSource: Boolean(selectedPaymentMethodId),
16262
16326
  invoiceId: invoice.id
16263
16327
  }, (err, res) => {
16264
- dispatch({
16265
- type: DISABLE_SUBMIT,
16266
- payload: false
16267
- });
16268
- dispatch({
16269
- type: LOADING,
16270
- payload: false
16271
- });
16272
-
16273
- if (err) {
16274
- onFailure(err);
16275
- return dispatch({
16276
- type: SHOW_ALERT,
16277
- payload: {
16278
- type: "error",
16279
- content: getErrorMessages(err)
16280
- }
16281
- });
16282
- }
16283
-
16284
- onSuccess(res);
16328
+ confirmStripeCardPayment(res, err);
16285
16329
  });
16286
16330
  };
16287
16331
 
@@ -16361,7 +16405,7 @@ const PaymentMethodContainerWithoutStripe = ({
16361
16405
  source,
16362
16406
  error
16363
16407
  }) => {
16364
- var _ref3, _ref4, _state$updatedPrice2, _source$card3;
16408
+ var _ref3, _ref4, _state$updatedPrice2;
16365
16409
 
16366
16410
  if (error) {
16367
16411
  return handlePaymentError(error);
@@ -16387,25 +16431,7 @@ const PaymentMethodContainerWithoutStripe = ({
16387
16431
  }, 0);
16388
16432
  };
16389
16433
 
16390
- const totalAmount = (_ref3 = (_ref4 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal();
16391
-
16392
- if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
16393
- return resolveTaxCalculation().then(res => {
16394
- var _res$totalAmountWithT;
16395
-
16396
- return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
16397
- source,
16398
- error
16399
- }) => {
16400
- if (error) {
16401
- return handlePaymentError(error);
16402
- }
16403
-
16404
- toggleAuthenticationPendingView(true, source);
16405
- });
16406
- });
16407
- }
16408
-
16434
+ (_ref3 = (_ref4 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal();
16409
16435
  return handlePayment(source);
16410
16436
  }).catch(error => {
16411
16437
  return handlePaymentError(error);
@@ -16499,7 +16525,7 @@ const PaymentMethodContainerWithoutStripe = ({
16499
16525
  } else if (stripeSource && type === "orderCreate") {
16500
16526
  purchase(new StripeGateway(), stripeSource.id, state, dispatch);
16501
16527
  } else if (stripeSource && type === "invoicePayment") {
16502
- payInvoice(new StripeGateway(), stripeSource.id, dispatch);
16528
+ payInvoice(new StripeGateway(), stripeSource.id);
16503
16529
  }
16504
16530
  };
16505
16531
 
@@ -16649,7 +16675,7 @@ const PaymentMethodContainerWithoutStripe = ({
16649
16675
  case HANDLE_PAYPAL_SUBSCRIPTION:
16650
16676
  return lib_5(state, (state, dispatch) => {
16651
16677
  if (type === "invoicePayment") {
16652
- payInvoice(new PaypalGateway(), action.payload, dispatch);
16678
+ payInvoice(new PaypalGateway(), action.payload);
16653
16679
  } else {
16654
16680
  handlePaypalSubscription(state, action.payload);
16655
16681
  }
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.6.0-beta.26",
4
+ "version": "3.6.0-beta.27",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",