@pelcro/react-pelcro-js 3.26.0-sandbox.1 → 3.26.0-sandbox.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
@@ -14651,7 +14651,6 @@ class SelectModal extends React.Component {
14651
14651
  });
14652
14652
  });
14653
14653
  });
14654
- console.log("bugsnag Triggered");
14655
14654
  }
14656
14655
  });
14657
14656
  _defineProperty$3(this, "componentWillUnmount", () => {
@@ -17216,7 +17215,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17216
17215
  };
17217
17216
  const submitUsingCybersource = (state, dispatch) => {
17218
17217
  var _cybersourceInstanceR;
17219
- console.log("State", state);
17220
17218
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
17221
17219
  if (isUsingExistingPaymentMethod) {
17222
17220
  // no need to create a new source using cybersrce
@@ -17257,7 +17255,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17257
17255
  } else if (type === "orderCreate") {
17258
17256
  purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17259
17257
  } else if (type === "invoicePayment") {
17260
- payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17258
+ payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17261
17259
  } else if (type === "updatePaymentSource") {
17262
17260
  createNewCybersourceCard();
17263
17261
  }
@@ -17579,7 +17577,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17579
17577
  } else if (type === "orderCreate") {
17580
17578
  purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17581
17579
  } else if (type === "invoicePayment") {
17582
- payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17580
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17583
17581
  } else if (type === "updatePaymentSource") {
17584
17582
  createNewTapCard();
17585
17583
  }
@@ -17790,7 +17788,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17790
17788
  } else if (type === "orderCreate") {
17791
17789
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17792
17790
  } else if (type === "invoicePayment") {
17793
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17791
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17794
17792
  } else if (type === "updatePaymentSource") {
17795
17793
  createNewVantivCard();
17796
17794
  }
@@ -18263,30 +18261,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18263
18261
  updateTotalAmountWithTax();
18264
18262
  }
18265
18263
  };
