@pelcro/react-pelcro-js 3.26.0-beta.77 → 3.26.0-beta.79

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
@@ -3541,7 +3541,9 @@ var messages$17 = {
3541
3541
  }
3542
3542
  };
3543
3543
  var errors$h = {
3544
- "": ""
3544
+ facebookNoEmail: "Your Facebook account doesn't have an email address. Please use a different login method or add an email to your Facebook account.",
3545
+ googleNoEmail: "Your Google account doesn't have an email address. Please use a different login method or add an email to your Google account.",
3546
+ auth0NoEmail: "Your Auth0 account doesn't have an email address. Please use a different login method or add an email to your Auth0 account."
3545
3547
  };
3546
3548
  var login_en = {
3547
3549
  labels: labels$14,
@@ -3602,7 +3604,9 @@ var messages$15 = {
3602
3604
  }
3603
3605
  };
3604
3606
  var errors$g = {
3605
- "": ""
3607
+ facebookNoEmail: "Your Facebook account doesn't have an email address. Please use a different login method or add an email to your Facebook account.",
3608
+ googleNoEmail: "Your Google account doesn't have an email address. Please use a different login method or add an email to your Google account.",
3609
+ auth0NoEmail: "Your Auth0 account doesn't have an email address. Please use a different login method or add an email to your Auth0 account."
3606
3610
  };
3607
3611
  var gift$3 = {
3608
3612
  titles: {
@@ -4503,7 +4507,9 @@ var messages$Q = {
4503
4507
  }
4504
4508
  };
4505
4509
  var errors$c = {
4506
- "": ""
4510
+ facebookNoEmail: "Votre compte Facebook n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Facebook.",
4511
+ googleNoEmail: "Votre compte Google n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Google.",
4512
+ auth0NoEmail: "Votre compte Auth0 n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Auth0."
4507
4513
  };
4508
4514
  var login_fr = {
4509
4515
  labels: labels$O,
@@ -4564,7 +4570,9 @@ var messages$O = {
4564
4570
  }
4565
4571
  };
4566
4572
  var errors$b = {
4567
- "": ""
4573
+ facebookNoEmail: "Votre compte Facebook n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Facebook.",
4574
+ googleNoEmail: "Votre compte Google n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Google.",
4575
+ auth0NoEmail: "Votre compte Auth0 n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Auth0."
4568
4576
  };
4569
4577
  var gift$2 = {
4570
4578
  titles: {
@@ -5455,7 +5463,9 @@ var messages$x = {
5455
5463
  }
5456
5464
  };
5457
5465
  var errors$7 = {
5458
- "": ""
5466
+ facebookNoEmail: "Facebook 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Facebook 계정에 이메일을 추가해 주세요.",
5467
+ googleNoEmail: "Google 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Google 계정에 이메일을 추가해 주세요.",
5468
+ auth0NoEmail: "Auth0 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Auth0 계정에 이메일을 추가해 주세요."
5459
5469
  };
5460
5470
  var login_ko = {
5461
5471
  labels: labels$w,
@@ -5516,7 +5526,9 @@ var messages$v = {
5516
5526
  }
5517
5527
  };
5518
5528
  var errors$6 = {
5519
- "": ""
5529
+ facebookNoEmail: "Facebook 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Facebook 계정에 이메일을 추가해 주세요.",
5530
+ googleNoEmail: "Google 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Google 계정에 이메일을 추가해 주세요.",
5531
+ auth0NoEmail: "Auth0 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Auth0 계정에 이메일을 추가해 주세요."
5520
5532
  };
5521
5533
  var gift$1 = {
5522
5534
  titles: {
@@ -6509,7 +6521,9 @@ var messages$e = {
6509
6521
  }
6510
6522
  };
6511
6523
  var errors$2 = {
6512
- "": ""
6524
+ facebookNoEmail: "Tu cuenta de Facebook no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Facebook.",
6525
+ googleNoEmail: "Tu cuenta de Google no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Google.",
6526
+ auth0NoEmail: "Tu cuenta de Auth0 no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Auth0."
6513
6527
  };
6514
6528
  var login_es = {
6515
6529
  labels: labels$e,
@@ -6570,7 +6584,9 @@ var messages$c = {
6570
6584
  }
6571
6585
  };
6572
6586
  var errors$1 = {
6573
- "": ""
6587
+ facebookNoEmail: "Tu cuenta de Facebook no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Facebook.",
6588
+ googleNoEmail: "Tu cuenta de Google no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Google.",
6589
+ auth0NoEmail: "Tu cuenta de Auth0 no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Auth0."
6574
6590
  };
6575
6591
  var gift = {
6576
6592
  titles: {
@@ -14083,6 +14099,9 @@ const FacebookLoginButton = _ref => {
14083
14099
  labelClassName = "",
14084
14100
  iconClassName = ""
14085
14101
  } = _ref;
14102
+ const {
14103
+ t
14104
+ } = useTranslation("login");
14086
14105
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
14087
14106
  const {
14088
14107
  dispatch: loginDispatch
@@ -14091,6 +14110,27 @@ const FacebookLoginButton = _ref => {
14091
14110
  dispatch: registerDispatch
14092
14111
  } = React.useContext(store$m);
14093
14112
  const onSuccess = facebookUser => {
14113
+ // Check if email is provided by Facebook
14114
+ if (!(facebookUser !== null && facebookUser !== void 0 && facebookUser.email)) {
14115
+ // Show error message for both login and register stores
14116
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14117
+ type: SHOW_ALERT,
14118
+ payload: {
14119
+ type: "error",
14120
+ content: t("errors.facebookNoEmail")
14121
+ }
14122
+ });
14123
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14124
+ type: SHOW_ALERT,
14125
+ payload: {
14126
+ type: "error",
14127
+ content: t("errors.facebookNoEmail")
14128
+ }
14129
+ });
14130
+ return;
14131
+ }
14132
+
14133
+ // Proceed with social login if email is available
14094
14134
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14095
14135
  type: HANDLE_SOCIAL_LOGIN,
14096
14136
  payload: {
@@ -14246,6 +14286,9 @@ const GoogleLoginButton = _ref => {
14246
14286
  labelClassName = "",
14247
14287
  iconClassName = ""
14248
14288
  } = _ref;
14289
+ const {
14290
+ t
14291
+ } = useTranslation("login");
14249
14292
  const googleClientId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
14250
14293
  const {
14251
14294
  dispatch: loginDispatch
@@ -14261,15 +14304,38 @@ const GoogleLoginButton = _ref => {
14261
14304
  });
14262
14305
  }, []);
14263
14306
  const onSuccess = response => {
14264
- var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
14307
+ var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getGivenName2, _profile$getFamilyNam2;
14265
14308
  const profile = response.getBasicProfile();
14266
14309
  const accessToken = (_response$getAuthResp = response.getAuthResponse()) === null || _response$getAuthResp === void 0 ? void 0 : _response$getAuthResp.id_token;
14310
+ const email = (_profile$getEmail = profile.getEmail) === null || _profile$getEmail === void 0 ? void 0 : _profile$getEmail.call(profile);
14311
+
14312
+ // Check if email is provided by Google
14313
+ if (!email) {
14314
+ // Show error message for both login and register stores
14315
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14316
+ type: SHOW_ALERT,
14317
+ payload: {
14318
+ type: "error",
14319
+ content: t("errors.googleNoEmail")
14320
+ }
14321
+ });
14322
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14323
+ type: SHOW_ALERT,
14324
+ payload: {
14325
+ type: "error",
14326
+ content: t("errors.googleNoEmail")
14327
+ }
14328
+ });
14329
+ return;
14330
+ }
14331
+
14332
+ // Proceed with social login if email is available
14267
14333
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14268
14334
  type: HANDLE_SOCIAL_LOGIN,
