@pelcro/react-pelcro-js 3.36.0 → 3.38.0

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
@@ -3363,12 +3363,19 @@ var paymentMethod_en = {
3363
3363
  select: select$6,
3364
3364
  "delete": {
3365
3365
  title: "Delete payment method",
3366
- subtitle: "This payment method could be associated with active subscriptions or serve as the default payment method. Please choose from the available options below for replacement.",
3366
+ subtitle: "Are you sure you want to delete the selected payment method?",
3367
+ details: "Payment method details",
3368
+ message: "This action is irreversible and will permanently remove the payment method from the system. Please ensure that there are no pending transactions or subscriptions associated with this payment method.",
3369
+ buttons: {
3370
+ "delete": "Delete payment method",
3371
+ back: "Go back"
3372
+ },
3367
3373
  options: {
3368
- select: "Select an existing payment method",
3374
+ select: "Select a payment method to be the default",
3369
3375
  add: "Add a new payment method"
3370
3376
  },
3371
- paymentMethodReplaced: "Payment Method Successfully Deleted and Replaced"
3377
+ paymentMethodReplaced: "Payment Method Successfully Deleted and Replaced",
3378
+ deletedSuccessfully: "Payment Method Successfully Deleted"
3372
3379
  },
3373
3380
  create: create$5
3374
3381
  };
@@ -9589,6 +9596,17 @@ const getPaymentCardIcon$1 = name => {
9589
9596
  }), /*#__PURE__*/React__default['default'].createElement("path", {
9590
9597
  fill: "#FFF",
9591
9598
  d: "M22.255 20l-2.113 4.683L18.039 20h-2.695v6.726L12.341 20h-2.274L7 26.981h1.815l.671-1.558h3.432l.682 1.558h3.465v-5.185l2.299 5.185h1.563l2.351-5.095v5.095H25V20H22.255zM10.135 23.915l1.026-2.44 1.066 2.44H10.135zM37.883 23.413L41 20.018h-2.217l-1.994 2.164L34.86 20H28v6.982h6.635l2.092-2.311L38.767 27h2.21L37.883 23.413zM33.728 25.516h-4.011v-1.381h3.838v-1.323h-3.838v-1.308l4.234.012 1.693 1.897L33.728 25.516z"
9599
+ })),
9600
+ amex: /*#__PURE__*/React__default['default'].createElement("svg", {
9601
+ className: "plc-w-16",
9602
+ xmlns: "http://www.w3.org/2000/svg",
9603
+ viewBox: "0 0 48 48"
9604
+ }, /*#__PURE__*/React__default['default'].createElement("path", {
9605
+ fill: "#1976D2",
9606
+ d: "M45,35c0,2.209-1.791,4-4,4H7c-2.209,0-4-1.791-4-4V13c0-2.209,1.791-4,4-4h34c2.209,0,4,1.791,4,4V35z"
9607
+ }), /*#__PURE__*/React__default['default'].createElement("path", {
9608
+ fill: "#FFF",
9609
+ d: "M22.255 20l-2.113 4.683L18.039 20h-2.695v6.726L12.341 20h-2.274L7 26.981h1.815l.671-1.558h3.432l.682 1.558h3.465v-5.185l2.299 5.185h1.563l2.351-5.095v5.095H25V20H22.255zM10.135 23.915l1.026-2.44 1.066 2.44H10.135zM37.883 23.413L41 20.018h-2.217l-1.994 2.164L34.86 20H28v6.982h6.635l2.092-2.311L38.767 27h2.21L37.883 23.413zM33.728 25.516h-4.011v-1.381h3.838v-1.323h-3.838v-1.308l4.234.012 1.693 1.897L33.728 25.516z"
9592
9610
  }))
9593
9611
  };
