paymob-pixel-alpha 1.1.64 → 1.1.65

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 +231 -296
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -76694,7 +76694,6 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
76694
76694
  paymentMethodType,
76695
76695
  useCvv
76696
76696
  } = payment;
76697
- const formattedAmount = formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(String(amount), currency);
76698
76697
  const {
76699
76698
  t
76700
76699
  } = useTranslation_useTranslation('card');
@@ -76741,7 +76740,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
76741
76740
  } = formatCurrencyForDisplay_formatCurrencyForDisplay(currency);
76742
76741
  const [showFeesDetails, setShowFeesDetails] = (0,react.useState)(false);
76743
76742
  const [discountedAmount, setDiscountedAmount] = (0,react.useState)('');
76744
- const [feesAmount, setFeesAmount] = (0,react.useState)(payment != null && payment.feesAmount ? formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(String(payment.feesAmount), currency) : '');
76743
+ const [feesAmount, setFeesAmount] = (0,react.useState)((payment == null ? void 0 : payment.feesAmount) || '');
76745
76744
  const [updatedPaymentToken, setUpdatedPaymentToken] = (0,react.useState)('');
76746
76745
  const showCvvInput = paymentMethodType === constants_PAYMENT_METHODS_TYPES.MOTO && useCvv || paymentMethodType === constants_PAYMENT_METHODS_TYPES.ONLINE;
76747
76746
  const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== src_constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
@@ -77026,12 +77025,10 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
77026
77025
  const discountIntegrationId = discounts == null || (_discounts$data = discounts.data) == null || (_discounts$data = _discounts$data.find(discount => (discount == null ? void 0 : discount.integration_id) === integrationId)) == null ? void 0 : _discounts$data.integration_id;
77027
77026
  if (!hasDiscount || !discountIntegrationId) return;
77028
77027
  const res = await checkDiscount(updatedPaymentToken || paymentToken, discountIntegrationId, identifier, savedCardType);
77029
- console.log("🚀 ~ handleSavedCardDiscount ~ res:", res);
77030
77028
  handleDiscount(res);
77031
77029
  if (res.status === 200) return true;
77032
77030
  };
77033
77031
  const handleDiscount = res => {
77034
- console.log("🚀 ~ handleDiscount ~ res:", res);
77035
77032
  handleResetDiscountMessages();
77036
77033
  if (!res) return;
77037
77034
  if (res.status === 200) {
@@ -77076,7 +77073,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
77076
77073
  };
77077
77074
  const handleFeesReset = () => {
77078
77075
  setTotalAmount("");
77079
- setFeesAmount(payment != null && payment.feesAmount ? formatAmountBasedOnCurrency_formatAmountBasedOnCurrency(String(payment.feesAmount), currency) : '');
77076
+ setFeesAmount((payment == null ? void 0 : payment.feesAmount) || '');
77080
77077
  setShowFeesDetails(false);
77081
77078
  setUpdatedPaymentToken("");
77082
77079
  handleResetDiscountMessages();
@@ -77275,7 +77272,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
77275
77272
  fontFamily: currencyFontFamily
77276
77273
  },
77277
77274
  children: displayCurrency
77278
- }), ' ', totalAmount || formattedAmount]
77275
+ }), ' ', amount]
77279
77276
  })]
77280
77277
  }), discountedAmount && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
77281
77278
  className: "flex justify-between items-center text-green-600",
@@ -77482,7 +77479,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
77482
77479
  style: {
77483
77480
  textDecoration: 'line-through'
77484
77481
  },
77485
- children: formattedAmount
77482
+ children: amount
77486
77483
  })]
77487
77484
  }),
77488
77485
  onClick: () => setShouldSubmitData(true),
@@ -77563,7 +77560,7 @@ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
77563
77560
  style: {
77564
77561
  textDecoration: 'line-through'
77565
77562
  },
77566
- children: formattedAmount
77563
+ children: amount
77567
77564
  })]
77568
77565
  }),
