paymob-pixel-alpha 1.1.2 → 1.1.4

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 +221 -53
  3. package/package.json +1 -1
  4. package/styles.css +43 -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,7 +19983,7 @@ 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)({});
@@ -19950,6 +20000,7 @@ function CardElement({
19950
20000
  const [sendOTPLoading, setSendOTPLoading] = (0,react.useState)(false);
19951
20001
  const [paymentId, setPaymentId] = (0,react.useState)('');
19952
20002
  const [otpErrorMessage, setOTPErrorMessage] = (0,react.useState)('');
20003
+ const tokenizationResolve = (0,react.useRef)(null);
19953
20004
  const isCardValid = hideCardHolderName ? !isActionBtnDisabled : !(isActionBtnDisabled || !cardHolderName);
19954
20005
  const isAmexCardSelected = (selectedCard == null ? void 0 : selectedCard.type) === constants_CARD_TYPES.AMEX;
19955
20006
  const selectedCardCvvLength = selectedCardCVV.length;
@@ -19958,7 +20009,7 @@ function CardElement({
19958
20009
  const shouldDisablePayBtn = showCvvInput ? loading || (isAmexCardSelected ? selectedCardCvvLength !== constants_AMEX_CVV_LENGTH : selectedCardCvvLength !== constants_CVV_LENGTH) : !selectedCardId;
19959
20010
  (0,react.useEffect)(() => {
19960
20011
  const handleDataFromIframe = event => {
19961
- var _event$data, _event$data2;
20012
+ var _event$data, _event$data2, _event$data3;
19962
20013
  if (!event.data) return;
19963
20014
  if (!event.data.type) return;
19964
20015
  if (event.data.shouldFocusOnCardName) {
@@ -19968,7 +20019,7 @@ function CardElement({
19968
20019
  }
19969
20020
  }
19970
20021
  if (event.data.iframeCardHight) {
19971
- setHeight(event.data.iframeCardHight + 0.5);
20022
+ setHeight(event.data.iframeCardHight);
19972
20023
  }
19973
20024
  if (event.data.selectedCardCVV) {
19974
20025
  setSelectedCardCVV(event.data.selectedCardCVV);
@@ -19991,6 +20042,10 @@ function CardElement({
19991
20042
  if ((event == null || (_event$data2 = event.data) == null ? void 0 : _event$data2.type) === 'openCVVToolTipModal') {
19992
20043
  setShowCVVTooltipModal(true);
19993
20044
  }
20045
+ if ((event == null || (_event$data3 = event.data) == null ? void 0 : _event$data3.type) === 'tokenizationResponse' && tokenizationResolve.current) {
20046
+ tokenizationResolve.current(event.data.response.res);
20047
+ tokenizationResolve.current = null;
20048
+ }
19994
20049
  };
19995
20050
  const handlePaymentResponse = ({
19996
20051
  res,
@@ -20100,6 +20155,7 @@ function CardElement({
20100
20155
  }
20101
20156
  }, [isIframeLoaded, payment]);
20102
20157
  (0,react.useEffect)(() => {
20158
+ let resizeObserver = null;
20103
20159
  if (isIframeLoaded) {
20104
20160
  var _iframe$contentWindow;
20105
20161
  (_iframe$contentWindow = iframe.contentWindow) == null || _iframe$contentWindow.postMessage({
@@ -20111,7 +20167,21 @@ function CardElement({
20111
20167
  }
20112
20168
  }
20113
20169
  }, '*');
20170
+ const nextElement = iframe.nextElementSibling;
20171
+ resizeObserver = new ResizeObserver(entries => {
20172
+ for (let entry of entries) {
20173
+ const width = Math.floor(entry.contentRect.width - 0.5);
20174
+ if (nextElement) {
20175
+ nextElement.style.width = `${width}px`;
20176
+ }
20177
+ }
20178
+ });
20179
+ resizeObserver.observe(iframe);
20114
20180
  }
20181
+ return () => {
20182
+ var _resizeObserver;
20183
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.disconnect();
20184
+ };
20115
20185
  }, [isIframeLoaded, iframeRef.current]);
20116
20186
  (0,react.useEffect)(() => {
20117
20187
  var _iframe$contentWindow2;
@@ -20133,21 +20203,43 @@ function CardElement({
20133
20203
  previousValidationRef.current = isCardValid;
20134
20204
  }
20135
20205
  }, [isCardValid, shouldDisablePayBtn]);
20206
+ (0,react.useImperativeHandle)(ref, () => ({
20207
+ handleGenerateToken
20208
+ }));
20209
+ async function handleGenerateToken() {
20210
+ return new Promise((resolve, reject) => {
20211
+ var _iframe$contentWindow3;
20212
+ if (loading || !isCardValid || isLoading) {
20213
+ return reject();
20214
+ }
20215
+ tokenizationResolve.current = resolve;
20216
+ (_iframe$contentWindow3 = iframe.contentWindow) == null || _iframe$contentWindow3.postMessage({
20217
+ type: 'tokenizeCard',
20218
+ payload: {
20219
+ publicKey,
20220
+ cardHolderName,
20221
+ shouldSubmitData: true
20222
+ }
20223
+ }, '*');
20224
+ });
20225
+ }
20226
+ ;
20136
20227
  const sendCardData = shouldSubmitData => {
20137
- var _iframe$contentWindow3, _payment$subType, _payment$subType2;
20138
- (_iframe$contentWindow3 = iframe.contentWindow) == null || _iframe$contentWindow3.postMessage({
20228
+ var _iframe$contentWindow4, _payment$subType, _payment$subType2;
20229
+ (_iframe$contentWindow4 = iframe.contentWindow) == null || _iframe$contentWindow4.postMessage({
20139
20230
  type: 'cardData',
20140
20231
  payload: {
20141
- paymentToken: payment.token,
20232
+ paymentToken: payment == null ? void 0 : payment.token,
20142
20233
  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
20234
+ paymentToken: payment == null || (_payment$subType = payment.subType) == null ? void 0 : _payment$subType.token,
20235
+ type: payment == null || (_payment$subType2 = payment.subType) == null ? void 0 : _payment$subType2.type
20145
20236
  },
20146
20237
  currency,
20147
20238
  cardHolderName,
20148
20239
  saveCard: forceSaveCard || saveCard,
20149
20240
  tenure,
20150
- shouldSubmitData: shouldSubmitData
20241
+ shouldSubmitData: shouldSubmitData,
20242
+ country
20151
20243
  }
20152
20244
  }, '*');
20153
20245
  };
@@ -20155,8 +20247,8 @@ function CardElement({
20155
20247
  setShouldSubmitData(true);
20156
20248
  };
20157
20249
  const handleFocusToPrevInput = () => {
20158
- var _iframe$contentWindow4;
20159
- (_iframe$contentWindow4 = iframe.contentWindow) == null || _iframe$contentWindow4.postMessage({
20250
+ var _iframe$contentWindow5;
20251
+ (_iframe$contentWindow5 = iframe.contentWindow) == null || _iframe$contentWindow5.postMessage({
20160
20252
  type: 'setPrevFocus',
20161
20253
  payload: {
20162
20254
  shouldFocusOnCVV: true
@@ -20241,9 +20333,9 @@ function CardElement({
20241
20333
  }
20242
20334
  };
20243
20335
  const handleOTPSubmit = async otp => {
20244
- var _iframe$contentWindow5, _payment$subType3;
20336
+ var _iframe$contentWindow6, _payment$subType3;
20245
20337
  setSendOTPLoading(true);
20246
- (_iframe$contentWindow5 = iframe.contentWindow) == null || _iframe$contentWindow5.postMessage({
20338
+ (_iframe$contentWindow6 = iframe.contentWindow) == null || _iframe$contentWindow6.postMessage({
20247
20339
  type: 'otpData',
20248
20340
  payload: {
20249
20341
  paymentToken: payment.token,
@@ -20318,7 +20410,8 @@ function CardElement({
20318
20410
  },
20319
20411
  cancelButton: Object.assign({}, customStyle == null ? void 0 : customStyle.button, {
20320
20412
  backgroundColor: '#fff',
20321
- lineHeight: 'normal'
20413
+ lineHeight: 'normal',
20414
+ color: ''
20322
20415
  }),
20323
20416
  button: customStyle == null ? void 0 : customStyle.button,
20324
20417
  label: customStyle == null ? void 0 : customStyle.label,
@@ -20349,7 +20442,7 @@ function CardElement({
20349
20442
  })]
20350
20443
  }), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20351
20444
  className: "[&>div:nth-child(even)]:w-[calc(100%-1px)]",
20352
- children: [!isIframeLoaded && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20445
+ children: [(!isIframeLoaded || !(payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION)) && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
20353
20446
  className: "-mt-1",
20354
20447
  children: [/*#__PURE__*/(0,jsx_runtime.jsx)(dist_Skeleton, {
20355
20448
  height: 37
@@ -20370,17 +20463,20 @@ function CardElement({
20370
20463
  src: `${baseUrl}/${environment['IFRAME_PATH']}/?type=card&v=2`
20371
20464
  // src={`http://localhost:9001/${environment['IFRAME_PATH']}/?type=card&v=2`}
20372
20465
  ,
20466
+ className: card_module['iframe'],
20373
20467
  style: {
20374
- border: '0',
20375
- overflow: 'hidden',
20376
- display: isIframeLoaded ? 'block' : 'none'
20468
+ display: isIframeLoaded && (payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION) ? 'block' : 'none'
20377
20469
  },
20378
20470
  frameBorder: "0",
20379
20471
  scrolling: "no",
20380
20472
  width: "100%",
20381
20473
  height: height,
20382
- onLoad: () => setIsIframeLoaded(true)
20383
- }), isIframeLoaded && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
20474
+ onLoad: () => {
20475
+ setTimeout(() => {
20476
+ setIsIframeLoaded(true);
20477
+ }, 200);
20478
+ }
20479
+ }), isIframeLoaded && (payment.token || integrationType === INTEGRATION_TYPE.TOKENIZATION) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
20384
20480
  children: [!hideCardHolderName && /*#__PURE__*/(0,jsx_runtime.jsx)(components_CardHolder_CardHolder, {
20385
20481
  onChange: handleCardHolderChange,
20386
20482
  focusToPrevInput: handleFocusToPrevInput,
@@ -20414,7 +20510,7 @@ function CardElement({
20414
20510
  onChange: e => setSaveCard(e.target.checked),
20415
20511
  customStyle: customStyle == null ? void 0 : customStyle.label
20416
20512
  })
20417
- }), !disablePay && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
20513
+ }), !disablePay && integrationType === INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
20418
20514
  className: card_module['action-btn'],
20419
20515
  children: /*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button, {
20420
20516
  id: 'pay-button',
@@ -20424,7 +20520,7 @@ function CardElement({
20424
20520
  onClick: () => setShouldSubmitData(true),
20425
20521
  customStyle: customStyle == null ? void 0 : customStyle.button
20426
20522
  })
20427
- }), showPaymobLogo && /*#__PURE__*/(0,jsx_runtime.jsx)(CopyrightsViewTwo_Copyrights, {
20523
+ }), showPaymobLogo && integrationType === INTEGRATION_TYPE.DIRECT_PAYMENT && /*#__PURE__*/(0,jsx_runtime.jsx)(CopyrightsViewTwo_Copyrights, {
20428
20524
  isElements: true
20429
20525
  })]
20430
20526
  })]
@@ -20473,7 +20569,7 @@ function CardElement({
20473
20569
  })]
20474
20570
  })]
20475
20571
  });
20476
- }
20572
+ });
20477
20573
  /* harmony default export */ const Payments_Card = (CardElement);
20478
20574
  ;// CONCATENATED MODULE: ../../libs/form-validation/src/lib/form-validation.ts
20479
20575
 
@@ -26952,7 +27048,8 @@ function ApplePay(props) {
26952
27048
  checkDiscount,
26953
27049
  isPixel,
26954
27050
  isLoading,
26955
- paymentName
27051
+ paymentName,
27052
+ country
26956
27053
  } = props;
26957
27054
  const [loading, setLoading] = (0,react.useState)(false);
26958
27055
  const [discount, setDiscount] = (0,react.useState)({
@@ -26992,7 +27089,7 @@ function ApplePay(props) {
26992
27089
  amount: discount.hasDiscount ? discount.discountAmount : amount
26993
27090
  }
26994
27091
  };
26995
- if (window.location.hostname === "accept.paymob.com" || window.location.hostname === "accept.paymobsolutions.com") {
27092
+ if (country === 'EGYPT') {
26996
27093
  payload.supportedNetworks.push('meeza');
26997
27094
  }
26998
27095
  if (clientInfo === null) {
@@ -27107,7 +27204,7 @@ function ApplePay(props) {
27107
27204
  icon: apple_pay_namespaceObject,
27108
27205
  fullWidth: true,
27109
27206
  onClick: handleSubmit,
27110
- className: `!mt-0 !p-0 ${discount.hasDiscount ? 'min-h-[2.875rem]' : ''}`,
27207
+ className: `!bg-black !mt-0 !p-0 ${discount.hasDiscount ? 'min-h-[2.875rem]' : ''}`,
27111
27208
  customStyle: customStyle,
27112
27209
  disabled: loading || isLoading,
27113
27210
  loading: loading || isLoading
@@ -27426,7 +27523,8 @@ function ApplePayElements({
27426
27523
  onBeforePaymentComplete,
27427
27524
  onAfterPaymentComplete,
27428
27525
  onPaymentCancel,
27429
- isLoading
27526
+ isLoading,
27527
+ country
27430
27528
  }) {
27431
27529
  var _amount$toString;
27432
27530
  const {
@@ -27439,6 +27537,7 @@ function ApplePayElements({
27439
27537
  window.location.href = resData.redirection_url;
27440
27538
  };
27441
27539
  return /*#__PURE__*/(0,jsx_runtime.jsx)(ApplePay, {
27540
+ country: country,
27442
27541
  countryCode: currency == null ? void 0 : currency.slice(0, 2),
27443
27542
  currency: currency,
27444
27543
  amount: (_amount$toString = amount.toString()) == null ? void 0 : _amount$toString.replace(/,/g, ''),
@@ -27525,6 +27624,35 @@ async function fetchPayments(publicKey, clientSecret, paymentMethods) {
27525
27624
  savedCards: formattedSavedCards
27526
27625
  };
27527
27626
  }
27627
+ ;// CONCATENATED MODULE: ./src/constants/countries.ts
27628
+ const COUNTRIES = {
27629
+ EGYPT: 'EGYPT',
27630
+ UAE: 'UAE',
27631
+ PAKISTAN: 'PAKISTAN',
27632
+ OMAN: 'OMAN',
27633
+ SAUDI_ARABIA: 'SAUDI_ARABIA'
27634
+ };
27635
+ const COUNTRY_TO_CODE = {
27636
+ [COUNTRIES.EGYPT]: 'egy',
27637
+ [COUNTRIES.UAE]: 'are',
27638
+ [COUNTRIES.PAKISTAN]: 'pak',
27639
+ [COUNTRIES.OMAN]: 'omn',
27640
+ [COUNTRIES.SAUDI_ARABIA]: 'sau'
27641
+ };
27642
+ const CODE_TO_COUNTRY = Object.fromEntries(Object.entries(COUNTRY_TO_CODE).map(([country, code]) => [code, country]));
27643
+ ;// CONCATENATED MODULE: ./src/utils/getCountry.ts
27644
+
27645
+ function getCountryCodeByKeys(publicKey, clientSecret) {
27646
+ let countryCode = publicKey.split('_')[0] || '';
27647
+ if (!['egy', 'are', 'pak', 'omn', 'sau'].includes(countryCode)) {
27648
+ countryCode = clientSecret.split('_')[0] || '';
27649
+ }
27650
+ return countryCode;
27651
+ }
27652
+ function getCountryByKeys(publicKey, clientSecret) {
27653
+ const countryCode = getCountryCodeByKeys(publicKey, clientSecret);
27654
+ return CODE_TO_COUNTRY[countryCode];
27655
+ }
27528
27656
  ;// CONCATENATED MODULE: ./src/components/Payments/List/index.tsx
27529
27657
 
27530
27658
 
@@ -27537,6 +27665,7 @@ async function fetchPayments(publicKey, clientSecret, paymentMethods) {
27537
27665
 
27538
27666
 
27539
27667
 
27668
+
27540
27669
  const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27541
27670
  var _customStyle$containe;
27542
27671
  const {
@@ -27555,7 +27684,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27555
27684
  hideCardHolderName,
27556
27685
  publicKey,
27557
27686
  clientSecret,
27558
- selectedPaymentMethods
27687
+ selectedPaymentMethods,
27688
+ integrationType
27559
27689
  } = props;
27560
27690
  const {
27561
27691
  t
@@ -27566,6 +27696,7 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27566
27696
  const [savedCardsList, setSavedCardsList] = (0,react.useState)(savedCards);
27567
27697
  const [errorMessage, setErrorMessage] = (0,react.useState)('');
27568
27698
  const [isLoading, setIsLoading] = (0,react.useState)(false);
27699
+ const country = getCountryByKeys(publicKey, clientSecret);
27569
27700
  (0,react.useImperativeHandle)(ref, () => ({
27570
27701
  getData: async () => {
27571
27702
  setIsLoading(true);
@@ -27633,7 +27764,8 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27633
27764
  onAfterPaymentComplete: onAfterPaymentComplete,
27634
27765
  onPaymentCancel: onPaymentCancel,
27635
27766
  customStyle: customStyle == null ? void 0 : customStyle.button,
27636
- isLoading: isLoading
27767
+ isLoading: isLoading,
27768
+ country: country
27637
27769
  }), isGooglePay() && /*#__PURE__*/(0,jsx_runtime.jsx)(GooglePayElement, {
27638
27770
  payment: googlePaymentMethod,
27639
27771
  customStyle: customStyle == null ? void 0 : customStyle.button,
@@ -27679,6 +27811,10 @@ const PaymentsList = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27679
27811
  showPaymobLogo,
27680
27812
  hideCardHolderName,
27681
27813
  isLoading,
27814
+ country,
27815
+ integrationType,
27816
+ publicKey,
27817
+ ref,
27682
27818
  isList: true
27683
27819
  })
27684
27820
  })]
@@ -27790,7 +27926,9 @@ function getStyles(customStyle) {
27790
27926
  container: Object.assign({}, colorContainer, fontFamily, verticalSpacingBetweenComponents, containerPadding, widthOfContainer),
27791
27927
  tabs: Object.assign({}, fontFamily, radiusBorder),
27792
27928
  label: Object.assign({}, fontFamily, fontWeightLabel, fontSizeLabel, textColorForLabel),
27793
- input: Object.assign({}, fontFamily, fontWeightInputFields, fontSizeInputFields, colorBorderInputFields, radiusBorder, colorInputFields, textColorForInput, verticalPadding),
27929
+ input: Object.assign({}, fontFamily, fontWeightInputFields, fontSizeInputFields, colorBorderInputFields, radiusBorder, colorInputFields, textColorForInput, verticalPadding, {
27930
+ borderStyle: 'solid'
27931
+ }),
27794
27932
  button: Object.assign({}, fontFamily, fontWeightPaymentButton, fontSizePaymentButton, colorBorderPaymentButton, radiusBorder, colorPrimaryPaymentButton, textColorForPaymentButton, verticalPaddingButton, {
27795
27933
  disabled: Object.assign({}, colorDisabled)
27796
27934
  }),
@@ -27836,7 +27974,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27836
27974
  hideCardHolderName,
27837
27975
  publicKey,
27838
27976
  clientSecret,
27839
- selectedPaymentMethods
27977
+ selectedPaymentMethods,
27978
+ integrationType
27840
27979
  } = props;
27841
27980
  const [paymentMethod, setPaymentMethod] = (0,react.useState)(payment);
27842
27981
  const styles = getStyles(customStyle);
@@ -27857,7 +27996,10 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27857
27996
  onAfterPaymentComplete,
27858
27997
  onCardValidationChanged,
27859
27998
  showPaymobLogo,
27860
- hideCardHolderName
27999
+ hideCardHolderName,
28000
+ integrationType,
28001
+ publicKey,
28002
+ ref
27861
28003
  });
27862
28004
  case 'CARD-INSTALLMENT':
27863
28005
  return /*#__PURE__*/(0,jsx_runtime.jsx)(BankInstalment, {
@@ -27955,7 +28097,8 @@ const Payments_Payments = /*#__PURE__*/(0,react.forwardRef)((props, ref) => {
27955
28097
  publicKey: publicKey,
27956
28098
  clientSecret: clientSecret,
27957
28099
  selectedPaymentMethods: selectedPaymentMethods,
27958
- ref: ref
28100
+ ref: ref,
28101
+ integrationType: integrationType
27959
28102
  });
27960
28103
  };
27961
28104
  return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
@@ -31530,19 +31673,35 @@ class Pixel {
31530
31673
  this._root = null;
31531
31674
  this._error = null;
31532
31675
  this._paymentsRef = null;
31676
+ this._integrationType = void 0;
31533
31677
  this._options = Object.assign({}, options, {
31534
31678
  showPaymobLogo: (_options$showPaymobLo = options.showPaymobLogo) != null ? _options$showPaymobLo : true
31535
31679
  });
31536
31680
  this._baseURL = this.updateAPIBaseURL();
31537
31681
  this._paymentsRef = /*#__PURE__*/react.createRef();
31538
31682
  Pixel._instance = this;
31539
- this.getData();
31683
+ if (this._options['clientSecret'] && this._options['paymentMethods']) {
31684
+ this._integrationType = 'directPayment';
31685
+ this.getData();
31686
+ } else {
31687
+ this._integrationType = 'tokenization';
31688
+ this.renderCard();
31689
+ }
31540
31690
  }
31541
31691
  updateAPIBaseURL() {
31542
31692
  const baseURL = getAPIURLByKeys(this._options['publicKey'], this._options['clientSecret']);
31543
31693
  lib_axios.defaults.baseURL = baseURL;
31544
31694
  return baseURL;
31545
31695
  }
31696
+ renderCard() {
31697
+ this._paymentList = [{
31698
+ name: 'card',
31699
+ type: 'card',
31700
+ amount: '',
31701
+ currency: ''
31702
+ }];
31703
+ this.render();
31704
+ }
31546
31705
  async getData() {
31547
31706
  const publicKey = this._options['publicKey'];
31548
31707
  const clientSecret = this._options['clientSecret'];
@@ -31606,6 +31765,13 @@ class Pixel {
31606
31765
  }
31607
31766
  return await Pixel._instance._paymentsRef.current.getData();
31608
31767
  }
31768
+ static async submit() {
31769
+ var _Pixel$_instance2;
31770
+ if (!((_Pixel$_instance2 = Pixel._instance) != null && (_Pixel$_instance2 = _Pixel$_instance2._paymentsRef) != null && (_Pixel$_instance2 = _Pixel$_instance2.current) != null && _Pixel$_instance2.handleGenerateToken)) {
31771
+ throw new Error('Pixel not initialized');
31772
+ }
31773
+ return await Pixel._instance._paymentsRef.current.handleGenerateToken();
31774
+ }
31609
31775
  render() {
31610
31776
  const container = document.getElementById(this._options['elementId']);
31611
31777
  if (!container) {
@@ -31645,6 +31811,8 @@ class Pixel {
31645
31811
  onPaymentCancel: this.handleOnPaymentCancel.bind(this)
31646
31812
  }, this._options.cardValidationChanged && {
31647
31813
  onCardValidationChanged: this.handleCardValidationChanged.bind(this)
31814
+ }, {
31815
+ integrationType: this._integrationType
31648
31816
  }), Date.now())
31649
31817
  }));
31650
31818
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paymob-pixel-alpha",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
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
  }
@@ -1698,6 +1719,11 @@ video {
1698
1719
  border-top-color: rgb(255 21 82 / var(--tw-border-opacity));
1699
1720
  }
1700
1721
 
1722
+ .\!bg-black {
1723
+ --tw-bg-opacity: 1 !important;
1724
+ background-color: rgb(0 0 0 / var(--tw-bg-opacity)) !important;
1725
+ }
1726
+
1701
1727
  .bg-\[\#0002\] {
1702
1728
  background-color: #0002;
1703
1729
  }
@@ -1997,6 +2023,11 @@ video {
1997
2023
  padding-bottom: 0.625rem;
1998
2024
  }
1999
2025
 
2026
+ .py-\[0\.6rem\] {
2027
+ padding-top: 0.6rem;
2028
+ padding-bottom: 0.6rem;
2029
+ }
2030
+
2000
2031
  .py-\[10px\] {
2001
2032
  padding-top: 10px;
2002
2033
  padding-bottom: 10px;
@@ -2084,6 +2115,10 @@ video {
2084
2115
  line-height: 2.25rem;
2085
2116
  }
2086
2117
 
2118
+ .text-\[0\.65rem\] {
2119
+ font-size: 0.65rem;
2120
+ }
2121
+
2087
2122
  .text-\[2rem\] {
2088
2123
  font-size: 2rem;
2089
2124
  }
@@ -2977,3 +3012,11 @@ video {
2977
3012
  .\[\&_input\]\:pl-6 input {
2978
3013
  padding-left: 1.5rem;
2979
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
+ }