9594
9612
  return name ? icons[name.toLowerCase()] : /*#__PURE__*/React__default['default'].createElement("svg", {
@@ -9640,6 +9658,19 @@ function notifyBugsnag(callback, startOptions) {
9640
9658
  }
9641
9659
  callback();
9642
9660
  }
9661
+ const refreshUser = () => {
9662
+ var _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro6$user$;
9663
+ window.Pelcro.user.refresh({
9664
+ auth_token: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : (_window$Pelcro6$user$ = _window$Pelcro6$user.read()) === null || _window$Pelcro6$user$ === void 0 ? void 0 : _window$Pelcro6$user$.auth_token
9665
+ }, (err, res) => {
9666
+ if (err) {
9667
+ console.error(err);
9668
+ }
9669
+ if (res) {
9670
+ return res.data;
9671
+ }
9672
+ });
9673
+ };
9643
9674
 
9644
9675
  const resources = {
9645
9676
  en: {
@@ -11605,7 +11636,7 @@ const debounce = (func, waitTime) => {
11605
11636
  };
11606
11637
  };
11607
11638
  function getSiteCardProcessor() {
11608
- var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
11639
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4;
11609
11640
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
11610
11641
  return "vantiv";
11611
11642
  }
@@ -11615,6 +11646,9 @@ function getSiteCardProcessor() {
11615
11646
  if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
11616
11647
  return "cybersource";
11617
11648
  }
11649
+ if ((_window$Pelcro$site$r4 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r4 !== void 0 && _window$Pelcro$site$r4.braintree_gateway_settings) {
11650
+ return "braintree";
11651
+ }
11618
11652
  return "stripe";
11619
11653
  }
11620
11654
  function getFourDigitYear(lastTwoDigits) {
@@ -11717,6 +11751,7 @@ const loadPaymentSDKs = () => {
11717
11751
  } = usePelcro.getStore();
11718
11752
  const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11719
11753
  const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11754
+ const supportsBraintree = Boolean(window.Pelcro.site.read().braintree_gateway_settings);
11720
11755
  whenUserReady(() => {
11721
11756
  if (!window.Stripe && !supportsVantiv && !supportsTap) {
11722
11757
  pure_1(window.Pelcro.environment.stripe);
@@ -11726,9 +11761,15 @@ const loadPaymentSDKs = () => {
11726
11761
 
11727
11762
  // Load PayPal SDKs
11728
11763
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
11764
+ if (supportsPaypal || supportsBraintree) {
11765
+ window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/client.min.js", "braintree-sdk");
11766
+ }
11729
11767
  if (supportsPaypal) {
11730
- window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
11731
- window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
11768
+ window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
11769
+ }
11770
+ if (supportsBraintree) {
11771
+ window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/three-d-secure.min.js", "braintree-3D-secure-sdk");
11772
+ window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.99.0/js/hosted-fields.min.js", "braintree-hosted-fields-sdk");
11732
11773
  }
11733
11774
 
11734
11775
  // Load Vantiv SDKs
@@ -12610,8 +12651,8 @@ const SET_CANCEL_SUBSCRIPTION_REASON = "SET_CANCEL_SUBSCRIPTION_REASON";
12610
12651
  const SET_CANCEL_SUBSCRIPTION_OPTION = "SET_CANCEL_SUBSCRIPTION_OPTION";
12611
12652
  const HANDLE_CHECKBOX_CHANGE = "HANDLE_CHECKBOX_CHANGE";
12612
12653
  const SET_IS_DEFAULT_PAYMENT_METHOD = "SET_IS_DEFAULT_PAYMENT_METHOD";
12613
- const SET_DELETE_PAYMENT_METHOD_OPTION = "SET_DELETE_PAYMENT_METHOD_OPTION";
12614
12654
  const SET_PAYMENT_METHODS = "SET_PAYMENT_METHODS";
12655
+ const SHOW_PAYMENT_METHOD_SELECT = "SHOW_PAYMENT_METHOD_SELECT";
12615
12656
  const SET_SUBSCRIPTION_SUSPEND_DATE = "SET_SUBSCRIPTION_SUSPEND_DATE";
12616
12657
  const SET_EMAILS = "SET_EMAILS";
12617
12658
  const SET_EMAILS_ERROR = "SET_EMAILS_ERROR";
@@ -16364,7 +16405,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
16364
16405
  var _generateUserError = /*#__PURE__*/new WeakMap();
16365
16406
  class Payment {
16366
16407
  /**
16367
- * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
16408
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway|BraintreeGateway)} paymentGateway
16368
16409
  */
16369
16410
  constructor(paymentGateway) {
16370
16411
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -16383,7 +16424,7 @@ class Payment {
16383
16424
  _classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
16384
16425
  writable: true,
16385
16426
  value: gateway => {
16386
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
16427
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway || gateway instanceof BraintreeGateway);
16387
16428
  }
16388
16429
  });
16389
16430
  _classPrivateFieldInitSpec$1(this, _generateUserError, {
@@ -16438,7 +16479,8 @@ const PAYMENT_GATEWAYS_ENUM = {
16438
16479
  paypal: "braintree",
16439
16480
  vantiv: "vantiv",
16440
16481
  tap: "tap",
16441
- cybersource: "cybersource"
16482
+ cybersource: "cybersource",
16483
+ braintree: "braintree"
16442
16484
  };
16443
16485
 
16444
16486
  /**
@@ -17377,6 +17419,218 @@ class CybersourceGateway {
17377
17419
  });
17378
17420
  }
17379
17421
  }
17422
+ var _paymentGateway6 = /*#__PURE__*/new WeakMap();
17423
+ var _createSubscription6 = /*#__PURE__*/new WeakMap();
17424
+ var _renewSubscription5 = /*#__PURE__*/new WeakMap();
17425
+ var _createGiftedSubscription6 = /*#__PURE__*/new WeakMap();
17426
+ var _renewGiftedSubscription5 = /*#__PURE__*/new WeakMap();
17427
+ var _purchaseEcommerceOrder5 = /*#__PURE__*/new WeakMap();
17428
+ var _payInvoice6 = /*#__PURE__*/new WeakMap();
17429
+ class BraintreeGateway {
17430
+ constructor() {
17431
+ _classPrivateFieldInitSpec$1(this, _paymentGateway6, {
17432
+ writable: true,
17433
+ value: PAYMENT_GATEWAYS_ENUM["braintree"]
17434
+ });
17435
+ _defineProperty$3(this, "execute", (options, callback) => {
17436
+ const types = PAYMENT_TYPES;
17437
+ switch (options.type) {
17438
+ case types.CREATE_SUBSCRIPTION:
17439
+ return _classPrivateFieldGet(this, _createSubscription6).call(this, options, callback);
17440
+ case types.RENEW_SUBSCRIPTION:
17441
+ return _classPrivateFieldGet(this, _renewSubscription5).call(this, options, callback);
17442
+ case types.CREATE_GIFTED_SUBSCRIPTION:
17443
+ return _classPrivateFieldGet(this, _createGiftedSubscription6).call(this, options, callback);
17444
+ case types.RENEW_GIFTED_SUBSCRIPTION:
17445
+ return _classPrivateFieldGet(this, _renewGiftedSubscription5).call(this, options, callback);
17446
+ case types.PURCHASE_ECOMMERCE_ORDER:
17447
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder5).call(this, options, callback);
17448
+ case types.PAY_INVOICE:
17449
+ return _classPrivateFieldGet(this, _payInvoice6).call(this, options, callback);
17450
+ default:
17451
+ console.error("Unsupported payment method: braintree Gateway");
17452
+ }
17453
+ });
17454
+ _classPrivateFieldInitSpec$1(this, _createSubscription6, {
17455
+ writable: true,
17456
+ value: (options, callback) => {
17457
+ const {
17458
+ token,
17459
+ plan,
17460
+ couponCode,
17461
+ product,
17462
+ quantity = 1,
17463
+ addressId,
17464
+ isExistingSource
17465
+ } = options;
17466
+ const params = isExistingSource ? {
17467
+ source_id: token
17468
+ } : {
17469
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17470
+ gateway_token: token
17471
+ };
17472
+ window.Pelcro.subscription.create({
17473
+ quantity,
17474
+ auth_token: window.Pelcro.user.read().auth_token,
17475
+ plan_id: plan.id,
17476
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17477
+ coupon_code: couponCode,
17478
+ address_id: product.address_required ? addressId : null,
17479
+ ...params
17480
+ }, (err, res) => {
17481
+ callback(err, res);
17482
+ });
17483
+ }
17484
+ });
17485
+ _classPrivateFieldInitSpec$1(this, _renewSubscription5, {
17486
+ writable: true,
17487
+ value: (options, callback) => {
17488
+ const {
17489
+ subscriptionIdToRenew,
17490
+ token,
17491
+ plan,
17492
+ couponCode,
17493
+ product,
17494
+ addressId,
17495
+ isExistingSource
17496
+ } = options;
17497
+ const params = isExistingSource ? {
17498
+ source_id: token
17499
+ } : {
17500
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17501
+ gateway_token: token
17502
+ };
17503
+ window.Pelcro.subscription.renew({
17504
+ auth_token: window.Pelcro.user.read().auth_token,
17505
+ plan_id: plan.id,
17506
+ coupon_code: couponCode,
17507
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17508
+ subscription_id: subscriptionIdToRenew,
17509
+ address_id: product.address_required ? addressId : null,
17510
+ ...params
17511
+ }, (err, res) => {
17512
+ callback(err, res);
17513
+ });
17514
+ }
17515
+ });
17516
+ _classPrivateFieldInitSpec$1(this, _createGiftedSubscription6, {
17517
+ writable: true,
17518
+ value: (options, callback) => {
17519
+ const {
17520
+ token,
17521
+ plan,
17522
+ couponCode,
17523
+ product,
17524
+ giftRecipient,
17525
+ quantity = 1,
17526
+ addressId,
17527
+ isExistingSource
17528
+ } = options;
17529
+ const params = isExistingSource ? {
17530
+ source_id: token
17531
+ } : {
17532
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17533
+ gateway_token: token
17534
+ };
17535
+ window.Pelcro.subscription.create({
17536
+ quantity,
17537
+ auth_token: window.Pelcro.user.read().auth_token,
17538
+ plan_id: plan.id,
17539
+ coupon_code: couponCode,
17540
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17541
+ gift_recipient_email: giftRecipient.email,
17542
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
17543
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
17544
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
17545
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
17546
+ address_id: product.address_required ? addressId : null,
17547
+ ...params
17548
+ }, (err, res) => {
17549
+ callback(err, res);
17550
+ });
17551
+ }
17552
+ });
17553
+ _classPrivateFieldInitSpec$1(this, _renewGiftedSubscription5, {
17554
+ writable: true,
17555
+ value: (options, callback) => {
17556
+ const {
17557
+ subscriptionIdToRenew,
17558
+ token,
17559
+ product,
17560
+ plan,
17561
+ couponCode,
17562
+ addressId,
17563
+ isExistingSource
17564
+ } = options;
17565
+ const params = isExistingSource ? {
17566
+ source_id: token
17567
+ } : {
17568
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17569
+ gateway_token: token
17570
+ };
17571
+ window.Pelcro.subscription.renewGift({
17572
+ auth_token: window.Pelcro.user.read().auth_token,
17573
+ plan_id: plan.id,
17574
+ coupon_code: couponCode,
17575
+ subscription_id: subscriptionIdToRenew,
17576
+ address_id: product.address_required ? addressId : null,
17577
+ ...params
17578
+ }, (err, res) => {
17579
+ callback(err, res);
17580
+ });
17581
+ }
17582
+ });
17583
+ _classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder5, {
17584
+ writable: true,
17585
+ value: (options, callback) => {
17586
+ const {
17587
+ token,
17588
+ items,
17589
+ couponCode,
17590
+ addressId,
17591
+ isExistingSource
17592
+ } = options;
17593
+ const params = isExistingSource ? {
17594
+ source_id: token
17595
+ } : {
17596
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17597
+ gateway_token: token
17598
+ };
17599
+ window.Pelcro.ecommerce.order.create({
17600
+ items,
17601
+ coupon_code: couponCode,
17602
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17603
+ ...params,
17604
+ ...(addressId && {
17605
+ address_id: addressId
17606
+ })
17607
+ }, (err, res) => {
17608
+ callback(err, res);
17609
+ });
17610
+ }
17611
+ });
17612
+ _classPrivateFieldInitSpec$1(this, _payInvoice6, {
17613
+ writable: true,
17614
+ value: (options, callback) => {
17615
+ const {
17616
+ token,
17617
+ invoiceId
17618
+ } = options;
17619
+ const params = options.isExistingSource ? {
17620
+ source_id: token,
17621
+ invoice_id: invoiceId
17622
+ } : {
17623
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway6),
17624
+ gateway_token: token,
17625
+ invoice_id: invoiceId
17626
+ };
17627
+ window.Pelcro.invoice.pay(params, (err, res) => {
17628
+ callback(err, res);
17629
+ });
17630
+ }
17631
+ });
17632
+ }
17633
+ }
17380
17634
 
17381
17635
  /**
17382
17636
  * @typedef {Object} PaymentStateType
@@ -17400,6 +17654,7 @@ class CybersourceGateway {
17400
17654
  const initialState$l = {
17401
17655
  disableSubmit: false,
17402
17656
  isLoading: false,
17657
+ isSkeletonLoaded: false,
17403
17658
  disableCouponButton: false,
17404
17659
  couponObject: null,
17405
17660
  couponCode: "",
@@ -18046,52 +18301,620 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18046
18301
  };
18047
18302
  /* ====== End Tap integration ======== */
18048
18303
 
18049
- const submitUsingVantiv = state => {
18050
- const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18051
- if (isUsingExistingPaymentMethod) {
18052
- // no need to create a new source using vantiv
18053
- return handleVantivPayment(null, state.couponCode);
18054
- }
18055
- if (!vantivInstanceRef.current) {
18056
- return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
18057
- }
18058
- const orderId = `pelcro-${new Date().getTime()}`;
18059
- /*
18060
- calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
18061
- */
18062
- vantivInstanceRef.current.getPaypageRegistrationId({
18063
- id: orderId,
18064
- orderId: orderId
18065
- });
18066
- };
18067
- function handleVantivPayment(paymentRequest, couponCode) {
18068
- if (paymentRequest) {
18069
- const SUCCESS_STATUS = "870";
18070
- if (paymentRequest.response !== SUCCESS_STATUS) {
18071
- switch (paymentRequest.response) {
18072
- case "871":
18073
- return handlePaymentError({
18074
- error: new Error("Invalid account number")
18075
- });
18076
- default:
18077
- return handlePaymentError({
18078
- error: new Error(paymentRequest.message)
18079
- });
18304
+ /* ====== Start Braintree integration ======== */
18305
+ const braintreeInstanceRef = React__default['default'].useRef(null);
18306
+ const braintree3DSecureInstanceRef = React__default['default'].useRef(null);
18307
+ function getClientToken() {
18308
+ return new Promise((resolve, reject) => {
18309
+ window.Pelcro.payment.generateClientToken({
18310
+ auth_token: window.Pelcro.user.read().auth_token,
18311
+ site_id: window.Pelcro.siteid
18312
+ }, (error, response) => {
18313
+ if (error) {
18314
+ reject(error);
18315
+ }
18316
+ if (response) {
18317
+ resolve(response.client_token);
18080
18318
  }
18319
+ });
18320
+ });
18321
+ }
18322
+ async function initializeBraintree() {
18323
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
18324
+ if (cardProcessor === "braintree" && !selectedPaymentMethodId) {
18325
+ const braintreeToken = await getClientToken();
18326
+ const isBraintreeEnabled = Boolean(braintreeToken);
18327
+ if (!isBraintreeEnabled) {
18328
+ console.error("Braintree integration is currently not enabled on this site's config");
18329
+ return;
18081
18330
  }
18082
- }
18083
- const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18084
- if (type === "createPayment") {
18085
- handleVantivSubscription();
18086
- } else if (type === "orderCreate") {
18087
- purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
18088
- } else if (type === "invoicePayment") {
18089
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
18090
- } else if (type === "createPaymentSource") {
18091
- createNewVantivCard();
18092
- } else if (type === "updatePaymentSource") {
18093
- updateVantivCard();
18094
- } else if (type === "deletePaymentSource") {
18331
+ if (type !== "updatePaymentSource") {
18332
+ braintreeInstanceRef.current = new window.braintree.client.create({
18333
+ authorization: braintreeToken
18334
+ }).then(clientInstance => {
18335
+ const options = {
18336
+ authorization: braintreeToken,
18337
+ styles: {
18338
+ input: {
18339
+ "font-size": "14px"
18340
+ },
18341
+ "input.invalid": {
18342
+ color: "red"
18343
+ },
18344
+ "input.valid": {
18345
+ color: "green"
18346
+ }
18347
+ },
18348
+ fields: {
18349
+ number: {
18350
+ container: "#card-number",
18351
+ placeholder: "4111 1111 1111 1111"
18352
+ },
18353
+ cvv: {
18354
+ container: "#cvv",
18355
+ placeholder: "123"
18356
+ },
18357
+ expirationDate: {
18358
+ container: "#expiration-date",
18359
+ placeholder: "10/2022"
18360
+ }
18361
+ }
18362
+ };
18363
+ dispatch({
18364
+ type: SKELETON_LOADER,
18365
+ payload: true
18366
+ });
18367
+ braintree3DSecureInstanceRef.current = new window.braintree.threeDSecure.create({
18368
+ version: 2,
18369
+ authorization: braintreeToken
18370
+ }).then(threeDSecureInstance => {
18371
+ return threeDSecureInstance;
18372
+ });
18373
+ return window.braintree.hostedFields.create(options);
18374
+ });
18375
+ braintreeInstanceRef.current.then(hostedFieldInstance => {
18376
+ hostedFieldInstance.on("notEmpty", function (event) {
18377
+ const field = event.fields[event.emittedBy];
18378
+ if (field.isPotentiallyValid) {
18379
+ field.container.classList.remove("pelcro-input-invalid");
18380
+ }
18381
+ });
18382
+ hostedFieldInstance.on("validityChange", function (event) {
18383
+ const field = event.fields[event.emittedBy];
18384
+
18385
+ // Remove any previously applied error or warning classes
18386
+ field.container.classList.remove("is-valid");
18387
+ field.container.classList.remove("pelcro-input-invalid");
18388
+ if (field.isValid) {
18389
+ field.container.classList.add("is-valid");
18390
+ } else if (field.isPotentiallyValid) ; else {
18391
+ field.container.classList.add("pelcro-input-invalid");
18392
+ }
18393
+ });
18394
+ });
18395
+ } else if (type == "updatePaymentSource" && paymentMethodToEdit) {
18396
+ const {
18397
+ properties
18398
+ } = paymentMethodToEdit !== null && paymentMethodToEdit !== void 0 ? paymentMethodToEdit : {};
18399
+ const {
18400
+ exp_month: expMonth,
18401
+ exp_year: expYear
18402
+ } = properties !== null && properties !== void 0 ? properties : {};
18403
+ braintreeInstanceRef.current = new window.braintree.client.create({
18404
+ authorization: braintreeToken
18405
+ }).then(clientInstance => {
18406
+ const options = {
18407
+ client: clientInstance,
18408
+ styles: {
18409
+ input: {
18410
+ "font-size": "14px"
18411
+ },
18412
+ "input.invalid": {
18413
+ color: "red"
18414
+ },
18415
+ "input.valid": {
18416
+ color: "green"
18417
+ }
18418
+ },
18419
+ fields: {
18420
+ expirationMonth: {
18421
+ container: "#expiration-month",
18422
+ prefill: expMonth
18423
+ },
18424
+ expirationYear: {
18425
+ container: "#expiration-year",
18426
+ prefill: expYear
18427
+ }
18428
+ }
18429
+ };
18430
+ dispatch({
18431
+ type: SKELETON_LOADER,
18432
+ payload: true
18433
+ });
18434
+ return window.braintree.hostedFields.create(options);
18435
+ });
18436
+ braintreeInstanceRef.current.then(hostedFieldInstance => {
18437
+ hostedFieldInstance.on("notEmpty", function (event) {
18438
+ const field = event.fields[event.emittedBy];
18439
+ if (field.isPotentiallyValid) {
18440
+ field.container.classList.remove("pelcro-input-invalid");
18441
+ }
18442
+ });
18443
+ hostedFieldInstance.on("validityChange", function (event) {
18444
+ const field = event.fields[event.emittedBy];
18445
+
18446
+ // Remove any previously applied error or warning classes
18447
+ field.container.classList.remove("is-valid");
18448
+ field.container.classList.remove("pelcro-input-invalid");
18449
+ if (field.isValid) {
18450
+ field.container.classList.add("is-valid");
18451
+ } else if (field.isPotentiallyValid) ; else {
18452
+ field.container.classList.add("pelcro-input-invalid");
18453
+ }
18454
+ });
18455
+ });
18456
+ }
18457
+ }
18458
+ }
18459
+ React.useEffect(() => {
18460
+ initializeBraintree();
18461
+ }, [selectedPaymentMethodId, paymentMethodToEdit]);
18462
+ const braintreeErrorHandler = tokenizeErr => {
18463
+ var _tokenizeErr$details, _tokenizeErr$details2;
18464
+ const cardNumber = document.querySelector("#card-number");
18465
+ const expirationDate = document.querySelector("#expiration-date");
18466
+ const cvv = document.querySelector("#cvv");
18467
+ const fields = tokenizeErr !== null && tokenizeErr !== void 0 && (_tokenizeErr$details = tokenizeErr.details) !== null && _tokenizeErr$details !== void 0 && _tokenizeErr$details.invalidFields ? Object.values(tokenizeErr === null || tokenizeErr === void 0 ? void 0 : (_tokenizeErr$details2 = tokenizeErr.details) === null || _tokenizeErr$details2 === void 0 ? void 0 : _tokenizeErr$details2.invalidFields) : null;
18468
+ switch (tokenizeErr.code) {
18469
+ case "HOSTED_FIELDS_FIELDS_EMPTY":
18470
+ // occurs when none of the fields are filled in
18471
+ cardNumber.classList.add("pelcro-input-invalid");
18472
+ expirationDate.classList.add("pelcro-input-invalid");
18473
+ cvv.classList.add("pelcro-input-invalid");
18474
+ return "All fields are empty! Please fill out the form.";
18475
+ // break;
18476
+ case "HOSTED_FIELDS_FIELDS_INVALID":
18477
+ // occurs when certain fields do not pass client side validation
18478
+ console.error("Some fields are invalid:", tokenizeErr.details.invalidFieldKeys.toString());
18479
+
18480
+ // you can also programmatically access the field containers for the invalid fields
18481
+ // tokenizeErr.details.invalidFields.forEach(function (
18482
+ // fieldContainer
18483
+ // ) {
18484
+ // fieldContainer.className = "invalid";
18485
+ // });
18486
+ fields.forEach(field => {
18487
+ field.classList.add("pelcro-input-invalid");
18488
+ });
18489
+ return `Some fields are invalid: ${tokenizeErr.details.invalidFieldKeys.toString()}`;
18490
+ case "HOSTED_FIELDS_TOKENIZATION_FAIL_ON_DUPLICATE":
18491
+ // occurs when:
18492
+ // * the client token used for client authorization was generated
18493
+ // with a customer ID and the fail on duplicate payment method
18494
+ // option is set to true
18495
+ // * the card being tokenized has previously been vaulted (with any customer)
18496
+ // See: https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#options.fail_on_duplicate_payment_method
18497
+ return "This payment method already exists in your vault.";
18498
+ case "HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED":
18499
+ // occurs when:
18500
+ // * the client token used for client authorization was generated
18501
+ // with a customer ID and the verify card option is set to true
18502
+ // and you have credit card verification turned on in the Braintree
18503
+ // control panel
18504
+ // * the cvv does not pass verification (https://developer.paypal.com/braintree/docs/reference/general/testing#avs-and-cvv/cid-responses)
18505
+ // See: https://developer.paypal.com/braintree/docs/reference/request/client-token/generate#options.verify_card
18506
+ return "CVV did not pass verification";
18507
+ case "HOSTED_FIELDS_FAILED_TOKENIZATION":
18508
+ // occurs for any other tokenization error on the server
18509
+ return "Tokenization failed server side. Is the card valid?";
18510
+ case "HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR":
18511
+ // occurs when the Braintree gateway cannot be contacted
18512
+ return "Network error occurred when tokenizing.";
18513
+ default:
18514
+ console.error("Something bad happened!", tokenizeErr);
18515
+ return "Something bad happened!";
18516
+ }
18517
+ };
18518
+ const submitUsingBraintree = (state, dispatch) => {
18519
+ var _ref6, _ref7, _state$updatedPrice2;
18520
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18521
+ if (isUsingExistingPaymentMethod) {
18522
+ // no need to create a new source using braintree
18523
+ return handleBraintreePayment(null, state.couponCode);
18524
+ }
18525
+ if (!braintreeInstanceRef.current) {
18526
+ return console.error("Braintree sdk script wasn't loaded, you need to load braintree sdk before rendering the braintree payment flow");
18527
+ }
18528
+ const getOrderItemsTotal = () => {
18529
+ if (!order) {
18530
+ return null;
18531
+ }
18532
+ const isQuickPurchase = !Array.isArray(order);
18533
+ if (isQuickPurchase) {
18534
+ return order.price * order.quantity;
18535
+ }
18536
+ if (order.length === 0) {
18537
+ return null;
18538
+ }
18539
+ return order.reduce((total, item) => {
18540
+ return total + item.price * item.quantity;
18541
+ }, 0);
18542
+ };
18543
+ const totalAmount = (_ref6 = (_ref7 = (_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 && _ref7 !== void 0 ? _ref7 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref6 !== void 0 ? _ref6 : getOrderItemsTotal();
18544
+ braintreeInstanceRef.current.then(hostedFieldInstance => {
18545
+ hostedFieldInstance.tokenize((tokenizeErr, payload) => {
18546
+ if (tokenizeErr) {
18547
+ dispatch({
18548
+ type: DISABLE_SUBMIT,
18549
+ payload: false
18550
+ });
18551
+ dispatch({
18552
+ type: LOADING,
18553
+ payload: false
18554
+ });
18555
+ return dispatch({
18556
+ type: SHOW_ALERT,
18557
+ payload: {
18558
+ type: "error",
18559
+ content: braintreeErrorHandler(tokenizeErr)
18560
+ }
18561
+ });
18562
+ }
18563
+ if (type == "updatePaymentSource" || type == "deletePaymentSource") {
18564
+ handleBraintreePayment(payload, state.couponCode);
18565
+ } else {
18566
+ braintree3DSecureInstanceRef.current.then(threeDSecureInstance => {
18567
+ threeDSecureInstance.verifyCard({
18568
+ onLookupComplete: function (data, next) {
18569
+ next();
18570
+ },
18571
+ amount: totalAmount !== null && totalAmount !== void 0 ? totalAmount : "0.00",
18572
+ nonce: payload.nonce,
18573
+ bin: payload.details.bin
18574
+ }).then(payload => {
18575
+ if (payload.liabilityShifted) {
18576
+ handleBraintreePayment(payload, state.couponCode);
18577
+ } else if (payload.liabilityShiftPossible) {
18578
+ dispatch({
18579
+ type: DISABLE_SUBMIT,
18580
+ payload: false
18581
+ });
18582
+ dispatch({
18583
+ type: LOADING,
18584
+ payload: false
18585
+ });
18586
+ return dispatch({
18587
+ type: SHOW_ALERT,
18588
+ payload: {
18589
+ type: "error",
18590
+ content: "We encountered an issue verifying your transaction with 3D Secure, please try again."
18591
+ }
18592
+ });
18593
+ } else {
18594
+ // Liability has not shifted and will not shift
18595
+ dispatch({
18596
+ type: DISABLE_SUBMIT,
18597
+ payload: false
18598
+ });
18599
+ dispatch({
18600
+ type: LOADING,
18601
+ payload: false
18602
+ });
18603
+ return dispatch({
18604
+ type: SHOW_ALERT,
18605
+ payload: {
18606
+ type: "error",
18607
+ content: "We encountered an issue verifying your transaction with 3D Secure, please try another payment method."
18608
+ }
18609
+ });
18610
+ }
18611
+ }).catch(error => {
18612
+ console.error(error);
18613
+ dispatch({
18614
+ type: DISABLE_SUBMIT,
18615
+ payload: false
18616
+ });
18617
+ dispatch({
18618
+ type: LOADING,
18619
+ payload: false
18620
+ });
18621
+ return dispatch({
18622
+ type: SHOW_ALERT,
18623
+ payload: {
18624
+ type: "error",
18625
+ content: "There was a problem with your request."
18626
+ }
18627
+ });
18628
+ });
18629
+ });
18630
+ }
18631
+ });
18632
+ }).catch(error => {
18633
+ if (error) {
18634
+ console.error(error);
18635
+ return;
18636
+ }
18637
+ });
18638
+ };
18639
+ const handleBraintreePayment = (braintreePaymentRequest, couponCode) => {
18640
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18641
+ const braintreeNonce = braintreePaymentRequest === null || braintreePaymentRequest === void 0 ? void 0 : braintreePaymentRequest.nonce;
18642
+ if (type === "createPayment") {
18643
+ handleBraintreeSubscription();
18644
+ } else if (type === "orderCreate") {
18645
+ purchase(new BraintreeGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce, state, dispatch);
18646
+ } else if (type === "invoicePayment") {
18647
+ payInvoice(new BraintreeGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce);
18648
+ } else if (type === "createPaymentSource") {
18649
+ createNewBraintreeCard();
18650
+ } else if (type === "updatePaymentSource") {
18651
+ updateBraintreeCard();
18652
+ } else if (type === "deletePaymentSource") {
18653
+ replaceBraintreeCard();
18654
+ }
18655
+ function createNewBraintreeCard() {
18656
+ window.Pelcro.paymentMethods.create({
18657
+ auth_token: window.Pelcro.user.read().auth_token,
18658
+ token: braintreeNonce,
18659
+ gateway: "braintree"
18660
+ }, (err, res) => {
18661
+ dispatch({
18662
+ type: DISABLE_SUBMIT,
18663
+ payload: false
18664
+ });
18665
+ dispatch({
18666
+ type: LOADING,
18667
+ payload: false
18668
+ });
18669
+ if (err) {
18670
+ onFailure(err);
18671
+ return dispatch({
18672
+ type: SHOW_ALERT,
18673
+ payload: {
18674
+ type: "error",
18675
+ content: getErrorMessages(err)
18676
+ }
18677
+ });
18678
+ }
18679
+ dispatch({
18680
+ type: SHOW_ALERT,
18681
+ payload: {
18682
+ type: "success",
18683
+ content: t("messages.sourceCreated")
18684
+ }
18685
+ });
18686
+ onSuccess(res);
18687
+ });
18688
+ }
18689
+ function replaceBraintreeCard() {
18690
+ const {
18691
+ id: paymentMethodId
18692
+ } = paymentMethodToDelete;
18693
+ window.Pelcro.paymentMethods.create({
18694
+ auth_token: window.Pelcro.user.read().auth_token,
18695
+ token: braintreeNonce,
18696
+ gateway: "braintree"
18697
+ }, (err, res) => {
18698
+ if (err) {
18699
+ dispatch({
18700
+ type: DISABLE_SUBMIT,
18701
+ payload: false
18702
+ });
18703
+ dispatch({
18704
+ type: LOADING,
18705
+ payload: false
18706
+ });
18707
+ onFailure(err);
18708
+ return dispatch({
18709
+ type: SHOW_ALERT,
18710
+ payload: {
18711
+ type: "error",
18712
+ content: getErrorMessages(err)
18713
+ }
18714
+ });
18715
+ }
18716
+ if (res) {
18717
+ setTimeout(() => {
18718
+ window.Pelcro.paymentMethods.deletePaymentMethod({
18719
+ auth_token: window.Pelcro.user.read().auth_token,
18720
+ payment_method_id: paymentMethodId
18721
+ }, (err, res) => {
18722
+ dispatch({
18723
+ type: DISABLE_SUBMIT,
18724
+ payload: false
18725
+ });
18726
+ dispatch({
18727
+ type: LOADING,
18728
+ payload: false
18729
+ });
18730
+ if (err) {
18731
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
18732
+ return dispatch({
18733
+ type: SHOW_ALERT,
18734
+ payload: {
18735
+ type: "error",
18736
+ content: getErrorMessages(err)
18737
+ }
18738
+ });
18739
+ }
18740
+ onSuccess(res);
18741
+ });
18742
+ }, 2000);
18743
+ }
18744
+ });
18745
+ }
18746
+ function updateBraintreeCard() {
18747
+ const {
18748
+ id: paymentMethodId
18749
+ } = paymentMethodToEdit;
18750
+ const {
18751
+ expirationMonth,
18752
+ expirationYear
18753
+ } = braintreePaymentRequest === null || braintreePaymentRequest === void 0 ? void 0 : braintreePaymentRequest.details;
18754
+ const {
18755
+ isDefault
18756
+ } = state;
18757
+ window.Pelcro.paymentMethods.update({
18758
+ auth_token: window.Pelcro.user.read().auth_token,
18759
+ payment_method_id: paymentMethodId,
18760
+ token: braintreeNonce,
18761
+ gateway: "braintree",
18762
+ exp_month: expirationMonth,
18763
+ exp_year: expirationYear,
18764
+ is_default: isDefault
18765
+ }, (err, res) => {
18766
+ dispatch({
18767
+ type: DISABLE_SUBMIT,
18768
+ payload: false
18769
+ });
18770
+ dispatch({
18771
+ type: LOADING,
18772
+ payload: false
18773
+ });
18774
+ if (err) {
18775
+ onFailure(err);
18776
+ return dispatch({
18777
+ type: SHOW_ALERT,
18778
+ payload: {
18779
+ type: "error",
18780
+ content: getErrorMessages(err)
18781
+ }
18782
+ });
18783
+ }
18784
+ dispatch({
18785
+ type: SHOW_ALERT,
18786
+ payload: {
18787
+ type: "success",
18788
+ content: t("messages.sourceUpdated")
18789
+ }
18790
+ });
18791
+ onSuccess(res);
18792
+ });
18793
+ }
18794
+ function handleBraintreeSubscription() {
18795
+ const payment = new Payment(new BraintreeGateway());
18796
+ const createSubscription = !isGift && !subscriptionIdToRenew;
18797
+ const renewSubscription = !isGift && subscriptionIdToRenew;
18798
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
18799
+ const renewGift = isRenewingGift;
18800
+ if (renewGift) {
18801
+ return payment.execute({
18802
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
18803
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
18804
+ plan,
18805
+ couponCode,
18806
+ product,
18807
+ isExistingSource: isUsingExistingPaymentMethod,
18808
+ subscriptionIdToRenew,
18809
+ addressId: selectedAddressId
18810
+ }, (err, res) => {
18811
+ if (err) {
18812
+ return handlePaymentError(err);
18813
+ }
18814
+ onSuccess(res);
18815
+ });
18816
+ } else if (giftSubscriprition) {
18817
+ return payment.execute({
18818
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
18819
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
18820
+ quantity: plan.quantity,
18821
+ plan,
18822
+ couponCode,
18823
+ product,
18824
+ isExistingSource: isUsingExistingPaymentMethod,
18825
+ giftRecipient,
18826
+ addressId: selectedAddressId
18827
+ }, (err, res) => {
18828
+ if (err) {
18829
+ return handlePaymentError(err);
18830
+ }
18831
+ onSuccess(res);
18832
+ });
18833
+ } else if (renewSubscription) {
18834
+ return payment.execute({
18835
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
18836
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
18837
+ quantity: plan.quantity,
18838
+ plan,
18839
+ couponCode,
18840
+ product,
18841
+ isExistingSource: isUsingExistingPaymentMethod,
18842
+ subscriptionIdToRenew,
18843
+ addressId: selectedAddressId
18844
+ }, (err, res) => {
18845
+ if (err) {
18846
+ return handlePaymentError(err);
18847
+ }
18848
+ onSuccess(res);
18849
+ });
18850
+ } else if (createSubscription) {
18851
+ return payment.execute({
18852
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
18853
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : braintreeNonce,
18854
+ quantity: plan.quantity,
18855
+ plan,
18856
+ couponCode,
18857
+ product,
18858
+ isExistingSource: isUsingExistingPaymentMethod,
18859
+ addressId: selectedAddressId
18860
+ }, (err, res) => {
18861
+ if (err) {
18862
+ return handlePaymentError(err);
18863
+ }
18864
+ onSuccess(res);
18865
+ });
18866
+ }
18867
+ }
18868
+ };
18869
+
18870
+ /* ====== End Braintree integration ======== */
18871
+
18872
+ const submitUsingVantiv = state => {
18873
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18874
+ if (isUsingExistingPaymentMethod) {
18875
+ // no need to create a new source using vantiv
18876
+ return handleVantivPayment(null, state.couponCode);
18877
+ }
18878
+ if (!vantivInstanceRef.current) {
18879
+ return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
18880
+ }
18881
+ const orderId = `pelcro-${new Date().getTime()}`;
18882
+ /*
18883
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
18884
+ */
18885
+ vantivInstanceRef.current.getPaypageRegistrationId({
18886
+ id: orderId,
18887
+ orderId: orderId
18888
+ });
18889
+ };
18890
+ function handleVantivPayment(paymentRequest, couponCode) {
18891
+ if (paymentRequest) {
18892
+ const SUCCESS_STATUS = "870";
18893
+ if (paymentRequest.response !== SUCCESS_STATUS) {
18894
+ switch (paymentRequest.response) {
18895
+ case "871":
18896
+ return handlePaymentError({
18897
+ error: new Error("Invalid account number")
18898
+ });
18899
+ default:
18900
+ return handlePaymentError({
18901
+ error: new Error(paymentRequest.message)
18902
+ });
18903
+ }
18904
+ }
18905
+ }
18906
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18907
+ if (type === "createPayment") {
18908
+ handleVantivSubscription();
18909
+ } else if (type === "orderCreate") {
18910
+ purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
18911
+ } else if (type === "invoicePayment") {
18912
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
18913
+ } else if (type === "createPaymentSource") {
18914
+ createNewVantivCard();
18915
+ } else if (type === "updatePaymentSource") {
18916
+ updateVantivCard();
18917
+ } else if (type === "deletePaymentSource") {
18095
18918
  replaceVantivCard();
18096
18919
  }
18097
18920
  function createNewVantivCard() {
@@ -18125,6 +18948,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18125
18948
  content: t("messages.sourceCreated")
18126
18949
  }
18127
18950
  });
18951
+ refreshUser();
18128
18952
  onSuccess(res);
18129
18953
  });
18130
18954
  }
@@ -18179,6 +19003,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18179
19003
  }
18180
19004
  });
18181
19005
  }
19006
+ refreshUser();
18182
19007
  onSuccess(res);
18183
19008
  });
18184
19009
  }, 2000);
@@ -18240,6 +19065,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18240
19065
  content: t("messages.sourceUpdated")
18241
19066
  }