14269
14335
  payload: {
14270
14336
  idpName: "google",
14271
14337
  idpToken: accessToken,
14272
- email: (_profile$getEmail = profile.getEmail) === null || _profile$getEmail === void 0 ? void 0 : _profile$getEmail.call(profile),
14338
+ email: email,
14273
14339
  firstName: (_profile$getGivenName = profile.getGivenName) === null || _profile$getGivenName === void 0 ? void 0 : _profile$getGivenName.call(profile),
14274
14340
  lastName: (_profile$getFamilyNam = profile.getFamilyName) === null || _profile$getFamilyNam === void 0 ? void 0 : _profile$getFamilyNam.call(profile)
14275
14341
  }
@@ -14279,7 +14345,7 @@ const GoogleLoginButton = _ref => {
14279
14345
  payload: {
14280
14346
  idpName: "google",
14281
14347
  idpToken: accessToken,
14282
- email: (_profile$getEmail2 = profile.getEmail) === null || _profile$getEmail2 === void 0 ? void 0 : _profile$getEmail2.call(profile),
14348
+ email: email,
14283
14349
  firstName: (_profile$getGivenName2 = profile.getGivenName) === null || _profile$getGivenName2 === void 0 ? void 0 : _profile$getGivenName2.call(profile),
14284
14350
  lastName: (_profile$getFamilyNam2 = profile.getFamilyName) === null || _profile$getFamilyNam2 === void 0 ? void 0 : _profile$getFamilyNam2.call(profile)
14285
14351
  }
@@ -14351,6 +14417,9 @@ const Auth0LoginButton = _ref => {
14351
14417
  const {
14352
14418
  dispatch: registerDispatch
14353
14419
  } = React.useContext(store$m);
14420
+ const {
14421
+ t
14422
+ } = useTranslation("login");
14354
14423
  function handleClick() {
14355
14424
  var _auth0InstanceRef$cur, _auth0InstanceRef$cur2, _auth0InstanceRef$cur3;
14356
14425
  if (!auth0Loaded) {
@@ -14382,6 +14451,28 @@ const Auth0LoginButton = _ref => {
14382
14451
  given_name,
14383
14452
  family_name
14384
14453
  } = user;
14454
+
14455
+ // Check if email is provided by Auth0
14456
+ if (!email) {
14457
+ // Show error message for both login and register stores
14458
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14459
+ type: SHOW_ALERT,
14460
+ payload: {
14461
+ type: "error",
14462
+ content: t("errors.auth0NoEmail")
14463
+ }
14464
+ });
14465
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14466
+ type: SHOW_ALERT,
14467
+ payload: {
14468
+ type: "error",
14469
+ content: t("errors.auth0NoEmail")
14470
+ }
14471
+ });
14472
+ return;
14473
+ }
14474
+
14475
+ // Proceed with social login if email is available
14385
14476
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14386
14477
  type: HANDLE_SOCIAL_LOGIN,
