@pelcro/react-pelcro-js 3.26.0-beta.28 → 3.26.0-beta.29

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
@@ -3354,17 +3354,23 @@ var select$6 = {
3354
3354
  changePaymentMethod: "Change"
3355
3355
  }
3356
3356
  };
3357
+ var create$5 = {
3358
+ title: "Add a new payment method",
3359
+ subtitle: "Enter the fields below to add your credit card information"
3360
+ };
3357
3361
  var paymentMethod_en = {
3358
3362
  update: update$3,
3359
3363
  select: select$6,
3360
3364
  "delete": {
3361
- title: "Active subscriptions are linked to this payment method.",
3362
- subtitle: "Please choose an existing card or add a new payment method.",
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.",
3363
3367
  options: {
3364
3368
  select: "Select an existing payment method",
3365
3369
  add: "Add a new payment method"
3366
- }
3367
- }
3370
+ },
3371
+ paymentMethodReplaced: "Payment Method Successfully Deleted and Replaced"
3372
+ },
3373
+ create: create$5
3368
3374
  };
3369
3375
 
3370
3376
  var title$z = "Enter your email to subscribe to our newsletter";
@@ -4300,9 +4306,23 @@ var select$4 = {
4300
4306
  changePaymentMethod: "Modifier"
4301
4307
  }
4302
4308
  };
4309
+ var create$4 = {
4310
+ title: "Ajouter un nouveau mode de paiement",
4311
+ subtitle: "Saisissez les champs ci-dessous pour ajouter les informations relatives à votre carte de crédit"
4312
+ };
4303
4313
  var paymentMethod_fr = {
4304
4314
  update: update$2,
4305
- select: select$4
4315
+ select: select$4,
4316
+ "delete": {
4317
+ title: "Supprimer un mode de paiement",
4318
+ subtitle: "Ce mode de paiement peut être associé à des abonnements actifs ou servir de mode de paiement par défaut. Veuillez choisir parmi les options disponibles ci-dessous pour le remplacement.",
4319
+ options: {
4320
+ select: "Sélectionner un mode de paiement existant",
4321
+ add: "Ajouter un nouveau mode de paiement"
4322
+ },
4323
+ paymentMethodReplaced: "Méthode de paiement supprimée et remplacée avec succès"
4324
+ },
4325
+ create: create$4
4306
4326
  };
4307
4327
 
4308
4328
  var title$q = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
@@ -4405,6 +4425,7 @@ var labels$P = {
4405
4425
  lastName: "Nom de famille",
4406
4426
  phone: "Téléphoner",
4407
4427
  freeItems: "Articles gratuits",
4428
+ isDefault: "Défini comme valeur par défaut",
4408
4429
  order: "Commande",
4409
4430
  amount: "Montant",
4410
4431
  email: "Courriel",
@@ -5227,9 +5248,23 @@ var select$2 = {
5227
5248
  changePaymentMethod: "변경"
5228
5249
  }
5229
5250
  };
5251
+ var create$3 = {
5252
+ title: "새 결제 방법 추가",
5253
+ subtitle: "신용카드 정보를 추가하려면 아래 입력란을 입력하세요."
5254
+ };
5230
5255
  var paymentMethod_ko = {
5231
5256
  update: update$1,
5232
- select: select$2
5257
+ select: select$2,
5258
+ "delete": {
5259
+ title: "결제 방법 삭제",
5260
+ subtitle: "이 결제 방법은 활성 구독과 연결되거나 기본 결제 방법으로 사용될 수 있습니다. 아래에서 사용 가능한 옵션 중에서 선택하여 대체하세요.",
5261
+ options: {
5262
+ select: "기존 결제 방법 선택",
5263
+ add: "새 결제 방법 추가"
5264
+ },
5265
+ paymentMethodReplaced: "결제 방법 삭제 및 교체 성공"
5266
+ },
5267
+ create: create$3
5233
5268
  };
5234
5269
 
5235
5270
  var title$h = "Frieze 뉴스레터를 구독하려면 이메일을 입력하세요.";
@@ -5335,7 +5370,8 @@ var labels$x = {
5335
5370
  order: "주문",
5336
5371
  amount: "금액",
5337
5372
  email: "이메일",
5338
- password: "비밀번호"
5373
+ password: "비밀번호",
5374
+ isDefault: "기본값으로 설정"
5339
5375
  };
5340
5376
  var checkoutForm_ko = {
5341
5377
  messages: messages$y,
@@ -6259,9 +6295,23 @@ var select = {
6259
6295
  changePaymentMethod: "Cambiar"
6260
6296
  }
6261
6297
  };