18266
-
18267
- /**
18268
- * Attempt to confirm a Stripe card payment via it's PaymentIntent.
18269
- * Only trigger method if PaymentIntent status is `requires_action`.
18270
- *
18271
- * @see https://stripe.com/docs/payments/intents#intent-statuses
18272
- *
18273
- * @param response
18274
- * @param error
18275
- * @returns {*}
18276
- */
18277
- const confirmStripeCardPayment = function (response, error) {
18278
- let isSubCreate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
18264
+ const confirmStripePaymentIntent = (response, error) => {
18279
18265
  if (response) {
18280
18266
  var _response$data;
18281
18267
  const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
18282
- if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18268
+ if (paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18283
18269
  stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
18284
- if (!isSubCreate) {
18285
- dispatch({
18286
- type: DISABLE_SUBMIT,
18287
- payload: false
18288
- });
18289
- }
18290
18270
  dispatch({
18291
18271
  type: LOADING,
18292
18272
  payload: false
@@ -18297,53 +18277,52 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18297
18277
  type: SHOW_ALERT,
18298
18278
  payload: {
18299
18279
  type: "error",
18300
- content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
18280
+ content: getErrorMessages(res.error)
18301
18281
  }
18302
18282
  });
18303
18283
  }
18304
18284
  onSuccess(res);
18305
18285
  });
18306
- } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18307
- if (!isSubCreate) {
18286
+ }
18287
+ }
18288
+ };
18289
+
18290
+ /**
18291
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
18292
+ * Only trigger method if PaymentIntent status is `requires_action`.
18293
+ *
18294
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
18295
+ *
18296
+ * @param response
18297
+ * @param error
18298
+ * @returns {*}
18299
+ */
18300
+ const confirmStripeIntentSetup = (response, error, stripeSource) => {
18301
+ var _response$data2;
18302
+ const setup_intent = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.setup_intent;
18303
+ if (setup_intent !== null && setup_intent !== void 0 && setup_intent.client_secret) {
18304
+ var _response$data3, _response$data3$sourc;
18305
+ stripe.confirmCardSetup(setup_intent.client_secret, {
18306
+ payment_method: (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : (_response$data3$sourc = _response$data3.source) === null || _response$data3$sourc === void 0 ? void 0 : _response$data3$sourc.object_id
18307
+ }).then(res => {
18308
+ var _response$data4;
18309
+ if (res.error) {
18308
18310
  dispatch({
18309
- type: DISABLE_SUBMIT,
18311
+ type: LOADING,
18310
18312
  payload: false
18311
18313
  });
18314
+ onFailure(res.error);
18315
+ return dispatch({
18316
+ type: SHOW_ALERT,
18317
+ payload: {
18318
+ type: "error",
18319
+ content: getErrorMessages(res.error)
18320
+ }
18321
+ });
18312
18322
  }
18313
- dispatch({
18314
- type: LOADING,
18315
- payload: false
18316
- });
18317
- onFailure(error);
18318
- return dispatch({
18319
- type: SHOW_ALERT,
18320
- payload: {
18321
- type: "error",
18322
- content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
18323
- }
18324
- });
18325
- } else {
18326
- onSuccess(response);
18327
- }
18328
- } else {
18329
- dispatch({
18330
- type: DISABLE_SUBMIT,
18331
- payload: false
18323
+ return handlePayment(response === null || response === void 0 ? void 0 : (_response$data4 = response.data) === null || _response$data4 === void 0 ? void 0 : _response$data4.source);
18332
18324
  });
18333
- dispatch({
18334
- type: LOADING,
18335
- payload: false
18336
- });
18337
- if (error) {
18338
- onFailure(error);
18339
- return dispatch({
18340
- type: SHOW_ALERT,
18341
- payload: {
18342
- type: "error",
18343
- content: getErrorMessages(error)
18344
- }
18345
- });
18346
- }
18325
+ } else {
18347
18326
  onSuccess(response);
18348
18327
  }
18349
18328
  };
@@ -18353,8 +18332,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18353
18332
  } = state;
18354
18333
  if (!subscriptionIdToRenew) {
18355
18334
  window.Pelcro.subscription.create({
18356
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18357
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18335
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18358
18336
  auth_token: window.Pelcro.user.read().auth_token,
18359
18337
  plan_id: plan.id,
18360
18338
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -18367,20 +18345,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18367
18345
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
18368
18346
  address_id: product.address_required ? selectedAddressId : null
18369
18347
  }, (err, res) => {
18370
- confirmStripeCardPayment(res, err, true);
18371
- });
18372
- } else {
18373
- if (isRenewingGift) {
18374
- window.Pelcro.subscription.renewGift({
18375
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18376
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18377
- auth_token: window.Pelcro.user.read().auth_token,
18378
- plan_id: plan.id,
18379
- quantity: plan.quantity,
18380
- coupon_code: couponCode,
18381
- subscription_id: subscriptionIdToRenew,
18382
- address_id: product.address_required ? selectedAddressId : null
18383
- }, (err, res) => {
18348
+ var _res$data, _res$data$payment_int;
18349
+ if ((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$payment_int = _res$data.payment_intent) === null || _res$data$payment_int === void 0 ? void 0 : _res$data$payment_int.status) === "requires_action") {
18350
+ confirmStripePaymentIntent(res);
18351
+ } else {
18384
18352
  dispatch({
18385
18353
  type: DISABLE_SUBMIT,
18386
18354
  payload: false
@@ -18399,12 +18367,48 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18399
18367
  }
18400
18368
  });
18401
18369
  }
18402
- onGiftRenewalSuccess(res);
18370
+ onSuccess(res);
18371
+ }
18372
+ });
18373
+ } else {
18374
+ if (isRenewingGift) {
18375
+ window.Pelcro.subscription.renewGift({
18376
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18377
+ auth_token: window.Pelcro.user.read().auth_token,
18378
+ plan_id: plan.id,
18379
+ quantity: plan.quantity,
18380
+ coupon_code: couponCode,
18381
+ subscription_id: subscriptionIdToRenew,
18382
+ address_id: product.address_required ? selectedAddressId : null
18383
+ }, (err, res) => {
18384
+ var _res$data2, _res$data2$payment_in;
18385
+ if ((res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$payment_in = _res$data2.payment_intent) === null || _res$data2$payment_in === void 0 ? void 0 : _res$data2$payment_in.status) === "requires_action") {
18386
+ confirmStripePaymentIntent(res);
18387
+ } else {
18388
+ dispatch({
18389
+ type: DISABLE_SUBMIT,
18390
+ payload: false
18391
+ });
18392
+ dispatch({
18393
+ type: LOADING,
18394
+ payload: false
18395
+ });
18396
+ if (err) {
18397
+ onFailure(err);
18398
+ return dispatch({
18399
+ type: SHOW_ALERT,
18400
+ payload: {
18401
+ type: "error",
18402
+ content: getErrorMessages(err)
18403
+ }
18404
+ });
18405
+ }
18406
+ onGiftRenewalSuccess(res);
18407
+ }
18403
18408
  });
18404
18409
  } else {
18405
18410
  window.Pelcro.subscription.renew({
18406
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18407
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18411
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18408
18412
  auth_token: window.Pelcro.user.read().auth_token,
18409
18413
  plan_id: plan.id,
18410
18414
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -18412,25 +18416,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18412
18416
  subscription_id: subscriptionIdToRenew,
18413
18417
  address_id: product.address_required ? selectedAddressId : null
18414
18418
  }, (err, res) => {
18415
- dispatch({
18416
- type: DISABLE_SUBMIT,
18417
- payload: false
18418
- });
18419
- dispatch({
18420
- type: LOADING,
18421
- payload: false
18422
- });
18423
- if (err) {
18424
- onFailure(err);
18425
- return dispatch({
18426
- type: SHOW_ALERT,
18427
- payload: {
18428
- type: "error",
18429
- content: getErrorMessages(err)
18430
- }
18419
+ var _res$data3, _res$data3$payment_in;
18420
+ if ((res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$payment_in = _res$data3.payment_intent) === null || _res$data3$payment_in === void 0 ? void 0 : _res$data3$payment_in.status) === "requires_action") {
18421
+ confirmStripePaymentIntent(res);
18422
+ } else {
18423
+ dispatch({
18424
+ type: DISABLE_SUBMIT,
18425
+ payload: false
18426
+ });
18427
+ dispatch({
18428
+ type: LOADING,
18429
+ payload: false
18431
18430
  });
18431
+ if (err) {
18432
+ onFailure(err);
18433
+ return dispatch({
18434
+ type: SHOW_ALERT,
18435
+ payload: {
18436
+ type: "error",
18437
+ content: getErrorMessages(err)
18438
+ }
18439
+ });
18440
+ }
18441
+ onSuccess(res);
18432
18442
  }
18433
- onSuccess(res);
18434
18443
  });
18435
18444
  }
18436
18445
  }
@@ -18517,7 +18526,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18517
18526
  onSuccess(res);
18518
18527
  });