18242
19067
  });
19068
+ refreshUser();
18243
19069
  onSuccess(res);
18244
19070
  });
18245
19071
  }
@@ -18397,13 +19223,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18397
19223
  });
18398
19224
 
18399
19225
  // When Google pay / Apple pay source created
18400
- paymentRequest.on("source", _ref6 => {
19226
+ paymentRequest.on("source", _ref8 => {
18401
19227
  var _source$card;
18402
19228
  let {
18403
19229
  complete,
18404
19230
  source,
18405
19231
  ...data
18406
- } = _ref6;
19232
+ } = _ref8;
18407
19233
  dispatch({
18408
19234
  type: DISABLE_COUPON_BUTTON,
18409
19235
  payload: true
@@ -18418,11 +19244,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18418
19244
  });
18419
19245
  complete("success");
18420
19246
  if ((source === null || source === void 0 ? void 0 : (_source$card = source.card) === null || _source$card === void 0 ? void 0 : _source$card.three_d_secure) === "required") {
18421
- return generate3DSecureSource(source).then(_ref7 => {
19247
+ return generate3DSecureSource(source).then(_ref9 => {
18422
19248
  let {
18423
19249
  source,
18424
19250
  error
18425
- } = _ref7;
19251
+ } = _ref9;
18426
19252
  if (error) {
18427
19253
  return handlePaymentError(error);
18428
19254
  }
@@ -18798,6 +19624,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18798
19624
  type: LOADING,
18799
19625
  payload: false
18800
19626
  });
19627
+ refreshUser();
18801
19628
  onSuccess(res);
18802
19629
  return;
18803
19630
  }
@@ -18813,6 +19640,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18813
19640
  content: t("messages.sourceCreated")
18814
19641
  }
18815
19642
  });
19643
+ refreshUser();
18816
19644
  onSuccess(res);
18817
19645
  return;
18818
19646
  }