77569
77566
  customStyle: customStyle == null ? void 0 : customStyle.button,
@@ -84342,7 +84339,7 @@ const payWithKnet = (token, payload) => {
84342
84339
  source: {
84343
84340
  identifier: 'KnetCard',
84344
84341
  amount_cents: payload.amount,
84345
- unified_checkout: payload.isElements ? 'False' : 'True',
84342
+ unified_checkout: 'False',
84346
84343
  subtype: 'KNET'
84347
84344
  },
84348
84345
  payment_token: token,
@@ -85244,11 +85241,10 @@ function GooglePayElement({
85244
85241
  }
85245
85242
  ;// ./src/services/applePayService.ts
85246
85243
 
85247
- const applePayService_validatemerchant = async (appleURL, integrationId, displayName) => {
85244
+ const applePayService_validatemerchant = async (appleURL, integrationId) => {
85248
85245
  return lib_axios.post(`/api/auth/merchant/validate`, {
85249
85246
  appleURL,
85250
- integrationId,
85251
- displayName
85247
+ integrationId
85252
85248
  }).then(res => res.data.api_response).catch(err => err == null ? void 0 : err.response);
85253
85249
  };
85254
85250
  const paymentauthorized = async (applePaytoken, paymentToken) => {
@@ -85279,8 +85275,7 @@ function ApplePayElements({
85279
85275
  onAfterPaymentComplete,
85280
85276
  onPaymentCancel,
85281
85277
  isLoading,
85282
- country,
85283
- displayName
85278
+ country
85284
85279
  }) {
85285
85280
  var _amount$toString;
85286
85281
  const {
@@ -85298,7 +85293,6 @@ function ApplePayElements({
85298
85293
  currency: currency,
85299
85294
  amount: (_amount$toString = amount.toString()) == null ? void 0 : _amount$toString.replace(/,/g, ''),
85300
85295
  merchantName: merchantName,
85301
- displayName: displayName,
85302
85296
  paymentToken: (applePay == null ? void 0 : applePay.token) || '',
85303
85297
  integrationId: (applePay == null ? void 0 : applePay.id) || '',
85304
85298
  validatemerchant: applePayService_validatemerchant,
@@ -85647,83 +85641,6 @@ const ListView = _ref => {
85647
85641
  });
85648
85642
  };
85649
85643
  /* harmony default export */ const List_ListView = ((/* unused pure expression or super */ null && (ListView)));
85650
- ;// ./src/utils/ShadowWrapper.tsx
85651
-
85652
-
85653
-
85654
-
85655
- const ShadowWrapper = ({
85656
- elementId,
85657
- children
85658
- }) => {
85659
- const [shadowRoot, setShadowRoot] = (0,react.useState)(null);
85660
- const [error, setError] = (0,react.useState)(null);
85661
- (0,react.useEffect)(() => {
85662
- if (!document.getElementById(elementId)) return;
85663
- document.getElementById(elementId).innerHTML = '';
85664
- const container = document.getElementById(elementId).appendChild(document.createElement('div'));
85665
- if (!('attachShadow' in Element.prototype)) {
85666
- setError('Shadow DOM is not supported in this browser');
85667
- return;
85668
- }
85669
- try {
85670
- let shadow = container.shadowRoot;
85671
- if (!shadow) {
85672
- shadow = container.attachShadow({
85673
- mode: 'open'
85674
- });
85675
- environment.PIXEL_CSS_LINKS.forEach(href => {
85676
- if (href.match(/\.(woff2?|ttf|otf|eot)$/)) {
85677
- const fontName = 'currencyFont';
85678
- const font = new FontFace(fontName, `url(${href})`);
85679
- font.load().then(loadedFace => {
85680
- var _shadow;
85681
- //@ts-ignore
85682
- document.fonts.add(loadedFace);
85683
- const style = document.createElement('style');
85684
- style.textContent = `
85685
- @font-face {
85686
- font-family: '${fontName}';
85687
- src: url('${href}');
85688
- font-display: swap;
85689
- }
85690
- `;
85691
- (_shadow = shadow) == null || _shadow.appendChild(style);
85692
- }).catch(err => console.error(`Failed to load font: ${href}`, err));
85693
- } else {
85694
- var _shadow2;
85695
- const link = document.createElement('link');
85696
- link.rel = 'stylesheet';
85697
- link.href = href;
85698
- (_shadow2 = shadow) == null || _shadow2.appendChild(link);
85699
- }
85700
- });
85701
- }
85702
- setShadowRoot(shadow);
85703
- } catch (error) {
85704
- console.error('Failed to create Shadow DOM:', error);
85705
- setError(`Failed to create Shadow DOM: ${error instanceof Error ? error.message : String(error)}`);
85706
- }
85707
- return () => {
85708
- setShadowRoot(null);
85709
- };
85710
- }, [elementId]);
85711
- if (error) {
85712
- const container = document.getElementById(elementId);
85713
- return /*#__PURE__*/(0,react_dom.createPortal)(/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
85714
- style: {
85715
- color: 'red',
85716
- padding: '10px'
85717
- },
85718
- children: error
85719
- }), container);
85720
- }
85721
- if (shadowRoot) {
85722
- return /*#__PURE__*/(0,react_dom.createPortal)(children, shadowRoot);
85723
- }
85724
- return null;
85725
- };
85726
- /* harmony default export */ const utils_ShadowWrapper = (ShadowWrapper);
85727
85644
  ;// ./src/components/Payments/List/index.tsx
85728
85645
 
85729
85646
 
@@ -85740,11 +85657,9 @@ const ShadowWrapper = ({
85740
85657
 
85741
85658
 
85742
85659
 
85743
-
85744
85660
  const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85745
85661
  var _customStyle$containe;
85746
85662
  const {
85747
- elementId,
85748
85663
  payments,
85749
85664
  customStyle,
85750
85665
  baseUrl,
@@ -85763,8 +85678,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85763
85678
  selectedPaymentMethods,
85764
85679
  integrationType,
85765
85680
  discounts,
85766
- viewMode,
85767
- displayName
85681
+ viewMode
85768
85682
  } = props;
85769
85683
  const {
85770
85684
  t
@@ -85825,6 +85739,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85825
85739
  if (a.type === 'knet-apple-pay' && b.type === 'knet') return 1;
85826
85740
  return 0;
85827
85741
  });
85742
+ console.log('paymentMethods list', paymentMethods);
85828
85743
  const isApplePay = () => {
85829
85744
  const hasApplePay = !!filteredPaymentList.find(item => item.name === 'apple-pay');
85830
85745
  return hasApplePay && isApplePaySupported();
@@ -85874,8 +85789,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85874
85789
  onPaymentCancel: onPaymentCancel,
85875
85790
  customStyle: customStyle == null ? void 0 : customStyle.button,
85876
85791
  isLoading: isLoading,
85877
- country: country,
85878
- displayName: displayName
85792
+ country: country
85879
85793
  }), isGooglePay() && /*#__PURE__*/(0,jsx_runtime.jsx)(GooglePayElement, {
85880
85794
  payment: googlePaymentMethod,
85881
85795
  customStyle: customStyle == null ? void 0 : customStyle.button,
@@ -85905,13 +85819,50 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85905
85819
  })
85906
85820
  })
85907
85821
  })]