6298
+ var create$2 = {
6299
+ title: "Añadir un nuevo método de pago",
6300
+ subtitle: "Introduzca los campos siguientes para añadir los datos de su tarjeta de crédito"
6301
+ };
6262
6302
  var paymentMethod_es = {
6263
6303
  update: update,
6264
- select: select
6304
+ select: select,
6305
+ "delete": {
6306
+ title: "Eliminar método de pago",
6307
+ subtitle: "Este método de pago podría estar asociado a suscripciones activas o servir como método de pago predeterminado. Elija entre las opciones disponibles a continuación para sustituirlo.",
6308
+ options: {
6309
+ select: "Seleccione un método de pago existente",
6310
+ add: "Añadir un nuevo método de pago"
6311
+ },
6312
+ paymentMethodReplaced: "Método de pago eliminado y sustituido correctamente"
6313
+ },
6314
+ create: create$2
6265
6315
  };
6266
6316
 
6267
6317
  var title$8 = "Ingresa tu correo para suscribirte a nuestro boletín";
@@ -6367,7 +6417,8 @@ var labels$f = {
6367
6417
  order: "Pida",
6368
6418
  amount: "Importe",
6369
6419
  email: "Correo",
6370
- password: "Contraseña"
6420
+ password: "Contraseña",
6421
+ isDefault: "Fijar por defecto"
6371
6422
  };
6372
6423
  var checkoutForm_es = {
6373
6424
  messages: messages$f,
@@ -9407,6 +9458,9 @@ const initialState$o = {
9407
9458
  couponCode: null,
9408
9459
  // memberships
9409
9460
  selectedMembership: null,
9461
+ // paymentMethods
9462
+ paymentMethodToDelete: null,
9463
+ paymentMethodToEdit: null,
9410
9464
  // User
9411
9465
  isAuthenticated: () => window.Pelcro.user.isAuthenticated(),
9412
9466
  selectedPaymentMethodId: null,
@@ -12842,6 +12896,7 @@ const SET_CONFIRM_PASSWORD = "SET_CONFIRM_PASSWORD";
12842
12896
  const CONFIRM_PASSWORD_USED = "CONFIRM_PASSWORD_USED";
12843
12897
  const DISABLE_SUBMIT = "DISABLE_SUBMIT";
12844
12898
  const LOADING = "LOADING";
12899
+ const SKELETON_LOADER = "SKELETON_LOADER";
12845
12900
  const SUBMIT_PAYMENT = "SUBMIT_PAYMENT";
12846
12901
  const SUBSCRIBE = "CREATE_SUBSCRIPTION";
12847
12902
  const HANDLE_PAYPAL_SUBSCRIPTION = "HANDLE_PAYPAL_SUBSCRIPTION";
@@ -18292,7 +18347,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18292
18347
  purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
18293
18348
  } else if (type === "invoicePayment") {
18294
18349
  payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
18295
- } else if (type === "updatePaymentSource") {
18350
+ } else if (type === "createPaymentSource" || type === "updatePaymentSource") {
18296
18351
  createNewCybersourceCard();
18297
18352
  }
18298
18353
  function createNewCybersourceCard() {
@@ -18622,7 +18677,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18622
18677
  purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
18623
18678
  } else if (type === "invoicePayment") {
18624
18679
  payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
18625
- } else if (type === "updatePaymentSource") {
18680
+ } else if (type === "createPaymentSource" || type === "updatePaymentSource") {
18626
18681
  createNewTapCard();
18627
18682
  }
18628
18683
  function createNewTapCard() {
@@ -18833,12 +18888,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18833
18888
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
18834
18889
  } else if (type === "invoicePayment") {
18835
18890
  payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
18891
+ } else if (type === "createPaymentSource") {
18892
+ createNewVantivCard();
18836
18893
  } else if (type === "updatePaymentSource") {
18837
- if (paymentMethodToEdit) {
18838
- updateVantivCard();
18839
- } else {
18840
- createNewVantivCard();
18841
- }
18894
+ updateVantivCard();
18842
18895
  } else if (type === "deletePaymentSource") {
18843
18896
  replaceVantivCard();
18844
18897
  }
@@ -18908,15 +18961,15 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18908
18961
  payment_method_id: paymentMethodId
18909
18962
  }, (err, res) => {
18910
18963
  if (err) {
18911
- return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
18964
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
18965
+ return dispatch({
18966
+ type: SHOW_ALERT,
18967
+ payload: {
18968
+ type: "error",
18969
+ content: getErrorMessages(err)
18970
+ }
18971
+ });
18912
18972
  }
18913
- dispatch({
18914
- type: SHOW_ALERT,
18915
- payload: {
18916
- type: "success",
18917
- content: t("messages.sourceUpdated")
18918
- }
18919
- });
18920
18973
  onSuccess(res);
18921
18974
  });