@@ -18832,6 +19660,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18832
19660
  content: t("messages.sourceUpdated")
18833
19661
  }
18834
19662
  });
19663
+ refreshUser();
18835
19664
  onSuccess(res);
18836
19665
  return;
18837
19666
  }
@@ -18859,6 +19688,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18859
19688
  }
18860
19689
  });
18861
19690
  }
19691
+ refreshUser();
18862
19692
  onSuccess(res);
18863
19693
  });
18864
19694
  }, 2000);
@@ -18890,7 +19720,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18890
19720
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
18891
19721
  address_id: product.address_required ? selectedAddressId : null
18892
19722
  }, (err, res) => {
18893
- if (res.data.setup_intent) {
19723
+ var _res$data;
19724
+ if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.setup_intent) {
18894
19725
  return confirmStripeIntentSetup(res, "subCreate");
18895
19726
  }
18896
19727
  confirmStripeCardPayment(res, err, true);
@@ -19134,11 +19965,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19134
19965
  const createPaymentSource = (state, dispatch) => {
19135
19966
  return stripe.createSource({
19136
19967
  type: "card"
19137
- }).then(_ref8 => {
19968
+ }).then(_ref10 => {
19138
19969
  let {
19139
19970
  source,
19140
19971
  error
19141
- } = _ref8;
19972
+ } = _ref10;
19142
19973
  if (error) {
19143
19974
  return handlePaymentError(error);
19144
19975
  }
@@ -19156,7 +19987,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19156
19987
  auth_token: window.Pelcro.user.read().auth_token,
19157
19988
  token: source.id
19158
19989
  }, (err, res) => {
19159
- var _res$data, _res$data$setup_inten, _res$data2, _res$data2$setup_inte;
19990
+ var _res$data2, _res$data2$setup_inte, _res$data3, _res$data3$setup_inte;
19160
19991
  if (err) {
19161
19992
  dispatch({
19162
19993
  type: DISABLE_SUBMIT,
@@ -19175,7 +20006,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19175
20006
  }
19176
20007
  });
19177
20008
  }
19178
- if (((_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$setup_inten = _res$data.setup_intent) === null || _res$data$setup_inten === void 0 ? void 0 : _res$data$setup_inten.status) === "requires_action" || ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$setup_inte = _res$data2.setup_intent) === null || _res$data2$setup_inte === void 0 ? void 0 : _res$data2$setup_inte.status) === "requires_confirmation") {
20009
+ if (((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : (_res$data2$setup_inte = _res$data2.setup_intent) === null || _res$data2$setup_inte === void 0 ? void 0 : _res$data2$setup_inte.status) === "requires_action" || ((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$setup_inte = _res$data3.setup_intent) === null || _res$data3$setup_inte === void 0 ? void 0 : _res$data3$setup_inte.status) === "requires_confirmation") {
19179
20010
  confirmStripeIntentSetup(res, "create");
19180
20011
  } else {
19181
20012
  dispatch({
@@ -19189,6 +20020,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19189
20020
  content: t("messages.sourceCreated")
19190
20021
  }
19191
20022
  });
20023
+ refreshUser();
19192
20024
  onSuccess(res);
19193
20025
  }
19194
20026
  });