85908
- }), /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
85909
- elementId: elementId,
85910
- children: paymentMethods.length >= 1 && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
85911
- className: list_module['payments-list'],
85912
- children: paymentMethods.length === 1 ? renderSelectedPaymentMethod(paymentMethods[0], {
85822
+ }), paymentMethods.length >= 1 && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
85823
+ className: list_module['payments-list'],
85824
+ children: paymentMethods.length === 1 ? renderSelectedPaymentMethod(paymentMethods[0], {
85825
+ customStyle,
85826
+ paymentMethodsCount: paymentMethods.length,
85827
+ baseUrl,
85828
+ disablePay,
85829
+ savedCards: savedCardsList,
85830
+ forceSaveCard,
85831
+ showSaveCard,
85832
+ onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
85833
+ onAfterPaymentComplete,
85834
+ onCardValidationChanged,
85835
+ showPaymobLogo,
85836
+ hideCardHolderName,
85837
+ isLoading,
85838
+ country,
85839
+ integrationType,
85840
+ publicKey,
85841
+ ref: cardRef,
85842
+ discounts: discounts == null ? void 0 : discounts.cards
85843
+ }) : /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
85844
+ children: viewMode === 'list' ? /*#__PURE__*/(0,jsx_runtime.jsx)(ListView, {
85845
+ paymentMethods: paymentMethods,
85846
+ customStyle,
85847
+ baseUrl,
85848
+ disablePay,
85849
+ savedCards: savedCardsList,
85850
+ forceSaveCard,
85851
+ showSaveCard,
85852
+ onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
85853
+ onAfterPaymentComplete,
85854
+ onCardValidationChanged,
85855
+ showPaymobLogo,
85856
+ hideCardHolderName,
85857
+ isLoading,
85858
+ country,
85859
+ integrationType,
85860
+ publicKey,
85861
+ ref: cardRef,
85862
+ discounts: discounts == null ? void 0 : discounts.cards
85863
+ }) : /*#__PURE__*/(0,jsx_runtime.jsx)(List_TabView, {
85864
+ paymentMethods: paymentMethods,
85913
85865
  customStyle,
85914
- paymentMethodsCount: paymentMethods.length,
85915
85866
  baseUrl,
85916
85867
  disablePay,
85917
85868
  savedCards: savedCardsList,
@@ -85928,46 +85879,6 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
85928
85879
  publicKey,
85929
85880
  ref: cardRef,
85930
85881
  discounts: discounts == null ? void 0 : discounts.cards
85931
- }) : /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
85932
- children: viewMode === 'list' ? /*#__PURE__*/(0,jsx_runtime.jsx)(ListView, {
85933
- paymentMethods: paymentMethods,
85934
- customStyle,
85935
- baseUrl,
85936
- disablePay,
85937
- savedCards: savedCardsList,
85938
- forceSaveCard,
85939
- showSaveCard,
85940
- onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
85941
- onAfterPaymentComplete,
85942
- onCardValidationChanged,
85943
- showPaymobLogo,
85944
- hideCardHolderName,
85945
- isLoading,
85946
- country,
85947
- integrationType,
85948
- publicKey,
85949
- ref: cardRef,
85950
- discounts: discounts == null ? void 0 : discounts.cards
85951
- }) : /*#__PURE__*/(0,jsx_runtime.jsx)(List_TabView, {
85952
- paymentMethods: paymentMethods,
85953
- customStyle,
85954
- baseUrl,
85955
- disablePay,
85956
- savedCards: savedCardsList,
85957
- forceSaveCard,
85958
- showSaveCard,
85959
- onBeforePaymentComplete: onBeforePaymentComplete && handleOnBeforePaymentComplete,
85960
- onAfterPaymentComplete,
85961
- onCardValidationChanged,
85962
- showPaymobLogo,
85963
- hideCardHolderName,
85964
- isLoading,
85965
- country,
85966
- integrationType,
85967
- publicKey,
85968
- ref: cardRef,
85969
- discounts: discounts == null ? void 0 : discounts.cards
85970
- })
85971
85882
  })
