@fractalpay/fractalpay-next-dev 0.0.252 → 0.0.253

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var require_package = __commonJS({
39
39
  "package.json"(exports, module) {
40
40
  module.exports = {
41
41
  name: "@fractalpay/fractalpay-next-dev",
42
- version: "0.0.252",
42
+ version: "0.0.253",
43
43
  private: false,
44
44
  type: "module",
45
45
  scripts: {
@@ -8694,7 +8694,7 @@ function PartialPayment(props) {
8694
8694
  }
8695
8695
 
8696
8696
  // src/app/components/Skysystemz/PayButtonWithForm.tsx
8697
- import { useEffect as useEffect18, useState as useState12, useMemo } from "react";
8697
+ import { useEffect as useEffect19, useState as useState12, useMemo } from "react";
8698
8698
 
8699
8699
  // src/app/components/Skysystemz/SkyChargewidgetstyles.tsx
8700
8700
  import { jsx as jsx29 } from "react/jsx-runtime";
@@ -9540,7 +9540,7 @@ padding:0px !important;
9540
9540
  }
9541
9541
 
9542
9542
  // src/app/components/Atoms/ModelContentSky/ModelContentSky.tsx
9543
- import { useCallback, useEffect as useEffect17, useRef as useRef12, useState as useState11 } from "react";
9543
+ import { useCallback, useEffect as useEffect18, useRef as useRef12, useState as useState11 } from "react";
9544
9544
  import axios9 from "axios";
9545
9545
  import Swal5 from "sweetalert2";
9546
9546
 
@@ -9830,7 +9830,44 @@ var ErrorCardOverlay_default = ErrorCardOverlay;
9830
9830
 
9831
9831
  // src/app/components/Atoms/Googlepay/Googlepay.tsx
9832
9832
  import { useRef as useRef10 } from "react";
9833
- import Script from "next/script";
9833
+
9834
+ // src/app/components/Atoms/Googlepay/GooglePayScriptLoader.tsx
9835
+ import { useEffect as useEffect15 } from "react";
9836
+ var googlePayScriptLoaded = false;
9837
+ var GooglePayScriptLoader = ({
9838
+ onLoad
9839
+ }) => {
9840
+ useEffect15(() => {
9841
+ if (googlePayScriptLoaded) {
9842
+ onLoad == null ? void 0 : onLoad();
9843
+ return;
9844
+ }
9845
+ const existingScript = document.querySelector(
9846
+ `script[src="https://pay.google.com/gp/p/js/pay.js"]`
9847
+ );
9848
+ if (!existingScript) {
9849
+ const script2 = document.createElement("script");
9850
+ script2.src = "https://pay.google.com/gp/p/js/pay.js";
9851
+ script2.async = true;
9852
+ script2.onload = () => {
9853
+ console.log("\u2705 Google Pay script loaded");
9854
+ googlePayScriptLoaded = true;
9855
+ console.log("google:", window.google);
9856
+ onLoad == null ? void 0 : onLoad();
9857
+ };
9858
+ script2.onerror = (err) => {
9859
+ console.error("\u274C Google Pay script failed", err);
9860
+ };
9861
+ document.head.appendChild(script2);
9862
+ } else {
9863
+ googlePayScriptLoaded = true;
9864
+ onLoad == null ? void 0 : onLoad();
9865
+ }
9866
+ }, []);
9867
+ return null;
9868
+ };
9869
+
9870
+ // src/app/components/Atoms/Googlepay/Googlepay.tsx
9834
9871
  import { Fragment as Fragment19, jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
9835
9872
  function GooglePayComponent({
9836
9873
  amount,
@@ -9929,6 +9966,10 @@ function GooglePayComponent({
9929
9966
  const initializeGooglePay = async () => {
9930
9967
  try {
9931
9968
  const client = getPaymentsClient();
9969
+ if (!client) {
9970
+ console.error("Google Pay client not ready");
9971
+ return;
9972
+ }
9932
9973
  const response = await client.isReadyToPay(
9933
9974
  getIsReadyToPayRequest()
9934
9975
  );
@@ -9940,7 +9981,9 @@ function GooglePayComponent({
9940
9981
  buttonColor: "black",
9941
9982
  buttonRadius: 8
9942
9983
  });
9943
- containerRef.current.innerHTML = "";
9984
+ if (containerRef.current) {
9985
+ containerRef.current.innerHTML = "";
9986
+ }
9944
9987
  containerRef.current.appendChild(button);
9945
9988
  }
9946
9989
  } catch (err) {
@@ -9949,6 +9992,10 @@ function GooglePayComponent({
9949
9992
  };
9950
9993
  const onGooglePayClick = async () => {
9951
9994
  const client = getPaymentsClient();
9995
+ if (!client) {
9996
+ console.error("Google Pay client not ready");
9997
+ return;
9998
+ }
9952
9999
  try {
9953
10000
  await client.loadPaymentData(getPaymentDataRequest());
9954
10001
  } catch (err) {
@@ -9957,44 +10004,23 @@ function GooglePayComponent({
9957
10004
  }
9958
10005
  }
9959
10006
  };
9960
- const processPayment = async (paymentData) => {
9961
- var _a, _b;
9962
- console.log(paymentData, "paymentData");
9963
- try {
9964
- const token = (_b = (_a = paymentData == null ? void 0 : paymentData.paymentMethodData) == null ? void 0 : _a.tokenizationData) == null ? void 0 : _b.token;
9965
- if (!token) throw new Error("Missing token");
9966
- const parsed = JSON.parse(token);
9967
- console.log(parsed, "pararararqr");
9968
- alert("Payment successful!");
9969
- } catch (err) {
9970
- console.error("Processing error:", err);
9971
- alert("Payment processing failed");
9972
- } finally {
9973
- setLoading(false);
9974
- }
9975
- };
9976
10007
  const onScriptLoad = () => {
9977
10008
  if (!googlePayEnvironment2 || !googlePayGatewayMerchantId2 || !amount || !googlePayMerchantId2) {
9978
10009
  console.error("Missing Google Pay config");
9979
10010
  return;
9980
10011
  }
9981
- initializeGooglePay();
10012
+ setTimeout(() => {
10013
+ initializeGooglePay();
10014
+ }, 0);
9982
10015
  };
9983
10016
  return /* @__PURE__ */ jsxs20(Fragment19, { children: [
9984
10017
  /* @__PURE__ */ jsx34("div", { ref: containerRef, className: "text-center" }),
9985
- /* @__PURE__ */ jsx34(
9986
- Script,
9987
- {
9988
- src: "https://pay.google.com/gp/p/js/pay.js",
9989
- strategy: "afterInteractive",
9990
- onLoad: onScriptLoad
9991
- }
9992
- )
10018
+ /* @__PURE__ */ jsx34(GooglePayScriptLoader, { onLoad: onScriptLoad })
9993
10019
  ] });
9994
10020
  }
9995
10021
 
9996
10022
  // src/app/components/Atoms/Applepay/ApplePayButton.tsx
9997
- import { useEffect as useEffect16, useRef as useRef11 } from "react";
10023
+ import { useEffect as useEffect17, useRef as useRef11 } from "react";
9998
10024
  import { jsx as jsx35 } from "react/jsx-runtime";
9999
10025
  function ApplePayButton({
10000
10026
  applePayMerchantId: applePayMerchantId2,
@@ -10101,14 +10127,14 @@ function ApplePayButton({
10101
10127
  console.log("\u274C Apple Pay flow failed:", err == null ? void 0 : err.message);
10102
10128
  }
10103
10129
  }
10104
- useEffect16(() => {
10130
+ useEffect17(() => {
10105
10131
  if (window.ApplePaySession && window.ApplePaySession.canMakePayments()) {
10106
10132
  console.log("\u2705 Apple Pay is available");
10107
10133
  } else {
10108
10134
  console.log("\u274C Apple Pay NOT available");
10109
10135
  }
10110
10136
  }, []);
10111
- useEffect16(() => {
10137
+ useEffect17(() => {
10112
10138
  const btn = applePayRef.current;
10113
10139
  if (!btn) return;
10114
10140
  const handleClick = () => handleApplePayClick();
@@ -11055,13 +11081,13 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11055
11081
  setOrderLoader(false);
11056
11082
  }
11057
11083
  };
11058
- useEffect17(() => {
11084
+ useEffect18(() => {
11059
11085
  if (!show && !autoTrigger) {
11060
11086
  hasRunRef.current = false;
11061
11087
  cardListRunRef.current = false;
11062
11088
  }
11063
11089
  }, [show, autoTrigger]);
11064
- useEffect17(() => {
11090
+ useEffect18(() => {
11065
11091
  if (!hasRunRef.current && (show || autoTrigger) && onLoad) {
11066
11092
  getPaymentDetails();
11067
11093
  if (isPartial && !partialRef) {
@@ -11069,7 +11095,7 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11069
11095
  }
11070
11096
  }
11071
11097
  }, [show, autoTrigger, isPartial, onLoad]);
11072
- useEffect17(() => {
11098
+ useEffect18(() => {
11073
11099
  if ((show || autoTrigger) && pass_fee_amount) {
11074
11100
  let cashdisc = Number(amount) - Number(pass_fee_amount);
11075
11101
  if (cashdisc && !isNaN(cashdisc)) {
@@ -11131,7 +11157,7 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11131
11157
  console.error("3DS Auth failed \u274C", status);
11132
11158
  setError(`3DS Authentication ${status}`);
11133
11159
  };
11134
- useEffect17(() => {
11160
+ useEffect18(() => {
11135
11161
  if (setHandleCloseRef) {
11136
11162
  setHandleCloseRef(() => handleClose);
11137
11163
  }
@@ -11149,7 +11175,7 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11149
11175
  setPartialError("");
11150
11176
  }
11151
11177
  };
11152
- useEffect17(() => {
11178
+ useEffect18(() => {
11153
11179
  if (typeof FractalTokenizer === "undefined") return;
11154
11180
  const tokenizer = new FractalTokenizer({
11155
11181
  styles: {}
@@ -11160,7 +11186,7 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11160
11186
  activeinCard,
11161
11187
  activetab
11162
11188
  });
11163
- useEffect17(() => {
11189
+ useEffect18(() => {
11164
11190
  stateRef.current = {
11165
11191
  activeinBank,
11166
11192
  activeinCard,
@@ -11184,7 +11210,7 @@ var ModelContentSky = ({ amount, bankAmount, submitBtnText = "Pay", session_toke
11184
11210
  }
11185
11211
  }
11186
11212
  }, []);
11187
- useEffect17(() => {
11213
+ useEffect18(() => {
11188
11214
  onSubmit == null ? void 0 : onSubmit(submit);
11189
11215
  }, [onSubmit, submit]);
11190
11216
  function detectCardType(cardinput) {
@@ -11779,7 +11805,7 @@ var PaymentWidget = ({
11779
11805
  ]
11780
11806
  );
11781
11807
  const [commonProps, setCommonProps] = useState12(initialCommonProps);
11782
- useEffect18(() => {
11808
+ useEffect19(() => {
11783
11809
  if (show) {
11784
11810
  setCommonProps(initialCommonProps);
11785
11811
  }
@@ -11810,7 +11836,7 @@ var PaymentWidget = ({
11810
11836
  setLoading(false);
11811
11837
  }
11812
11838
  };
11813
- useEffect18(() => {
11839
+ useEffect19(() => {
11814
11840
  if (show && isPartial && partialRef) {
11815
11841
  getskyosOrderDetails();
11816
11842
  }
@@ -11832,7 +11858,7 @@ var PaymentWidget = ({
11832
11858
  };
11833
11859
 
11834
11860
  // src/app/components/Skysystemz/EmbeddedCheckout.tsx
11835
- import { useEffect as useEffect20, useState as useState13, useMemo as useMemo2 } from "react";
11861
+ import { useEffect as useEffect21, useState as useState13, useMemo as useMemo2 } from "react";
11836
11862
  import axios11 from "axios";
11837
11863
 
11838
11864
  // src/app/components/Skysystemz/EmbeddedCheckoutStyles.tsx
@@ -12184,10 +12210,10 @@ padding:0px !important;
12184
12210
  }
12185
12211
 
12186
12212
  // src/app/components/Atoms/Applepay/ApplePayScriptLoader.tsx
12187
- import { useEffect as useEffect19 } from "react";
12213
+ import { useEffect as useEffect20 } from "react";
12188
12214
  var applePayScriptLoaded = false;
12189
12215
  var ApplePayScriptLoader = () => {
12190
- useEffect19(() => {
12216
+ useEffect20(() => {
12191
12217
  if (applePayScriptLoaded) return;
12192
12218
  const existingScript = document.querySelector(
12193
12219
  `script[src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js"]`
@@ -12291,7 +12317,7 @@ var EmbeddedCheckout = ({
12291
12317
  ]
12292
12318
  );
12293
12319
  const [commonProps, setCommonProps] = useState13(initialCommonProps);
12294
- useEffect20(() => {
12320
+ useEffect21(() => {
12295
12321
  if (show) {
12296
12322
  setCommonProps(initialCommonProps);
12297
12323
  }
@@ -12322,13 +12348,13 @@ var EmbeddedCheckout = ({
12322
12348
  setLoading(false);
12323
12349
  }
12324
12350
  };
12325
- useEffect20(() => {
12351
+ useEffect21(() => {
12326
12352
  if (show && isPartial && partialRef) {
12327
12353
  getskyosOrderDetails();
12328
12354
  }
12329
12355
  }, [show, isPartial, partialRef]);
12330
12356
  console.log(onLoad, "onLoad");
12331
- useEffect20(() => {
12357
+ useEffect21(() => {
12332
12358
  const supported = !!window.ApplePaySession;
12333
12359
  let canPay = false;
12334
12360
  if (supported) {