@@ -19211,7 +20043,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19211
20043
  exp_year: year,
19212
20044
  is_default: isDefault
19213
20045
  }, (err, res) => {
19214
- var _res$data3, _res$data3$setup_inte, _res$data4, _res$data4$setup_inte;
20046
+ var _res$data4, _res$data4$setup_inte, _res$data5, _res$data5$setup_inte;
19215
20047
  dispatch({
19216
20048
  type: DISABLE_SUBMIT,
19217
20049
  payload: false
@@ -19230,7 +20062,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19230
20062
  }
19231
20063
  });
19232
20064
  }
19233
- if (((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : (_res$data3$setup_inte = _res$data3.setup_intent) === null || _res$data3$setup_inte === void 0 ? void 0 : _res$data3$setup_inte.status) === "requires_action" || ((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$setup_inte = _res$data4.setup_intent) === null || _res$data4$setup_inte === void 0 ? void 0 : _res$data4$setup_inte.status) === "requires_confirmation") {
20065
+ if (((_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : (_res$data4$setup_inte = _res$data4.setup_intent) === null || _res$data4$setup_inte === void 0 ? void 0 : _res$data4$setup_inte.status) === "requires_action" || ((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$setup_inte = _res$data5.setup_intent) === null || _res$data5$setup_inte === void 0 ? void 0 : _res$data5$setup_inte.status) === "requires_confirmation") {
19234
20066
  confirmStripeIntentSetup(res, "update");
19235
20067
  } else {
19236
20068
  dispatch({
@@ -19240,6 +20072,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19240
20072
  content: t("messages.sourceUpdated")
19241
20073
  }
19242
20074
  });
20075
+ refreshUser();
19243
20076
  onSuccess(res);
19244
20077
  }
19245
20078
  });
@@ -19250,11 +20083,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19250
20083
  } = paymentMethodToDelete;
19251
20084
  return stripe.createSource({
19252
20085
  type: "card"
19253
- }).then(_ref9 => {
20086
+ }).then(_ref11 => {
19254
20087
  let {
19255
20088
  source,
19256
20089
  error
19257
- } = _ref9;
20090
+ } = _ref11;
19258
20091
  if (error) {
19259
20092
  return handlePaymentError(error);
19260
20093
  }
@@ -19272,7 +20105,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19272
20105
  auth_token: window.Pelcro.user.read().auth_token,
19273
20106
  token: source.id
19274
20107
  }, (err, res) => {
19275
- var _res$data5, _res$data5$setup_inte, _res$data6, _res$data6$setup_inte;
20108
+ var _res$data6, _res$data6$setup_inte, _res$data7, _res$data7$setup_inte;
19276
20109
  if (err) {
19277
20110
  onFailure(err);
19278
20111
  return dispatch({
@@ -19283,7 +20116,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19283
20116
  }
19284
20117
  });
19285
20118
  }
19286
- if (((_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : (_res$data5$setup_inte = _res$data5.setup_intent) === null || _res$data5$setup_inte === void 0 ? void 0 : _res$data5$setup_inte.status) === "requires_action" || ((_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_confirmation") {
20119
+ 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" || ((_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : (_res$data7$setup_inte = _res$data7.setup_intent) === null || _res$data7$setup_inte === void 0 ? void 0 : _res$data7$setup_inte.status) === "requires_confirmation") {
19287
20120
  confirmStripeIntentSetup(res, "replace", paymentMethodId);
19288
20121
  } else {
19289
20122
  setTimeout(() => {
@@ -19309,6 +20142,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19309
20142
  }
19310
20143
  });
19311
20144
  }
20145
+ refreshUser();
19312
20146
  onSuccess(res);
19313
20147
  });
19314
20148
  }, 2000);
@@ -19351,12 +20185,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19351
20185
  }
19352
20186
  stripe.createSource({
19353
20187
  type: "card"
19354
- }).then(_ref10 => {
19355
- var _ref11, _ref12, _state$updatedPrice2;
20188
+ }).then(_ref12 => {
20189
+ var _ref13, _ref14, _state$updatedPrice3;
19356
20190
  let {
19357
20191
  source,
19358
20192
  error
19359
- } = _ref10;
20193
+ } = _ref12;
19360
20194
  if (error) {
19361
20195
  return handlePaymentError(error);
19362
20196
  }
@@ -19375,7 +20209,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19375
20209
  return total + item.price * item.quantity;
19376
20210
  }, 0);
19377
20211
  };