85972
85883
  })
85973
85884
  })]
@@ -86167,12 +86078,10 @@ function getStyles_getStyles(customStyle) {
86167
86078
 
86168
86079
 
86169
86080
 
86170
-
86171
86081
 
86172
86082
 
86173
86083
  const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
86174
86084
  const {
86175
- elementId,
86176
86085
  payment,
86177
86086
  customStyle,
86178
86087
  paymentList,
@@ -86192,8 +86101,7 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
86192
86101
  selectedPaymentMethods,
86193
86102
  integrationType,
86194
86103
  discounts,
86195
- viewMode = 'tab',
86196
- displayName
86104
+ viewMode = 'tab'
86197
86105
  } = props;
86198
86106
  const [paymentMethod, setPaymentMethod] = (0,react.useState)(payment);
86199
86107
  const styles = getStyles_getStyles(customStyle);
@@ -86202,163 +86110,111 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
86202
86110
  var _paymentMethod$name;
86203
86111
  switch ((_paymentMethod$name = paymentMethod.name) == null ? void 0 : _paymentMethod$name.toUpperCase()) {
86204
86112
  case 'CARD':
86205
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86206
- elementId: elementId,
86207
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Card, {
86208
- payment: paymentMethod,
86209
- customStyle: styles,
86210
- baseUrl,
86211
- savedCards,
86212
- disablePay,
86213
- forceSaveCard,
86214
- showSaveCard,
86215
- onBeforePaymentComplete,
86216
- onAfterPaymentComplete,
86217
- onCardValidationChanged,
86218
- showPaymobLogo,
86219
- hideCardHolderName,
86220
- integrationType,
86221
- publicKey
86222
- })
86113
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Card, {
86114
+ payment: paymentMethod,
86115
+ customStyle: styles,
86116
+ baseUrl,
86117
+ savedCards,
86118
+ disablePay,
86119
+ forceSaveCard,
86120
+ showSaveCard,
86121
+ onBeforePaymentComplete,
86122
+ onAfterPaymentComplete,
86123
+ onCardValidationChanged,
86124
+ showPaymobLogo,
86125
+ hideCardHolderName,
86126
+ integrationType,
86127
+ publicKey
86223
86128
  });
