@pelcro/react-pelcro-js 3.23.0-beta.10 → 3.23.0-beta.12

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
@@ -9374,16 +9374,19 @@ const ZERO_DECIMAL_CURRENCIES = ["BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW"
9374
9374
  const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase());
9375
9375
  const sortCountries = countries => {
9376
9376
  const sortable = [];
9377
- delete countries.CA;
9378
- delete countries.US;
9379
- for (const abbr in countries) {
9380
- sortable.push([abbr, countries[abbr]]);
9377
+ const {
9378
+ CA,
9379
+ US,
9380
+ ...rest
9381
+ } = countries;
9382
+ for (const abbr in rest) {
9383
+ sortable.push([abbr, rest[abbr]]);
9381
9384
  }
9382
9385
  sortable.sort((a, b) => {
9383
9386
  if (a[1] > b[1]) return 1;
9384
9387
  return -1;
9385
9388
  });
9386
- sortable.unshift(["US", "United States"], ["CA", "Canada"]);
9389
+ sortable.unshift(["US", US], ["CA", CA]);
9387
9390
  return sortable;
9388
9391
  };
9389
9392
 
@@ -17988,6 +17991,22 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17988
17991
  });
17989
17992
  updateTotalAmountWithTax();
17990
17993
  }, []);
17994
+ const fireBugSnag = _ref2 => {
17995
+ let {
17996
+ error,
17997
+ title
17998
+ } = _ref2;
17999
+ notifyBugsnag(() => {
18000
+ Bugsnag.notify(title !== null && title !== void 0 ? title : "ERROR", event => {
18001
+ var _document$getElementB, _document$querySelect;
18002
+ event.addMetadata("MetaData", {
18003
+ error: error !== null && error !== void 0 ? error : "ERROR",
18004
+ paymentModalViewed: (_document$getElementB = !!document.getElementById("pelcro-subscription-create-modal")) !== null && _document$getElementB !== void 0 ? _document$getElementB : false,
18005
+ errorAppeared: (_document$querySelect = !!document.querySelector(".pelcro-alert-error")) !== null && _document$querySelect !== void 0 ? _document$querySelect : false
18006
+ });
18007
+ });
18008
+ });
18009
+ };
17991
18010
 
17992
18011
  /*====== Start Cybersource integration ========*/
17993
18012
  const cybersourceErrorHandle = err => {
@@ -17997,10 +18016,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17997
18016
  const errorMessages = [];
17998
18017
 
17999
18018
  // enumerable error (ex: validation errors)
18000
- Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref2 => {
18019
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref3 => {
18001
18020
  let {
18002
18021
  message
18003
- } = _ref2;
18022
+ } = _ref3;
18004
18023
  errorMessages.push(message);
18005
18024
  });
18006
18025
 
@@ -18238,7 +18257,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18238
18257
 
18239
18258
  /*====== Start Tap integration ========*/
18240
18259
  const submitUsingTap = state => {
18241
- var _ref3, _ref4, _getPlanAmount;
18260
+ var _ref4, _ref5, _getPlanAmount;
18242
18261
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18243
18262
  if (isUsingExistingPaymentMethod) {
18244
18263
  // no need to create a new source using tap
@@ -18270,7 +18289,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18270
18289
  return plan.amount;
18271
18290
  }
18272
18291
  }