18519
18528
  };
18520
- const purchase = (gatewayService, gatewayToken, state, dispatch) => {
18529
+ const purchase = (gatewayService, backendSource, state, dispatch) => {
18521
18530
  const isQuickPurchase = !Array.isArray(order);
18522
18531
  const mappedOrderItems = isQuickPurchase ? [{
18523
18532
  sku_id: order.id,
@@ -18532,45 +18541,85 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18532
18541
  const payment = new Payment(gatewayService);
18533
18542
  payment.execute({
18534
18543
  type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
18535
- token: gatewayToken,
18536
- isExistingSource: Boolean(selectedPaymentMethodId),
18544
+ token: backendSource,
18545
+ isExistingSource: true,
18537
18546
  items: mappedOrderItems,
18538
18547
  addressId: selectedAddressId,
18539
18548
  couponCode
18540
18549
  }, (err, orderResponse) => {
18541
- var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
18542
- if (err) {
18543
- toggleAuthenticationSuccessPendingView(false);
18544
- dispatch({
18545
- type: DISABLE_SUBMIT,
18546
- payload: false
18547
- });
18548
- dispatch({
18549
- type: LOADING,
18550
- payload: false
18551
- });
18552
- onFailure(err);
18553
- return dispatch({
18554
- type: SHOW_ALERT,
18555
- payload: {
18556
- type: "error",
18557
- content: getErrorMessages(err)
18550
+ var _res, _res$data4, _res$data4$payment_in;
18551
+ if (((_res = res) === null || _res === void 0 ? void 0 : (_res$data4 = _res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$payment_in = _res$data4.payment_intent) === null || _res$data4$payment_in === void 0 ? void 0 : _res$data4$payment_in.status) === "requires_action") {
18552
+ confirmStripePaymentIntent(res);
18553
+ } else {
18554
+ var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
18555
+ if (err) {
18556
+ toggleAuthenticationSuccessPendingView(false);
18557
+ dispatch({
18558
+ type: DISABLE_SUBMIT,
18559
+ payload: false
18560
+ });
18561
+ dispatch({
18562
+ type: LOADING,
18563
+ payload: false
18564
+ });
18565
+ onFailure(err);
18566
+ return dispatch({
18567
+ type: SHOW_ALERT,
18568
+ payload: {
18569
+ type: "error",
18570
+ content: getErrorMessages(err)
18571
+ }
18572
+ });
18573
+ }
18574
+ if (isQuickPurchase) {
18575
+ set({
18576
+ order: null
18577
+ });
18578
+ } else {
18579
+ set({
18580
+ order: null,
18581
+ cartItems: []
18582
+ });
18583
+ }
18584
+ window.Pelcro.user.refresh({
18585
+ auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
18586
+ }, (err, res) => {
18587
+ dispatch({
18588
+ type: DISABLE_SUBMIT,
18589
+ payload: false
18590
+ });
18591
+ dispatch({
18592
+ type: LOADING,
18593
+ payload: false
18594
+ });
18595
+ toggleAuthenticationSuccessPendingView(false);
18596
+ if (err) {
18597
+ onFailure(err);
18598
+ return dispatch({
18599
+ type: SHOW_ALERT,
18600
+ payload: {
18601
+ type: "error",
18602
+ content: getErrorMessages(err)
18603
+ }
18604
+ });
18558
18605
  }
18606
+ onSuccess(orderResponse);
18559
18607
  });
18560
18608
  }
18561
- if (isQuickPurchase) {
18562
- set({
18563
- order: null
18564
- });
18609
+ });
18610
+ };
18611
+ const payInvoice = (gatewayService, backendSource, dispatch) => {
18612
+ const payment = new Payment(gatewayService);
18613
+ return payment.execute({
18614
+ type: PAYMENT_TYPES.PAY_INVOICE,
18615
+ token: backendSource,
18616
+ isExistingSource: true,
18617
+ invoiceId: invoice.id
18618
+ }, (err, res) => {
18619
+ var _res$data5, _res$data5$payment_in;
18620
+ if ((res === null || res === void 0 ? void 0 : (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$payment_in = _res$data5.payment_intent) === null || _res$data5$payment_in === void 0 ? void 0 : _res$data5$payment_in.status) === "requires_action") {
18621
+ confirmStripePaymentIntent(res);
18565
18622
  } else {
18566
- set({
18567
- order: null,
18568
- cartItems: []
18569
- });
18570
- }
18571
- window.Pelcro.user.refresh({
18572
- auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
18573
- }, (err, res) => {
18574
18623
  dispatch({
18575
18624
  type: DISABLE_SUBMIT,
18576
18625
  payload: false
@@ -18579,7 +18628,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18579
18628
  type: LOADING,
18580
18629
  payload: false
18581
18630
  });
18582
- toggleAuthenticationSuccessPendingView(false);
18583
18631
  if (err) {
18584
18632
  onFailure(err);
18585
18633
  return dispatch({
@@ -18590,21 +18638,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18590
18638
  }
18591
18639
  });
18592
18640
  }
18593
- onSuccess(orderResponse);
18594
- });
18595
- });
18596
- };
18597
- const payInvoice = (gatewayService, gatewayToken, dispatch) => {
18598
- const payment = new Payment(gatewayService);
18599
- return payment.execute({
18600
- type: PAYMENT_TYPES.PAY_INVOICE,
18601
- token: gatewayToken,
18602
- isExistingSource: Boolean(selectedPaymentMethodId),
18603
- invoiceId: invoice.id
18604
- }, (err, res) => {
18605
- confirmStripeCardPayment(res, err);
18641
+ onSuccess(res);
18642
+ }
18606
18643
  });
18607
18644
  };
18645
+ console.log("trigger release");
18608
18646
  const updatePaymentSource = (state, dispatch) => {
18609
18647
  return stripe.createSource({
18610
18648
  type: "card"
@@ -18719,7 +18757,36 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18719
18757
  }, 0);
18720
18758
  };
18721
18759
  (_ref10 = (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref10 !== void 0 ? _ref10 : getOrderItemsTotal();
18722
- return handlePayment(source);
18760
+ return resolveTaxCalculation().then(res => window.Pelcro.source.create({
18761
+ auth_token: window.Pelcro.user.read().auth_token,
18762
+ token: source.id
18763
+ }, (err, res) => {
18764
+ var _res$data6, _res$data6$setup_inte;
18765
+ if (((_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : (_res$data6$setup_inte = _res$data6.setup_intent) === null || _res$data6$setup_inte === void 0 ? void 0 : _res$data6$setup_inte.status) === "requires_action") {
18766
+ confirmStripeIntentSetup(res);
18767
+ } else {
18768
+ var _res$data7;
18769
+ if (err) {
18770
+ onFailure(err);
18771
+ dispatch({
18772
+ type: DISABLE_SUBMIT,
18773
+ payload: false
18774
+ });
18775
+ dispatch({
18776
+ type: LOADING,
18777
+ payload: false
18778
+ });
18779
+ return dispatch({
18780
+ type: SHOW_ALERT,
18781
+ payload: {
18782
+ type: "error",
18783
+ content: getErrorMessages(err)
18784
+ }
18785
+ });
18786
+ }
18787
+ return handlePayment((_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.source);
18788
+ }
18789
+ }));
18723
18790
  }).catch(error => {
18724
18791
  return handlePaymentError(error);
18725
18792
  });
@@ -18747,12 +18814,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18747
18814
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
18748
18815
  address_id: selectedAddressId
18749
18816
  }, (error, res) => {
18750
- var _res$data, _res$data2;
18817
+ var _res$data8, _res$data9;
18751
18818
  if (error) {
18752
18819
  return reject(error);
18753
18820
  }
18754
- const taxAmount = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.taxes;
18755
- const totalAmountWithTax = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.total;
18821
+ const taxAmount = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.taxes;
18822
+ const totalAmountWithTax = (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.total;
18756
18823
  resolve({
18757
18824
  totalAmountWithTax,
18758
18825
  taxAmount
@@ -18796,13 +18863,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18796
18863
  }
18797
18864
  });
18798
18865
  };
18799
- const handlePayment = stripeSource => {
18800
- if (stripeSource && type === "createPayment") {
18801
- subscribe(stripeSource, state, dispatch);
18802
- } else if (stripeSource && type === "orderCreate") {
18803
- purchase(new StripeGateway(), stripeSource.id, state, dispatch);
18804
- } else if (stripeSource && type === "invoicePayment") {
18805
- payInvoice(new StripeGateway(), stripeSource.id);
18866
+ const handlePayment = backendSource => {
18867
+ if (backendSource && type === "createPayment") {
18868
+ subscribe(backendSource, state, dispatch);
18869
+ } else if (backendSource && type === "orderCreate") {
18870
+ purchase(new StripeGateway(), backendSource.id, state, dispatch);
18871
+ } else if (backendSource && type === "invoicePayment") {
18872
+ payInvoice(new StripeGateway(), backendSource.id, dispatch);
18806
18873
  }
18807
18874
  };
18808
18875
  const handlePaymentError = error => {
@@ -18926,7 +18993,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18926
18993
  isLoading: true
18927
18994
  }, (state, dispatch) => {
18928
18995
  if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
18929
- return submitPayment(state);
18996
+ return submitPayment(state, dispatch);
18930
18997
  }
18931
18998
  if (getSiteCardProcessor() === "vantiv") {
18932
18999
  return submitUsingVantiv(state);
@@ -18947,12 +19014,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18947
19014
  if (type === "updatePaymentSource") {
18948
19015
  return updatePaymentSource(state, dispatch);
18949
19016
  }
18950
- submitPayment(state);
19017
+ submitPayment(state, dispatch);
18951
19018
  });
18952
19019
  case HANDLE_PAYPAL_SUBSCRIPTION:
18953
19020
  return lib_5(state, (state, dispatch) => {
18954
19021
  if (type === "invoicePayment") {
18955
- payInvoice(new PaypalGateway(), action.payload);
19022
+ payInvoice(new PaypalGateway(), action.payload, dispatch);
18956
19023
  } else {
18957
19024
  handlePaypalSubscription(state, action.payload);
18958
19025
  }
package/dist/index.esm.js CHANGED
@@ -14621,7 +14621,6 @@ class SelectModal extends Component {
14621
14621
  });
14622
14622
  });
14623
14623
  });
14624
- console.log("bugsnag Triggered");
14625
14624
  }
14626
14625
  });
14627
14626
  _defineProperty$3(this, "componentWillUnmount", () => {
@@ -17186,7 +17185,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17186
17185
  };
17187
17186
  const submitUsingCybersource = (state, dispatch) => {
17188
17187
  var _cybersourceInstanceR;
17189
- console.log("State", state);
17190
17188
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
17191
17189
  if (isUsingExistingPaymentMethod) {
17192
17190
  // no need to create a new source using cybersrce
@@ -17227,7 +17225,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17227
17225
  } else if (type === "orderCreate") {
17228
17226
  purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17229
17227
  } else if (type === "invoicePayment") {
17230
- payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17228
+ payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17231
17229
  } else if (type === "updatePaymentSource") {
17232
17230
  createNewCybersourceCard();
17233
17231
  }
@@ -17549,7 +17547,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17549
17547
  } else if (type === "orderCreate") {
17550
17548
  purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17551
17549
  } else if (type === "invoicePayment") {
17552
- payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17550
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17553
17551
  } else if (type === "updatePaymentSource") {
17554
17552
  createNewTapCard();
17555
17553
  }
@@ -17760,7 +17758,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17760
17758
  } else if (type === "orderCreate") {
17761
17759
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
17762
17760
  } else if (type === "invoicePayment") {
17763
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
17761
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
17764
17762
  } else if (type === "updatePaymentSource") {
17765
17763
  createNewVantivCard();
17766
17764
  }
@@ -18233,30 +18231,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18233
18231
  updateTotalAmountWithTax();
18234
18232
  }
18235
18233
  };