86224
86129
  case 'CARD-INSTALLMENT':
86225
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86226
- elementId: elementId,
86227
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(BankInstalment, {
86228
- payment: paymentMethod,
86229
- customStyle: styles,
86230
- baseUrl
86231
- })
86130
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(BankInstalment, {
86131
+ payment: paymentMethod,
86132
+ customStyle: styles,
86133
+ baseUrl
86232
86134
  });
86233
86135
  case 'KNET':
86234
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86235
- elementId: elementId,
86236
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Knet, {
86237
- payment: paymentMethod,
86238
- customStyle: styles
86239
- })
86136
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Knet, {
86137
+ payment: paymentMethod,
86138
+ customStyle: styles
86240
86139
  });
86241
86140
  case 'KNET-APPLE-PAY':
86242
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86243
- elementId: elementId,
86244
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_KnetApplePay, {
86245
- payment: paymentMethod,
86246
- customStyle: styles
86247
- })
86141
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_KnetApplePay, {
86142
+ payment: paymentMethod,
86143
+ customStyle: styles
86248
86144
  });
86249
86145
  case 'NIFT':
86250
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86251
- elementId: elementId,
86252
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(NiftElement, {
86253
- payment: paymentMethod,
86254
- customStyle: styles
86255
- })
86146
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(NiftElement, {
86147
+ payment: paymentMethod,
86148
+ customStyle: styles
86256
86149
  });
86257
86150
  case 'EASYPAISADIRECT':
86258
86151
  case 'EASYPAISA':
86259
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86260
- elementId: elementId,
86261
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(EasypaisaElement, {
86262
- payment: paymentMethod,
86263
- customStyle: styles
86264
- })
86152
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(EasypaisaElement, {
86153
+ payment: paymentMethod,
86154
+ customStyle: styles
86265
86155
  });
86266
86156
  case 'JAZZCASH':
86267
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86268
- elementId: elementId,
86269
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(JazzcashElement, {
86270
- payment: paymentMethod,
86271
- customStyle: styles
86272
- })
86157
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(JazzcashElement, {
86158
+ payment: paymentMethod,
86159
+ customStyle: styles
86273
86160
  });