14387
14478
  payload: {
@@ -18214,7 +18305,9 @@ class CybersourceGateway {
18214
18305
  quantity = 1,
18215
18306
  addressId,
18216
18307
  isExistingSource,
18217
- fingerprint_session_id
18308
+ fingerprint_session_id,
18309
+ cardExpirationMonth,
18310
+ cardExpirationYear
18218
18311
  } = options;
18219
18312
  const params = isExistingSource ? {
18220
18313
  source_id: token
@@ -18230,6 +18323,8 @@ class CybersourceGateway {
18230
18323
  coupon_code: couponCode,
18231
18324
  address_id: product.address_required ? addressId : null,
18232
18325
  fingerprint_session_id: fingerprint_session_id,
18326
+ card_expiration_month: cardExpirationMonth,
18327
+ card_expiration_year: cardExpirationYear,
18233
18328
  ...params
18234
18329
  }, (err, res) => {
18235
18330
  callback(err, res);
@@ -18246,7 +18341,9 @@ class CybersourceGateway {
18246
18341
  couponCode,
18247
18342
  product,
18248
18343
  addressId,
18249
- isExistingSource
18344
+ isExistingSource,
18345
+ cardExpirationMonth,
18346
+ cardExpirationYear
18250
18347
  } = options;
18251
18348
  const params = isExistingSource ? {
18252
18349
  source_id: token
@@ -18261,6 +18358,8 @@ class CybersourceGateway {
18261
18358
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
18262
18359
  subscription_id: subscriptionIdToRenew,
18263
18360
  address_id: product.address_required ? addressId : null,
18361
+ card_expiration_month: cardExpirationMonth,
18362
+ card_expiration_year: cardExpirationYear,
18264
18363
  ...params
18265
18364
  }, (err, res) => {
18266
18365
  callback(err, res);
@@ -18278,7 +18377,9 @@ class CybersourceGateway {
18278
18377
  giftRecipient,
18279
18378
  quantity = 1,
18280
18379
  addressId,
18281
- isExistingSource
18380
+ isExistingSource,
18381
+ cardExpirationMonth,
18382
+ cardExpirationYear
18282
18383
  } = options;
18283
18384
  const params = isExistingSource ? {
18284
18385
  source_id: token
@@ -18298,6 +18399,8 @@ class CybersourceGateway {
18298
18399
  gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
18299
18400
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
18300
18401
  address_id: product.address_required ? addressId : null,
18402
+ card_expiration_month: cardExpirationMonth,
18403
+ card_expiration_year: cardExpirationYear,
18301
18404
  ...params
18302
18405
  }, (err, res) => {
18303
18406
  callback(err, res);
@@ -18314,7 +18417,9 @@ class CybersourceGateway {
18314
18417
  plan,
18315
18418
  couponCode,
18316
18419
  addressId,
18317
- isExistingSource
18420
+ isExistingSource,
18421
+ cardExpirationMonth,
18422
+ cardExpirationYear
18318
18423
  } = options;
18319
18424
  const params = isExistingSource ? {
18320
18425
  source_id: token
@@ -18328,6 +18433,8 @@ class CybersourceGateway {
18328
18433
  coupon_code: couponCode,
18329
18434
  subscription_id: subscriptionIdToRenew,
18330
18435
  address_id: product.address_required ? addressId : null,
18436
+ card_expiration_month: cardExpirationMonth,
18437
+ card_expiration_year: cardExpirationYear,
18331
18438
  ...params
18332
18439
  }, (err, res) => {
18333
18440
  callback(err, res);
@@ -18342,7 +18449,9 @@ class CybersourceGateway {
18342
18449
  items,
18343
18450
  couponCode,
18344
18451
  addressId,
18345
- isExistingSource
18452
+ isExistingSource,
18453
+ cardExpirationMonth,
18454
+ cardExpirationYear
18346
18455
  } = options;
18347
18456
  const params = isExistingSource ? {
18348
18457
  source_id: token
@@ -18357,7 +18466,9 @@ class CybersourceGateway {
18357
18466
  ...params,
18358
18467
  ...(addressId && {
18359
18468
  address_id: addressId
18360
- })
18469
+ }),
18470
+ card_expiration_month: cardExpirationMonth,
18471
+ card_expiration_year: cardExpirationYear
18361
18472
  }, (err, res) => {
18362
18473
  callback(err, res);
18363
18474
  });
@@ -18798,7 +18909,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18798
18909
  }
18799
18910
  });
18800
18911
  }
18801
- handleCybersourcePayment(response.token, state);
18912
+ handleCybersourcePayment(response, state);
18802
18913
  });
18803
18914
  };
18804
18915
  function handleCybersourcePayment(paymentRequest, state) {
@@ -18816,7 +18927,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18816
18927
  window.Pelcro.source.create({
18817
18928
  auth_token: window.Pelcro.user.read().auth_token,
18818
18929
  token: paymentRequest,
18819
- gateway: "cybersource"
18930
+ gateway: "cybersource",
18931
+ cardExpirationMonth: state.month,
18932
+ cardExpirationYear: state.year
18820
18933
  }, (err, res) => {
18821
18934
  dispatch({
18822
18935
  type: DISABLE_SUBMIT,
@@ -18844,6 +18957,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18844
18957
  content: t("messages.sourceUpdated")
18845
18958
  }
18846
18959
  });
18960
+
18961
+ // Reinitialize Cybersource microform after successful payment
18962
+ setTimeout(() => {
18963
+ cybersourceInstanceRef.current = null;
18964
+ initCybersourceScript();
18965
+ }, 1000);
18847
18966
  onSuccess(res);
18848
18967
  } //
18849
18968
  );
@@ -18867,11 +18986,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18867
18986
  product,
18868
18987
  isExistingSource: isUsingExistingPaymentMethod,
18869
18988
  subscriptionIdToRenew,
18870
- addressId: selectedAddressId
18989
+ addressId: selectedAddressId,
18990
+ cardExpirationMonth: state.month,
18991
+ cardExpirationYear: state.year
18871
18992
  }, (err, res) => {
18872
18993
  if (err) {
18873
18994
  return handlePaymentError(err);
18874
18995
  }
18996
+
18997
+ // Reinitialize Cybersource microform after successful payment
18998
+ setTimeout(() => {
18999
+ cybersourceInstanceRef.current = null;
19000
+ initCybersourceScript();
19001
+ }, 1000);
18875
19002
  onSuccess(res);
18876
19003
  });
18877
19004
  } else if (giftSubscriprition) {
@@ -18884,11 +19011,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18884
19011
  product,
18885
19012
  isExistingSource: isUsingExistingPaymentMethod,
18886
19013
  giftRecipient,
18887
- addressId: selectedAddressId
19014
+ addressId: selectedAddressId,
19015
+ cardExpirationMonth: state.month,
19016
+ cardExpirationYear: state.year
18888
19017
  }, (err, res) => {
18889
19018
  if (err) {
18890
19019
  return handlePaymentError(err);
18891
19020
  }
19021
+
19022
+ // Reinitialize Cybersource microform after successful payment
19023
+ setTimeout(() => {
19024
+ cybersourceInstanceRef.current = null;
19025
+ initCybersourceScript();
19026
+ }, 1000);
18892
19027
  onSuccess(res);
18893
19028
  });
18894
19029
  } else if (renewSubscription) {
@@ -18901,11 +19036,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18901
19036
  product,
18902
19037
  isExistingSource: isUsingExistingPaymentMethod,
18903
19038
  subscriptionIdToRenew,
18904
- addressId: selectedAddressId
19039
+ addressId: selectedAddressId,
19040
+ cardExpirationMonth: state.month,
19041
+ cardExpirationYear: state.year
18905
19042
  }, (err, res) => {
18906
19043
  if (err) {
18907
19044
  return handlePaymentError(err);
18908
19045
  }
19046
+
19047
+ // Reinitialize Cybersource microform after successful payment
19048
+ setTimeout(() => {
19049
+ cybersourceInstanceRef.current = null;
19050
+ initCybersourceScript();
19051
+ }, 1000);
18909
19052
  onSuccess(res);
18910
19053
  });
18911
19054
  } else if (createSubscription) {
@@ -18918,22 +19061,27 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18918
19061
  product,
18919
19062
  isExistingSource: isUsingExistingPaymentMethod,
18920
19063
  addressId: selectedAddressId,
18921
- fingerprint_session_id: state.cyberSourceSessionId
19064
+ fingerprint_session_id: state.cyberSourceSessionId,
19065
+ cardExpirationMonth: state.month,
19066
+ cardExpirationYear: state.year
18922
19067
  }, (err, res) => {
18923
19068
  if (err) {
18924
19069
  return handlePaymentError(err);
18925
19070
  }
19071
+
19072
+ // Reinitialize Cybersource microform after successful payment
19073
+ setTimeout(() => {
19074
+ cybersourceInstanceRef.current = null;
19075
+ initCybersourceScript();
19076
+ }, 1000);
18926
19077
  onSuccess(res);
18927
19078
  });
