paymob-pixel-alpha 1.1.68 → 1.1.70

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.
Files changed (2) hide show
  1. package/main.js +161 -74
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -24082,42 +24082,47 @@ const PhoneInput_PhoneInput = /*#__PURE__*/(/* unused pure expression or super *
24082
24082
  name,
24083
24083
  label,
24084
24084
  labelHint,
24085
- defaultPhoneNumber,
24085
+ phoneNumber,
24086
+ country,
24086
24087
  placeholder,
24087
24088
  disabled,
24088
24089
  autoFocus = false,
24089
24090
  error,
24090
24091
  onChangeHandler,
24091
24092
  onCountryChange,
24092
- defaultCountry = 'eg',
24093
24093
  disableSelectCountry,
24094
24094
  onFocus,
24095
24095
  onBlur,
24096
24096
  canToggleToTextInput = false,
24097
24097
  autoComplete = false
24098
24098
  } = props;
24099
- const [selectedCountry, setSelectedCountry] = useState(Countries[defaultCountry] || Countries.eg);
24099
+ const isPhoneControlled = phoneNumber !== undefined;
24100
+ const isCountryControlled = country !== undefined;
24101
+ const countryIso2 = Countries[country || 'eg'];
24102
+ const [internalCountry, setInternalCountry] = useState(countryIso2);
24103
+ const [internalValue, setInternalValue] = useState(phoneNumber || '');
24100
24104
  const [showDropdown, setShowDropdown] = useState(false);
24101
- const [value, setValue] = useState(defaultPhoneNumber || '');
24105
+ const selectedCountry = isCountryControlled ? countryIso2 : internalCountry;
24106
+ const value = (isPhoneControlled ? phoneNumber : internalValue).replace(selectedCountry.countryCode, '');
24102
24107
  const toggleDropdown = () => {
24103
24108
  setShowDropdown(prevState => !prevState);
24104
24109
  };
24105
24110
  const selectCountry = country => {
24106
- setSelectedCountry(country);
24111
+ if (!isCountryControlled) setInternalCountry(country);
24107
24112
  setShowDropdown(false);
24108
- onChangeHandler == null || onChangeHandler(country.countryCode + value, country.countryIso2);
24113
+ onChangeHandler == null || onChangeHandler(country.countryCode + value, country.countryIso2, value);
24109
24114
  onCountryChange && onCountryChange(country.countryIso2);
24110
24115
  };
24111
24116
  const handlePhoneChange = e => {
24112
- const value = e.target.value;
24113
- if (value === '') {
24114
- setValue('');
24115
- onChangeHandler('', selectedCountry.countryIso2);
24117
+ const newValue = e.target.value;
24118
+ if (newValue === '') {
24119
+ if (!isPhoneControlled) setInternalValue('');
24120
+ onChangeHandler == null || onChangeHandler('', selectedCountry.countryIso2, '');
24116
24121
  return;
24117
24122
  }
24118
- if (!/^[0-9]+$/.test(value) && !canToggleToTextInput) return;
24119
- setValue(value);
24120
- onChangeHandler(selectedCountry.countryCode + value, selectedCountry.countryIso2);
24123
+ if (!/^[0-9]+$/.test(newValue) && !canToggleToTextInput) return;
24124
+ if (!isPhoneControlled) setInternalValue(newValue);
24125
+ onChangeHandler == null || onChangeHandler(selectedCountry.countryCode + newValue, selectedCountry.countryIso2, newValue);
24121
24126
  };
24122
24127
  return /*#__PURE__*/_jsxs("div", {
24123
24128
  className: styles['container'],
@@ -24209,7 +24214,7 @@ const PhoneField_PhoneField = props => {
24209
24214
  onChangeHandler,
24210
24215
  onApplyHandler,
24211
24216
  onCountryChange,
24212
- defaultCountry,
24217
+ country,
24213
24218
  applyBtnText,
24214
24219
  errorMsg,
24215
24220
  closeOnSubmit = true
@@ -24238,7 +24243,7 @@ const PhoneField_PhoneField = props => {
24238
24243
  ref: inputRef,
24239
24244
  name: fieldName,
24240
24245
  placeholder: placeholder,
24241
- defaultCountry: defaultCountry,
24246
+ country: country,
24242
24247
  onChangeHandler: handleChange,
24243
24248
  onCountryChange: onCountryChange,
24244
24249
  onFocus: handleFocus,
@@ -50431,8 +50436,7 @@ const Modal_Modal = props => {
50431
50436
  onCloseHandler && useClickOutside_useClickOutside(dialogRef, onCloseHandler, open && closeOnClickOutside, true);
50432
50437
  return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
50433
50438
  children: [!isTopLayer && open && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
50434
- className: modal_module['modal__overlay'],
50435
- onClick: closeOnClickOutside ? onCloseHandler : undefined
50439
+ className: modal_module['modal__overlay']
50436
50440
  }), /*#__PURE__*/(0,jsx_runtime.jsxs)("dialog", {
50437
50441
  ref: dialogRef,
50438
50442
  "data-modal-is-mobile": isMobile,
@@ -59959,7 +59963,7 @@ const FiltersBar_FiltersBar = ({
59959
59963
  placeholder: placeholder,
59960
59964
  horizontalPlacement: isMobile ? "center" : "inline_auto",
59961
59965
  verticalPlacement: "auto",
59962
- defaultCountry: COUNTRIES_INFO[country || "EGY"].country_code_iso2.toLowerCase(),
59966
+ country: COUNTRIES_INFO[country || "EGY"].country_code_iso2.toLowerCase(),
59963
59967
  onChangeHandler: phone => handleFieldsErrors(phone, id, validations),
59964
59968
  errorMsg: fieldsErrors[id],
59965
59969
  onApplyHandler: onApply
@@ -70607,7 +70611,7 @@ const ContactForm = /*#__PURE__*/(/* unused pure expression or super */ null &&
70607
70611
  validate: value => {
70608
70612
  if (!value) return !phoneRequired || t('PHONE_IS_REQUIRED');
70609
70613
  const validPhone = parseMax(countryCode + value);
70610
- return (validPhone == null ? void 0 : validPhone.getType()) === 'MOBILE' && (validPhone == null ? void 0 : validPhone.isValid()) || t('PHONE_NOT_VALID');
70614
+ return ((validPhone == null ? void 0 : validPhone.getType()) === 'MOBILE' || (validPhone == null ? void 0 : validPhone.getType()) === 'FIXED_LINE_OR_MOBILE') && (validPhone == null ? void 0 : validPhone.isValid()) || t('PHONE_NOT_VALID');
70611
70615
  }
70612
70616
  });
70613
70617
  }, []);
@@ -79070,10 +79074,13 @@ const ClickOTPModal = ({
79070
79074
  setOtp('');
79071
79075
  };
79072
79076
  const handleSendToEmail = async () => {
79073
- setIsLoading(true);
79074
- await onSendToEmail();
79075
- setIsLoading(false);
79076
- setOtp('');
79077
+ try {
79078
+ setIsLoading(true);
79079
+ await onSendToEmail();
79080
+ } catch (_unused) {} finally {
79081
+ setIsLoading(false);
79082
+ setOtp('');
79083
+ }
79077
79084
  };
79078
79085
  const title = _type === 'phone' ? isPhoneVerified ? t('WELCOME_BACK') : t('VERIFY_YOUR_ACCOUNT') : t('CONFIRM_ITS_YOU');
79079
79086
  const text = (_type === 'phone' ? `${t('LOGGED_IN_AS')} ${email} \n` : '') + `${t('PLEASE_ENTER_CODE_TO_VERIFY', {
@@ -81589,14 +81596,15 @@ function IframeCard(props) {
81589
81596
  expiryRegister,
81590
81597
  cvcRegister,
81591
81598
  getValues,
81592
- cardType
81599
+ cardType,
81600
+ watch
81593
81601
  } = useHookForm({
81594
81602
  isIframe: true,
81595
81603
  hasOmanNetIntegration: hasOmanNetIntegration || integrationType === 'tokenization',
81596
81604
  countryName: country
81597
81605
  });
81598
81606
  const timeoutIdRef = useRef();
81599
- const cardNum = getValues('number');
81607
+ const cardNum = watch('number');
81600
81608
  const isValidCard = valid.number(cardNum).isValid;
81601
81609
  const currentIntegrationId = hasOmanNetIntegration && (cardType === CARD_TYPES.OMAN || cardType === CARD_TYPES.MAAL) ? subType.integrationId : integrationId;
81602
81610
  const currentPaymentToken = hasOmanNetIntegration && (cardType === CARD_TYPES.OMAN || cardType === CARD_TYPES.MAAL) ? subType.paymentToken : paymentToken;
@@ -81777,6 +81785,8 @@ function IframeCard(props) {
81777
81785
  tenure
81778
81786
  }).then(() => {
81779
81787
  isSubmittingRef.current = false;
81788
+ }).catch(() => {
81789
+ isSubmittingRef.current = false;
81780
81790
  });
81781
81791
  }
81782
81792
  setShouldSubmitData(false);
@@ -82796,7 +82806,7 @@ function SavedCardsViewTwo(props) {
82796
82806
  if (loading) return true;
82797
82807
  if (isAddingCard) return false;
82798
82808
  if (isSplitPaymentsView && !splitAmount) return true;
82799
- if (showCvvInput) {
82809
+ if (showCvvInput && !(selectedCard != null && selectedCard.networkToken)) {
82800
82810
  const requiredLength = isAmexCardSelected ? AMEX_CVV_LENGTH : CVV_LENGTH;
82801
82811
  return selectedCardCvvLength !== requiredLength;
82802
82812
  }
@@ -83679,7 +83689,8 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
83679
83689
  publicKey,
83680
83690
  discounts,
83681
83691
  onPaymentCancel,
83682
- isInstantRefundActive
83692
+ isInstantRefundActive,
83693
+ onPaymentStateChanged
83683
83694
  }, ref) => {
83684
83695
  var _customStyle$discount, _customStyle$containe, _customStyle$containe2, _customStyle$button, _customStyle$containe3, _customStyle$labelTex, _customStyle$buttonTe, _customStyle$placehol, _customStyle$discount2, _customStyle$discount3, _customStyle$errorTex, _customStyle$errorTex2, _customStyle$errorTex3, _customStyle$errorTex4, _customStyle$hintText, _customStyle$labelTex2, _customStyle$buttonTe2, _customStyle$labelTex3, _customStyle$buttonTe3, _customStyle$buttonTe4, _customStyle$buttonTe5;
83685
83696
  const {
@@ -83743,6 +83754,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
83743
83754
  const [instantRefundAmount, setInstantRefundAmount] = (0,react.useState)('');
83744
83755
  const [isInquiringInstantRefund, setIsInquiringInstantRefund] = (0,react.useState)(false);
83745
83756
  const [isInstantRefundChecked, setIsInstantRefundChecked] = (0,react.useState)(false);
83757
+ const checkInstantRefundGeographicEligibility = () => {
83758
+ const countriesCurrencies = ["EGP"];
83759
+ return countriesCurrencies.includes(currency);
83760
+ };
83746
83761
  const showCvvInput = paymentMethodType === constants_PAYMENT_METHODS_TYPES.MOTO && useCvv || paymentMethodType === constants_PAYMENT_METHODS_TYPES.ONLINE;
83747
83762
  const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== src_constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
83748
83763
  const resetInstantRefundState = () => {
@@ -83832,9 +83847,14 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
83832
83847
  res
83833
83848
  } = toggleResponse != null ? toggleResponse : {};
83834
83849
  if (success && res) {
83835
- handleDiscount(res);
83850
+ if (res.status === 200) {
83851
+ handleDiscount(res);
83852
+ }
83836
83853
  }
83837
- instantRefundToggleResolve.current == null || instantRefundToggleResolve.current(!!success);
83854
+ instantRefundToggleResolve.current == null || instantRefundToggleResolve.current({
83855
+ ok: !!success,
83856
+ res
83857
+ });
83838
83858
  instantRefundToggleResolve.current = null;
83839
83859
  setIsInquiringInstantRefund(false);
83840
83860
  }
@@ -83990,6 +84010,21 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
83990
84010
  previousValidationRef.current = isCardValid;
83991
84011
  }
83992
84012
  }, [isCardValid, shouldDisablePayBtn]);
84013
+ (0,react.useEffect)(() => {
84014
+ var _instantRefundData$in, _instantRefundData$el;
84015
+ if (!instantRefundData || !totalAmount || !isInstantRefundActive) return;
84016
+ onPaymentStateChanged == null || onPaymentStateChanged({
84017
+ type: 'INSTANT_REFUND_TOGGLE',
84018
+ payload: {
84019
+ enabled: isInstantRefundChecked,
84020
+ instantRefundAmount: Number((_instantRefundData$in = instantRefundData == null ? void 0 : instantRefundData.instant_refund_fees) != null ? _instantRefundData$in : 0) / 100,
84021
+ eligible: (_instantRefundData$el = instantRefundData == null ? void 0 : instantRefundData.eligible) != null ? _instantRefundData$el : false,
84022
+ totalAmount,
84023
+ originalAmount: payment == null ? void 0 : payment.amount,
84024
+ currency
84025
+ }
84026
+ });
84027
+ }, [isInstantRefundChecked, instantRefundData, totalAmount]);
83993
84028
  (0,react.useImperativeHandle)(ref, () => ({
83994
84029
  handleGenerateToken
83995
84030
  }));
@@ -84232,7 +84267,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84232
84267
  }, '*');
84233
84268
  instantRefundToggleTimeoutRef.current = setTimeout(() => {
84234
84269
  if (instantRefundToggleResolve.current) {
84235
- instantRefundToggleResolve.current(false);
84270
+ instantRefundToggleResolve.current({
84271
+ ok: false,
84272
+ res: undefined
84273
+ });
84236
84274
  instantRefundToggleResolve.current = null;
84237
84275
  setIsInquiringInstantRefund(false);
84238
84276
  }
@@ -84243,13 +84281,25 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84243
84281
  const discountIntegrationId = getDiscountIntegrationId();
84244
84282
  if (!discountIntegrationId) {
84245
84283
  applyNoDiscountInstantRefundAmounts(nextChecked);
84246
- return true;
84284
+ return {
84285
+ ok: true,
84286
+ res: undefined
84287
+ };
84247
84288
  }
84248
84289
  const token = nextChecked ? instantRefundData == null ? void 0 : instantRefundData.new_payment_token : payment == null ? void 0 : payment.token;
84249
84290
  const res = await checkDiscount(token, payment.id, selectedCard.identifier, selectedCard.type);
84250
- if ((res == null ? void 0 : res.status) !== 200) return false;
84291
+ if ((res == null ? void 0 : res.status) !== 200) {
84292
+ return {
84293
+ ok: true,
84294
+ res: res
84295
+ };
84296
+ }
84297
+ ;
84251
84298
  handleDiscount(res);
84252
- return true;
84299
+ return {
84300
+ ok: true,
84301
+ res: res
84302
+ };
84253
84303
  };
84254
84304
  const handleInstantRefundToggleChange = async currentChecked => {
84255
84305
  if (!payment || !(instantRefundData != null && instantRefundData.eligible)) return false;
@@ -84257,10 +84307,11 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84257
84307
  const isSavedCardContext = !!(savedCards != null && savedCards.length) && !showCardModal && !!selectedCard;
84258
84308
  setIsInquiringInstantRefund(true);
84259
84309
  try {
84260
- const ok = isSavedCardContext ? await handleSavedCardToggle(nextChecked) : await postToggleToIframe(nextChecked);
84261
- if (!ok) return false;
84310
+ var _response$res;
84311
+ const response = isSavedCardContext ? await handleSavedCardToggle(nextChecked) : await postToggleToIframe(nextChecked);
84312
+ if (!response.ok) return false;
84262
84313
  setIsInstantRefundChecked(nextChecked);
84263
- if (!hasDiscountForPayment) {
84314
+ if (!hasDiscountForPayment || ((_response$res = response.res) == null ? void 0 : _response$res.status) !== 200) {
84264
84315
  applyNoDiscountInstantRefundAmounts(nextChecked);
84265
84316
  }
84266
84317
  return true;
@@ -84446,7 +84497,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84446
84497
  fontFamily: currencyFontFamily
84447
84498
  },
84448
84499
  children: displayCurrency
84449
- }), ' ', totalAmount || formattedAmount]
84500
+ }), ' ', formattedAmount]
84450
84501
  })]
84451
84502
  }), discountedAmount && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
84452
84503
  className: "flex justify-between items-center text-green-600",
@@ -84583,10 +84634,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84583
84634
  }), /*#__PURE__*/(0,jsx_runtime.jsx)("iframe", {
84584
84635
  title: 'Elements',
84585
84636
  id: "iFrame",
84586
- ref: iframeRef,
84587
- src: `${baseUrl}/${environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`
84588
- // src={`http://localhost:9001/${environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`}
84637
+ ref: iframeRef
84638
+ // src={`${baseUrl}/${environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`}
84589
84639
  ,
84640
+ src: `http://localhost:9001/${environment['IFRAME_PATH']}/?type=card&v=2&integration_type=${integrationType}`,
84590
84641
  className: Card_card_module['iframe'],
84591
84642
  style: {
84592
84643
  display: isIframeLoaded && (payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION) ? 'block' : 'none'
@@ -84637,7 +84688,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84637
84688
  customError: customStyle == null || (_customStyle$errorTex4 = customStyle.errorText) == null ? void 0 : _customStyle$errorTex4.holderName
84638
84689
  })
84639
84690
  })]
84640
- }), isInstantRefundActive && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
84691
+ }), isInstantRefundActive && checkInstantRefundGeographicEligibility() && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
84641
84692
  checked: isInstantRefundChecked,