86274
86161
  case 'POSTPAY':
86275
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86276
- elementId: elementId,
86277
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(PostpayElement, {
86278
- payment: paymentMethod,
86279
- customStyle: styles
86280
- })
86162
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(PostpayElement, {
86163
+ payment: paymentMethod,
86164
+ customStyle: styles
86281
86165
  });
86282
86166
  case 'TABBY':
86283
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86284
- elementId: elementId,
86285
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(TabbyElement, {
86286
- payment: paymentMethod,
86287
- customStyle: styles
86288
- })
86167
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(TabbyElement, {
86168
+ payment: paymentMethod,
86169
+ customStyle: styles
86289
86170
  });
86290
86171
  case 'WALLETS':
86291
86172
  case 'WALLET':
86292
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86293
- elementId: elementId,
86294
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(WalletElement, {
86295
- payment: paymentMethod,
86296
- customStyle: styles
86297
- })
86173
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(WalletElement, {
86174
+ payment: paymentMethod,
86175
+ customStyle: styles
86298
86176
  });
86299
86177
  case 'FORSA':
86300
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86301
- elementId: elementId,
86302
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(ForsaElements, {
86303
- payment: paymentMethod,
86304
- customStyle: styles
86305
- })
86178
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(ForsaElements, {
86179
+ payment: paymentMethod,
86180
+ customStyle: styles
86306
86181
  });
86307
86182
  case 'PREMIUM':
86308
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86309
- elementId: elementId,
86310
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(PremiumElement, {
86311
- payment: paymentMethod,
86312
- customStyle: styles,
86313
- baseUrl
86314
- })
86183
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(PremiumElement, {
86184
+ payment: paymentMethod,
86185
+ customStyle: styles,
86186
+ baseUrl
86315
86187
  });
86316
86188
  case 'KIOSK':
86317
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86318
- elementId: elementId,
86319
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Aman, {
86320
- payment: paymentMethod,
86321
- customStyle: styles
86322
- })
86189
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_Aman, {
86190
+ payment: paymentMethod,
86191
+ customStyle: styles
86323
86192
  });
86324
86193
  case 'VALU':
86325
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86326
- elementId: elementId,
86327
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_ValU, {
86328
- payment: paymentMethod,
86329
- customStyle: styles
86330
- })
86194
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(Payments_ValU, {
86195
+ payment: paymentMethod,
86196
+ customStyle: styles
86331
86197
  });
86332
86198
  case 'SOUHOOLAV3':
86333
86199
  case 'SOUHOOLA':
86334
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86335
- elementId: elementId,
86336
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(SouhoolaElements, {
86337
- payment: paymentMethod,
86338
- customStyle: styles
86339
- })
86200
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(SouhoolaElements, {
86201
+ payment: paymentMethod,
86202
+ customStyle: styles
86340
86203
  });
86341
86204
  case 'SYMPL':
86342
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86343
- elementId: elementId,
86344
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(SymplElement, {
86345
- payment: paymentMethod,
86346
- customStyle: styles,
86347
- baseUrl
86348
- })
86205
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(SymplElement, {
86206
+ payment: paymentMethod,
86207
+ customStyle: styles,
86208
+ baseUrl
86349
86209
  });
86350
86210
  case 'STCPAY':
86351
- return /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
86352
- elementId: elementId,
86353
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(StcPayElement, {
86354
- payment: paymentMethod,
86355
- customStyle: styles
86356
- })
86211
+ return /*#__PURE__*/(0,jsx_runtime.jsx)(StcPayElement, {
86212
+ payment: paymentMethod,
86213
+ customStyle: styles
86357
86214
  });
86358
86215
  }
86359
86216
  }
86360
86217
  return /*#__PURE__*/(0,jsx_runtime.jsx)(List, {
86361
- elementId: elementId,
86362
86218
  payments: paymentList,
86363
86219
  setPaymentMethod: setPaymentMethod,
86364
86220
  customStyle: styles,
@@ -86379,8 +86235,7 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
86379
86235
  ref: ref,
86380
86236
  integrationType: integrationType,
86381
86237
  discounts: discounts,
86382
- viewMode: viewMode,
86383
- displayName: displayName
86238
+ viewMode: viewMode
86384
86239
  });