18922
18975
  });
@@ -19807,7 +19860,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19807
19860
  }
19808
19861
  });
19809
19862
  };
19810
- const updatePaymentSource = (state, dispatch) => {
19863
+ const createPaymentSource = (state, dispatch) => {
19811
19864
  return stripe.createSource({
19812
19865
  type: "card"
19813
19866
  }).then(_ref8 => {
@@ -19861,6 +19914,120 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19861
19914
  });
19862
19915
  });
19863
19916
  };
19917
+ const updatePaymentSource = (state, dispatch) => {
19918
+ const {
19919
+ isDefault,
19920
+ month,
19921
+ year
19922
+ } = state;
19923
+ const {
19924
+ id: paymentMethodId
19925
+ } = paymentMethodToEdit;
19926
+ window.Pelcro.paymentMethods.update({
19927
+ auth_token: window.Pelcro.user.read().auth_token,
19928
+ payment_method_id: paymentMethodId,
19929
+ gateway: "stripe",
19930
+ exp_month: month,
19931
+ exp_year: year,
19932
+ is_default: isDefault
19933
+ }, (err, res) => {
19934
+ dispatch({
19935
+ type: DISABLE_SUBMIT,
19936
+ payload: false
19937
+ });
19938
+ dispatch({
19939
+ type: LOADING,
19940
+ payload: false
19941
+ });
19942
+ if (err) {
19943
+ onFailure(err);
19944
+ return dispatch({
19945
+ type: SHOW_ALERT,
19946
+ payload: {
19947
+ type: "error",
19948
+ content: getErrorMessages(err)
19949
+ }
19950
+ });
19951
+ }
19952
+ dispatch({
19953
+ type: SHOW_ALERT,
19954
+ payload: {
19955
+ type: "success",
19956
+ content: t("messages.sourceUpdated")
19957
+ }
19958
+ });
19959
+ onSuccess(res);
19960
+ });
19961
+ };
19962
+ const replacePaymentSource = (state, dispatch) => {
19963
+ const {
19964
+ id: paymentMethodId
19965
+ } = paymentMethodToDelete;
19966
+ return stripe.createSource({
19967
+ type: "card"
19968
+ }).then(_ref9 => {
19969
+ var _source$card3;
19970
+ let {
19971
+ source,
19972
+ error
19973
+ } = _ref9;
19974
+ if (error) {
19975
+ return handlePaymentError(error);
19976
+ }
19977
+
19978
+ // We don't support source creation for 3D secure yet
19979
+ if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required") {
19980
+ return handlePaymentError({
19981
+ error: {
19982
+ message: t("messages.cardAuthNotSupported")
19983
+ }
19984
+ });
19985
+ }
19986
+ window.Pelcro.paymentMethods.create({
19987
+ auth_token: window.Pelcro.user.read().auth_token,
19988
+ token: source.id
19989
+ }, (err, res) => {
19990
+ if (err) {
19991
+ onFailure(err);
19992
+ return dispatch({
19993
+ type: SHOW_ALERT,
19994
+ payload: {
19995
+ type: "error",
19996
+ content: getErrorMessages(err)
19997
+ }
19998
+ });
19999
+ }
20000
+ if (res) {
20001
+ setTimeout(() => {
20002
+ window.Pelcro.paymentMethods.deletePaymentMethod({
20003
+ auth_token: window.Pelcro.user.read().auth_token,
20004
+ payment_method_id: paymentMethodId
20005
+ }, (err, res) => {
20006
+ dispatch({
20007
+ type: DISABLE_SUBMIT,
20008
+ payload: false
20009
+ });
20010
+ dispatch({
20011
+ type: LOADING,
20012
+ payload: false
20013
+ });
20014
+ if (err) {
20015
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
20016
+ return dispatch({
20017
+ type: SHOW_ALERT,
20018
+ payload: {
20019
+ type: "error",
20020
+ content: getErrorMessages(err)
20021
+ }
20022
+ });
20023
+ }
20024
+ onSuccess(res);
20025
+ });
20026
+ }, 1000);
20027
+ }
20028
+ });
20029
+ });
20030
+ };
19864
20031
  const updatePaymentRequest = state => {
19865
20032
  var _state$paymentRequest;
19866
20033
  state === null || state === void 0 ? void 0 : (_state$paymentRequest = state.paymentRequest) === null || _state$paymentRequest === void 0 ? void 0 : _state$paymentRequest.update({
@@ -19940,12 +20107,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19940
20107
  }
19941
20108
  stripe.createSource({
19942
20109
  type: "card"
19943
- }).then(_ref9 => {
19944
- var _ref10, _ref11, _state$updatedPrice;
20110
+ }).then(_ref10 => {
20111
+ var _ref11, _ref12, _state$updatedPrice;
19945
20112
  let {
19946
20113
  source,
19947
20114
  error
19948
- } = _ref9;
20115
+ } = _ref10;
19949
20116
  if (error) {
19950
20117
  return handlePaymentError(error);
19951
20118
  }
@@ -19964,7 +20131,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19964
20131
  return total + item.price * item.quantity;
19965
20132
  }, 0);
19966
20133
  };