18236
-
18237
- /**
18238
- * Attempt to confirm a Stripe card payment via it's PaymentIntent.
18239
- * Only trigger method if PaymentIntent status is `requires_action`.
18240
- *
18241
- * @see https://stripe.com/docs/payments/intents#intent-statuses
18242
- *
18243
- * @param response
18244
- * @param error
18245
- * @returns {*}
18246
- */
18247
- const confirmStripeCardPayment = function (response, error) {
18248
- let isSubCreate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
18234
+ const confirmStripePaymentIntent = (response, error) => {
18249
18235
  if (response) {
18250
18236
  var _response$data;
18251
18237
  const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
18252
- if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18238
+ if (paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18253
18239
  stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
18254
- if (!isSubCreate) {
18255
- dispatch({
18256
- type: DISABLE_SUBMIT,
18257
- payload: false
18258
- });
18259
- }
18260
18240
  dispatch({
18261
18241
  type: LOADING,
18262
18242
  payload: false
@@ -18267,53 +18247,52 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18267
18247
  type: SHOW_ALERT,
18268
18248
  payload: {
18269
18249
  type: "error",
18270
- content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
18250
+ content: getErrorMessages(res.error)
18271
18251
  }
18272
18252
  });
18273
18253
  }
18274
18254
  onSuccess(res);
18275
18255
  });
18276
- } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
18277
- if (!isSubCreate) {
18256
+ }
18257
+ }
18258
+ };
18259
+
18260
+ /**
18261
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
18262
+ * Only trigger method if PaymentIntent status is `requires_action`.
18263
+ *
18264
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
18265
+ *
18266
+ * @param response
18267
+ * @param error
18268
+ * @returns {*}
18269
+ */
18270
+ const confirmStripeIntentSetup = (response, error, stripeSource) => {
18271
+ var _response$data2;
18272
+ const setup_intent = (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.setup_intent;
18273
+ if (setup_intent !== null && setup_intent !== void 0 && setup_intent.client_secret) {
18274
+ var _response$data3, _response$data3$sourc;
18275
+ stripe.confirmCardSetup(setup_intent.client_secret, {
18276
+ payment_method: (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : (_response$data3$sourc = _response$data3.source) === null || _response$data3$sourc === void 0 ? void 0 : _response$data3$sourc.object_id
18277
+ }).then(res => {
18278
+ var _response$data4;
18279
+ if (res.error) {
18278
18280
  dispatch({
18279
- type: DISABLE_SUBMIT,
18281
+ type: LOADING,
18280
18282
  payload: false
18281
18283
  });
18284
+ onFailure(res.error);
18285
+ return dispatch({
18286
+ type: SHOW_ALERT,
18287
+ payload: {
18288
+ type: "error",
18289
+ content: getErrorMessages(res.error)
18290
+ }
18291
+ });
18282
18292
  }
18283
- dispatch({
18284
- type: LOADING,
18285
- payload: false
18286
- });
18287
- onFailure(error);
18288
- return dispatch({
18289
- type: SHOW_ALERT,
18290
- payload: {
18291
- type: "error",
18292
- content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
18293
- }
18294
- });
18295
- } else {
18296
- onSuccess(response);
18297
- }
18298
- } else {
18299
- dispatch({
18300
- type: DISABLE_SUBMIT,
18301
- payload: false
18293
+ return handlePayment(response === null || response === void 0 ? void 0 : (_response$data4 = response.data) === null || _response$data4 === void 0 ? void 0 : _response$data4.source);
18302
18294
  });
18303
- dispatch({
18304
- type: LOADING,
18305
- payload: false
18306
- });
18307
- if (error) {
18308
- onFailure(error);
18309
- return dispatch({
18310
- type: SHOW_ALERT,
18311
- payload: {
18312
- type: "error",
18313
- content: getErrorMessages(error)
18314
- }
18315
- });
18316
- }
18295
+ } else {
18317
18296
  onSuccess(response);
18318
18297
  }
18319
18298
  };
@@ -18323,8 +18302,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18323
18302
  } = state;
18324
18303
  if (!subscriptionIdToRenew) {
18325
18304
  window.Pelcro.subscription.create({
18326
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18327
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18305
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18328
18306
  auth_token: window.Pelcro.user.read().auth_token,
18329
18307
  plan_id: plan.id,
18330
18308
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -18337,20 +18315,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18337
18315
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
18338
18316
  address_id: product.address_required ? selectedAddressId : null
18339
18317
  }, (err, res) => {
18340
- confirmStripeCardPayment(res, err, true);
18341
- });
18342
- } else {
18343
- if (isRenewingGift) {
18344
- window.Pelcro.subscription.renewGift({
18345
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18346
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18347
- auth_token: window.Pelcro.user.read().auth_token,
18348
- plan_id: plan.id,
18349
- quantity: plan.quantity,
18350
- coupon_code: couponCode,
18351
- subscription_id: subscriptionIdToRenew,
18352
- address_id: product.address_required ? selectedAddressId : null
18353
- }, (err, res) => {
18318
+ var _res$data, _res$data$payment_int;
18319
+ if ((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$payment_int = _res$data.payment_intent) === null || _res$data$payment_int === void 0 ? void 0 : _res$data$payment_int.status) === "requires_action") {
18320
+ confirmStripePaymentIntent(res);
18321
+ } else {
18354
18322
  dispatch({
18355
18323
  type: DISABLE_SUBMIT,
18356
18324
  payload: false
@@ -18369,12 +18337,48 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18369
18337
  }
18370
18338
  });
18371
18339
  }
18372
- onGiftRenewalSuccess(res);
18340
+ onSuccess(res);
18341
+ }
18342
+ });
18343
+ } else {
18344
+ if (isRenewingGift) {
18345
+ window.Pelcro.subscription.renewGift({
18346
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18347
+ auth_token: window.Pelcro.user.read().auth_token,
18348
+ plan_id: plan.id,
18349
+ quantity: plan.quantity,
18350
+ coupon_code: couponCode,
18351
+ subscription_id: subscriptionIdToRenew,
18352
+ address_id: product.address_required ? selectedAddressId : null
18353
+ }, (err, res) => {
18354
+ var _res$data2, _res$data2$payment_in;
18355
+ if ((res === null || res === void 0 ? void 0 : (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$payment_in = _res$data2.payment_intent) === null || _res$data2$payment_in === void 0 ? void 0 : _res$data2$payment_in.status) === "requires_action") {
18356
+ confirmStripePaymentIntent(res);
18357
+ } else {
18358
+ dispatch({
18359
+ type: DISABLE_SUBMIT,
18360
+ payload: false
18361
+ });
18362
+ dispatch({
18363
+ type: LOADING,
18364
+ payload: false
18365
+ });
18366
+ if (err) {
18367
+ onFailure(err);
18368
+ return dispatch({
18369
+ type: SHOW_ALERT,
18370
+ payload: {
18371
+ type: "error",
18372
+ content: getErrorMessages(err)
18373
+ }
18374
+ });
18375
+ }
18376
+ onGiftRenewalSuccess(res);
18377
+ }
18373
18378
  });
18374
18379
  } else {
18375
18380
  window.Pelcro.subscription.renew({
18376
- source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18377
- stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
18381
+ source_id: (stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id) || undefined,
18378
18382
  auth_token: window.Pelcro.user.read().auth_token,
18379
18383
  plan_id: plan.id,
18380
18384
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -18382,25 +18386,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18382
18386
  subscription_id: subscriptionIdToRenew,
18383
18387
  address_id: product.address_required ? selectedAddressId : null
18384
18388
  }, (err, res) => {
18385
- dispatch({
18386
- type: DISABLE_SUBMIT,
18387
- payload: false
18388
- });
18389
- dispatch({
18390
- type: LOADING,
18391
- payload: false
18392
- });
18393
- if (err) {
18394
- onFailure(err);
18395
- return dispatch({
18396
- type: SHOW_ALERT,
18397
- payload: {
18398
- type: "error",
18399
- content: getErrorMessages(err)
18400
- }
18389
+ var _res$data3, _res$data3$payment_in;
18390
+ if ((res === null || res === void 0 ? void 0 : (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$payment_in = _res$data3.payment_intent) === null || _res$data3$payment_in === void 0 ? void 0 : _res$data3$payment_in.status) === "requires_action") {
18391
+ confirmStripePaymentIntent(res);
18392
+ } else {
18393
+ dispatch({
18394
+ type: DISABLE_SUBMIT,
18395
+ payload: false
18396
+ });
18397
+ dispatch({
18398
+ type: LOADING,
18399
+ payload: false
18401
18400
  });
18401
+ if (err) {
18402
+ onFailure(err);
18403
+ return dispatch({
18404
+ type: SHOW_ALERT,
18405
+ payload: {
18406
+ type: "error",
18407
+ content: getErrorMessages(err)
18408
+ }
18409
+ });
18410
+ }
18411
+ onSuccess(res);
18402
18412
  }
18403
- onSuccess(res);
18404
18413
  });
18405
18414
  }
18406
18415
  }
@@ -18487,7 +18496,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18487
18496
  onSuccess(res);
18488
18497
  });
18489
18498
  };