19378
- (_ref11 = (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref11 !== void 0 ? _ref11 : getOrderItemsTotal();
20212
+ (_ref13 = (_ref14 = (_state$updatedPrice3 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice3 !== void 0 ? _state$updatedPrice3 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref14 !== void 0 ? _ref14 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref13 !== void 0 ? _ref13 : getOrderItemsTotal();
19379
20213
  return handlePayment(source);
19380
20214
  }).catch(error => {
19381
20215
  return handlePaymentError(error);
@@ -19404,12 +20238,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19404
20238
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
19405
20239
  address_id: selectedAddressId
19406
20240
  }, (error, res) => {
19407
- var _res$data7, _res$data8;
20241
+ var _res$data8, _res$data9;
19408
20242
  if (error) {
19409
20243
  return reject(error);
19410
20244
  }
19411
- const taxAmount = (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.taxes;
19412
- const totalAmountWithTax = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.total;
20245
+ const taxAmount = (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.taxes;
20246
+ const totalAmountWithTax = (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.total;
19413
20247
  resolve({
19414
20248
  totalAmountWithTax,
19415
20249
  taxAmount
@@ -19557,6 +20391,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19557
20391
  ...state,
19558
20392
  isLoading: action.payload
19559
20393
  });
20394
+ case SKELETON_LOADER:
20395
+ return lib_7({
20396
+ ...state,
20397
+ isSkeletonLoaded: action.payload
20398
+ });
19560
20399
  case SHOW_COUPON_FIELD:
19561
20400
  return lib_7({
19562
20401
  ...state,
@@ -19594,6 +20433,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19594
20433
  if (getSiteCardProcessor() === "cybersource") {
19595
20434
  return submitUsingCybersource(state, dispatch);
19596
20435
  }
20436
+ if (getSiteCardProcessor() === "braintree") {
20437
+ return submitUsingBraintree(state, dispatch);
20438
+ }
19597
20439
  if (selectedPaymentMethodId) {
19598
20440
  // pay with selected method (source) if exists already
19599
20441
  return handlePayment({
@@ -19982,6 +20824,11 @@ const CheckoutForm = _ref => {
19982
20824
  paymentMethodToEdit
19983
20825
  } = usePelcro();
19984
20826
  const cardProcessor = getSiteCardProcessor();
20827
+ const {
20828
+ state: {
20829
+ isSkeletonLoaded
20830
+ }
20831
+ } = React.useContext(store$l);
19985
20832
  if (selectedPaymentMethodId) {
19986
20833
  return null;
19987
20834
  }
@@ -20013,12 +20860,61 @@ const CheckoutForm = _ref => {
20013
20860
  placeholder: "Exp Year *"
20014
20861
  }))));
20015
20862
  }
20016
- if (cardProcessor === "stripe") {
20863
+ if (cardProcessor === "braintree") {
20017
20864
  if (type === "updatePaymentSource") {
20018
20865
  var _paymentMethodToEdit$;
20866
+ return /*#__PURE__*/React__default['default'].createElement("div", null, isSkeletonLoaded && paymentMethodToEdit ? /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
20867
+ htmlFor: "card-number"
20868
+ }, "Card Number *"), /*#__PURE__*/React__default['default'].createElement(Input, {
20869
+ id: "card-number",
20870
+ className: "plc-tracking-widest plc-flex-grow plc-h-12 plc-text-center",
20871
+ value: `•••• •••• •••• ${paymentMethodToEdit === null || paymentMethodToEdit === void 0 ? void 0 : (_paymentMethodToEdit$ = paymentMethodToEdit.properties) === null || _paymentMethodToEdit$ === void 0 ? void 0 : _paymentMethodToEdit$.last4}`,
20872
+ disabled: true
20873
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
20874
+ className: "plc-flex plc-items-start plc-space-x-8 plc-my-6"
20875
+ }, /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
20876
+ htmlFor: "expiration-month"
20877
+ }, "Expiration Month *"), /*#__PURE__*/React__default['default'].createElement("div", {
20878
+ id: "expiration-month",
20879
+ className: "pelcro-input-field plc-h-12 plc-bg-white"
20880
+ })), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
20881
+ htmlFor: "expiration-year"
20882
+ }, "Expiration Year *"), /*#__PURE__*/React__default['default'].createElement("div", {
20883
+ id: "expiration-year",
20884
+ className: "pelcro-input-field plc-h-12 plc-bg-white"
20885
+ })))) : /*#__PURE__*/React__default['default'].createElement("div", {
20886
+ className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
20887
+ }));
20888
+ }
20889
+ return /*#__PURE__*/React__default['default'].createElement("div", null, isSkeletonLoaded ? /*#__PURE__*/React__default['default'].createElement("div", {
20890
+ className: "plc-max-w-[50em]"
20891
+ }, /*#__PURE__*/React__default['default'].createElement("label", {
20892
+ htmlFor: "card-number"
20893
+ }, "Card Number *"), /*#__PURE__*/React__default['default'].createElement("div", {
20894
+ id: "card-number",
20895
+ className: "pelcro-input-field plc-h-12 plc-bg-white"
20896
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
20897
+ className: "plc-flex plc-items-start plc-space-x-8 plc-my-6"
20898
+ }, /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
20899
+ htmlFor: "expiration-date"
20900
+ }, "Expiration Date *"), /*#__PURE__*/React__default['default'].createElement("div", {
20901
+ id: "expiration-date",
20902
+ className: "pelcro-input-field plc-h-12 plc-bg-white"
20903
+ })), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("label", {
20904
+ htmlFor: "cvv"
20905
+ }, "CVC *"), /*#__PURE__*/React__default['default'].createElement("div", {
20906
+ id: "cvv",
20907
+ className: "pelcro-input-field plc-h-12 plc-bg-white"
20908
+ })))) : /*#__PURE__*/React__default['default'].createElement("div", {
20909
+ className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded plc-animate-pulse"
20910
+ }));
20911
+ }
20912
+ if (cardProcessor === "stripe") {
20913
+ if (type === "updatePaymentSource") {
20914
+ var _paymentMethodToEdit$2;
20019
20915
  return /*#__PURE__*/React__default['default'].createElement("div", null, paymentMethodToEdit ? /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(Input, {
20020
20916
  className: "plc-tracking-widest plc-flex-grow plc-text-center",
20021
- value: `•••• •••• •••• ${paymentMethodToEdit === null || paymentMethodToEdit === void 0 ? void 0 : (_paymentMethodToEdit$ = paymentMethodToEdit.properties) === null || _paymentMethodToEdit$ === void 0 ? void 0 : _paymentMethodToEdit$.last4}`,
20917
+ value: `•••• •••• •••• ${paymentMethodToEdit === null || paymentMethodToEdit === void 0 ? void 0 : (_paymentMethodToEdit$2 = paymentMethodToEdit.properties) === null || _paymentMethodToEdit$2 === void 0 ? void 0 : _paymentMethodToEdit$2.last4}`,
20022
20918
  disabled: true
20023
20919
  })) : /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(Input, {
20024
20920
  className: "plc-bg-gray-300 plc-animate-pulse"
@@ -25335,7 +26231,8 @@ const PasswordResetContainer = _ref => {
25335
26231
  email,
25336
26232
  password,
25337
26233
  password_confirmation: confirmPassword,
25338
- token
26234
+ token,
26235
+ referer: window.location.origin
25339
26236
  }, (err, res) => {
25340
26237
  dispatch({
25341
26238
  type: DISABLE_SUBMIT,
@@ -25567,7 +26464,8 @@ const PasswordForgotContainer = _ref => {
25567
26464
  email
25568
26465
  } = _ref2;
25569
26466
  window.Pelcro.password.forgot({
25570
- email
26467
+ email,
26468
+ referer: window.location.origin
25571
26469
  }, (err, res) => {
25572
26470
  dispatch({
25573
26471
  type: DISABLE_SUBMIT,
@@ -27692,17 +28590,21 @@ const AddressSelectModal = _ref => {
27692
28590
  AddressSelectModal.viewId = "address-select";
27693
28591
 
27694
28592
  const moveDefaultPaymentMethodToStart = paymentMethods => {
27695
- var _window$Pelcro$user$r;
27696
- const defaultPaymentMethod = (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.source;
28593
+ const defaultPaymentMethod = getDefaultPaymentMethod(paymentMethods);
27697
28594
  const paymentMethodsWithoutDefault = paymentMethods.filter(paymentMethod => paymentMethod.id !== defaultPaymentMethod.id);
27698
28595
  if (defaultPaymentMethod.status !== "chargeable") {
27699
28596
  return paymentMethodsWithoutDefault;
27700
28597
  }
27701
28598
  return [defaultPaymentMethod, ...paymentMethodsWithoutDefault];
27702
28599
  };
28600
+ const getDefaultPaymentMethod = paymentMethods => {
28601
+ const defaultPaymentMethod = paymentMethods.find(paymentMethod => paymentMethod.is_default);
28602
+ return defaultPaymentMethod;
28603
+ };
27703
28604
  const initialState$5 = {
27704
28605
  paymentMethods: [],
27705
28606
  selectedPaymentMethodId: null,
28607
+ skeletonLoader: true,
27706
28608
  isSubmitting: false,
27707
28609
  alert: {
27708
28610
  type: "error",
@@ -27733,12 +28635,11 @@ const PaymentMethodSelectContainer = _ref => {
27733
28635
  });
27734
28636
  return onSuccess(selectedPaymentMethodId);
27735
28637
  };
27736
- const getInitialSelectedMethodId = () => {
27737
- var _window$Pelcro$user$r2;
28638
+ const getInitialSelectedMethodId = paymentMethods => {
27738
28639
  if (selectedPaymentMethodIdFromStore) {
27739
28640
  return selectedPaymentMethodIdFromStore;
27740
28641
  }
27741
- const defaultMethod = (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.source;
28642
+ const defaultMethod = getDefaultPaymentMethod(paymentMethods);
27742
28643
  if (defaultMethod && defaultMethod.status === "chargeable") {
27743
28644
  return String(defaultMethod.id);
27744
28645
  }
@@ -27755,7 +28656,12 @@ const PaymentMethodSelectContainer = _ref => {
27755
28656
  return lib_7({
27756
28657
  ...state,
27757
28658
  paymentMethods: moveDefaultPaymentMethodToStart(action.payload),
27758
- selectedPaymentMethodId: getInitialSelectedMethodId()
28659
+ selectedPaymentMethodId: getInitialSelectedMethodId(action.payload)
28660
+ });
28661
+ case SKELETON_LOADER:
28662
+ return lib_7({
28663
+ ...state,
28664
+ skeletonLoader: action.payload
27759
28665
  });
27760
28666
  case HANDLE_SUBMIT:
27761
28667
  return lib_5({
@@ -27767,10 +28673,23 @@ const PaymentMethodSelectContainer = _ref => {
27767
28673
  }
27768
28674
  }, initialState$5);
27769
28675
  React.useEffect(() => {
27770
- var _window$Pelcro$user$r3;
27771
- dispatch({
27772
- type: LOAD_PAYMENT_METHODS,
27773
- payload: (_window$Pelcro$user$r3 = window.Pelcro.user.read().sources) !== null && _window$Pelcro$user$r3 !== void 0 ? _window$Pelcro$user$r3 : []
28676
+ window.Pelcro.paymentMethods.list({
28677
+ auth_token: window.Pelcro.user.read().auth_token
28678
+ }, (err, res) => {
28679
+ if (err) {
28680
+ return console.error(err);
28681
+ }
28682
+ if (res) {
28683
+ var _res$data;
28684
+ dispatch({
28685
+ type: LOAD_PAYMENT_METHODS,
28686
+ payload: (_res$data = res.data) !== null && _res$data !== void 0 ? _res$data : []
28687
+ });
28688
+ dispatch({
28689
+ type: SKELETON_LOADER,
28690
+ payload: false
28691
+ });
28692
+ }
27774
28693
  });
27775
28694
  }, []);
27776
28695
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -27799,7 +28718,8 @@ const PaymentMethodSelectList = () => {
27799
28718
  dispatch,
27800
28719
  state: {
27801
28720
  paymentMethods,
27802
- selectedPaymentMethodId
28721
+ selectedPaymentMethodId,
28722
+ skeletonLoader
27803
28723
  }
27804
28724
  } = React.useContext(store$5);
27805
28725
  const handlePaymentMethodSelect = event => {
@@ -27808,7 +28728,9 @@ const PaymentMethodSelectList = () => {
27808
28728
  payload: event.target.value
27809
28729
  });
27810
28730
  };
27811
- return /*#__PURE__*/React__default['default'].createElement("div", {
28731
+ return /*#__PURE__*/React__default['default'].createElement("div", null, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
28732
+ className: "plc-w-full plc-h-20 plc-bg-gray-300 plc-rounded-md plc-animate-pulse"
28733
+ }) : /*#__PURE__*/React__default['default'].createElement("div", {
27812
28734
  className: "plc-px-3 plc-py-2 plc-space-y-4 plc-overflow-y-scroll plc-max-h-80 pelcro-payment-method-select-wrapper"
27813
28735
  }, paymentMethods.map(paymentMethod => {
27814
28736
  var _paymentMethod$proper, _paymentMethod$proper2, _paymentMethod$proper3, _paymentMethod$proper4;
@@ -27831,7 +28753,7 @@ const PaymentMethodSelectList = () => {
27831
28753
  }, "\u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022 ", (_paymentMethod$proper2 = paymentMethod.properties) === null || _paymentMethod$proper2 === void 0 ? void 0 : _paymentMethod$proper2.last4), /*#__PURE__*/React__default['default'].createElement("p", {
27832
28754
  className: "plc-text-sm plc-text-gray-500"
27833
28755
  }, t("select.expires"), " ", (_paymentMethod$proper3 = paymentMethod.properties) === null || _paymentMethod$proper3 === void 0 ? void 0 : _paymentMethod$proper3.exp_month, "/", (_paymentMethod$proper4 = paymentMethod.properties) === null || _paymentMethod$proper4 === void 0 ? void 0 : _paymentMethod$proper4.exp_year))));
27834
- }));
28756
+ })));
27835
28757
  };
27836
28758
 
27837
28759
  const PaymentMethodSelectSubmit = _ref => {
@@ -27933,10 +28855,10 @@ const initialState$4 = {
27933
28855
  paymentMethods: [],
27934
28856
  selectedPaymentMethodId: null,
27935
28857
  isSubmitting: false,
27936
- deleteOption: "",
27937
- disableSubmit: false,
28858
+ disableSubmit: true,
27938
28859
  isLoading: false,
27939
28860
  skeletonLoader: true,
28861
+ showPaymentMethodSelect: false,
27940
28862
  alert: {
27941
28863
  type: "error",
27942
28864
  content: ""
@@ -27973,20 +28895,19 @@ const PaymentMethodDeleteContainer = _ref => {
27973
28895
  type: SKELETON_LOADER,
27974
28896
  payload: false
27975
28897
  });
27976
- if (res.data.length !== 1) {
27977
- dispatch({
27978
- type: SET_DELETE_PAYMENT_METHOD_OPTION,
27979
- payload: "select"
27980
- });
27981
- } else {
28898
+ if (res.data.length !== 1 && paymentMethodToDelete.is_default && paymentMethodToDelete.deletable) {
27982
28899
  dispatch({
27983
- type: SET_DELETE_PAYMENT_METHOD_OPTION,
27984
- payload: "add"
28900
+ type: SHOW_PAYMENT_METHOD_SELECT,
28901
+ payload: true
27985
28902
  });
27986
28903
  }
28904
+ dispatch({
28905
+ type: DISABLE_SUBMIT,
28906
+ payload: false
28907
+ });
27987
28908
  }
27988
28909
  });
27989
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
28910
+ }, [paymentMethodToDelete]); // eslint-disable-line react-hooks/exhaustive-deps
27990
28911
 
27991
28912
  const setDefaultPaymentMethod = () => {
27992
28913
  const {
@@ -27998,6 +28919,15 @@ const PaymentMethodDeleteContainer = _ref => {
27998
28919
  is_default: true
27999
28920
  }, (err, res) => {
28000
28921
  if (err) {
28922
+ dispatch({
28923
+ type: DISABLE_SUBMIT,
28924
+ payload: false
28925
+ });
28926
+ dispatch({
28927
+ type: LOADING,
28928
+ payload: false
28929
+ });
28930
+ console.log(err);
28001
28931
  onFailure(err);
28002
28932
  return dispatch({
28003
28933
  type: SHOW_ALERT,
@@ -28020,6 +28950,14 @@ const PaymentMethodDeleteContainer = _ref => {
28020
28950
  auth_token: window.Pelcro.user.read().auth_token,
28021
28951
  payment_method_id: paymentMethodId
28022
28952
  }, (err, res) => {
28953
+ dispatch({
28954
+ type: DISABLE_SUBMIT,
28955
+ payload: false
28956
+ });
28957
+ dispatch({
28958
+ type: LOADING,
28959
+ payload: false
28960
+ });
28023
28961
  if (err) {
28024
28962
  onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
28025
28963
  return dispatch({
@@ -28030,14 +28968,6 @@ const PaymentMethodDeleteContainer = _ref => {
28030
28968
  }
28031
28969
  });
28032
28970
  }
28033
- dispatch({
28034
- type: DISABLE_SUBMIT,
28035
- payload: false
28036
- });
28037
- dispatch({
28038
- type: LOADING,
28039
- payload: false
28040
- });
28041
28971
  onSuccess(res);
28042
28972
  });
28043
28973
  };
@@ -28053,11 +28983,12 @@ const PaymentMethodDeleteContainer = _ref => {
28053
28983
  ...state,
28054
28984
  disableSubmit: true,
28055
28985
  isLoading: true
28056
- }, (state, dispatch) => setDefaultPaymentMethod());
28057
- case SET_DELETE_PAYMENT_METHOD_OPTION:
28058
- return lib_7({
28059
- ...state,
28060
- deleteOption: action.payload
28986
+ }, (state, dispatch) => {
28987
+ if (state.showPaymentMethodSelect) {
28988
+ setDefaultPaymentMethod();
28989
+ } else {
28990
+ deletePaymentMethod();
28991
+ }
28061
28992
  });
28062
28993
  case SET_PAYMENT_METHODS:
28063
28994
  return lib_7({
@@ -28084,6 +29015,11 @@ const PaymentMethodDeleteContainer = _ref => {
28084
29015
  ...state,
28085
29016
  skeletonLoader: action.payload
28086
29017
  });
29018
+ case SHOW_PAYMENT_METHOD_SELECT:
29019
+ return lib_7({
29020
+ ...state,
29021
+ showPaymentMethodSelect: action.payload
29022
+ });
28087
29023
  default:
28088
29024
  return state;
28089
29025
  }
@@ -28106,6 +29042,91 @@ const PaymentMethodDeleteContainer = _ref => {
28106
29042
  })));
28107
29043
  };
28108
29044
 
29045
+ const PaymentMethodDeleteList = props => {
29046
+ const {
29047
+ t
29048
+ } = useTranslation("paymentMethod");
29049
+ const {
29050
+ dispatch,
29051
+ state: {
29052
+ selectedPaymentMethodId,
29053
+ paymentMethods,
29054
+ skeletonLoader,
29055
+ showPaymentMethodSelect
29056
+ }
29057
+ } = React.useContext(store$4);
29058
+ const {
29059
+ paymentMethodToDelete
29060
+ } = usePelcro();
29061
+ const createPaymentMethodItems = () => {
29062
+ if (paymentMethods.length) {
29063
+ return paymentMethods.filter(paymentMethod => (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id) !== (paymentMethodToDelete === null || paymentMethodToDelete === void 0 ? void 0 : paymentMethodToDelete.id)).map(paymentMethod => /*#__PURE__*/React__default['default'].createElement("option", {
29064
+ key: paymentMethod.id,
29065
+ value: paymentMethod.id
29066
+ }, paymentMethod.properties.brand, " -", " ", paymentMethod.properties.last4, " -", " ", paymentMethod.properties.exp_month, " /", paymentMethod.properties.exp_year));
29067
+ }
29068
+ };
29069
+ const handlePaymentMethodSelect = event => {
29070
+ dispatch({
29071
+ type: SELECT_PAYMENT_METHOD,
29072
+ payload: event.target.value
29073
+ });
29074
+ };
29075
+ if (showPaymentMethodSelect) {
29076
+ return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
29077
+ className: "plc-w-full plc-h-8 plc-bg-gray-300 plc-rounded-md plc-animate-pulse"
29078
+ }) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethods && /*#__PURE__*/React__default['default'].createElement("div", {
29079
+ className: "plc-mt-4"
29080
+ }, /*#__PURE__*/React__default['default'].createElement(Select, {
29081
+ label: t("delete.options.select"),
29082
+ name: "default-payment-method",
29083
+ onChange: handlePaymentMethodSelect,
29084
+ value: selectedPaymentMethodId
29085
+ }, /*#__PURE__*/React__default['default'].createElement("option", {
29086
+ value: "",
29087
+ disabled: true,
29088
+ selected: true
29089
+ }), createPaymentMethodItems()))));
29090
+ } else {
29091
+ return null;
29092
+ }
29093
+ };
29094
+
29095
+ const PaymentMethodDetails = () => {
29096
+ var _paymentMethodToDelet, _paymentMethodToDelet2, _paymentMethodToDelet3, _paymentMethodToDelet4;
29097
+ const {
29098
+ state: {
29099
+ skeletonLoader
29100
+ }
29101
+ } = React.useContext(store$4);
29102
+ const {
29103
+ t
29104
+ } = useTranslation("paymentMethod");
29105
+ const {
29106
+ paymentMethodToDelete
29107
+ } = usePelcro();
29108
+ return /*#__PURE__*/React__default['default'].createElement("div", {
29109
+ className: "plc-text-left plc-mr-auto plc-mb-6"
29110
+ }, /*#__PURE__*/React__default['default'].createElement("h4", {
29111
+ className: "plc-mb-2"
29112
+ }, t("delete.details")), skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
29113
+ className: "plc-w-full plc-h-16 plc-bg-gray-300 plc-rounded-md plc-animate-pulse"
29114
+ }) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethodToDelete && /*#__PURE__*/React__default['default'].createElement("div", {
29115
+ key: paymentMethodToDelete === null || paymentMethodToDelete === void 0 ? void 0 : paymentMethodToDelete.id,
29116
+ className: `plc-p-2 plc-pl-4 plc-shadow-md_dark plc-text-gray-900 plc-rounded pelcro-payment-method-wrapper`
29117
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
29118
+ className: "plc-flex plc-items-center plc-space-x-2 plc-w-full pelcro-select-payment-method-radio",
29119
+ id: `pelcro-payment-method-select-${paymentMethodToDelete === null || paymentMethodToDelete === void 0 ? void 0 : paymentMethodToDelete.id}`,
29120
+ name: "paymentMethod"
29121
+ }, getPaymentCardIcon$1((_paymentMethodToDelet = paymentMethodToDelete.properties) === null || _paymentMethodToDelet === void 0 ? void 0 : _paymentMethodToDelet.brand), /*#__PURE__*/React__default['default'].createElement("div", {
29122
+ className: "plc-flex plc-flex-col plc-text-lg pelcro-payment-method-details"
29123
+ }, /*#__PURE__*/React__default['default'].createElement("p", {
29124
+ className: "plc-font-semibold"
29125
+ }, "\u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022", " ", (_paymentMethodToDelet2 = paymentMethodToDelete.properties) === null || _paymentMethodToDelet2 === void 0 ? void 0 : _paymentMethodToDelet2.last4), /*#__PURE__*/React__default['default'].createElement("p", {
29126
+ className: "plc-text-sm plc-text-gray-500"
29127
+ }, t("select.expires"), " ", (_paymentMethodToDelet3 = paymentMethodToDelete.properties) === null || _paymentMethodToDelet3 === void 0 ? void 0 : _paymentMethodToDelet3.exp_month, "/", (_paymentMethodToDelet4 = paymentMethodToDelete.properties) === null || _paymentMethodToDelet4 === void 0 ? void 0 : _paymentMethodToDelet4.exp_year))))));
29128
+ };
29129
+
28109
29130
  const PaymentMethodDeleteSubmit = _ref => {
28110
29131
  let {
28111
29132
  name,
@@ -28119,7 +29140,9 @@ const PaymentMethodDeleteSubmit = _ref => {
28119
29140
  dispatch,
28120
29141
  state: {
28121
29142
  isLoading,
28122
- isDisabled
29143
+ disableSubmit,
29144
+ showPaymentMethodSelect,
29145
+ selectedPaymentMethodId
28123
29146
  }
28124
29147
  } = React.useContext(store$4);
28125
29148
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
@@ -28129,116 +29152,38 @@ const PaymentMethodDeleteSubmit = _ref => {
28129
29152
  });
28130
29153
  onClick === null || onClick === void 0 ? void 0 : onClick();
28131
29154
  },