19967
- (_ref10 = (_ref11 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : 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();
20134
+ (_ref11 = (_ref12 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : 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();
19968
20135
  return handlePayment(source);
19969
20136
  }).catch(error => {
19970
20137
  return handlePaymentError(error);
@@ -20208,9 +20375,15 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20208
20375
  });
20209
20376
  }
20210
20377
  }
20378
+ if (type === "createPaymentSource") {
20379
+ return createPaymentSource(state, dispatch);
20380
+ }
20211
20381
  if (type === "updatePaymentSource") {
20212
20382
  return updatePaymentSource(state, dispatch);
20213
20383
  }
20384
+ if (type === "deletePaymentSource") {
20385
+ return replacePaymentSource(state, dispatch);
20386
+ }
20214
20387
  if (!isAuthenticated() && plan.type === "donation") {
20215
20388
  return sendRegisterRequest(state, () => submitPayment(state));
20216
20389
  } else {
@@ -20598,7 +20771,10 @@ const PelcroPaymentRequestButton = props => {
20598
20771
  }
20599
20772
  return null;
20600
20773
  };
20601
- const CheckoutForm = () => {
20774
+ const CheckoutForm = _ref => {
20775
+ let {
20776
+ type
20777
+ } = _ref;
20602
20778
  const {
20603
20779
  selectedPaymentMethodId
20604
20780
  } = usePelcro();
@@ -20635,6 +20811,21 @@ const CheckoutForm = () => {
20635
20811
  }))));
20636
20812
  }
20637
20813
  if (cardProcessor === "stripe") {
20814
+ if (type === "updatePaymentSource") {
20815
+ return /*#__PURE__*/React__default['default'].createElement("div", {
20816
+ className: "plc-flex plc-items-end plc-justify-between plc-my-2"
20817
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
20818
+ className: "plc-w-6/12 plc-pr-4"
20819
+ }, /*#__PURE__*/React__default['default'].createElement(MonthSelect, {
20820
+ store: store$l,
20821
+ placeholder: "Exp Month *"
20822
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
20823
+ className: "plc-w-6/12"
20824
+ }, /*#__PURE__*/React__default['default'].createElement(YearSelect, {
20825
+ store: store$l,
20826
+ placeholder: "Exp Year *"
20827
+ })));
20828
+ }
20638
20829
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
20639
20830
  autoFocus: true
20640
20831
  }), /*#__PURE__*/React__default['default'].createElement("img", {
@@ -21829,7 +22020,9 @@ function PaymentMethodView(_ref) {
21829
22020
  label: t("labels.email"),
21830
22021
  required: true,
21831
22022
  autoFocus: true
21832
- })), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, null), showCoupon && /*#__PURE__*/React__default['default'].createElement("div", {
22023
+ })), /*#__PURE__*/React__default['default'].createElement(CheckoutForm, {
22024
+ type: type
22025
+ }), showCoupon && /*#__PURE__*/React__default['default'].createElement("div", {
21833
22026
  className: "plc-mb-2"
21834
22027
  }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), type === "updatePaymentSource" && /*#__PURE__*/React__default['default'].createElement(PaymentMethodUpdateSetDefault, {
21835
22028
  id: "pelcro-input-is-default",
@@ -28548,7 +28741,10 @@ const initialState$4 = {
28548
28741
  paymentMethods: [],
28549
28742
  selectedPaymentMethodId: null,
28550
28743
  isSubmitting: false,
28551
- deleteOption: "add",
28744
+ deleteOption: "",
28745
+ disableSubmit: false,
28746
+ isLoading: false,
28747
+ skeletonLoader: true,
28552
28748
  alert: {
28553
28749
  type: "error",
28554
28750
  content: ""
@@ -28581,28 +28777,32 @@ const PaymentMethodDeleteContainer = _ref => {
28581
28777
  type: SET_PAYMENT_METHODS,
28582
28778
  payload: res.data
28583
28779
  });
28584
- // if (res.data.length !== 1) {
28585
- // dispatch({
28586
- // type: SET_DELETE_PAYMENT_METHOD_OPTION,
28587
- // payload: "select"
28588
- // });
28589
- // } else {
28590
- // dispatch({
28591
- // type: SET_DELETE_PAYMENT_METHOD_OPTION,
28592
- // payload: "add"
28593
- // });
28594
- // }
28780
+ dispatch({
28781
+ type: SKELETON_LOADER,
28782
+ payload: false
28783
+ });
28784
+ if (res.data.length !== 1) {
28785
+ dispatch({
28786
+ type: SET_DELETE_PAYMENT_METHOD_OPTION,
28787
+ payload: "select"
28788
+ });
28789
+ } else {
28790
+ dispatch({
28791
+ type: SET_DELETE_PAYMENT_METHOD_OPTION,
28792
+ payload: "add"
28793
+ });
28794
+ }
28595
28795
  }
28596
28796
  });