18928
19079
  }
18929
19080
  }
18930
19081
  }
18931
- const tokenizeCard = (error, microformInstance) => {
18932
- if (error) {
18933
- return;
18934
- }
18935
- cybersourceInstanceRef.current = microformInstance;
18936
- };
19082
+
19083
+ // No longer needed - microform instance is stored directly in initCybersourceScript
19084
+
18937
19085
  const appendCybersourceFingerprintScripts = () => {
18938
19086
  var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4;
18939
19087
  const uniqueId = crypto.randomUUID();
@@ -18957,6 +19105,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18957
19105
  }
18958
19106
  };
18959
19107
  const initCybersourceScript = () => {
19108
+ // Clear existing card number field before reinitializing
19109
+ const cardNumberElement = document.querySelector("#cybersourceCardNumber");
19110
+ if (cardNumberElement) {
19111
+ cardNumberElement.innerHTML = "";
19112
+ }
19113
+
18960
19114
  // jwk api call
18961
19115
  window.Pelcro.payment.getJWK({
18962
19116
  auth_token: window.Pelcro.user.read().auth_token,
@@ -18981,35 +19135,56 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18981
19135
  });
18982
19136
  }
18983
19137
  const {
18984
- key: jwk
19138
+ key: jwk,
19139
+ captureContext,
19140
+ js_client
18985
19141
  } = res;
18986
- // SETUP MICROFORM
18987
- // eslint-disable-next-line no-undef
18988
- FLEX.microform({
18989
- keyId: jwk.kid,
18990
- keystore: jwk,
18991
- container: "#cybersourceCardNumber",
18992
- placeholder: "Card Number",
18993
- styles: {
18994
- input: {
18995
- "font-size": "14px",
18996
- "font-family": "helvetica, tahoma, calibri, sans-serif",
18997
- color: "#555"
18998
- },
18999
- ":focus": {
19000
- color: "blue"
19001
- },
19002
- ":disabled": {
19003
- cursor: "not-allowed"
19004
- },
19005
- valid: {
19006
- color: "#3c763d"
19007
- },
19008
- invalid: {
19009
- color: "#a94442"
19142
+
19143
+ // Load the SDK from the dynamic URL (if not already loaded)
19144
+ const existingScript = document.querySelector(`script[src="${js_client}"]`);
19145
+ if (!existingScript) {
19146
+ window.Pelcro.helpers.loadSDK(js_client, "cybersource-cdn");
19147
+ }
19148
+ const initializeMicroform = () => {
19149
+ // SETUP MICROFORM
19150
+ // eslint-disable-next-line no-undef
19151
+ const flex = new Flex(captureContext);
19152
+ const microform = flex.microform({
19153
+ styles: {
19154
+ input: {
19155
+ "font-size": "14px",
19156
+ "font-family": "helvetica, tahoma, calibri, sans-serif",
19157
+ color: "#555"
19158
+ },
19159
+ ":focus": {
19160
+ color: "blue"
19161
+ },
19162
+ ":disabled": {
19163
+ cursor: "not-allowed"
19164
+ },
19165
+ valid: {
19166
+ color: "#3c763d"
19167
+ },
19168
+ invalid: {
19169
+ color: "#a94442"
19170
+ }
19010
19171
  }
19011
- }
19012
- }, tokenizeCard);
19172
+ });
19173
+ const number = microform.createField("number", {
19174
+ placeholder: "Enter your card number"
19175
+ });
19176
+ number.load("#cybersourceCardNumber");
19177
+ cybersourceInstanceRef.current = microform;
19178
+ };
19179
+
19180
+ // Wait for SDK to load then initialize microform
19181
+ if (existingScript) {
19182
+ // Script already loaded, initialize immediately
19183
+ initializeMicroform();
19184
+ } else {
19185
+ // Wait for new script to load
19186
+ document.querySelector(`script[src="${js_client}"]`).addEventListener("load", initializeMicroform);
19187
+ }
19013
19188
  });
19014
19189
  };
19015
19190
 
@@ -20205,13 +20380,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20205
20380
  if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
20206
20381
  initTapScript();
20207
20382
  }
20208
- if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
20209
- window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
20210
- document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
20211
- initCybersourceScript();
20212
- });
20213
- }
20214
- if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
20383
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId) {
20215
20384
  initCybersourceScript();
20216
20385
  }