18273
- const totalAmount = (_ref3 = (_ref4 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref4 !== void 0 ? _ref4 : getOrderItemsTotal()) !== null && _ref3 !== void 0 ? _ref3 : 10;
18292
+ const totalAmount = (_ref4 = (_ref5 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref5 !== void 0 ? _ref5 : getOrderItemsTotal()) !== null && _ref4 !== void 0 ? _ref4 : 10;
18274
18293
  tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
18275
18294
  if (result.error) {
18276
18295
  // Inform the user if there was an error
@@ -18768,13 +18787,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18768
18787
  });
18769
18788
 
18770
18789
  // When Google pay / Apple pay source created
18771
- paymentRequest.on("source", _ref5 => {
18790
+ paymentRequest.on("source", _ref6 => {
18772
18791
  var _source$card;
18773
18792
  let {
18774
18793
  complete,
18775
18794
  source,
18776
18795
  ...data
18777
- } = _ref5;
18796
+ } = _ref6;
18778
18797
  dispatch({
18779
18798
  type: DISABLE_COUPON_BUTTON,
18780
18799
  payload: true
@@ -18789,13 +18808,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18789
18808
  });
18790
18809
  complete("success");
18791
18810
  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") {
18792
- return generate3DSecureSource(source).then(_ref6 => {
18811
+ return generate3DSecureSource(source).then(_ref7 => {
18793
18812
  let {
18794
18813
  source,
18795
18814
  error
18796
- } = _ref6;
18815
+ } = _ref7;
18797
18816
  if (error) {
18798
- return handlePaymentError(error);
18817
+ handlePaymentError(error);
18818
+ fireBugSnag({
18819
+ error,
18820
+ title: "generate3DSecureSource - ERROR"
18821
+ });
18822
+ return;
18799
18823
  }
18800
18824
  toggleAuthenticationPendingView(true, source);
18801
18825
  });
@@ -19079,13 +19103,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19079
19103
  });
19080
19104
  if (res.error) {
19081
19105
  onFailure(res.error);
19082
- return dispatch({
19106
+ dispatch({
19083
19107
  type: SHOW_ALERT,
19084
19108
  payload: {
19085
19109
  type: "error",
19086
19110
  content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
19087
19111
  }
19088
19112
  });
19113
+ fireBugSnag({
19114
+ error: getErrorMessages(res.error),
19115
+ title: "StripeConfirmCardPayment - ERROR"
19116
+ });
19117
+ return;
19089
19118
  }
19090
19119
  onSuccess(res);
19091
19120
  });
@@ -19101,13 +19130,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19101
19130
  payload: false
19102
19131
  });
19103
19132
  onFailure(error);
19104
- return dispatch({
19133
+ dispatch({
19105
19134
  type: SHOW_ALERT,
19106
19135
  payload: {
19107
19136
  type: "error",
19108
19137
  content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
19109
19138
  }
19110
19139
  });
19140
+ fireBugSnag({
19141
+ error: getErrorMessages(error),
19142
+ title: "StripeConfirmCardPayment - ERROR"
19143
+ });
19144
+ return;
19111
19145
  } else {
19112
19146
  onSuccess(response);
19113
19147
  }
@@ -19122,13 +19156,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19122
19156
  });
19123
19157
  if (error) {
19124
19158
  onFailure(error);
19125
- return dispatch({
19159
+ dispatch({
19126
19160
  type: SHOW_ALERT,
19127
19161
  payload: {
19128
19162
  type: "error",
19129
19163
  content: getErrorMessages(error)
19130
19164
  }
19131
19165
  });
19166
+ fireBugSnag({
19167
+ error: getErrorMessages(error),
19168
+ title: "StripeConfirmCardPayment - ERROR"
19169
+ });
19170
+ return;
19132
19171
  }
19133
19172
  onSuccess(response);
19134
19173
  }
@@ -19394,12 +19433,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19394
19433
  const updatePaymentSource = (state, dispatch) => {
19395
19434
  return stripe.createSource({
19396
19435
  type: "card"
19397
- }).then(_ref7 => {
19436
+ }).then(_ref8 => {
19398
19437
  var _source$card2;
19399
19438
  let {
19400
19439
  source,
19401
19440
  error
19402
- } = _ref7;
19441
+ } = _ref8;
19403
19442
  if (error) {
19404
19443
  return handlePaymentError(error);
19405
19444
  }
@@ -19524,12 +19563,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19524
19563
  }
19525
19564
  stripe.createSource({
19526
19565
  type: "card"
19527
- }).then(_ref8 => {
19528
- var _ref9, _ref10, _state$updatedPrice;
19566
+ }).then(_ref9 => {
19567
+ var _ref10, _ref11, _state$updatedPrice;
19529
19568
  let {
19530
19569
  source,
19531
19570
  error
19532
- } = _ref8;
19571
+ } = _ref9;
19533
19572
  if (error) {
19534
19573
  return handlePaymentError(error);
19535
19574
  }
@@ -19548,7 +19587,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19548
19587
  return total + item.price * item.quantity;
19549
19588
  }, 0);
19550
19589
  };