28597
- }, []);
28797
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
28798
+
28598
28799
  const setDefaultPaymentMethod = () => {
28599
28800
  const {
28600
28801
  selectedPaymentMethodId: paymentMethodId
28601
28802
  } = state;
28602
- window.Pelcro.paymentMethods.update({
28803
+ window.Pelcro.paymentMethods.setDefaultPaymentMethod({
28603
28804
  auth_token: window.Pelcro.user.read().auth_token,
28604
- payment_method_id: paymentMethodId,
28605
- is_default: true
28805
+ payment_method_id: paymentMethodId
28606
28806
  }, (err, res) => {
28607
28807
  if (err) {
28608
28808
  onFailure(err);
@@ -28614,7 +28814,9 @@ const PaymentMethodDeleteContainer = _ref => {
28614
28814
  }
28615
28815
  });
28616
28816
  }
28617
- deletePaymentMethod();
28817
+ setTimeout(() => {
28818
+ deletePaymentMethod();
28819
+ }, 1000);
28618
28820
  });
28619
28821
  };
28620
28822
  const deletePaymentMethod = () => {
@@ -28626,14 +28828,22 @@ const PaymentMethodDeleteContainer = _ref => {
28626
28828
  payment_method_id: paymentMethodId
28627
28829
  }, (err, res) => {
28628
28830
  if (err) {
28629
- return onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
28831
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
28832
+ return dispatch({
28833
+ type: SHOW_ALERT,
28834
+ payload: {
28835
+ type: "error",
28836
+ content: getErrorMessages(err)
28837
+ }
28838
+ });
28630
28839
  }
28631
28840
  dispatch({
28632
- type: SHOW_ALERT,
28633
- payload: {
28634
- type: "success",
28635
- content: "messages.sourceUpdated"
28636
- }
28841
+ type: DISABLE_SUBMIT,
28842
+ payload: false
28843
+ });
28844
+ dispatch({
28845
+ type: LOADING,
28846
+ payload: false
28637
28847
  });
28638
28848
  onSuccess(res);
28639
28849
  });
@@ -28648,7 +28858,8 @@ const PaymentMethodDeleteContainer = _ref => {
28648
28858
  case HANDLE_SUBMIT:
28649
28859
  return lib_5({
28650
28860
  ...state,
28651
- isSubmitting: true
28861
+ disableSubmit: true,
28862
+ isLoading: true
28652
28863
  }, (state, dispatch) => setDefaultPaymentMethod());
28653
28864
  case SET_DELETE_PAYMENT_METHOD_OPTION:
28654
28865
  return lib_7({
@@ -28660,6 +28871,26 @@ const PaymentMethodDeleteContainer = _ref => {
28660
28871
  ...state,
28661
28872
  paymentMethods: action.payload
28662
28873
  });
28874
+ case SHOW_ALERT:
28875
+ return lib_7({
28876
+ ...state,
28877
+ alert: action.payload
28878
+ });
28879
+ case DISABLE_SUBMIT:
28880
+ return lib_7({
28881
+ ...state,
28882
+ disableSubmit: action.payload
28883
+ });
28884
+ case LOADING:
28885
+ return lib_7({
28886
+ ...state,
28887
+ isLoading: action.payload
28888
+ });
28889
+ case SKELETON_LOADER:
28890
+ return lib_7({
28891
+ ...state,
28892
+ skeletonLoader: action.payload
28893
+ });
28663
28894
  default:
28664
28895
  return state;
28665
28896
  }
@@ -28694,8 +28925,8 @@ const PaymentMethodDeleteSubmit = _ref => {
28694
28925
  const {
28695
28926
  dispatch,
28696
28927
  state: {
28697
- selectedPaymentMethodId,
28698
- isSubmitting
28928
+ isLoading,
28929
+ isDisabled
28699
28930
  }
28700
28931
  } = React.useContext(store$4);
28701
28932
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
@@ -28705,8 +28936,8 @@ const PaymentMethodDeleteSubmit = _ref => {
28705
28936
  });
28706
28937
  onClick === null || onClick === void 0 ? void 0 : onClick();
28707
28938
  },