20217
20386
  if (cardProcessor === "cybersource") {
@@ -20810,7 +20979,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20810
20979
  gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
20811
20980
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
20812
20981
  address_id: product.address_required ? selectedAddressId : null,
20813
- metadata: props === null || props === void 0 ? void 0 : props.subCreateMetadata
20982
+ metadata: props === null || props === void 0 ? void 0 : props.subCreateMetadata,
20983
+ cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
20984
+ cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
20814
20985
  }, (err, res) => {
20815
20986
  var _res$data;
20816
20987
  if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.setup_intent) {
@@ -20985,7 +21156,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20985
21156
  isExistingSource: Boolean(selectedPaymentMethodId),
20986
21157
  items: mappedOrderItems,
20987
21158
  addressId: selectedAddressId,
20988
- couponCode
21159
+ couponCode,
21160
+ cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
21161
+ cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
20989
21162
  }, (err, orderResponse) => {
20990
21163
  var _window$Pelcro14, _window$Pelcro14$user, _window$Pelcro14$user2;
20991
21164
  if (err) {
@@ -21333,7 +21506,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
21333
21506
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
21334
21507
  ...(selectedAddressId && {
21335
21508
  address_id: selectedAddressId
21336
- })
21509
+ }),
21510
+ card_expiration_month: state === null || state === void 0 ? void 0 : state.month,
21511
+ card_expiration_year: state === null || state === void 0 ? void 0 : state.year
21337
21512
  }, (err, res) => {
21338
21513
  if (err) {
21339
21514
  return handlePaymentError(err);
package/dist/index.esm.js CHANGED
@@ -3511,7 +3511,9 @@ var messages$17 = {
3511
3511
  }
3512
3512
  };
3513
3513
  var errors$h = {
3514
- "": ""
3514
+ facebookNoEmail: "Your Facebook account doesn't have an email address. Please use a different login method or add an email to your Facebook account.",
3515
+ googleNoEmail: "Your Google account doesn't have an email address. Please use a different login method or add an email to your Google account.",
3516
+ auth0NoEmail: "Your Auth0 account doesn't have an email address. Please use a different login method or add an email to your Auth0 account."
3515
3517
  };
3516
3518
  var login_en = {
3517
3519
  labels: labels$14,
@@ -3572,7 +3574,9 @@ var messages$15 = {
3572
3574
  }
3573
3575
  };
3574
3576
  var errors$g = {
3575
- "": ""
3577
+ facebookNoEmail: "Your Facebook account doesn't have an email address. Please use a different login method or add an email to your Facebook account.",
3578
+ googleNoEmail: "Your Google account doesn't have an email address. Please use a different login method or add an email to your Google account.",
3579
+ auth0NoEmail: "Your Auth0 account doesn't have an email address. Please use a different login method or add an email to your Auth0 account."
3576
3580
  };
3577
3581
  var gift$3 = {
3578
3582
  titles: {
@@ -4473,7 +4477,9 @@ var messages$Q = {
4473
4477
  }
4474
4478
  };
4475
4479
  var errors$c = {
4476
- "": ""
4480
+ facebookNoEmail: "Votre compte Facebook n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Facebook.",
4481
+ googleNoEmail: "Votre compte Google n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Google.",
4482
+ auth0NoEmail: "Votre compte Auth0 n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Auth0."
4477
4483
  };
4478
4484
  var login_fr = {
4479
4485
  labels: labels$O,
@@ -4534,7 +4540,9 @@ var messages$O = {
4534
4540
  }
4535
4541
  };
4536
4542
  var errors$b = {
4537
- "": ""
4543
+ facebookNoEmail: "Votre compte Facebook n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Facebook.",
4544
+ googleNoEmail: "Votre compte Google n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Google.",
4545
+ auth0NoEmail: "Votre compte Auth0 n'a pas d'adresse e-mail. Veuillez utiliser une autre méthode de connexion ou ajouter une adresse e-mail à votre compte Auth0."
4538
4546
  };
4539
4547
  var gift$2 = {
4540
4548
  titles: {
@@ -5425,7 +5433,9 @@ var messages$x = {
5425
5433
  }
5426
5434
  };
5427
5435
  var errors$7 = {
5428
- "": ""
5436
+ facebookNoEmail: "Facebook 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Facebook 계정에 이메일을 추가해 주세요.",
5437
+ googleNoEmail: "Google 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Google 계정에 이메일을 추가해 주세요.",
5438
+ auth0NoEmail: "Auth0 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Auth0 계정에 이메일을 추가해 주세요."
5429
5439
  };
5430
5440
  var login_ko = {
5431
5441
  labels: labels$w,
@@ -5486,7 +5496,9 @@ var messages$v = {
5486
5496
  }
5487
5497
  };
5488
5498
  var errors$6 = {
5489
- "": ""
5499
+ facebookNoEmail: "Facebook 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Facebook 계정에 이메일을 추가해 주세요.",
5500
+ googleNoEmail: "Google 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Google 계정에 이메일을 추가해 주세요.",
5501
+ auth0NoEmail: "Auth0 계정에 이메일 주소가 없습니다. 다른 로그인 방법을 사용하거나 Auth0 계정에 이메일을 추가해 주세요."
5490
5502
  };
5491
5503
  var gift$1 = {
5492
5504
  titles: {
@@ -6479,7 +6491,9 @@ var messages$e = {
6479
6491
  }
6480
6492
  };
6481
6493
  var errors$2 = {
6482
- "": ""
6494
+ facebookNoEmail: "Tu cuenta de Facebook no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Facebook.",
6495
+ googleNoEmail: "Tu cuenta de Google no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Google.",
6496
+ auth0NoEmail: "Tu cuenta de Auth0 no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Auth0."
6483
6497
  };
6484
6498
  var login_es = {
6485
6499
  labels: labels$e,
@@ -6540,7 +6554,9 @@ var messages$c = {
6540
6554
  }
6541
6555
  };
6542
6556
  var errors$1 = {
6543
- "": ""
6557
+ facebookNoEmail: "Tu cuenta de Facebook no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Facebook.",
6558
+ googleNoEmail: "Tu cuenta de Google no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Google.",
6559
+ auth0NoEmail: "Tu cuenta de Auth0 no tiene una dirección de correo electrónico. Por favor, usa un método de inicio de sesión diferente o agrega un correo electrónico a tu cuenta de Auth0."
6544
6560
  };
6545
6561
  var gift = {
6546
6562
  titles: {
@@ -14053,6 +14069,9 @@ const FacebookLoginButton = _ref => {
14053
14069
  labelClassName = "",
14054
14070
  iconClassName = ""
14055
14071
  } = _ref;
14072
+ const {
14073
+ t
14074
+ } = useTranslation("login");
14056
14075
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
14057
14076
  const {
14058
14077
  dispatch: loginDispatch
@@ -14061,6 +14080,27 @@ const FacebookLoginButton = _ref => {
14061
14080
  dispatch: registerDispatch
14062
14081
  } = useContext(store$m);
14063
14082
  const onSuccess = facebookUser => {
14083
+ // Check if email is provided by Facebook
14084
+ if (!(facebookUser !== null && facebookUser !== void 0 && facebookUser.email)) {
14085
+ // Show error message for both login and register stores
14086
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14087
+ type: SHOW_ALERT,
14088
+ payload: {
14089
+ type: "error",
14090
+ content: t("errors.facebookNoEmail")
14091
+ }
14092
+ });
14093
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14094
+ type: SHOW_ALERT,
14095
+ payload: {
14096
+ type: "error",
14097
+ content: t("errors.facebookNoEmail")
14098
+ }
14099
+ });
14100
+ return;
14101
+ }
14102
+
14103
+ // Proceed with social login if email is available
14064
14104
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14065
14105
  type: HANDLE_SOCIAL_LOGIN,
14066
14106
  payload: {
@@ -14216,6 +14256,9 @@ const GoogleLoginButton = _ref => {
14216
14256
  labelClassName = "",
14217
14257
  iconClassName = ""
14218
14258
  } = _ref;
14259
+ const {
14260
+ t
14261
+ } = useTranslation("login");
14219
14262
  const googleClientId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
14220
14263
  const {
14221
14264
  dispatch: loginDispatch
@@ -14231,15 +14274,38 @@ const GoogleLoginButton = _ref => {
14231
14274
  });
14232
14275
  }, []);
14233
14276
  const onSuccess = response => {
14234
- var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
14277
+ var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getGivenName2, _profile$getFamilyNam2;
14235
14278
  const profile = response.getBasicProfile();
14236
14279
  const accessToken = (_response$getAuthResp = response.getAuthResponse()) === null || _response$getAuthResp === void 0 ? void 0 : _response$getAuthResp.id_token;
14280
+ const email = (_profile$getEmail = profile.getEmail) === null || _profile$getEmail === void 0 ? void 0 : _profile$getEmail.call(profile);
14281
+
14282
+ // Check if email is provided by Google
14283
+ if (!email) {
14284
+ // Show error message for both login and register stores
14285
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14286
+ type: SHOW_ALERT,
14287
+ payload: {
14288
+ type: "error",
14289
+ content: t("errors.googleNoEmail")
14290
+ }
14291
+ });
14292
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14293
+ type: SHOW_ALERT,
14294
+ payload: {
14295
+ type: "error",
14296
+ content: t("errors.googleNoEmail")
14297
+ }
14298
+ });
14299
+ return;
14300
+ }
14301
+
14302
+ // Proceed with social login if email is available
14237
14303
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14238
14304
  type: HANDLE_SOCIAL_LOGIN,