19551
- (_ref9 = (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref9 !== void 0 ? _ref9 : getOrderItemsTotal();
19590
+ (_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();
19552
19591
  return handlePayment(source);
19553
19592
  }).catch(error => {
19554
19593
  return handlePaymentError(error);
package/dist/index.esm.js CHANGED
@@ -9344,16 +9344,19 @@ const ZERO_DECIMAL_CURRENCIES = ["BIF", "CLP", "DJF", "GNF", "JPY", "KMF", "KRW"
9344
9344
  const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency.toUpperCase());
9345
9345
  const sortCountries = countries => {
9346
9346
  const sortable = [];
9347
- delete countries.CA;
9348
- delete countries.US;
9349
- for (const abbr in countries) {
9350
- sortable.push([abbr, countries[abbr]]);
9347
+ const {
9348
+ CA,
9349
+ US,
9350
+ ...rest
9351
+ } = countries;
9352
+ for (const abbr in rest) {
9353
+ sortable.push([abbr, rest[abbr]]);
9351
9354
  }
9352
9355
  sortable.sort((a, b) => {
9353
9356
  if (a[1] > b[1]) return 1;
9354
9357
  return -1;
9355
9358
  });
9356
- sortable.unshift(["US", "United States"], ["CA", "Canada"]);
9359
+ sortable.unshift(["US", US], ["CA", CA]);
9357
9360
  return sortable;
9358
9361
  };
9359
9362
 
@@ -17958,6 +17961,22 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17958
17961
  });
17959
17962
  updateTotalAmountWithTax();
17960
17963
  }, []);
17964
+ const fireBugSnag = _ref2 => {
17965
+ let {
17966
+ error,
17967
+ title
17968
+ } = _ref2;
17969
+ notifyBugsnag(() => {
17970
+ Bugsnag.notify(title !== null && title !== void 0 ? title : "ERROR", event => {
17971
+ var _document$getElementB, _document$querySelect;
17972
+ event.addMetadata("MetaData", {
17973
+ error: error !== null && error !== void 0 ? error : "ERROR",
17974
+ paymentModalViewed: (_document$getElementB = !!document.getElementById("pelcro-subscription-create-modal")) !== null && _document$getElementB !== void 0 ? _document$getElementB : false,
17975
+ errorAppeared: (_document$querySelect = !!document.querySelector(".pelcro-alert-error")) !== null && _document$querySelect !== void 0 ? _document$querySelect : false
17976
+ });
17977
+ });
17978
+ });
17979
+ };
17961
17980
 
17962
17981
  /*====== Start Cybersource integration ========*/
17963
17982
  const cybersourceErrorHandle = err => {
@@ -17967,10 +17986,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17967
17986
  const errorMessages = [];
17968
17987
 
17969
17988
  // enumerable error (ex: validation errors)
17970
- Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref2 => {
17989
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref3 => {
17971
17990
  let {
17972
17991
  message
17973
- } = _ref2;
17992
+ } = _ref3;
17974
17993
  errorMessages.push(message);
17975
17994
  });
17976
17995
 
@@ -18208,7 +18227,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18208
18227
 
18209
18228
  /*====== Start Tap integration ========*/
18210
18229
  const submitUsingTap = state => {
18211
- var _ref3, _ref4, _getPlanAmount;
18230
+ var _ref4, _ref5, _getPlanAmount;
18212
18231
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
18213
18232
  if (isUsingExistingPaymentMethod) {
18214
18233
  // no need to create a new source using tap
@@ -18240,7 +18259,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18240
18259
  return plan.amount;
18241
18260
  }
18242
18261
  }