28708
- disabled: !selectedPaymentMethodId,
28709
- isLoading: isSubmitting,
28939
+ disabled: isDisabled,
28940
+ isLoading: isLoading,
28710
28941
  className: "plc-w-full"
28711
28942
  }, otherProps), name !== null && name !== void 0 ? name : t("select.buttons.selectPaymentMethod"));
28712
28943
  };
@@ -28720,7 +28951,8 @@ const PaymentMethodDeleteList = props => {
28720
28951
  state: {
28721
28952
  deleteOption,
28722
28953
  selectedPaymentMethodId,
28723
- paymentMethods
28954
+ paymentMethods,
28955
+ skeletonLoader
28724
28956
  }
28725
28957
  } = React.useContext(store$4);
28726
28958
  const {
@@ -28732,8 +28964,10 @@ const PaymentMethodDeleteList = props => {
28732
28964
  payload: event.target.value
28733
28965
  });
28734
28966
  };
28735
- return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethods && deleteOption === "select" && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
28736
- className: "plc-px-3 plc-py-2 plc-space-y-4 plc-overflow-y-scroll plc-max-h-80 pelcro-payment-method-select-wrapper"
28967
+ return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
28968
+ className: "plc-w-full plc-h-40 plc-bg-gray-300 plc-rounded-md plc-animate-pulse"
28969
+ }) : /*#__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", {
28970
+ 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"
28737
28971
  }, paymentMethods.filter(paymentMethod => (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id) !== (paymentMethodToDelete === null || paymentMethodToDelete === void 0 ? void 0 : paymentMethodToDelete.id)).map(paymentMethod => {
28738
28972
  var _paymentMethod$proper, _paymentMethod$proper2, _paymentMethod$proper3, _paymentMethod$proper4;
28739
28973
  const isSelected = selectedPaymentMethodId === String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id);
@@ -28752,10 +28986,12 @@ const PaymentMethodDeleteList = props => {
28752
28986
  className: "plc-flex plc-flex-col plc-text-lg pelcro-payment-method-details"
28753
28987
  }, /*#__PURE__*/React__default['default'].createElement("p", {
28754
28988
  className: "plc-font-semibold"
28755
- }, "\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", {
28989
+ }, "\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", {
28756
28990
  className: "plc-text-sm plc-text-gray-500"
28757
28991
  }, 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))));
28758
- })), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteSubmit, null)), deleteOption === "add" && /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, {
28992
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
28993
+ className: "plc-px-3"
28994
+ }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteSubmit, null))), deleteOption === "add" && /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, {
28759
28995
  type: "deletePaymentSource",
28760
28996
  showCoupon: false,
28761
28997
  showExternalPaymentMethods: false,
@@ -28764,14 +29000,15 @@ const PaymentMethodDeleteList = props => {
28764
29000
  onFailure: props.onFailure,
28765
29001
  onSuccess: props.onSuccess,
28766
29002
  setAsDefault: true
28767
- }));
29003
+ })));
28768
29004
  };
28769
29005
 