14239
14305
  payload: {
14240
14306
  idpName: "google",
14241
14307
  idpToken: accessToken,
14242
- email: (_profile$getEmail = profile.getEmail) === null || _profile$getEmail === void 0 ? void 0 : _profile$getEmail.call(profile),
14308
+ email: email,
14243
14309
  firstName: (_profile$getGivenName = profile.getGivenName) === null || _profile$getGivenName === void 0 ? void 0 : _profile$getGivenName.call(profile),
14244
14310
  lastName: (_profile$getFamilyNam = profile.getFamilyName) === null || _profile$getFamilyNam === void 0 ? void 0 : _profile$getFamilyNam.call(profile)
14245
14311
  }
@@ -14249,7 +14315,7 @@ const GoogleLoginButton = _ref => {
14249
14315
  payload: {
14250
14316
  idpName: "google",
14251
14317
  idpToken: accessToken,
14252
- email: (_profile$getEmail2 = profile.getEmail) === null || _profile$getEmail2 === void 0 ? void 0 : _profile$getEmail2.call(profile),
14318
+ email: email,
14253
14319
  firstName: (_profile$getGivenName2 = profile.getGivenName) === null || _profile$getGivenName2 === void 0 ? void 0 : _profile$getGivenName2.call(profile),
14254
14320
  lastName: (_profile$getFamilyNam2 = profile.getFamilyName) === null || _profile$getFamilyNam2 === void 0 ? void 0 : _profile$getFamilyNam2.call(profile)
14255
14321
  }
@@ -14321,6 +14387,9 @@ const Auth0LoginButton = _ref => {
14321
14387
  const {
14322
14388
  dispatch: registerDispatch
14323
14389
  } = useContext(store$m);
14390
+ const {
14391
+ t
14392
+ } = useTranslation("login");
14324
14393
  function handleClick() {
14325
14394
  var _auth0InstanceRef$cur, _auth0InstanceRef$cur2, _auth0InstanceRef$cur3;
14326
14395
  if (!auth0Loaded) {
@@ -14352,6 +14421,28 @@ const Auth0LoginButton = _ref => {
14352
14421
  given_name,
14353
14422
  family_name
14354
14423
  } = user;
14424
+
14425
+ // Check if email is provided by Auth0
14426
+ if (!email) {
14427
+ // Show error message for both login and register stores
14428
+ loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14429
+ type: SHOW_ALERT,
14430
+ payload: {
14431
+ type: "error",
14432
+ content: t("errors.auth0NoEmail")
14433
+ }
14434
+ });
14435
+ registerDispatch === null || registerDispatch === void 0 ? void 0 : registerDispatch({
14436
+ type: SHOW_ALERT,
14437
+ payload: {
14438
+ type: "error",
14439
+ content: t("errors.auth0NoEmail")
14440
+ }
14441
+ });
14442
+ return;
14443
+ }
14444
+
14445
+ // Proceed with social login if email is available
14355
14446
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
14356
14447
  type: HANDLE_SOCIAL_LOGIN,
14357
14448
  payload: {
@@ -18184,7 +18275,9 @@ class CybersourceGateway {
18184
18275
  quantity = 1,
18185
18276
  addressId,
18186
18277
  isExistingSource,
18187
- fingerprint_session_id
18278
+ fingerprint_session_id,
18279
+ cardExpirationMonth,
18280
+ cardExpirationYear
18188
18281
  } = options;
18189
18282
  const params = isExistingSource ? {
18190
18283
  source_id: token
@@ -18200,6 +18293,8 @@ class CybersourceGateway {
18200
18293
  coupon_code: couponCode,
18201
18294
  address_id: product.address_required ? addressId : null,
18202
18295
  fingerprint_session_id: fingerprint_session_id,
18296
+ card_expiration_month: cardExpirationMonth,
18297
+ card_expiration_year: cardExpirationYear,
18203
18298
  ...params
18204
18299
  }, (err, res) => {
18205
18300
  callback(err, res);
@@ -18216,7 +18311,9 @@ class CybersourceGateway {
18216
18311
  couponCode,
18217
18312
  product,
18218
18313
  addressId,
18219
- isExistingSource
18314
+ isExistingSource,
18315
+ cardExpirationMonth,
18316
+ cardExpirationYear
18220
18317
  } = options;
18221
18318
  const params = isExistingSource ? {
18222
18319
  source_id: token
@@ -18231,6 +18328,8 @@ class CybersourceGateway {
18231
18328
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
18232
18329
  subscription_id: subscriptionIdToRenew,
18233
18330
  address_id: product.address_required ? addressId : null,
18331
+ card_expiration_month: cardExpirationMonth,
18332
+ card_expiration_year: cardExpirationYear,
18234
18333
  ...params
18235
18334
  }, (err, res) => {
18236
18335
  callback(err, res);
@@ -18248,7 +18347,9 @@ class CybersourceGateway {
18248
18347
  giftRecipient,
18249
18348
  quantity = 1,
18250
18349
  addressId,
18251
- isExistingSource
18350
+ isExistingSource,
18351
+ cardExpirationMonth,
18352
+ cardExpirationYear
18252
18353
  } = options;
18253
18354
  const params = isExistingSource ? {
18254
18355
  source_id: token
@@ -18268,6 +18369,8 @@ class CybersourceGateway {
18268
18369
  gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
18269
18370
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
18270
18371
  address_id: product.address_required ? addressId : null,
18372
+ card_expiration_month: cardExpirationMonth,
18373
+ card_expiration_year: cardExpirationYear,
18271
18374
  ...params
18272
18375
  }, (err, res) => {
18273
18376
  callback(err, res);
@@ -18284,7 +18387,9 @@ class CybersourceGateway {
18284
18387
  plan,
18285
18388
  couponCode,
18286
18389
  addressId,
18287
- isExistingSource
18390
+ isExistingSource,
18391
+ cardExpirationMonth,
18392
+ cardExpirationYear
18288
18393
  } = options;
18289
18394
  const params = isExistingSource ? {
18290
18395
  source_id: token
@@ -18298,6 +18403,8 @@ class CybersourceGateway {
18298
18403
  coupon_code: couponCode,
18299
18404
  subscription_id: subscriptionIdToRenew,
18300
18405
  address_id: product.address_required ? addressId : null,
18406
+ card_expiration_month: cardExpirationMonth,
18407
+ card_expiration_year: cardExpirationYear,
18301
18408
  ...params
18302
18409
  }, (err, res) => {
18303
18410
  callback(err, res);
@@ -18312,7 +18419,9 @@ class CybersourceGateway {
18312
18419
  items,
18313
18420
  couponCode,
18314
18421
  addressId,
18315
- isExistingSource
18422
+ isExistingSource,
18423
+ cardExpirationMonth,
18424
+ cardExpirationYear
18316
18425
  } = options;
18317
18426
  const params = isExistingSource ? {
18318
18427
  source_id: token
@@ -18327,7 +18436,9 @@ class CybersourceGateway {
18327
18436
  ...params,
18328
18437
  ...(addressId && {
18329
18438
  address_id: addressId
18330
- })
18439
+ }),
18440
+ card_expiration_month: cardExpirationMonth,
18441
+ card_expiration_year: cardExpirationYear
18331
18442
  }, (err, res) => {
18332
18443
  callback(err, res);
18333
18444
  });
@@ -18768,7 +18879,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18768
18879
  }
18769
18880
  });
18770
18881
  }
18771
- handleCybersourcePayment(response.token, state);
18882
+ handleCybersourcePayment(response, state);
18772
18883
  });
18773
18884
  };
18774
18885
  function handleCybersourcePayment(paymentRequest, state) {
@@ -18786,7 +18897,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18786
18897
  window.Pelcro.source.create({
18787
18898
  auth_token: window.Pelcro.user.read().auth_token,
18788
18899
  token: paymentRequest,
18789
- gateway: "cybersource"
18900
+ gateway: "cybersource",
18901
+ cardExpirationMonth: state.month,
18902
+ cardExpirationYear: state.year
18790
18903
  }, (err, res) => {
18791
18904
  dispatch({
18792
18905
  type: DISABLE_SUBMIT,
@@ -18814,6 +18927,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18814
18927
  content: t("messages.sourceUpdated")
18815
18928
  }
18816
18929
  });
18930
+
18931
+ // Reinitialize Cybersource microform after successful payment
18932
+ setTimeout(() => {
18933
+ cybersourceInstanceRef.current = null;
18934
+ initCybersourceScript();
18935
+ }, 1000);
18817
18936
  onSuccess(res);
18818
18937
  } //
18819
18938
  );
@@ -18837,11 +18956,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18837
18956
  product,
18838
18957
  isExistingSource: isUsingExistingPaymentMethod,
18839
18958
  subscriptionIdToRenew,
18840
- addressId: selectedAddressId
18959
+ addressId: selectedAddressId,
18960
+ cardExpirationMonth: state.month,
18961
+ cardExpirationYear: state.year
18841
18962
  }, (err, res) => {
18842
18963
  if (err) {
18843
18964
  return handlePaymentError(err);
18844
18965
  }
18966
+
18967
+ // Reinitialize Cybersource microform after successful payment
18968
+ setTimeout(() => {
18969
+ cybersourceInstanceRef.current = null;
18970
+ initCybersourceScript();
18971
+ }, 1000);
18845
18972
  onSuccess(res);
18846
18973
  });