84642
84693
  onChange: handleInstantRefundToggleChange,
84643
84694
  instantRefundData: instantRefundData,
@@ -84723,7 +84774,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
84723
84774
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
84724
84775
  children: discountAppliedMessage
84725
84776
  }), /*#__PURE__*/(0,jsx_runtime.jsx)(icons_CircleCheck, {})]
84726
- }), isInstantRefundActive && selectedCard && !showCardModal && card.id === selectedCardId && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
84777
+ }), isInstantRefundActive && selectedCard && !showCardModal && card.id === selectedCardId && checkInstantRefundGeographicEligibility() && /*#__PURE__*/(0,jsx_runtime.jsx)(InstantRefund_InstantRefundToggle, {
84727
84778
  checked: isInstantRefundChecked,
84728
84779
  onChange: handleInstantRefundToggleChange,
84729
84780
  instantRefundData: instantRefundData,
@@ -94718,11 +94769,21 @@ function KnetApplePay(props) {
94718
94769
  }
94719
94770
  }
94720
94771
  session.onvalidatemerchant = async event => {
94721
- const merchantSession = await validatemerchant(event.validationURL, integrationId);
94722
- session.completeMerchantValidation(merchantSession);
94772
+ try {
94773
+ const merchantSession = await validatemerchant(event.validationURL, integrationId);
94774
+ if (!merchantSession || typeof merchantSession !== 'object' || merchantSession.status === 0) {
94775
+ session.abort();
94776
+ setLoading(false);
94777
+ return;
94778
+ }
94779
+ session.completeMerchantValidation(merchantSession);
94780
+ } catch (e) {
94781
+ session.abort();
94782
+ setLoading(false);
94783
+ }
94723
94784
  };
94724
94785
  session.onpaymentauthorized = async event => {
94725
- var _payRes$data, _payRes$data2, _payRes$data3;
94786
+ var _event$payment, _payRes$data, _payRes$data2, _payRes$data3;
94726
94787
  let clientData = null;
94727
94788
  if (!clientInfo) {
94728
94789
  try {
@@ -94744,7 +94805,7 @@ function KnetApplePay(props) {
94744
94805
  console.log(e);
94745
94806
  }
94746
94807
  }
94747
- const payRes = await knetApplePayPayment(JSON.stringify(event.payment.token.paymentData), paymentToken, clientData);
94808
+ const payRes = await knetApplePayPayment(JSON.stringify((_event$payment = event.payment) == null || (_event$payment = _event$payment.token) == null ? void 0 : _event$payment.paymentData), paymentToken, clientData);
94748
94809
  setLoading(false);
94749
94810
  let status;
94750
94811
  let resStatus = '';
@@ -94779,15 +94840,19 @@ function KnetApplePay(props) {
94779
94840
  resStatus = 'invalid';
94780
94841
  }
94781
94842
  if (onAfterPaymentComplete) {
94782
- session.completePayment({
94783
- status
94784
- });
94843
+ try {
94844
+ session.completePayment({
94845
+ status
94846
+ });
94847
+ } catch (_) {}
94785
94848
  onAfterPaymentComplete(payRes);
94786
94849
  } else {
94787
94850
  onSubmit(resStatus, payRes.data);
94788
- session.completePayment({
94789
- status
94790
- });
94851
+ try {
94852
+ session.completePayment({
94853
+ status
94854
+ });
94855
+ } catch (_) {}
94791
94856
  }
94792
94857
  };
94793
94858
  session.oncancel = () => {
@@ -95075,14 +95140,18 @@ function apple_pay_ApplePay(props) {
95075
95140
  }
95076
95141
  }
95077
95142
  session.onvalidatemerchant = async event => {
95078
- console.log("start validation request");
95079
- console.log(`validationURL: ${event.validationURL}`);
95080
- console.log(`integrationId: ${integrationId}`);
95081
- const merchantSession = await validatemerchant(event.validationURL, integrationId, displayName);
95082
- console.log("validation request completed");
95083
- console.log(`merchantSession: ${merchantSession}`);
95084
- console.log("start completeMerchantValidation");
95085
- session.completeMerchantValidation(merchantSession);
95143
+ try {
95144
+ const merchantSession = await validatemerchant(event.validationURL, integrationId, displayName);
95145
+ if (!merchantSession || typeof merchantSession !== 'object' || merchantSession.status === 0) {
95146
+ session.abort();
95147
+ setLoading(false);
95148
+ return;
95149
+ }
95150
+ session.completeMerchantValidation(merchantSession);
95151
+ } catch (e) {
95152
+ session.abort();
95153
+ setLoading(false);
95154
+ }
95086
95155
  };
95087
95156
  session.onshippingcontactselected = async event => {
95088
95157
  console.log({
@@ -95110,7 +95179,7 @@ function apple_pay_ApplePay(props) {
95110
95179
  });
95111
95180
  };
95112
95181
  session.onpaymentauthorized = async event => {
95113
- var _payRes$data, _payRes$data2, _payRes$data3;
95182
+ var _event$payment, _payRes$data, _payRes$data2, _payRes$data3;
95114
95183
  let clientData = null;
95115
95184
  if (!clientInfo) {
95116
95185
  const billingAddress = event.payment.billingContact;
@@ -95157,7 +95226,7 @@ function apple_pay_ApplePay(props) {
95157
95226
  // dispatch(addClientInfo(clientData));
95158
95227
  // }
95159
95228
  console.log("start pay request");
95160
- const payRes = await paymentauthorized(JSON.stringify(event.payment.token.paymentData), paymentToken, clientData);
95229
+ const payRes = await paymentauthorized(JSON.stringify((_event$payment = event.payment) == null || (_event$payment = _event$payment.token) == null ? void 0 : _event$payment.paymentData), paymentToken, clientData);
95161
95230
  setLoading(false);
95162
95231
  let status;
95163
95232
  let resStatus = '';
@@ -95192,15 +95261,19 @@ function apple_pay_ApplePay(props) {
95192
95261
  resStatus = 'invalid';
95193
95262
  }
95194
95263
  if (onAfterPaymentComplete) {
95195
- session.completePayment({
95196
- status
95197
- });
95264
+ try {
95265
+ session.completePayment({
95266
+ status
95267
+ });
95268
+ } catch (_) {}
95198
95269
  onAfterPaymentComplete(payRes);
95199
95270
  } else {
95200
95271
  onSubmit(resStatus, payRes.data);
95201
- session.completePayment({
95202
- status
95203
- });
95272
+ try {
95273
+ session.completePayment({
95274
+ status
95275
+ });
95276
+ } catch (_) {}
95204
95277
  }
95205
95278
  //}
95206
95279
  };
@@ -96038,7 +96111,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96038
96111
  discounts,
96039
96112
  viewMode,
96040
96113
  displayName,
96041
- isInstantRefundActive
96114
+ isInstantRefundActive,
96115
+ onPaymentStateChanged
96042
96116
  } = props;
96043
96117
  const {
96044
96118
  t
@@ -96200,7 +96274,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96200
96274
  publicKey,
96201
96275
  ref: cardRef,
96202
96276
  discounts: discounts == null ? void 0 : discounts.cards,
96203
- isInstantRefundActive
96277
+ isInstantRefundActive,
96278
+ onPaymentStateChanged
96204
96279
  }) : /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
96205
96280
  children: viewMode === 'list' ? /*#__PURE__*/(0,jsx_runtime.jsx)(ListView, {
96206
96281
  paymentMethods: paymentMethods,
@@ -96221,7 +96296,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96221
96296
  publicKey,
96222
96297
  ref: cardRef,
96223
96298
  discounts: discounts == null ? void 0 : discounts.cards,
96224
- isInstantRefundActive
96299
+ isInstantRefundActive,
96300
+ onPaymentStateChanged
96225
96301
  }) : /*#__PURE__*/(0,jsx_runtime.jsx)(List_TabView, {
96226
96302
  paymentMethods: paymentMethods,
96227
96303
  customStyle,
@@ -96241,7 +96317,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96241
96317
  publicKey,
96242
96318
  ref: cardRef,
96243
96319
  discounts: discounts == null ? void 0 : discounts.cards,
96244
- isInstantRefundActive
96320
+ isInstantRefundActive,
96321
+ onPaymentStateChanged
96245
96322
  })
96246
96323
  })
96247
96324
  })]