28132
- disabled: isDisabled,
29155
+ disabled: showPaymentMethodSelect ? !selectedPaymentMethodId : disableSubmit,
28133
29156
  isLoading: isLoading,
28134
29157
  className: "plc-w-full"
28135
- }, otherProps), name !== null && name !== void 0 ? name : t("select.buttons.selectPaymentMethod"));
29158
+ }, otherProps), name !== null && name !== void 0 ? name : t("delete.buttons.delete"));
28136
29159
  };
28137
29160
 
28138
- const PaymentMethodDeleteList = props => {
29161
+ const PaymentMethodDeleteBack = _ref => {
29162
+ let {
29163
+ name,
29164
+ onClick,
29165
+ ...otherProps
29166
+ } = _ref;
28139
29167
  const {
28140
29168
  t
28141
29169
  } = useTranslation("paymentMethod");
28142
29170
  const {
28143
- dispatch,
28144
- state: {
28145
- deleteOption,
28146
- selectedPaymentMethodId,
28147
- paymentMethods,
28148
- skeletonLoader
28149
- }
28150
- } = React.useContext(store$4);
28151
- const {
28152
- paymentMethodToDelete
29171
+ switchView
28153
29172
  } = usePelcro();
28154
- const handlePaymentMethodSelect = event => {
28155
- dispatch({
28156
- type: SELECT_PAYMENT_METHOD,
28157
- payload: event.target.value
28158
- });
28159
- };
28160
- return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
28161
- className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded-md plc-animate-pulse"
28162
- }) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethods && deleteOption === "select" && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
28163
- className: "plc-px-3 plc-py-2 plc-space-y-4 plc-overflow-y-scroll no-scrollbar plc-max-h-80 pelcro-payment-method-select-wrapper plc-mb-4"
28164
- }, paymentMethods.filter(paymentMethod => (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id) !== (paymentMethodToDelete === null || paymentMethodToDelete === void 0 ? void 0 : paymentMethodToDelete.id)).map(paymentMethod => {
28165
- var _paymentMethod$proper, _paymentMethod$proper2, _paymentMethod$proper3, _paymentMethod$proper4;
28166
- const isSelected = selectedPaymentMethodId === String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id);
28167
- return /*#__PURE__*/React__default['default'].createElement("div", {
28168
- key: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id,
28169
- className: `plc-p-2 plc-pl-4 plc-shadow-md plc-text-gray-900 plc-rounded pelcro-payment-method-wrapper`
28170
- }, /*#__PURE__*/React__default['default'].createElement(Radio, {
28171
- className: "plc-flex plc-items-center pelcro-select-payment-method-radio",
28172
- labelClassName: "plc-flex plc-items-center plc-space-x-2 plc-cursor-pointer plc-w-full",
28173
- id: `pelcro-payment-method-select-${paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id}`,
28174
- name: "paymentMethod",
28175
- checked: isSelected,
28176
- value: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id,
28177
- onChange: handlePaymentMethodSelect
28178
- }, getPaymentCardIcon$1((_paymentMethod$proper = paymentMethod.properties) === null || _paymentMethod$proper === void 0 ? void 0 : _paymentMethod$proper.brand), /*#__PURE__*/React__default['default'].createElement("div", {
28179
- className: "plc-flex plc-flex-col plc-text-lg pelcro-payment-method-details"
28180
- }, /*#__PURE__*/React__default['default'].createElement("p", {
28181
- className: "plc-font-semibold"
28182
- }, "\u2022\u2022\u2022\u2022 \u2022\u2022\u2022\u2022", " ", (_paymentMethod$proper2 = paymentMethod.properties) === null || _paymentMethod$proper2 === void 0 ? void 0 : _paymentMethod$proper2.last4), /*#__PURE__*/React__default['default'].createElement("p", {
28183
- className: "plc-text-sm plc-text-gray-500"
28184
- }, t("select.expires"), " ", (_paymentMethod$proper3 = paymentMethod.properties) === null || _paymentMethod$proper3 === void 0 ? void 0 : _paymentMethod$proper3.exp_month, "/", (_paymentMethod$proper4 = paymentMethod.properties) === null || _paymentMethod$proper4 === void 0 ? void 0 : _paymentMethod$proper4.exp_year))));
28185
- })), /*#__PURE__*/React__default['default'].createElement("div", {
28186
- className: "plc-px-3"
28187
- }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteSubmit, null))), deleteOption === "add" && /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, {
28188
- type: "deletePaymentSource",
28189
- showCoupon: false,
28190
- showExternalPaymentMethods: false,
28191
- showApplePayButton: false,
28192
- onDisplay: props.onDisplay,
28193
- onFailure: props.onFailure,
28194
- onSuccess: props.onSuccess,
28195
- setAsDefault: true
28196
- })));
29173
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
29174
+ variant: "outline",
29175
+ onClick: () => {
29176
+ switchView("dashboard");
29177
+ onClick === null || onClick === void 0 ? void 0 : onClick();
29178
+ },
29179
+ className: "plc-w-full"
29180
+ }, otherProps), name !== null && name !== void 0 ? name : t("delete.buttons.back"));
28197
29181
  };