18847
18974
  } else if (giftSubscriprition) {
@@ -18854,11 +18981,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18854
18981
  product,
18855
18982
  isExistingSource: isUsingExistingPaymentMethod,
18856
18983
  giftRecipient,
18857
- addressId: selectedAddressId
18984
+ addressId: selectedAddressId,
18985
+ cardExpirationMonth: state.month,
18986
+ cardExpirationYear: state.year
18858
18987
  }, (err, res) => {
18859
18988
  if (err) {
18860
18989
  return handlePaymentError(err);
18861
18990
  }
18991
+
18992
+ // Reinitialize Cybersource microform after successful payment
18993
+ setTimeout(() => {
18994
+ cybersourceInstanceRef.current = null;
18995
+ initCybersourceScript();
18996
+ }, 1000);
18862
18997
  onSuccess(res);
18863
18998
  });
18864
18999
  } else if (renewSubscription) {
@@ -18871,11 +19006,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18871
19006
  product,
18872
19007
  isExistingSource: isUsingExistingPaymentMethod,
18873
19008
  subscriptionIdToRenew,
18874
- addressId: selectedAddressId
19009
+ addressId: selectedAddressId,
19010
+ cardExpirationMonth: state.month,
19011
+ cardExpirationYear: state.year
18875
19012
  }, (err, res) => {
18876
19013
  if (err) {
18877
19014
  return handlePaymentError(err);
18878
19015
  }
19016
+
19017
+ // Reinitialize Cybersource microform after successful payment
19018
+ setTimeout(() => {
19019
+ cybersourceInstanceRef.current = null;
19020
+ initCybersourceScript();
19021
+ }, 1000);
18879
19022
  onSuccess(res);
18880
19023
  });
18881
19024
  } else if (createSubscription) {
@@ -18888,22 +19031,27 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18888
19031
  product,
18889
19032
  isExistingSource: isUsingExistingPaymentMethod,
18890
19033
  addressId: selectedAddressId,
18891
- fingerprint_session_id: state.cyberSourceSessionId
19034
+ fingerprint_session_id: state.cyberSourceSessionId,
19035
+ cardExpirationMonth: state.month,
19036
+ cardExpirationYear: state.year
18892
19037
  }, (err, res) => {
18893
19038
  if (err) {
18894
19039
  return handlePaymentError(err);
18895
19040
  }
19041
+
19042
+ // Reinitialize Cybersource microform after successful payment
19043
+ setTimeout(() => {
19044
+ cybersourceInstanceRef.current = null;
19045
+ initCybersourceScript();
19046
+ }, 1000);
18896
19047
  onSuccess(res);
18897
19048
  });