18243
- const totalAmount = (_ref3 = (_ref4 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref4 !== void 0 ? _ref4 : getOrderItemsTotal()) !== null && _ref3 !== void 0 ? _ref3 : 10;
18262
+ const totalAmount = (_ref4 = (_ref5 = (_getPlanAmount = getPlanAmount()) !== null && _getPlanAmount !== void 0 ? _getPlanAmount : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref5 !== void 0 ? _ref5 : getOrderItemsTotal()) !== null && _ref4 !== void 0 ? _ref4 : 10;
18244
18263
  tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
18245
18264
  if (result.error) {
18246
18265
  // Inform the user if there was an error
@@ -18738,13 +18757,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18738
18757
  });
18739
18758
 
18740
18759
  // When Google pay / Apple pay source created
18741
- paymentRequest.on("source", _ref5 => {
18760
+ paymentRequest.on("source", _ref6 => {
18742
18761
  var _source$card;
18743
18762
  let {
18744
18763
  complete,
18745
18764
  source,
18746
18765
  ...data
18747
- } = _ref5;
18766
+ } = _ref6;
18748
18767
  dispatch({
18749
18768
  type: DISABLE_COUPON_BUTTON,
18750
18769
  payload: true
@@ -18759,13 +18778,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18759
18778
  });
18760
18779
  complete("success");
18761
18780
  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") {
18762
- return generate3DSecureSource(source).then(_ref6 => {
18781
+ return generate3DSecureSource(source).then(_ref7 => {
18763
18782
  let {
18764
18783
  source,
18765
18784
  error
18766
- } = _ref6;
18785
+ } = _ref7;
18767
18786
  if (error) {
18768
- return handlePaymentError(error);
18787
+ handlePaymentError(error);
18788
+ fireBugSnag({
18789
+ error,
18790
+ title: "generate3DSecureSource - ERROR"
18791
+ });
18792
+ return;
18769
18793
  }
18770
18794
  toggleAuthenticationPendingView(true, source);
18771
18795
  });
@@ -19049,13 +19073,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19049
19073
  });
19050
19074
  if (res.error) {
19051
19075
  onFailure(res.error);
19052
- return dispatch({
19076
+ dispatch({
19053
19077
  type: SHOW_ALERT,
19054
19078
  payload: {
19055
19079
  type: "error",
19056
19080
  content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
19057
19081
  }
19058
19082
  });
19083
+ fireBugSnag({
19084
+ error: getErrorMessages(res.error),
19085
+ title: "StripeConfirmCardPayment - ERROR"
19086
+ });
19087
+ return;
19059
19088
  }
19060
19089
  onSuccess(res);
19061
19090
  });
@@ -19071,13 +19100,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19071
19100
  payload: false
19072
19101
  });
19073
19102
  onFailure(error);
19074
- return dispatch({
19103
+ dispatch({
19075
19104
  type: SHOW_ALERT,
19076
19105
  payload: {
19077
19106
  type: "error",
19078
19107
  content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
19079
19108
  }
19080
19109
  });
19110
+ fireBugSnag({
19111
+ error: getErrorMessages(error),
19112
+ title: "StripeConfirmCardPayment - ERROR"
19113
+ });
19114
+ return;
19081
19115
  } else {
19082
19116
  onSuccess(response);
19083
19117
  }
@@ -19092,13 +19126,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19092
19126
  });
19093
19127
  if (error) {
19094
19128
  onFailure(error);
19095
- return dispatch({
19129
+ dispatch({
19096
19130
  type: SHOW_ALERT,
19097
19131
  payload: {
19098
19132
  type: "error",
19099
19133
  content: getErrorMessages(error)
19100
19134
  }
19101
19135
  });
19136
+ fireBugSnag({
19137
+ error: getErrorMessages(error),
19138
+ title: "StripeConfirmCardPayment - ERROR"
19139
+ });
19140
+ return;
19102
19141
  }
19103
19142
  onSuccess(response);
19104
19143
  }
@@ -19364,12 +19403,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19364
19403
  const updatePaymentSource = (state, dispatch) => {
19365
19404
  return stripe.createSource({
19366
19405
  type: "card"
19367
- }).then(_ref7 => {
19406
+ }).then(_ref8 => {
19368
19407
  var _source$card2;
19369
19408
  let {
19370
19409
  source,
19371
19410
  error
19372
- } = _ref7;
19411
+ } = _ref8;
19373
19412
  if (error) {
19374
19413
  return handlePaymentError(error);
19375
19414
  }
@@ -19494,12 +19533,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19494
19533
  }
19495
19534
  stripe.createSource({
19496
19535
  type: "card"
19497
- }).then(_ref8 => {
19498
- var _ref9, _ref10, _state$updatedPrice;
19536
+ }).then(_ref9 => {
19537
+ var _ref10, _ref11, _state$updatedPrice;
19499
19538
  let {
19500
19539
  source,
19501
19540
  error
19502
- } = _ref8;
19541
+ } = _ref9;
19503
19542
  if (error) {
19504
19543
  return handlePaymentError(error);
19505
19544
  }
@@ -19518,7 +19557,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19518
19557
  return total + item.price * item.quantity;
19519
19558
  }, 0);
19520
19559
  };
19521
- (_ref9 = (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref9 !== void 0 ? _ref9 : getOrderItemsTotal();
19560
+ (_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();
19522
19561
  return handlePayment(source);
19523
19562
  }).catch(error => {
19524
19563
  return handlePaymentError(error);
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.23.0-beta.10",
4
+ "version": "3.23.0-beta.12",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",