86385
86240
  };
86386
86241
  return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
@@ -90036,6 +89891,83 @@ i18next.use(initReactI18next).init({
90036
89891
  }
90037
89892
  });
90038
89893
  /* harmony default export */ const localization_i18n = ((/* unused pure expression or super */ null && (i18n)));
89894
+ ;// ./src/utils/ShadowWrapper.tsx
89895
+
89896
+
89897
+
89898
+
89899
+ const ShadowWrapper = ({
89900
+ elementId,
89901
+ children
89902
+ }) => {
89903
+ const [shadowRoot, setShadowRoot] = (0,react.useState)(null);
89904
+ const [error, setError] = (0,react.useState)(null);
89905
+ (0,react.useEffect)(() => {
89906
+ if (!document.getElementById(elementId)) return;
89907
+ document.getElementById(elementId).innerHTML = '';
89908
+ const container = document.getElementById(elementId).appendChild(document.createElement('div'));
89909
+ if (!('attachShadow' in Element.prototype)) {
89910
+ setError('Shadow DOM is not supported in this browser');
89911
+ return;
89912
+ }
89913
+ try {
89914
+ let shadow = container.shadowRoot;
89915
+ if (!shadow) {
89916
+ shadow = container.attachShadow({
89917
+ mode: 'open'
89918
+ });
89919
+ environment.PIXEL_CSS_LINKS.forEach(href => {
89920
+ if (href.match(/\.(woff2?|ttf|otf|eot)$/)) {
89921
+ const fontName = 'currencyFont';
89922
+ const font = new FontFace(fontName, `url(${href})`);
89923
+ font.load().then(loadedFace => {
89924
+ var _shadow;
89925
+ //@ts-ignore
89926
+ document.fonts.add(loadedFace);
89927
+ const style = document.createElement('style');
89928
+ style.textContent = `
89929
+ @font-face {
89930
+ font-family: '${fontName}';
89931
+ src: url('${href}');
89932
+ font-display: swap;
89933
+ }
89934
+ `;
89935
+ (_shadow = shadow) == null || _shadow.appendChild(style);
89936
+ }).catch(err => console.error(`Failed to load font: ${href}`, err));
89937
+ } else {
89938
+ var _shadow2;
89939
+ const link = document.createElement('link');
89940
+ link.rel = 'stylesheet';
89941
+ link.href = href;
89942
+ (_shadow2 = shadow) == null || _shadow2.appendChild(link);
89943
+ }
89944
+ });
89945
+ }
89946
+ setShadowRoot(shadow);
89947
+ } catch (error) {
89948
+ console.error('Failed to create Shadow DOM:', error);
89949
+ setError(`Failed to create Shadow DOM: ${error instanceof Error ? error.message : String(error)}`);
89950
+ }
89951
+ return () => {
89952
+ setShadowRoot(null);
89953
+ };
89954
+ }, [elementId]);
89955
+ if (error) {
89956
+ const container = document.getElementById(elementId);
89957
+ return /*#__PURE__*/(0,react_dom.createPortal)(/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
89958
+ style: {
89959
+ color: 'red',
89960
+ padding: '10px'
89961
+ },
89962
+ children: error
89963
+ }), container);
89964
+ }
89965
+ if (shadowRoot) {
89966
+ return /*#__PURE__*/(0,react_dom.createPortal)(children, shadowRoot);
89967
+ }
89968
+ return null;
89969
+ };
89970
+ /* harmony default export */ const utils_ShadowWrapper = (ShadowWrapper);
90039
89971
  ;// ./src/lib/pixel.tsx
90040
89972
  var _Pixel;
90041
89973
 
@@ -90048,6 +89980,7 @@ var _Pixel;
90048
89980
 