28198
29182
 
28199
- const PaymentMethodDeleteOptions = _ref => {
28200
- const {
28201
- state: {
28202
- deleteOption,
28203
- paymentMethods,
28204
- skeletonLoader
28205
- },
28206
- dispatch
28207
- } = React.useContext(store$4);
29183
+ function PaymentMethodDeleteView(props) {
28208
29184
  const {
28209
29185
  t
28210
29186
  } = useTranslation("paymentMethod");
28211
- const handleOptionSelect = event => {
28212
- dispatch({
28213
- type: SET_DELETE_PAYMENT_METHOD_OPTION,
28214
- payload: event.target.value
28215
- });
28216
- };
28217
- return /*#__PURE__*/React__default['default'].createElement("div", {
28218
- className: "plc-text-left plc-mr-auto plc-mb-6"
28219
- }, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
28220
- className: "plc-flex plc-flex-col plc-space-y-3"
28221
- }, /*#__PURE__*/React__default['default'].createElement(Radio, {
28222
- className: "plc-animate-puls"
28223
- }, /*#__PURE__*/React__default['default'].createElement("div", {
28224
- className: "plc-w-36 plc-bg-gray-300 plc-h-4 plc-rounded-md plc-animate-pulse"
28225
- })), /*#__PURE__*/React__default['default'].createElement(Radio, {
28226
- className: "plc-animate-pulse"
28227
- }, /*#__PURE__*/React__default['default'].createElement("div", {
28228
- className: "plc-w-36 plc-bg-gray-300 plc-h-4 plc-rounded-md plc-animate-pulse"
28229
- }))) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethods && paymentMethods.length !== 1 && /*#__PURE__*/React__default['default'].createElement(Radio, {
28230
- onChange: handleOptionSelect,
28231
- checked: deleteOption === "select",
28232
- value: "select"
28233
- }, t("delete.options.select")), /*#__PURE__*/React__default['default'].createElement(Radio, {
28234
- onChange: handleOptionSelect,
28235
- checked: deleteOption === "add",
28236
- value: "add"
28237
- }, t("delete.options.add"))));
28238
- };
28239
-
28240
- function PaymentMethodDeleteView(props) {
28241
- const [t] = useTranslation("paymentMethod");
28242
29187
  return /*#__PURE__*/React__default['default'].createElement("div", {
28243
29188
  id: "pelcro-payment-method-delete-view"
28244
29189
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -28246,12 +29191,12 @@ function PaymentMethodDeleteView(props) {
28246
29191
  }, /*#__PURE__*/React__default['default'].createElement("h4", {
28247
29192
  className: "plc-text-2xl plc-font-semibold plc-mb-2"
28248
29193
  }, t("delete.title")), /*#__PURE__*/React__default['default'].createElement("p", {
28249
- className: ""
28250
- }, t("delete.subtitle"))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
28251
- className: "plc-mb-2"
28252
- }), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteOptions, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteList, {
28253
- onSuccess: props.onSuccess
28254
- })));
29194
+ className: "plc-text-sm"
29195
+ }, t("delete.subtitle"))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDetails, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteList, null), /*#__PURE__*/React__default['default'].createElement("p", {
29196
+ className: "plc-text-sm plc-text-justify"
29197
+ }, t("delete.message")), /*#__PURE__*/React__default['default'].createElement("div", {
29198
+ className: "plc-space-x-0 plc-space-y-3 plc-w-full plc-flex plc-flex-col plc-items-center plc-justify-center plc-mt-4"
29199
+ }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteSubmit, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteBack, null))));
28255
29200
  }
28256
29201
 
28257
29202
  const PaymentMethodDeleteModal = props => {
@@ -28278,7 +29223,7 @@ const PaymentMethodDeleteModal = props => {
28278
29223
  nonInteraction: true
28279
29224
  });
28280
29225
  }
28281
- notify$1.success(t("delete.paymentMethodReplaced"));
29226
+ notify$1.success(t("delete.deletedSuccessfully"));
28282
29227
  resetView();
28283
29228
  };
28284
29229
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
@@ -29464,6 +30409,14 @@ const getPaymentCardIcon = name => {
29464
30409
  viewBox: "0 0 50 50"
29465
30410
  }, /*#__PURE__*/React__default['default'].createElement("path", {
29466
30411
  d: "M 5 7 C 2.25 7 0 9.25 0 12 L 0 38 C 0 40.75 2.25 43 5 43 L 45 43 C 47.75 43 50 40.75 50 38 L 50 12 C 50 9.25 47.75 7 45 7 Z M 5 9 L 45 9 C 46.667969 9 48 10.332031 48 12 L 48 38 C 48 39.667969 46.667969 41 45 41 L 5 41 C 3.332031 41 2 39.667969 2 38 L 2 12 C 2 10.332031 3.332031 9 5 9 Z M 8.5625 19.90625 L 4.84375 28.40625 L 7.0625 28.40625 L 7.875 26.5 L 12.0625 26.5 L 12.875 28.40625 L 17.09375 28.40625 L 17.09375 22.09375 L 19.90625 28.40625 L 21.8125 28.40625 L 24.65625 22.1875 L 24.65625 28.40625 L 26.75 28.40625 L 26.75 19.90625 L 23.40625 19.90625 L 20.84375 25.625 L 18.28125 19.90625 L 15 19.90625 L 15 28.09375 L 11.34375 19.90625 Z M 29.5 19.90625 L 29.5 28.4375 L 37.5 28.4375 L 40 25.59375 L 42.46875 28.4375 L 45.125 28.4375 L 41.375 24.0625 L 45.125 19.90625 L 42.46875 19.90625 L 40.0625 22.5625 L 37.75 19.90625 Z M 9.90625 21.6875 L 11.21875 24.6875 L 8.65625 24.6875 Z M 31.5625 21.71875 L 36.65625 21.75 L 38.6875 24.0625 L 36.40625 26.625 L 31.5625 26.625 L 31.5625 24.9375 L 36.1875 24.9375 L 36.1875 23.3125 L 31.5625 23.3125 Z"
30412
+ })),
30413
+ amex: /*#__PURE__*/React__default['default'].createElement("svg", {
30414
+ className: "plc-w-12",
30415
+ fill: "#ffffff",
30416
+ xmlns: "http://www.w3.org/2000/svg",
30417
+ viewBox: "0 0 50 50"
30418
+ }, /*#__PURE__*/React__default['default'].createElement("path", {
30419
+ d: "M 5 7 C 2.25 7 0 9.25 0 12 L 0 38 C 0 40.75 2.25 43 5 43 L 45 43 C 47.75 43 50 40.75 50 38 L 50 12 C 50 9.25 47.75 7 45 7 Z M 5 9 L 45 9 C 46.667969 9 48 10.332031 48 12 L 48 38 C 48 39.667969 46.667969 41 45 41 L 5 41 C 3.332031 41 2 39.667969 2 38 L 2 12 C 2 10.332031 3.332031 9 5 9 Z M 8.5625 19.90625 L 4.84375 28.40625 L 7.0625 28.40625 L 7.875 26.5 L 12.0625 26.5 L 12.875 28.40625 L 17.09375 28.40625 L 17.09375 22.09375 L 19.90625 28.40625 L 21.8125 28.40625 L 24.65625 22.1875 L 24.65625 28.40625 L 26.75 28.40625 L 26.75 19.90625 L 23.40625 19.90625 L 20.84375 25.625 L 18.28125 19.90625 L 15 19.90625 L 15 28.09375 L 11.34375 19.90625 Z M 29.5 19.90625 L 29.5 28.4375 L 37.5 28.4375 L 40 25.59375 L 42.46875 28.4375 L 45.125 28.4375 L 41.375 24.0625 L 45.125 19.90625 L 42.46875 19.90625 L 40.0625 22.5625 L 37.75 19.90625 Z M 9.90625 21.6875 L 11.21875 24.6875 L 8.65625 24.6875 Z M 31.5625 21.71875 L 36.65625 21.75 L 38.6875 24.0625 L 36.40625 26.625 L 31.5625 26.625 L 31.5625 24.9375 L 36.1875 24.9375 L 36.1875 23.3125 L 31.5625 23.3125 Z"
29467
30420
  }))
29468
30421
  };
29469
30422
  return (_icons$name$toLowerCa = icons[name === null || name === void 0 ? void 0 : name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
@@ -30790,23 +31743,8 @@ class Dashboard extends React.Component {
30790
31743
  });
30791
31744
  });
30792
31745
  _defineProperty$3(this, "onDeletePaymentMethodClick", source => {
30793
- const isDeletable = source === null || source === void 0 ? void 0 : source.deletable;
30794
- if (isDeletable) {
30795
- this.props.onClose();
30796
- notify$1.confirm((onSuccess, onFailure) => {
30797
- this.deletePaymentMethod(source.id, onSuccess, onFailure);
30798
- }, {
30799
- confirmMessage: this.locale("messages.paymentMethodDeletion.isSureToDelete"),
30800
- loadingMessage: this.locale("messages.paymentMethodDeletion.loading"),
30801
- successMessage: this.locale("messages.paymentMethodDeletion.success"),
30802
- errorMessage: this.locale("messages.paymentMethodDeletion.error")
30803
- }, {
30804
- closeButtonLabel: this.locale("labels.subCancellation.goBack")
30805
- });
30806
- } else {
30807
- this.props.setPaymentMethodToDelete(source.id);
30808
- return this.props.setView("payment-method-delete");
30809
- }
31746
+ this.props.setPaymentMethodToDelete(source.id);
31747
+ return this.props.setView("payment-method-delete");
30810
31748
  });
30811
31749
  _defineProperty$3(this, "displayRedeem", () => {
30812
31750
  return this.props.setView("gift-redeem");
@@ -35303,7 +36241,6 @@ exports.PaymentMethodCreateView = PaymentMethodCreateView;
35303
36241
  exports.PaymentMethodDeleteContainer = PaymentMethodDeleteContainer;
35304
36242
  exports.PaymentMethodDeleteList = PaymentMethodDeleteList;
35305
36243
  exports.PaymentMethodDeleteModal = PaymentMethodDeleteModal;
35306
- exports.PaymentMethodDeleteOptions = PaymentMethodDeleteOptions;
35307
36244
  exports.PaymentMethodDeleteSubmit = PaymentMethodDeleteSubmit;
35308
36245
  exports.PaymentMethodDeleteView = PaymentMethodDeleteView;
35309
36246
  exports.PaymentMethodSelectContainer = PaymentMethodSelectContainer;