paymob-pixel-alpha 1.1.3 → 1.1.5

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 (4) hide show
  1. package/main.css +1 -1
  2. package/main.js +243 -67
  3. package/package.json +1 -1
  4. package/styles.css +38 -0
package/main.css CHANGED
@@ -76,7 +76,7 @@
76
76
  }
77
77
  }
78
78
 
79
- .card_action-btn__9Y5Ha{display:flex;justify-content:center;gap:1rem}.card_gotham__a35IS{font-family:"Gotham"}.card_gotham__a35IS *{font-family:"Gotham"}
79
+ .card_action-btn__9Y5Ha{display:flex;justify-content:center;gap:1rem}.card_gotham__a35IS{font-family:"Gotham"}.card_gotham__a35IS *{font-family:"Gotham"}.card_iframe__cRxaZ{border:0;overflow:hidden;z-index:5;position:relative}
80
80
  .bank-details_actions__LE0s9{display:flex;justify-content:center;margin-top:.75rem}.bank-details_row__X6sSZ{display:flex;margin-bottom:.75rem;column-gap:.75rem}.bank-details_accountNoLogo__KOR5M{position:relative;left:-10px}
81
81
  .bank-selection_actions__fy7Ox{display:flex;justify-content:center;margin-top:1.5rem}
82
82
  .otp_error-message__Jl9Pb{color:red;font-size:13px;margin-bottom:20px}.otp_hint__FF51s{font-size:11px;color:#b7b7b7;font-weight:bold;text-align:center;display:block;margin-bottom:20px}.otp_hint__FF51s p{margin:0 5px}.otp_otp-container__qxM9e{margin-bottom:1.25rem}.otp_resend-otp-container__RTV7D{margin-bottom:1.25rem}.otp_actions__8W-lZ{display:flex;justify-content:center}
package/main.js CHANGED
@@ -7440,7 +7440,7 @@ function InputViewTwo_InputViewTwo(props) {
7440
7440
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
7441
7441
  className: "flex flex-col w-full [&_*]:border-box relative",
7442
7442
  children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
7443
- className: [`flex justify-between items-center gap-2 py-2.5 px-3 w-full h-10 relative overflow-hidden border border-gray-300 ${borderStyleState === borderStyle_borderStyleConstants.RECTANGULAR ? 'rounded-none' : 'rounded-lg'} bg-white`, className].join(' '),
7443
+ className: [`flex justify-between items-center gap-2 py-2.5 px-3 w-full h-10 relative overflow-hidden border border-solid border-gray-300 ${borderStyleState === borderStyle_borderStyleConstants.RECTANGULAR ? 'rounded-none' : 'rounded-lg'} bg-white`, className].join(' '),
7444
7444
  style: customStyle != null && customStyle.input ? customStyle == null ? void 0 : customStyle.input : customStyle,
7445
7445
  children: [label && /*#__PURE__*/(0,jsx_runtime.jsx)("label", {
7446
7446
  className: "w-5 h-5 text-sm flex justify-start items-center whitespace-nowrap text-end",
@@ -9990,10 +9990,21 @@ function Accordion(props) {
9990
9990
  const {
9991
9991
  borderStyle
9992
9992
  } = useSelector(state => state.customization);
9993
+ const isSympl = type === 'sympl' || type === 'symplv2';
9993
9994
  const sortedPaymentNames = ['card', 'e-wallet', 'installments', 'pay later', 'kiosk'];
9995
+ let badge = null;
9996
+ if (isSympl) {
9997
+ badge = /*#__PURE__*/_jsx("div", {
9998
+ className: "absolute -top-3 left-1/2 -translate-x-1/2 w-auto min-w-[8rem] h-4 flex px-2 py-[0.6rem] justify-center items-center rounded-2xl bg-gray-100 overflow-visible",
9999
+ children: /*#__PURE__*/_jsx("span", {
10000
+ className: "text-gray-700 text-[0.65rem] font-medium leading-6 tracking-[0.01rem] whitespace-nowrap",
10001
+ children: "0% interest on any card"
10002
+ })
10003
+ });
10004
+ }
9994
10005
  return /*#__PURE__*/_jsxs("div", {
9995
- className: `border border-gray-200 ${borderStyle === borderStyleConstants.RECTANGULAR ? 'rounded-none' : 'rounded-lg'} w-full px-4`,
9996
- children: [/*#__PURE__*/_jsxs("div", {
10006
+ className: `border border-gray-200 ${borderStyle === borderStyleConstants.RECTANGULAR ? 'rounded-none' : 'rounded-lg'} w-full px-4 relative`,
10007
+ children: [badge, /*#__PURE__*/_jsxs("div", {
9997
10008
  className: "flex gap-3 items-center cursor-pointer py-4",
9998
10009
  onClick: toggleAccordion,
9999
10010
  children: [/*#__PURE__*/_jsx("img", {
@@ -17078,7 +17089,7 @@ function SecureCheckout(props) {
17078
17089
  } = useTranslation('kitComponents');
17079
17090
  return /*#__PURE__*/_jsxs("div", {
17080
17091
  ref: scrollRef,
17081
- className: `flex ${!isMobile ? 'border-b justify-between border-gray-200 mx-20 py-11' : 'justify-center'} ${isMobile && isDark(colors == null ? void 0 : colors.accent) ? '[&_*]:text-white' : ''}`,
17092
+ className: `flex ${!isMobile ? 'border-b justify-between border-gray-200 mx-20 [@media(max-height:880px)]:py-4 py-11' : 'justify-center'} ${isMobile && isDark(colors == null ? void 0 : colors.accent) ? '[&_*]:text-white' : ''}`,
17082
17093
  style: {
17083
17094
  background: isMobile ? colors == null ? void 0 : colors.accent : ''
17084
17095
  },
@@ -18274,7 +18285,7 @@ function cardFormViewTwo_Card(props) {
18274
18285
  id: "pay-button",
18275
18286
  loading: loading,
18276
18287
  fullWidth: true,
18277
- disabled: !isDirty || !isValid,
18288
+ disabled: !isDirty || !isValid || loading,
18278
18289
  customStyle: styling.button
18279
18290
  })]
18280
18291
  })]
@@ -18757,7 +18768,8 @@ function IframeCard(props) {
18757
18768
  isOmanNetCard,
18758
18769
  setIsOmanNetCard,
18759
18770
  hasOmanNetIntegration,
18760
- setHasOmanNetIntegration
18771
+ setHasOmanNetIntegration,
18772
+ handleGenerateToken
18761
18773
  } = props;
18762
18774
  const [iframeCardHight, setIframeCardHight] = useState();
18763
18775
  const [iframeCustomStyles, setIframeCustomStyles] = useState({});
@@ -18770,6 +18782,9 @@ function IframeCard(props) {
18770
18782
  const [cardHolderError, setCardHolderError] = useState();
18771
18783
  const [cardHolderNameHidden, setCardHolderNameHidden] = useState(false);
18772
18784
  const [currency, setCurrency] = useState('');
18785
+ const [country, setCountry] = useState('');
18786
+ const [publicKey, setPublicKey] = useState('');
18787
+ const [integrationType, setIntegrationType] = useState('directPayment');
18773
18788
  const {
18774
18789
  handleSubmit,
18775
18790
  errors,
@@ -18782,7 +18797,8 @@ function IframeCard(props) {
18782
18797
  cardType
18783
18798
  } = useHookForm({
18784
18799
  isIframe: true,
18785
- hasOmanNetIntegration
18800
+ hasOmanNetIntegration,
18801
+ countryName: country
18786
18802
  });
18787
18803
  const timeoutIdRef = useRef();
18788
18804
  useEffect(() => {
@@ -18803,6 +18819,8 @@ function IframeCard(props) {
18803
18819
  handleCardStylesFromSDK(event.data.payload);
18804
18820
  } else if (event.data.type === 'cardHolderError') {
18805
18821
  handleCardHolderErrorFromSDK(event.data.payload);
18822
+ } else if (event.data.type === 'tokenizeCard') {
18823
+ handleTokenizeCardDataFromSDK(event.data.payload);
18806
18824
  }
18807
18825
  };
18808
18826
  const handleCardHolderErrorFromSDK = payload => {
@@ -18838,6 +18856,21 @@ function IframeCard(props) {
18838
18856
  if (payload.currency) {
18839
18857
  setCurrency(payload.currency);
18840
18858
  }
18859
+ if (payload.country) {
18860
+ setCountry(payload.country);
18861
+ }
18862
+ };
18863
+ const handleTokenizeCardDataFromSDK = payload => {
18864
+ setIntegrationType('tokenization');
18865
+ if (payload.publicKey) {
18866
+ setPublicKey(payload.publicKey);
18867
+ }
18868
+ if (payload.cardHolderName) {
18869
+ setCardHolderName(payload.cardHolderName);
18870
+ }
18871
+ if (payload.shouldSubmitData) {
18872
+ setShouldSubmitData(payload.shouldSubmitData);
18873
+ }
18841
18874
  };
18842
18875
  const handleCardStylesFromSDK = payload => {
18843
18876
  var _payload$options;
@@ -18872,14 +18905,22 @@ function IframeCard(props) {
18872
18905
  if (shouldSubmitData) {
18873
18906
  if (isValid && isDirty) {
18874
18907
  const data = getValues();
18875
- handleCardSubmit({
18876
- data,
18877
- cardHolderName,
18878
- paymentToken: hasOmanNetIntegration && isOmanNetCard ? subType.paymentToken : paymentToken,
18879
- subType: hasOmanNetIntegration && isOmanNetCard ? subType.type : 'CARD',
18880
- saveCard,
18881
- tenure
18882
- });
18908
+ if (integrationType === 'tokenization') {
18909
+ handleGenerateToken({
18910
+ data,
18911
+ cardHolderName,
18912
+ publicKey
18913
+ });
18914
+ } else {
18915
+ handleCardSubmit({
18916
+ data,
18917
+ cardHolderName,
18918
+ paymentToken: hasOmanNetIntegration && isOmanNetCard ? subType.paymentToken : paymentToken,
18919
+ subType: hasOmanNetIntegration && isOmanNetCard ? subType.type : 'CARD',
18920
+ saveCard,
18921
+ tenure
18922
+ });
18923
+ }
18883
18924
  setShouldSubmitData(false);
18884
18925
  }
18885
18926
  }
@@ -19832,7 +19873,7 @@ const environment = {
19832
19873
  };
19833
19874
  ;// CONCATENATED MODULE: ./src/components/Payments/Card/card.module.scss
19834
19875
  // extracted by mini-css-extract-plugin
19835
- /* harmony default export */ const card_module = ({"action-btn":"card_action-btn__9Y5Ha","gotham":"card_gotham__a35IS"});
19876
+ /* harmony default export */ const card_module = ({"action-btn":"card_action-btn__9Y5Ha","gotham":"card_gotham__a35IS","iframe":"card_iframe__cRxaZ"});
19836
19877
  ;// CONCATENATED MODULE: ./src/services/cardService.ts
19837
19878
 
19838
19879
  const payWithSavedCard = payload => {
@@ -19887,6 +19928,11 @@ const getErrorMsg = err => {
19887
19928
  }
19888
19929
  return DECLINED_MESSAGE;
19889
19930
  };
19931
+ ;// CONCATENATED MODULE: ./src/constants/index.ts
19932
+ const INTEGRATION_TYPE = {
19933
+ DIRECT_PAYMENT: 'directPayment',
19934
+ TOKENIZATION: 'tokenization'
19935
+ };
19890
19936
  ;// CONCATENATED MODULE: ./src/components/Payments/Card/index.tsx
19891
19937
 
19892
19938
 
@@ -19899,7 +19945,8 @@ const getErrorMsg = err => {
19899
19945
 
19900
19946
 
19901
19947
 
19902
- function CardElement({
19948
+
19949
+ const CardElement = /*#__PURE__*/(0,react.forwardRef)(({
19903
19950
  payment,
19904
19951
  customStyle,
19905
19952
  tenure,
@@ -19914,8 +19961,11 @@ function CardElement({
19914
19961
  onCardValidationChanged,
19915
19962
  showPaymobLogo,
19916
19963
  hideCardHolderName,
19917
- isLoading
19918
- }) {
19964
+ isLoading,
19965
+ country,
19966
+ integrationType,
19967
+ publicKey
19968
+ }, ref) => {
19919
19969
  var _customStyle$containe, _customStyle$containe2, _customStyle$button, _customStyle$containe3;
19920
19970
  const {
19921
19971
  token,
@@ -19933,11 +19983,10 @@ function CardElement({
19933
19983
  const [isActionBtnDisabled, setIsActionBtnDisabled] = (0,react.useState)(false);
19934
19984
  const [shouldSubmitData, setShouldSubmitData] = (0,react.useState)(false);
19935
19985
  const [saveCard, setSaveCard] = (0,react.useState)(false);
19936
- const [height, setHeight] = (0,react.useState)(80.5);
19986
+ const [height, setHeight] = (0,react.useState)(80);
19937
19987
  const [errorMessage, setErrorMessage] = (0,react.useState)('');
19938
19988
  const iframeRef = (0,react.useRef)(null);
19939
19989
  const [errors, setErrors] = (0,react.useState)({});
19940
- const iframe = document.getElementById('iFrame');
19941
19990
  const [isIframeLoaded, setIsIframeLoaded] = (0,react.useState)(false);
19942
19991
  const [showDeleteCardModal, setShowDeleteCardModal] = (0,react.useState)(false);
19943
19992
  const [selectedDeleteCard, setSelectedDeleteCard] = (0,react.useState)();
@@ -19950,6 +19999,7 @@ function CardElement({
19950
19999
  const [sendOTPLoading, setSendOTPLoading] = (0,react.useState)(false);
19951
20000
  const [paymentId, setPaymentId] = (0,react.useState)('');
19952
20001
  const [otpErrorMessage, setOTPErrorMessage] = (0,react.useState)('');
20002
+ const tokenizationResolve = (0,react.useRef)(null);
19953
20003
  const isCardValid = hideCardHolderName ? !isActionBtnDisabled : !(isActionBtnDisabled || !cardHolderName);
19954
20004
  const isAmexCardSelected = (selectedCard == null ? void 0 : selectedCard.type) === constants_CARD_TYPES.AMEX;
19955
20005
  const selectedCardCvvLength = selectedCardCVV.length;
@@ -19958,17 +20008,19 @@ function CardElement({
19958
20008
  const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
19959
20009
  (0,react.useEffect)(() => {
19960
20010
  const handleDataFromIframe = event => {
19961
- var _event$data, _event$data2;
20011
+ var _iframeRef$current, _event$data, _event$data2, _event$data3;
19962
20012
  if (!event.data) return;
19963
20013
  if (!event.data.type) return;
20014
+ if (event.source !== ((_iframeRef$current = iframeRef.current) == null ? void 0 : _iframeRef$current.contentWindow)) return;
19964
20015
  if (event.data.shouldFocusOnCardName) {
19965
- const cardNameField = document.querySelector(`input[name=name]`);
20016
+ var _iframeRef$current2;
20017
+ const cardNameField = (_iframeRef$current2 = iframeRef.current) == null || (_iframeRef$current2 = _iframeRef$current2.nextElementSibling) == null ? void 0 : _iframeRef$current2.querySelector(`input[name=name]`);
19966
20018
  if (cardNameField !== null) {
19967
20019
  cardNameField.focus();
19968
20020
  }
19969
20021
  }
19970
20022
  if (event.data.iframeCardHight) {
19971
- setHeight(event.data.iframeCardHight + 0.5);
20023
+ setHeight(event.data.iframeCardHight);
19972
20024
  }
19973
20025
  if (event.data.selectedCardCVV) {
19974
20026
  setSelectedCardCVV(event.data.selectedCardCVV);
@@ -19991,16 +20043,20 @@ function CardElement({
19991
20043
  if ((event == null || (_event$data2 = event.data) == null ? void 0 : _event$data2.type) === 'openCVVToolTipModal') {
19992
20044
  setShowCVVTooltipModal(true);
19993
20045
  }
20046
+ if ((event == null || (_event$data3 = event.data) == null ? void 0 : _event$data3.type) === 'tokenizationResponse' && tokenizationResolve.current) {
20047
+ tokenizationResolve.current(event.data.response.res);
20048
+ tokenizationResolve.current = null;
20049
+ }
19994
20050
  };
19995
20051
  const handlePaymentResponse = ({
19996
20052
  res,
19997
20053
  requiresOTP,
19998
20054
  isOTPResponse
19999
20055
  }) => {
20000
- var _res$data, _res$data2, _res$data3;
20056
+ var _iframeRef$current3, _res$data, _res$data2, _res$data3;
20001
20057
  setShouldSubmitData(false);
20002
20058
  setSendOTPLoading(false);
20003
- const cardHolderInput = document.getElementById('name');
20059
+ const cardHolderInput = (_iframeRef$current3 = iframeRef.current) == null || (_iframeRef$current3 = _iframeRef$current3.nextElementSibling) == null ? void 0 : _iframeRef$current3.querySelector(`input[name=name]`);
20004
20060
  if (cardHolderInput) {
20005
20061
  setTimeout(() => cardHolderInput.disabled = false, 1000);
20006
20062
  }
@@ -20072,10 +20128,11 @@ function CardElement({
20072
20128
  };
20073
20129
  }, [isCardValid, shouldDisablePayBtn, showCardModal, savedCards == null ? void 0 : savedCards.length]);
20074
20130
  (0,react.useEffect)(() => {
20075
- if (iframe && shouldSubmitData) {
20131
+ if (iframeRef.current && shouldSubmitData) {
20076
20132
  const handlePay = async () => {
20133
+ var _iframeRef$current4;
20077
20134
  if (loading) return;
20078
- const cardHolderInput = document.getElementById('name');
20135
+ const cardHolderInput = (_iframeRef$current4 = iframeRef.current) == null || (_iframeRef$current4 = _iframeRef$current4.nextElementSibling) == null ? void 0 : _iframeRef$current4.querySelector(`input[name=name]`);
20079
20136
  if (cardHolderInput) {
20080
20137
  cardHolderInput.disabled = true;
20081
20138
  }
@@ -20093,16 +20150,17 @@ function CardElement({
20093
20150
  };
20094
20151
  handlePay();
20095
20152
  }
20096
- }, [cardHolderName, saveCard, shouldSubmitData, iframe]);
20153
+ }, [cardHolderName, saveCard, shouldSubmitData, iframeRef.current]);
20097
20154
  (0,react.useEffect)(() => {
20098
20155
  if (isIframeLoaded) {
20099
20156
  sendCardData();
20100
20157
  }
20101
20158
  }, [isIframeLoaded, payment]);
20102
20159
  (0,react.useEffect)(() => {
20160
+ let resizeObserver = null;
20103
20161
  if (isIframeLoaded) {
20104
- var _iframe$contentWindow;
20105
- (_iframe$contentWindow = iframe.contentWindow) == null || _iframe$contentWindow.postMessage({
20162
+ var _iframeRef$current5, _iframeRef$current6;
20163
+ (_iframeRef$current5 = iframeRef.current) == null || (_iframeRef$current5 = _iframeRef$current5.contentWindow) == null || _iframeRef$current5.postMessage({
20106
20164
  type: 'customStyles',
20107
20165
  payload: {
20108
20166
  styling: customStyle,
@@ -20111,11 +20169,25 @@ function CardElement({
20111
20169
  }
20112
20170
  }
20113
20171
  }, '*');
20172
+ const nextElement = (_iframeRef$current6 = iframeRef.current) == null ? void 0 : _iframeRef$current6.nextElementSibling;
20173
+ resizeObserver = new ResizeObserver(entries => {
20174
+ for (let entry of entries) {
20175
+ const width = Math.floor(entry.contentRect.width - 0.5);
20176
+ if (nextElement) {
20177
+ nextElement.style.width = `${width}px`;
20178
+ }
20179
+ }
20180
+ });
20181
+ iframeRef.current && resizeObserver.observe(iframeRef.current);
20114
20182
  }
20183
+ return () => {
20184
+ var _resizeObserver;
20185
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.disconnect();
20186
+ };
20115
20187
  }, [isIframeLoaded, iframeRef.current]);
20116
20188
  (0,react.useEffect)(() => {
20117
- var _iframe$contentWindow2;
20118
- iframe == null || (_iframe$contentWindow2 = iframe.contentWindow) == null || _iframe$contentWindow2.postMessage({
20189
+ var _iframeRef$current7;
20190
+ (_iframeRef$current7 = iframeRef.current) == null || (_iframeRef$current7 = _iframeRef$current7.contentWindow) == null || _iframeRef$current7.postMessage({
20119
20191
  type: 'cardHolderError',
20120
20192
  payload: {
20121
20193
  error: errors['name']
@@ -20133,21 +20205,43 @@ function CardElement({
20133
20205
  previousValidationRef.current = isCardValid;
20134
20206
  }
20135
20207
  }, [isCardValid, shouldDisablePayBtn]);
20208
+ (0,react.useImperativeHandle)(ref, () => ({
20209
+ handleGenerateToken
20210
+ }));
20211
+ async function handleGenerateToken() {
20212
+ return new Promise((resolve, reject) => {
20213
+ var _iframeRef$current8;
20214
+ if (loading || !isCardValid || isLoading) {
20215
+ return reject();
20216
+ }
20217
+ tokenizationResolve.current = resolve;
20218
+ (_iframeRef$current8 = iframeRef.current) == null || (_iframeRef$current8 = _iframeRef$current8.contentWindow) == null || _iframeRef$current8.postMessage({
20219
+ type: 'tokenizeCard',
20220
+ payload: {
20221
+ publicKey,
20222
+ cardHolderName,
20223
+ shouldSubmitData: true
20224
+ }
20225
+ }, '*');
20226
+ });
20227
+ }
20228
+ ;
20136
20229
  const sendCardData = shouldSubmitData => {
20137
- var _iframe$contentWindow3, _payment$subType, _payment$subType2;
20138
- (_iframe$contentWindow3 = iframe.contentWindow) == null || _iframe$contentWindow3.postMessage({
20230
+ var _iframeRef$current9, _payment$subType, _payment$subType2;
20231
+ (_iframeRef$current9 = iframeRef.current) == null || (_iframeRef$current9 = _iframeRef$current9.contentWindow) == null || _iframeRef$current9.postMessage({
20139
20232
  type: 'cardData',
20140
20233
  payload: {
20141
- paymentToken: payment.token,
20234
+ paymentToken: payment == null ? void 0 : payment.token,
20142
20235
  subType: {
20143
- paymentToken: (_payment$subType = payment.subType) == null ? void 0 : _payment$subType.token,
20144
- type: (_payment$subType2 = payment.subType) == null ? void 0 : _payment$subType2.type
20236
+ paymentToken: payment == null || (_payment$subType = payment.subType) == null ? void 0 : _payment$subType.token,
20237
+ type: payment == null || (_payment$subType2 = payment.subType) == null ? void 0 : _payment$subType2.type
20145
20238
  },
20146
20239
  currency,
20147
20240
  cardHolderName,
20148
20241
  saveCard: forceSaveCard || saveCard,
20149
20242
  tenure,
20150
- shouldSubmitData: shouldSubmitData
20243
+ shouldSubmitData: shouldSubmitData,
20244
+ country
20151
20245
  }
20152
20246
  }, '*');
20153
20247
  };
@@ -20155,8 +20249,8 @@ function CardElement({
20155
20249
  setShouldSubmitData(true);
20156
20250
  };
20157
20251
  const handleFocusToPrevInput = () => {
20158
- var _iframe$contentWindow4;
20159
- (_iframe$contentWindow4 = iframe.contentWindow) == null || _iframe$contentWindow4.postMessage({
20252
+ var _iframeRef$current10;
20253
+ (_iframeRef$current10 = iframeRef.current) == null || (_iframeRef$current10 = _iframeRef$current10.contentWindow) == null || _iframeRef$current10.postMessage({
20160
20254
  type: 'setPrevFocus',
20161
20255
  payload: {
20162
20256
  shouldFocusOnCVV: true
@@ -20241,9 +20335,9 @@ function CardElement({
20241
20335
  }
20242
20336
  };
20243
20337
  const handleOTPSubmit = async otp => {
20244
- var _iframe$contentWindow5, _payment$subType3;
20338
+ var _iframeRef$current11, _payment$subType3;
20245
20339
  setSendOTPLoading(true);
20246
- (_iframe$contentWindow5 = iframe.contentWindow) == null || _iframe$contentWindow5.postMessage({
20340
+ (_iframeRef$current11 = iframeRef.current) == null || (_iframeRef$current11 = _iframeRef$current11.contentWindow) == null || _iframeRef$current11.postMessage({
20247
20341
  type: 'otpData',
20248
20342
  payload: {
20249
20343
  paymentToken: payment.token,
@@ -20350,7 +20444,7 @@ function CardElement({
20350
20444
  })]
20351
20445
  }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20352
20446
  className: "[&>div:nth-child(even)]:w-[calc(100%-1px)]",
20353
- children: [(!isIframeLoaded || !payment.token) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20447
+ children: [(!isIframeLoaded || !(payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION)) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20354
20448
  className: "-mt-1",
20355
20449
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
20356
20450
  height: 37
@@ -20371,10 +20465,9 @@ function CardElement({
20371
20465
  src: `${baseUrl}/${environment['IFRAME_PATH']}/?type=card&v=2`
20372
20466
  // src={`http://localhost:9001/${environment['IFRAME_PATH']}/?type=card&v=2`}
20373
20467
  ,
20468
+ className: card_module['iframe'],
20374
20469
  style: {
20375
- border: '0',
20376
- overflow: 'hidden',
20377
- display: isIframeLoaded && payment.token ? 'block' : 'none'
20470
+ display: isIframeLoaded && (payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION) ? 'block' : 'none'
20378
20471
  },
20379
20472
  frameBorder: "0",
20380
20473
  scrolling: "no",
@@ -20385,7 +20478,7 @@ function CardElement({
20385
20478
  setIsIframeLoaded(true);
20386
20479
  }, 200);
20387
20480
  }
20388
- }), isIframeLoaded && payment.token && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
20481
+ }), isIframeLoaded && (payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
20389
20482
  children: [!hideCardHolderName && /*#__PURE__*/(0,jsx_runtime.jsx)(components_CardHolder_CardHolder, {
20390
20483
  onChange: handleCardHolderChange,
20391
20484
  focusToPrevInput: handleFocusToPrevInput,
@@ -20419,7 +20512,7 @@ function CardElement({
20419
20512
  onChange: e => setSaveCard(e.target.checked),
20420
20513
  customStyle: customStyle == null ? void 0 : customStyle.label
20421
20514
  })
20422
- }), !disablePay && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
20515
+ }), !disablePay && integrationType === INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
20423
20516
  className: card_module['action-btn'],
20424
20517
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
20425
20518
  id: 'pay-button',
@@ -20429,7 +20522,7 @@ function CardElement({
20429
20522
  onClick: () => setShouldSubmitData(true),
20430
20523
  customStyle: customStyle == null ? void 0 : customStyle.button
20431
20524
  })
20432
- }), showPaymobLogo && /*#__PURE__*/(0,jsx_runtime.jsx)(CopyrightsViewTwo_Copyrights, {
20525
+ }), showPaymobLogo && integrationType === INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)(CopyrightsViewTwo_Copyrights, {
20433
20526
  isElements: true
20434
20527
  })]
20435
20528
  })]
@@ -20478,7 +20571,7 @@ function CardElement({
20478
20571
  })]
20479
20572
  })]
20480
20573
  });
20481
- }
20574
+ });
20482
20575
  /* harmony default export */ const Payments_Card = (CardElement);
20483
20576
  ;// CONCATENATED MODULE: ../../libs/form-validation/src/lib/form-validation.ts
20484
20577
 
@@ -26957,7 +27050,8 @@ function ApplePay(props) {
26957
27050
  checkDiscount,
26958
27051
  isPixel,
26959
27052
  isLoading,
26960
- paymentName
27053
+ paymentName,
27054
+ country
26961
27055
  } = props;
26962
27056
  const [loading, setLoading] = (0,react.useState)(false);
26963
27057
  const [discount, setDiscount] = (0,react.useState)({
@@ -26997,7 +27091,7 @@ function ApplePay(props) {
26997
27091
  amount: discount.hasDiscount ? discount.discountAmount : amount
26998
27092
  }
26999
27093
  };
27000
- if (window.location.hostname === "accept.paymob.com" || window.location.hostname === "accept.paymobsolutions.com") {
27094
+ if (country === 'EGYPT') {
27001
27095
  payload.supportedNetworks.push('meeza');
27002
27096
  }
27003
27097
  if (clientInfo === null) {
@@ -27431,7 +27525,8 @@ function ApplePayElements({
27431
27525
  onBeforePaymentComplete,
27432
27526
  onAfterPaymentComplete,
27433
27527
  onPaymentCancel,
27434
- isLoading
27528
+ isLoading,
27529
+ country
27435
27530
  }) {
27436
27531
  var _amount$toString;
27437
27532
  const {
@@ -27444,6 +27539,7 @@ function ApplePayElements({
27444
27539
  window.location.href = resData.redirection_url;
27445
27540
  };
27446
27541
  return /*#__PURE__*/(0,jsx_runtime.jsx)(ApplePay, {
27542
+ country: country,
27447
27543
  countryCode: currency == null ? void 0 : currency.slice(0, 2),
27448
27544
  currency: currency,
27449
27545
  amount: (_amount$toString = amount.toString()) == null ? void 0 : _amount$toString.replace(/,/g, ''),
@@ -27530,6 +27626,35 @@ async function fetchPayments(publicKey, clientSecret, paymentMethods) {
27530
27626
  savedCards: formattedSavedCards
27531
27627
  };
27532
27628
  }
27629
+ ;// CONCATENATED MODULE: ./src/constants/countries.ts
27630
+ const COUNTRIES = {
27631
+ EGYPT: 'EGYPT',
27632
+ UAE: 'UAE',
27633
+ PAKISTAN: 'PAKISTAN',
27634
+ OMAN: 'OMAN',
27635
+ SAUDI_ARABIA: 'SAUDI_ARABIA'
27636
+ };
27637
+ const COUNTRY_TO_CODE = {
27638
+ [COUNTRIES.EGYPT]: 'egy',
27639
+ [COUNTRIES.UAE]: 'are',
27640
+ [COUNTRIES.PAKISTAN]: 'pak',
27641
+ [COUNTRIES.OMAN]: 'omn',
27642
+ [COUNTRIES.SAUDI_ARABIA]: 'sau'
27643
+ };
27644
+ const CODE_TO_COUNTRY = Object.fromEntries(Object.entries(COUNTRY_TO_CODE).map(([country, code]) => [code, country]));
27645
+ ;// CONCATENATED MODULE: ./src/utils/getCountry.ts
27646
+
27647
+ function getCountryCodeByKeys(publicKey, clientSecret) {
27648
+ let countryCode = publicKey.split('_')[0] || '';
27649
+ if (!['egy', 'are', 'pak', 'omn', 'sau'].includes(countryCode)) {
27650
+ countryCode = clientSecret.split('_')[0] || '';
27651
+ }
27652
+ return countryCode;
27653
+ }
27654
+ function getCountryByKeys(publicKey, clientSecret) {
27655
+ const countryCode = getCountryCodeByKeys(publicKey, clientSecret);
27656
+ return CODE_TO_COUNTRY[countryCode];
27657
+ }
27533
27658
  ;// CONCATENATED MODULE: ./src/components/Payments/List/index.tsx
27534
27659
 
27535
27660
 
@@ -27542,6 +27667,7 @@ async function fetchPayments(publicKey, clientSecret, paymentMethods) {
27542
27667
 
27543
27668
 
27544
27669
 
27670
+
27545
27671
  const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27546
27672
  var _customStyle$containe;
27547
27673
  const {
@@ -27560,7 +27686,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27560
27686
  hideCardHolderName,
27561
27687
  publicKey,
27562
27688
  clientSecret,
27563
- selectedPaymentMethods
27689
+ selectedPaymentMethods,
27690
+ integrationType
27564
27691
  } = props;
27565
27692
  const {
27566
27693
  t
@@ -27571,6 +27698,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27571
27698
  const [savedCardsList, setSavedCardsList] = (0,react.useState)(savedCards);
27572
27699
  const [errorMessage, setErrorMessage] = (0,react.useState)('');
27573
27700
  const [isLoading, setIsLoading] = (0,react.useState)(false);
27701
+ const country = getCountryByKeys(publicKey, clientSecret);
27574
27702
  (0,react.useImperativeHandle)(ref, () => ({
27575
27703
  getData: async () => {
27576
27704
  setIsLoading(true);
@@ -27638,7 +27766,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27638
27766
  onAfterPaymentComplete: onAfterPaymentComplete,
27639
27767
  onPaymentCancel: onPaymentCancel,
27640
27768
  customStyle: customStyle == null ? void 0 : customStyle.button,
27641
- isLoading: isLoading
27769
+ isLoading: isLoading,
27770
+ country: country
27642
27771
  }), isGooglePay() && /*#__PURE__*/(0,jsx_runtime.jsx)(GooglePayElement, {
27643
27772
  payment: googlePaymentMethod,
27644
27773
  customStyle: customStyle == null ? void 0 : customStyle.button,
@@ -27684,6 +27813,10 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27684
27813
  showPaymobLogo,
27685
27814
  hideCardHolderName,
27686
27815
  isLoading,
27816
+ country,
27817
+ integrationType,
27818
+ publicKey,
27819
+ ref,
27687
27820
  isList: true
27688
27821
  })
27689
27822
  })]
@@ -27795,7 +27928,9 @@ function getStyles(customStyle) {
27795
27928
  container: Object.assign({}, colorContainer, fontFamily, verticalSpacingBetweenComponents, containerPadding, widthOfContainer),
27796
27929
  tabs: Object.assign({}, fontFamily, radiusBorder),
27797
27930
  label: Object.assign({}, fontFamily, fontWeightLabel, fontSizeLabel, textColorForLabel),
27798
- input: Object.assign({}, fontFamily, fontWeightInputFields, fontSizeInputFields, colorBorderInputFields, radiusBorder, colorInputFields, textColorForInput, verticalPadding),
27931
+ input: Object.assign({}, fontFamily, fontWeightInputFields, fontSizeInputFields, colorBorderInputFields, radiusBorder, colorInputFields, textColorForInput, verticalPadding, {
27932
+ borderStyle: 'solid'
27933
+ }),
27799
27934
  button: Object.assign({}, fontFamily, fontWeightPaymentButton, fontSizePaymentButton, colorBorderPaymentButton, radiusBorder, colorPrimaryPaymentButton, textColorForPaymentButton, verticalPaddingButton, {
27800
27935
  disabled: Object.assign({}, colorDisabled)
27801
27936
  }),
@@ -27841,7 +27976,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27841
27976
  hideCardHolderName,
27842
27977
  publicKey,
27843
27978
  clientSecret,
27844
- selectedPaymentMethods
27979
+ selectedPaymentMethods,
27980
+ integrationType
27845
27981
  } = props;
27846
27982
  const [paymentMethod, setPaymentMethod] = (0,react.useState)(payment);
27847
27983
  const styles = getStyles(customStyle);
@@ -27862,7 +27998,10 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27862
27998
  onAfterPaymentComplete,
27863
27999
  onCardValidationChanged,
27864
28000
  showPaymobLogo,
27865
- hideCardHolderName
28001
+ hideCardHolderName,
28002
+ integrationType,
28003
+ publicKey,
28004
+ ref
27866
28005
  });
27867
28006
  case 'CARD-INSTALLMENT':
27868
28007
  return /*#__PURE__*/(0,jsx_runtime.jsx)(BankInstalment, {
@@ -27960,7 +28099,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27960
28099
  publicKey: publicKey,
27961
28100
  clientSecret: clientSecret,
27962
28101
  selectedPaymentMethods: selectedPaymentMethods,
27963
- ref: ref
28102
+ ref: ref,
28103
+ integrationType: integrationType
27964
28104
  });
27965
28105
  };
27966
28106
  return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
@@ -31535,19 +31675,36 @@ class Pixel {
31535
31675
  this._root = null;
31536
31676
  this._error = null;
31537
31677
  this._paymentsRef = null;
31678
+ this._integrationType = void 0;
31538
31679
  this._options = Object.assign({}, options, {
31539
31680
  showPaymobLogo: (_options$showPaymobLo = options.showPaymobLogo) != null ? _options$showPaymobLo : true
31540
31681
  });
31541
31682
  this._baseURL = this.updateAPIBaseURL();
31542
31683
  this._paymentsRef = /*#__PURE__*/react.createRef();
31543
- Pixel._instance = this;
31544
- this.getData();
31684
+ Pixel._instances[options.elementId] = this;
31685
+ Pixel._lastInstanceId = options.elementId;
31686
+ if (this._options['clientSecret'] && this._options['paymentMethods']) {
31687
+ this._integrationType = 'directPayment';
31688
+ this.getData();
31689
+ } else {
31690
+ this._integrationType = 'tokenization';
31691
+ this.renderCard();
31692
+ }
31545
31693
  }
31546
31694
  updateAPIBaseURL() {
31547
31695
  const baseURL = getAPIURLByKeys(this._options['publicKey'], this._options['clientSecret']);
31548
31696
  lib_axios.defaults.baseURL = baseURL;
31549
31697
  return baseURL;
31550
31698
  }
31699
+ renderCard() {
31700
+ this._paymentList = [{
31701
+ name: 'card',
31702
+ type: 'card',
31703
+ amount: '',
31704
+ currency: ''
31705
+ }];
31706
+ this.render();
31707
+ }
31551
31708
  async getData() {
31552
31709
  const publicKey = this._options['publicKey'];
31553
31710
  const clientSecret = this._options['clientSecret'];
@@ -31604,12 +31761,28 @@ class Pixel {
31604
31761
  this._options.cardValidationChanged(isValid);
31605
31762
  }
31606
31763
  }
31607
- static async updateIntentionData() {
31608
- var _Pixel$_instance;
31609
- if (!((_Pixel$_instance = Pixel._instance) != null && (_Pixel$_instance = _Pixel$_instance._paymentsRef) != null && (_Pixel$_instance = _Pixel$_instance.current) != null && _Pixel$_instance.getData)) {
31764
+ static getInstance(instanceId) {
31765
+ const targetId = instanceId || this._lastInstanceId;
31766
+ if (!targetId || !this._instances[targetId]) {
31767
+ throw new Error('Invalid ID or Pixel not initialized');
31768
+ }
31769
+ return this._instances[targetId];
31770
+ }
31771
+ static async updateIntentionData(instanceId) {
31772
+ var _instance$_paymentsRe;
31773
+ const instance = this.getInstance(instanceId);
31774
+ if (!((_instance$_paymentsRe = instance._paymentsRef) != null && (_instance$_paymentsRe = _instance$_paymentsRe.current) != null && _instance$_paymentsRe.getData)) {
31610
31775
  throw new Error('Pixel not initialized');
31611
31776
  }
31612
- return await Pixel._instance._paymentsRef.current.getData();
31777
+ return await instance._paymentsRef.current.getData();
31778
+ }
31779
+ static async submit(instanceId) {
31780
+ var _instance$_paymentsRe2;
31781
+ const instance = this.getInstance(instanceId);
31782
+ if (!((_instance$_paymentsRe2 = instance._paymentsRef) != null && (_instance$_paymentsRe2 = _instance$_paymentsRe2.current) != null && _instance$_paymentsRe2.handleGenerateToken)) {
31783
+ throw new Error('Pixel not initialized');
31784
+ }
31785
+ return await instance._paymentsRef.current.handleGenerateToken();
31613
31786
  }
31614
31787
  render() {
31615
31788
  const container = document.getElementById(this._options['elementId']);
@@ -31650,12 +31823,15 @@ class Pixel {
31650
31823
  onPaymentCancel: this.handleOnPaymentCancel.bind(this)
31651
31824
  }, this._options.cardValidationChanged && {
31652
31825
  onCardValidationChanged: this.handleCardValidationChanged.bind(this)
31826
+ }, {
31827
+ integrationType: this._integrationType
31653
31828
  }), Date.now())
31654
31829
  }));
31655
31830
  }
31656
31831
  }
31657
31832
  _Pixel = Pixel;
31658
- Pixel._instance = null;
31833
+ Pixel._instances = {};
31834
+ Pixel._lastInstanceId = null;
31659
31835
  window.Pixel = Pixel;
31660
31836
  /* harmony default export */ const pixel = ((/* unused pure expression or super */ null && (Pixel)));
31661
31837
  ;// CONCATENATED MODULE: ./src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-pixel-alpha",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "keywords": ["paymob","pixel","paymob-pixel"],
5
5
  "main": "./main.js",
6
6
  "license": "MIT",
package/styles.css CHANGED
@@ -636,6 +636,14 @@ video {
636
636
  bottom: -1rem;
637
637
  }
638
638
 
639
+ .-top-3 {
640
+ top: -0.75rem;
641
+ }
642
+
643
+ .left-1\/2 {
644
+ left: 50%;
645
+ }
646
+
639
647
  .left-\[-16px\] {
640
648
  left: -16px;
641
649
  }
@@ -1176,6 +1184,10 @@ video {
1176
1184
  width: 100%;
1177
1185
  }
1178
1186
 
1187
+ .min-w-\[8rem\] {
1188
+ min-width: 8rem;
1189
+ }
1190
+
1179
1191
  .max-w-\[400px\] {
1180
1192
  max-width: 400px;
1181
1193
  }
@@ -1208,6 +1220,11 @@ video {
1208
1220
  flex-grow: 1;
1209
1221
  }
1210
1222
 
1223
+ .-translate-x-1\/2 {
1224
+ --tw-translate-x: -50%;
1225
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
1226
+ }
1227
+
1211
1228
  .-translate-y-1\/2 {
1212
1229
  --tw-translate-y: -50%;
1213
1230
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
@@ -1410,6 +1427,10 @@ video {
1410
1427
  overflow: hidden;
1411
1428
  }
1412
1429
 
1430
+ .overflow-visible {
1431
+ overflow: visible;
1432
+ }
1433
+
1413
1434
  .overflow-scroll {
1414
1435
  overflow: scroll;
1415
1436
  }
@@ -2002,6 +2023,11 @@ video {
2002
2023
  padding-bottom: 0.625rem;
2003
2024
  }
2004
2025
 
2026
+ .py-\[0\.6rem\] {
2027
+ padding-top: 0.6rem;
2028
+ padding-bottom: 0.6rem;
2029
+ }
2030
+
2005
2031
  .py-\[10px\] {
2006
2032
  padding-top: 10px;
2007
2033
  padding-bottom: 10px;
@@ -2089,6 +2115,10 @@ video {
2089
2115
  line-height: 2.25rem;
2090
2116
  }
2091
2117
 
2118
+ .text-\[0\.65rem\] {
2119
+ font-size: 0.65rem;
2120
+ }
2121
+
2092
2122
  .text-\[2rem\] {
2093
2123
  font-size: 2rem;
2094
2124
  }
@@ -2982,3 +3012,11 @@ video {
2982
3012
  .\[\&_input\]\:pl-6 input {
2983
3013
  padding-left: 1.5rem;
2984
3014
  }
3015
+
3016
+ @media(max-height:880px) {
3017
+
3018
+ .\[\@media\(max-height\:880px\)\]\:py-4 {
3019
+ padding-top: 1rem;
3020
+ padding-bottom: 1rem;
3021
+ }
3022
+ }