90049
89981
 
90050
89982
 
89983
+
90051
89984
  class Pixel {
90052
89985
  constructor(options) {
90053
89986
  var _options$showPaymobLo;
@@ -90212,35 +90145,37 @@ class Pixel {
90212
90145
  return;
90213
90146
  }
90214
90147
  this._root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode, {
90215
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(components_Payments, Object.assign({
90148
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(utils_ShadowWrapper, {
90216
90149
  elementId: elementId,
90217
- baseUrl: this._baseURL,
90218
- paymentList: this._paymentList,
90219
- payment: this._paymentMethod,
90220
- disablePay: this._options['disablePay'],
90221
- showPaymobLogo: this._options['showPaymobLogo'],
90222
- customStyle: this._options['customStyle'],
90223
- savedCards: this._savedCards,
90224
- forceSaveCard: this._options['forceSaveCard'],
90225
- showSaveCard: this._options['showSaveCard'],
90226
- hideCardHolderName: this._options['hideCardHolderName'],
90227
- publicKey: this._options['publicKey'],
90228
- clientSecret: this._options['clientSecret'],
90229
- selectedPaymentMethods: this._options['paymentMethods'],
90230
- ref: this._paymentsRef
90231
- }, this._options.beforePaymentComplete && {
90232
- onBeforePaymentComplete: this.handleBeforePaymentComplete.bind(this)
90233
- }, this._options.afterPaymentComplete && {
90234
- onAfterPaymentComplete: this.handleAfterPaymentComplete.bind(this)
90235
- }, this._options.onPaymentCancel && {
90236
- onPaymentCancel: this.handleOnPaymentCancel.bind(this)
90237
- }, this._options.cardValidationChanged && {
90238
- onCardValidationChanged: this.handleCardValidationChanged.bind(this)
90239
- }, {
90240
- integrationType: this._integrationType,
90241
- discounts: this._discounts,
90242
- viewMode: this._options.viewMode
90243
- }), Date.now())
90150
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(components_Payments, Object.assign({
90151
+ baseUrl: this._baseURL,
90152
+ paymentList: this._paymentList,
90153
+ payment: this._paymentMethod,
90154
+ disablePay: this._options['disablePay'],
90155
+ showPaymobLogo: this._options['showPaymobLogo'],
90156
+ customStyle: this._options['customStyle'],
90157
+ savedCards: this._savedCards,
90158
+ forceSaveCard: this._options['forceSaveCard'],
90159
+ showSaveCard: this._options['showSaveCard'],
90160
+ hideCardHolderName: this._options['hideCardHolderName'],
90161
+ publicKey: this._options['publicKey'],
90162
+ clientSecret: this._options['clientSecret'],
90163
+ selectedPaymentMethods: this._options['paymentMethods'],
90164
+ ref: this._paymentsRef
90165
+ }, this._options.beforePaymentComplete && {
90166
+ onBeforePaymentComplete: this.handleBeforePaymentComplete.bind(this)
90167
+ }, this._options.afterPaymentComplete && {
90168
+ onAfterPaymentComplete: this.handleAfterPaymentComplete.bind(this)
90169
+ }, this._options.onPaymentCancel && {
90170
+ onPaymentCancel: this.handleOnPaymentCancel.bind(this)
90171
+ }, this._options.cardValidationChanged && {
90172
+ onCardValidationChanged: this.handleCardValidationChanged.bind(this)
90173
+ }, {
90174
+ integrationType: this._integrationType,
90175
+ discounts: this._discounts,
90176
+ viewMode: this._options.viewMode
90177
+ }), Date.now())
90178
+ })
90244
90179
  }));
90245
90180
  }
90246
90181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-pixel-alpha",
3
- "version": "1.1.64",
3
+ "version": "1.1.65",
4
4
  "keywords": ["paymob","pixel","paymob-pixel"],
5
5
  "main": "./main.js",
6
6
  "license": "MIT",