18898
19049
  }
18899
19050
  }
18900
19051
  }
18901
- const tokenizeCard = (error, microformInstance) => {
18902
- if (error) {
18903
- return;
18904
- }
18905
- cybersourceInstanceRef.current = microformInstance;
18906
- };
19052
+
19053
+ // No longer needed - microform instance is stored directly in initCybersourceScript
19054
+
18907
19055
  const appendCybersourceFingerprintScripts = () => {
18908
19056
  var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _window$Pelcro$site$r4;
18909
19057
  const uniqueId = crypto.randomUUID();
@@ -18927,6 +19075,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18927
19075
  }
18928
19076
  };
18929
19077
  const initCybersourceScript = () => {
19078
+ // Clear existing card number field before reinitializing
19079
+ const cardNumberElement = document.querySelector("#cybersourceCardNumber");
19080
+ if (cardNumberElement) {
19081
+ cardNumberElement.innerHTML = "";
19082
+ }
19083
+
18930
19084
  // jwk api call
18931
19085
  window.Pelcro.payment.getJWK({
18932
19086
  auth_token: window.Pelcro.user.read().auth_token,
@@ -18951,35 +19105,56 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18951
19105
  });
18952
19106
  }
18953
19107
  const {
18954
- key: jwk
19108
+ key: jwk,
19109
+ captureContext,
19110
+ js_client
18955
19111
  } = res;
18956
- // SETUP MICROFORM
18957
- // eslint-disable-next-line no-undef
18958
- FLEX.microform({
18959
- keyId: jwk.kid,
18960
- keystore: jwk,
18961
- container: "#cybersourceCardNumber",
18962
- placeholder: "Card Number",
18963
- styles: {
18964
- input: {
18965
- "font-size": "14px",
18966
- "font-family": "helvetica, tahoma, calibri, sans-serif",
18967
- color: "#555"
18968
- },
18969
- ":focus": {
18970
- color: "blue"
18971
- },
18972
- ":disabled": {
18973
- cursor: "not-allowed"
18974
- },
18975
- valid: {
18976
- color: "#3c763d"
18977
- },
18978
- invalid: {
18979
- color: "#a94442"
19112
+
19113
+ // Load the SDK from the dynamic URL (if not already loaded)
19114
+ const existingScript = document.querySelector(`script[src="${js_client}"]`);
19115
+ if (!existingScript) {
19116
+ window.Pelcro.helpers.loadSDK(js_client, "cybersource-cdn");
19117
+ }
19118
+ const initializeMicroform = () => {
19119
+ // SETUP MICROFORM
19120
+ // eslint-disable-next-line no-undef
19121
+ const flex = new Flex(captureContext);
19122
+ const microform = flex.microform({
19123
+ styles: {
19124
+ input: {
19125
+ "font-size": "14px",
19126
+ "font-family": "helvetica, tahoma, calibri, sans-serif",
19127
+ color: "#555"
19128
+ },
19129
+ ":focus": {
19130
+ color: "blue"
19131
+ },
19132
+ ":disabled": {
19133
+ cursor: "not-allowed"
19134
+ },
19135
+ valid: {
19136
+ color: "#3c763d"
19137
+ },
19138
+ invalid: {
19139
+ color: "#a94442"
19140
+ }
18980
19141
  }
18981
- }
18982
- }, tokenizeCard);
19142
+ });
19143
+ const number = microform.createField("number", {
19144
+ placeholder: "Enter your card number"
19145
+ });
19146
+ number.load("#cybersourceCardNumber");
19147
+ cybersourceInstanceRef.current = microform;
19148
+ };
19149
+
19150
+ // Wait for SDK to load then initialize microform
19151
+ if (existingScript) {
19152
+ // Script already loaded, initialize immediately
19153
+ initializeMicroform();
19154
+ } else {
19155
+ // Wait for new script to load
19156
+ document.querySelector(`script[src="${js_client}"]`).addEventListener("load", initializeMicroform);
19157
+ }
18983
19158
  });
18984
19159
  };
18985
19160
 
@@ -20175,13 +20350,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20175
20350
  if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
20176
20351
  initTapScript();
20177
20352
  }
20178
- if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
20179
- window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
20180
- document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
20181
- initCybersourceScript();
20182
- });
20183
- }
20184
- if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
20353
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId) {
20185
20354
  initCybersourceScript();
20186
20355
  }
20187
20356
  if (cardProcessor === "cybersource") {
@@ -20780,7 +20949,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20780
20949
  gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
20781
20950
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
20782
20951
  address_id: product.address_required ? selectedAddressId : null,
20783
- metadata: props === null || props === void 0 ? void 0 : props.subCreateMetadata
20952
+ metadata: props === null || props === void 0 ? void 0 : props.subCreateMetadata,
20953
+ cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
20954
+ cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
20784
20955
  }, (err, res) => {
20785
20956
  var _res$data;
20786
20957
  if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.setup_intent) {
@@ -20955,7 +21126,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20955
21126
  isExistingSource: Boolean(selectedPaymentMethodId),
20956
21127
  items: mappedOrderItems,
20957
21128
  addressId: selectedAddressId,
20958
- couponCode
21129
+ couponCode,
21130
+ cardExpirationMonth: state === null || state === void 0 ? void 0 : state.month,
21131
+ cardExpirationYear: state === null || state === void 0 ? void 0 : state.year
20959
21132
  }, (err, orderResponse) => {
20960
21133
  var _window$Pelcro14, _window$Pelcro14$user, _window$Pelcro14$user2;
20961
21134
  if (err) {
@@ -21303,7 +21476,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
21303
21476
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
21304
21477
  ...(selectedAddressId && {
21305
21478
  address_id: selectedAddressId
21306
- })
21479
+ }),
21480
+ card_expiration_month: state === null || state === void 0 ? void 0 : state.month,
21481
+ card_expiration_year: state === null || state === void 0 ? void 0 : state.year
21307
21482
  }, (err, res) => {
21308
21483
  if (err) {
21309
21484
  return handlePaymentError(err);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.26.0-beta.77",
4
+ "version": "3.26.0-beta.79",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",