@@ -96465,7 +96542,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96465
96542
  integrationType,
96466
96543
  discounts,
96467
96544
  viewMode = 'tab',
96468
- isInstantRefundActive
96545
+ isInstantRefundActive,
96546
+ onPaymentStateChanged
96469
96547
  } = props;
96470
96548
  const [paymentMethod, setPaymentMethod] = (0,react.useState)(payment);
96471
96549
  const styles = getStyles_getStyles(customStyle);
@@ -96485,6 +96563,7 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96485
96563
  onBeforePaymentComplete,
96486
96564
  onAfterPaymentComplete,
96487
96565
  onCardValidationChanged,
96566
+ onPaymentStateChanged,
96488
96567
  showPaymobLogo,
96489
96568
  hideCardHolderName,
96490
96569
  integrationType,
@@ -96601,7 +96680,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
96601
96680
  integrationType: integrationType,
96602
96681
  discounts: discounts,
96603
96682
  viewMode: viewMode,
96604
- isInstantRefundActive: isInstantRefundActive
96683
+ isInstantRefundActive: isInstantRefundActive,
96684
+ onPaymentStateChanged: onPaymentStateChanged
96605
96685
  });
96606
96686
  };
96607
96687
  return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
@@ -97636,6 +97716,11 @@ class Pixel {
97636
97716
  this._options.cardValidationChanged(isValid);
97637
97717
  }