18490
- const purchase = (gatewayService, gatewayToken, state, dispatch) => {
18499
+ const purchase = (gatewayService, backendSource, state, dispatch) => {
18491
18500
  const isQuickPurchase = !Array.isArray(order);
18492
18501
  const mappedOrderItems = isQuickPurchase ? [{
18493
18502
  sku_id: order.id,
@@ -18502,45 +18511,85 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18502
18511
  const payment = new Payment(gatewayService);
18503
18512
  payment.execute({
18504
18513
  type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
18505
- token: gatewayToken,
18506
- isExistingSource: Boolean(selectedPaymentMethodId),
18514
+ token: backendSource,
18515
+ isExistingSource: true,
18507
18516
  items: mappedOrderItems,
18508
18517
  addressId: selectedAddressId,
18509
18518
  couponCode
18510
18519
  }, (err, orderResponse) => {
18511
- var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
18512
- if (err) {
18513
- toggleAuthenticationSuccessPendingView(false);
18514
- dispatch({
18515
- type: DISABLE_SUBMIT,
18516
- payload: false
18517
- });
18518
- dispatch({
18519
- type: LOADING,
18520
- payload: false
18521
- });
18522
- onFailure(err);
18523
- return dispatch({
18524
- type: SHOW_ALERT,
18525
- payload: {
18526
- type: "error",
18527
- content: getErrorMessages(err)
18520
+ var _res, _res$data4, _res$data4$payment_in;
18521
+ if (((_res = res) === null || _res === void 0 ? void 0 : (_res$data4 = _res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$payment_in = _res$data4.payment_intent) === null || _res$data4$payment_in === void 0 ? void 0 : _res$data4$payment_in.status) === "requires_action") {
18522
+ confirmStripePaymentIntent(res);
18523
+ } else {
18524
+ var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
18525
+ if (err) {
18526
+ toggleAuthenticationSuccessPendingView(false);
18527
+ dispatch({
18528
+ type: DISABLE_SUBMIT,
18529
+ payload: false
18530
+ });
18531
+ dispatch({
18532
+ type: LOADING,
18533
+ payload: false
18534
+ });
18535
+ onFailure(err);
18536
+ return dispatch({
18537
+ type: SHOW_ALERT,
18538
+ payload: {
18539
+ type: "error",
18540
+ content: getErrorMessages(err)
18541
+ }
18542
+ });
18543
+ }
18544
+ if (isQuickPurchase) {
18545
+ set({
18546
+ order: null
18547
+ });
18548
+ } else {
18549
+ set({
18550
+ order: null,
18551
+ cartItems: []
18552
+ });
18553
+ }
18554
+ window.Pelcro.user.refresh({
18555
+ auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
18556
+ }, (err, res) => {
18557
+ dispatch({
18558
+ type: DISABLE_SUBMIT,
18559
+ payload: false
18560
+ });
18561
+ dispatch({
18562
+ type: LOADING,
18563
+ payload: false
18564
+ });
18565
+ toggleAuthenticationSuccessPendingView(false);
18566
+ if (err) {
18567
+ onFailure(err);
18568
+ return dispatch({
18569
+ type: SHOW_ALERT,
18570
+ payload: {
18571
+ type: "error",
18572
+ content: getErrorMessages(err)
18573
+ }
18574
+ });
18528
18575
  }
18576
+ onSuccess(orderResponse);
18529
18577
  });
18530
18578
  }
18531
- if (isQuickPurchase) {
18532
- set({
18533
- order: null
18534
- });
18579
+ });
18580
+ };
18581
+ const payInvoice = (gatewayService, backendSource, dispatch) => {
18582
+ const payment = new Payment(gatewayService);
18583
+ return payment.execute({
18584
+ type: PAYMENT_TYPES.PAY_INVOICE,
18585
+ token: backendSource,
18586
+ isExistingSource: true,
18587
+ invoiceId: invoice.id
18588
+ }, (err, res) => {
18589
+ var _res$data5, _res$data5$payment_in;
18590
+ if ((res === null || res === void 0 ? void 0 : (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$payment_in = _res$data5.payment_intent) === null || _res$data5$payment_in === void 0 ? void 0 : _res$data5$payment_in.status) === "requires_action") {
18591
+ confirmStripePaymentIntent(res);
18535
18592
  } else {
18536
- set({
18537
- order: null,
18538
- cartItems: []
18539
- });
18540
- }
18541
- window.Pelcro.user.refresh({
18542
- auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
18543
- }, (err, res) => {
18544
18593
  dispatch({
18545
18594
  type: DISABLE_SUBMIT,
18546
18595
  payload: false
@@ -18549,7 +18598,6 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18549
18598
  type: LOADING,
18550
18599
  payload: false
18551
18600
  });
18552
- toggleAuthenticationSuccessPendingView(false);
18553
18601
  if (err) {
18554
18602
  onFailure(err);
18555
18603
  return dispatch({
@@ -18560,21 +18608,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18560
18608
  }
18561
18609
  });
18562
18610
  }
18563
- onSuccess(orderResponse);
18564
- });
18565
- });
18566
- };
18567
- const payInvoice = (gatewayService, gatewayToken, dispatch) => {
18568
- const payment = new Payment(gatewayService);
18569
- return payment.execute({
18570
- type: PAYMENT_TYPES.PAY_INVOICE,
18571
- token: gatewayToken,
18572
- isExistingSource: Boolean(selectedPaymentMethodId),
18573
- invoiceId: invoice.id
18574
- }, (err, res) => {
18575
- confirmStripeCardPayment(res, err);
18611
+ onSuccess(res);
18612
+ }
18576
18613
  });
18577
18614
  };
18615
+ console.log("trigger release");
18578
18616
  const updatePaymentSource = (state, dispatch) => {
18579
18617
  return stripe.createSource({
18580
18618
  type: "card"
@@ -18689,7 +18727,36 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18689
18727
  }, 0);
18690
18728
  };
18691
18729
  (_ref10 = (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref10 !== void 0 ? _ref10 : getOrderItemsTotal();
18692
- return handlePayment(source);
18730
+ return resolveTaxCalculation().then(res => window.Pelcro.source.create({
18731
+ auth_token: window.Pelcro.user.read().auth_token,
18732
+ token: source.id
18733
+ }, (err, res) => {
18734
+ var _res$data6, _res$data6$setup_inte;
18735
+ if (((_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : (_res$data6$setup_inte = _res$data6.setup_intent) === null || _res$data6$setup_inte === void 0 ? void 0 : _res$data6$setup_inte.status) === "requires_action") {
18736
+ confirmStripeIntentSetup(res);
18737
+ } else {
18738
+ var _res$data7;
18739
+ if (err) {
18740
+ onFailure(err);
18741
+ dispatch({
18742
+ type: DISABLE_SUBMIT,
18743
+ payload: false
18744
+ });
18745
+ dispatch({
18746
+ type: LOADING,
18747
+ payload: false
18748
+ });
18749
+ return dispatch({
18750
+ type: SHOW_ALERT,
18751
+ payload: {
18752
+ type: "error",
18753
+ content: getErrorMessages(err)
18754
+ }
18755
+ });
18756
+ }
18757
+ return handlePayment((_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.source);
18758
+ }
18759
+ }));
18693
18760
  }).catch(error => {
18694
18761
  return handlePaymentError(error);
18695
18762
  });
@@ -18717,12 +18784,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18717
18784
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
18718
18785
  address_id: selectedAddressId
18719
18786
  }, (error, res) => {
18720
- var _res$data, _res$data2;
18787
+ var _res$data8, _res$data9;
18721
18788
  if (error) {
18722
18789
  return reject(error);
18723
18790
  }
18724
- const taxAmount = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.taxes;
18725
- const totalAmountWithTax = (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.total;
18791
+ const taxAmount = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.taxes;
18792
+ const totalAmountWithTax = (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.total;
18726
18793
  resolve({
18727
18794
  totalAmountWithTax,
18728
18795
  taxAmount
@@ -18766,13 +18833,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18766
18833
  }
18767
18834
  });
18768
18835
  };
18769
- const handlePayment = stripeSource => {
18770
- if (stripeSource && type === "createPayment") {
18771
- subscribe(stripeSource, state, dispatch);
18772
- } else if (stripeSource && type === "orderCreate") {
18773
- purchase(new StripeGateway(), stripeSource.id, state, dispatch);
18774
- } else if (stripeSource && type === "invoicePayment") {
18775
- payInvoice(new StripeGateway(), stripeSource.id);
18836
+ const handlePayment = backendSource => {
18837
+ if (backendSource && type === "createPayment") {
18838
+ subscribe(backendSource, state, dispatch);
18839
+ } else if (backendSource && type === "orderCreate") {
18840
+ purchase(new StripeGateway(), backendSource.id, state, dispatch);
18841
+ } else if (backendSource && type === "invoicePayment") {
18842
+ payInvoice(new StripeGateway(), backendSource.id, dispatch);
18776
18843
  }
18777
18844
  };
18778
18845
  const handlePaymentError = error => {
@@ -18896,7 +18963,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18896
18963
  isLoading: true
18897
18964
  }, (state, dispatch) => {
18898
18965
  if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
18899
- return submitPayment(state);
18966
+ return submitPayment(state, dispatch);
18900
18967
  }
18901
18968
  if (getSiteCardProcessor() === "vantiv") {
18902
18969
  return submitUsingVantiv(state);
@@ -18917,12 +18984,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18917
18984
  if (type === "updatePaymentSource") {
18918
18985
  return updatePaymentSource(state, dispatch);
18919
18986
  }
18920
- submitPayment(state);
18987
+ submitPayment(state, dispatch);
18921
18988
  });
18922
18989
  case HANDLE_PAYPAL_SUBSCRIPTION:
18923
18990
  return lib_5(state, (state, dispatch) => {
18924
18991
  if (type === "invoicePayment") {
18925
- payInvoice(new PaypalGateway(), action.payload);
18992
+ payInvoice(new PaypalGateway(), action.payload, dispatch);
18926
18993
  } else {
18927
18994
  handlePaypalSubscription(state, action.payload);
18928
18995
  }
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.26.0-sandbox.1",
4
+ "version": "3.26.0-sandbox.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",