28770
29006
  const PaymentMethodDeleteOptions = _ref => {
28771
29007
  const {
28772
29008
  state: {
28773
29009
  deleteOption,
28774
- paymentMethods
29010
+ paymentMethods,
29011
+ skeletonLoader
28775
29012
  },
28776
29013
  dispatch
28777
29014
  } = React.useContext(store$4);
@@ -28786,27 +29023,53 @@ const PaymentMethodDeleteOptions = _ref => {
28786
29023
  };
28787
29024
  return /*#__PURE__*/React__default['default'].createElement("div", {
28788
29025
  className: "plc-text-left plc-mr-auto plc-mb-6"
29026
+ }, skeletonLoader ? /*#__PURE__*/React__default['default'].createElement("div", {
29027
+ className: "plc-flex plc-flex-col plc-space-y-3"
28789
29028
  }, /*#__PURE__*/React__default['default'].createElement(Radio, {
29029
+ className: "plc-animate-puls"
29030
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
29031
+ className: "plc-w-36 plc-bg-gray-300 plc-h-4 plc-rounded-md plc-animate-pulse"
29032
+ })), /*#__PURE__*/React__default['default'].createElement(Radio, {
29033
+ className: "plc-animate-pulse"
29034
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
29035
+ className: "plc-w-36 plc-bg-gray-300 plc-h-4 plc-rounded-md plc-animate-pulse"
29036
+ }))) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, paymentMethods && paymentMethods.length !== 1 && /*#__PURE__*/React__default['default'].createElement(Radio, {
29037
+ onChange: handleOptionSelect,
29038
+ checked: deleteOption === "select",
29039
+ value: "select"
29040
+ }, t("delete.options.select")), /*#__PURE__*/React__default['default'].createElement(Radio, {
28790
29041
  onChange: handleOptionSelect,
28791
29042
  checked: deleteOption === "add",
28792
29043
  value: "add"
28793
- }, t("delete.options.add")));
29044
+ }, t("delete.options.add"))));
28794
29045
  };
28795
29046
 
28796
- function PaymentMethodDeleteView() {
29047
+ function PaymentMethodDeleteView(props) {
28797
29048
  const [t] = useTranslation("paymentMethod");
28798
29049
  return /*#__PURE__*/React__default['default'].createElement("div", {
28799
29050
  id: "pelcro-payment-method-delete-view"
28800
29051
  }, /*#__PURE__*/React__default['default'].createElement("div", {
28801
- className: "plc-mb-2 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
29052
+ className: "plc-mb-6 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
28802
29053
  }, /*#__PURE__*/React__default['default'].createElement("h4", {
28803
- className: "plc-text-2xl plc-font-semibold"
28804
- }, t("delete.title")), /*#__PURE__*/React__default['default'].createElement("p", null, t("delete.subtitle"))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteContainer, null, /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteOptions, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteList, null)));
29054
+ className: "plc-text-2xl plc-font-semibold plc-mb-2"
29055
+ }, t("delete.title")), /*#__PURE__*/React__default['default'].createElement("p", {
29056
+ className: ""
29057
+ }, t("delete.subtitle"))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteContainer, props, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
29058
+ className: "plc-mb-2"
29059
+ }), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteOptions, null), /*#__PURE__*/React__default['default'].createElement(PaymentMethodDeleteList, {
29060
+ onSuccess: props.onSuccess
29061
+ })));
28805
29062
  }
28806
29063
 
28807
29064
  const PaymentMethodDeleteModal = props => {
28808
29065
  var _window, _window$Pelcro, _window$Pelcro$uiSett;
29066
+ const {
29067
+ t
29068
+ } = useTranslation("paymentMethod");
28809
29069
  const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
29070
+ const {
29071
+ resetView
29072
+ } = usePelcro();
28810
29073
  const onSuccess = res => {
28811
29074
  var _props$onSuccess;
28812
29075
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
@@ -28822,6 +29085,8 @@ const PaymentMethodDeleteModal = props => {
28822
29085
  nonInteraction: true
28823
29086
  });
28824
29087
  }
29088
+ notify.success(t("delete.paymentMethodReplaced"));
29089
+ resetView();
28825
29090
  };
28826
29091
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
28827
29092
  id: "pelcro-payment-method-delete-modal",
@@ -28833,6 +29098,64 @@ const PaymentMethodDeleteModal = props => {
28833
29098
  };
28834
29099
  PaymentMethodDeleteModal.viewId = "payment-method-delete";
28835
29100
 