97638
97718
  }
97719
+ handlePaymentStateChanged(state) {
97720
+ if (this._options.paymentStateChanged) {
97721
+ this._options.paymentStateChanged(state);
97722
+ }
97723
+ }
97639
97724
  static getInstance(instanceId, callingMethodName) {
97640
97725
  if (Object.keys(this._instances).length > 1 && !instanceId) {
97641
97726
  throw new Error(`Multiple Pixel instances detected. Please provide an instance ID for the ${callingMethodName || 'requested'} method.`);
@@ -97722,6 +97807,8 @@ class Pixel {
97722
97807
  onPaymentCancel: this.handleOnPaymentCancel.bind(this)
97723
97808
  }, this._options.cardValidationChanged && {
97724
97809
  onCardValidationChanged: this.handleCardValidationChanged.bind(this)
97810
+ }, this._options.paymentStateChanged && {
97811
+ onPaymentStateChanged: this.handlePaymentStateChanged.bind(this)
97725
97812
  }, {
97726
97813
  integrationType: this._integrationType,
97727
97814
  discounts: this._discounts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-pixel-alpha",
3
- "version": "1.1.68",
3
+ "version": "1.1.70",
4
4
  "keywords": ["paymob","pixel","paymob-pixel"],
5
5
  "main": "./main.js",
6
6
  "license": "MIT",