29101
+ const PaymentMethodCreateContainer = props => {
29102
+ return /*#__PURE__*/React__default['default'].createElement(PaymentMethodContainer, Object.assign({
29103
+ type: "createPaymentSource",
29104
+ className: "pelcro-payment-create-container"
29105
+ }, props));
29106
+ };
29107
+
29108
+ /**
29109
+ *
29110
+ */
29111
+ function PaymentMethodCreateView(props) {
29112
+ const [t] = useTranslation("paymentMethod");
29113
+ return /*#__PURE__*/React__default['default'].createElement("div", {
29114
+ id: "pelcro-payment-method-create-view"
29115
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
29116
+ className: "plc-mb-2 plc-text-center plc-text-gray-900 pelcro-title-wrapper"
29117
+ }, /*#__PURE__*/React__default['default'].createElement("h4", {
29118
+ className: "plc-text-2xl plc-font-semibold "
29119
+ }, t("create.title")), /*#__PURE__*/React__default['default'].createElement("p", null, t("create.subtitle"))), /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, {
29120
+ type: "createPaymentSource",
29121
+ showCoupon: false,
29122
+ showExternalPaymentMethods: false,
29123
+ showApplePayButton: false,
29124
+ onDisplay: props.onDisplay,
29125
+ onFailure: props.onFailure,
29126
+ onSuccess: props.onSuccess
29127
+ }));
29128
+ }
29129
+
29130
+ const PaymentMethodCreateModal = props => {
29131
+ var _window, _window$Pelcro, _window$Pelcro$uiSett;
29132
+ const enableReactGA4 = (_window = window) === null || _window === void 0 ? void 0 : (_window$Pelcro = _window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.enableReactGA4;
29133
+ const onSuccess = res => {
29134
+ var _props$onSuccess;
29135
+ (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
29136
+ if (enableReactGA4) {
29137
+ ReactGA4.event("Created payment card", {
29138
+ nonInteraction: true
29139
+ });
29140
+ } else {
29141
+ var _ReactGA$event;
29142
+ ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$event = ReactGA.event) === null || _ReactGA$event === void 0 ? void 0 : _ReactGA$event.call(ReactGA, {
29143
+ category: "ACTIONS",
29144
+ action: "Created payment card",
29145
+ nonInteraction: true
29146
+ });
29147
+ }
29148
+ };
29149
+ return /*#__PURE__*/React__default['default'].createElement(Modal, {
29150
+ id: "pelcro-payment-method-create-modal",
29151
+ onDisplay: props.onDisplay,
29152
+ onClose: props.onClose
29153
+ }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(PaymentMethodCreateView, Object.assign({}, props, {
29154
+ onSuccess: onSuccess
29155
+ }))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
29156
+ };
29157
+ PaymentMethodCreateModal.viewId = "payment-method-create";
29158
+
28836
29159
  function _extends$i() {
28837
29160
  _extends$i = Object.assign || function (target) {
28838
29161
  for (var i = 1; i < arguments.length; i++) {
@@ -31301,16 +31624,15 @@ class Dashboard extends React.Component {
31301
31624
  } else {
31302
31625
  this.props.setPaymentMethodToDelete(source.id);
31303
31626
  return this.props.setView("payment-method-delete");
31304
- // this.props.onClose();
31305
- // notify.warning(
31306
- // this.locale("messages.paymentMethodDeletion.nonDeletable")
31307
- // );
31308
31627
  }
31309
31628
  });
31310
31629
  _defineProperty$3(this, "displayRedeem", () => {
31311
31630
  return this.props.setView("gift-redeem");
31312
31631
  });
31313
- _defineProperty$3(this, "displaySourceCreate", e => {
31632
+ _defineProperty$3(this, "displaySourceCreate", () => {
31633
+ return this.props.setView("payment-method-create");
31634
+ });
31635
+ _defineProperty$3(this, "displaySourceEdit", e => {
31314
31636
  const source = e.currentTarget.dataset.key;
31315
31637
  this.props.setPaymentMethodToEdit(source);
31316
31638
  return this.props.setView("payment-method-update");
@@ -31590,7 +31912,7 @@ class Dashboard extends React.Component {
31590
31912
  className: "plc-text-white",
31591
31913
  icon: /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
31592
31914
  "data-key": source.id,
31593
- onClick: this.displaySourceCreate,
31915
+ onClick: this.displaySourceEdit,
31594
31916
  disabled: this.state.disableSubmit
31595
31917
  }), /*#__PURE__*/React__default['default'].createElement(Button, {
31596
31918
  id: "pelcro-button-delete-source-" + index,
@@ -35808,6 +36130,9 @@ exports.PasswordlessRequestViewButton = PasswordlessRequestViewButton;
35808
36130
  exports.PaymentCreateContainer = PaymentCreateContainer;
35809
36131
  exports.PaymentCreateView = PaymentCreateView;
35810
36132
  exports.PaymentMethodContainer = PaymentMethodContainer;
36133
+ exports.PaymentMethodCreateContainer = PaymentMethodCreateContainer;
36134
+ exports.PaymentMethodCreateModal = PaymentMethodCreateModal;
36135
+ exports.PaymentMethodCreateView = PaymentMethodCreateView;
35811
36136
  exports.PaymentMethodDeleteContainer = PaymentMethodDeleteContainer;
35812
36137
  exports.PaymentMethodDeleteList = PaymentMethodDeleteList;
35813
36138
  exports.PaymentMethodDeleteModal = PaymentMethodDeleteModal;