@pinerohit11/testwidget 0.2.123 → 0.2.125

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.d.mts CHANGED
@@ -13,6 +13,7 @@ interface Props$5 {
13
13
  discount?: string;
14
14
  tax?: string;
15
15
  surcharge?: string;
16
+ require_3ds?: boolean;
16
17
  }
17
18
  declare function RequestPayment(props: Props$5): React.JSX.Element;
18
19
 
@@ -29,6 +30,7 @@ interface Props$4 {
29
30
  discount?: string;
30
31
  tax?: string;
31
32
  surcharge?: string;
33
+ require_3ds?: boolean;
32
34
  }
33
35
  declare function RequestPreAuthPayment(props: Props$4): React.JSX.Element;
34
36
 
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ interface Props$5 {
13
13
  discount?: string;
14
14
  tax?: string;
15
15
  surcharge?: string;
16
+ require_3ds?: boolean;
16
17
  }
17
18
  declare function RequestPayment(props: Props$5): React.JSX.Element;
18
19
 
@@ -29,6 +30,7 @@ interface Props$4 {
29
30
  discount?: string;
30
31
  tax?: string;
31
32
  surcharge?: string;
33
+ require_3ds?: boolean;
32
34
  }
33
35
  declare function RequestPreAuthPayment(props: Props$4): React.JSX.Element;
34
36
 
package/dist/index.js CHANGED
@@ -173,6 +173,7 @@ var Loader_default = Loader;
173
173
  // src/app/components/baseurl.ts
174
174
  var masterBaseUrl = "https://dev-sky-node.fractalpay.com/";
175
175
  var baseUrl = "https://dev-widget.fractalpay.com/";
176
+ var fractalGatewayUrl = "https://api-dev.merchant-trends.com/";
176
177
 
177
178
  // src/app/components/Errortext.ts
178
179
  var ErrorText = {
@@ -471,7 +472,6 @@ var CustomModal2 = ({
471
472
  maxWidth
472
473
  }) => {
473
474
  if (!open) return null;
474
- console.log(maxWidth);
475
475
  return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(CustomModal2styles_default, null), /* @__PURE__ */ import_react4.default.createElement("div", { className: "fractal-popup" }, /* @__PURE__ */ import_react4.default.createElement("div", { className: "fractal-popup-content request-payment-popup-container", style: { maxWidth: `${maxWidth != null ? maxWidth : "auto"}` } }, children)));
476
476
  };
477
477
  var CustomModal2_default = CustomModal2;
@@ -807,7 +807,8 @@ function RequestPayment(props) {
807
807
  customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
808
808
  discount,
809
809
  surcharge,
810
- tax
810
+ tax,
811
+ require_3ds: props == null ? void 0 : props.require_3ds
811
812
  };
812
813
  let response = await import_axios.default.post(`${baseUrl}create-widget-order`, formData);
813
814
  if ((response == null ? void 0 : response.status) === 200) {
@@ -1045,7 +1046,8 @@ function RequestPreAuthPayment(props) {
1045
1046
  customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
1046
1047
  discount,
1047
1048
  surcharge,
1048
- tax
1049
+ tax,
1050
+ require_3ds: props == null ? void 0 : props.require_3ds
1049
1051
  };
1050
1052
  let response = await import_axios2.default.post(`${baseUrl}send-request-pre-auth-payment`, formData);
1051
1053
  if ((response == null ? void 0 : response.status) === 200) {
@@ -1198,7 +1200,7 @@ function RequestPreAuthPayment(props) {
1198
1200
  onClose: handleCloseConfirmationModal,
1199
1201
  maxWidth: "500px"
1200
1202
  },
1201
- /* @__PURE__ */ import_react7.default.createElement("div", { className: "fractal-popup-content", style: { padding: "0px" } }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ import_react7.default.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ import_react7.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ import_react7.default.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ import_react7.default.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ import_react7.default.createElement("defs", null, /* @__PURE__ */ import_react7.default.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ import_react7.default.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ import_react7.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ import_react7.default.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ import_react7.default.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ import_react7.default.createElement("br", null), "was sent"), /* @__PURE__ */ import_react7.default.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ import_react7.default.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
1203
+ /* @__PURE__ */ import_react7.default.createElement("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" } }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ import_react7.default.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ import_react7.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ import_react7.default.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ import_react7.default.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ import_react7.default.createElement("defs", null, /* @__PURE__ */ import_react7.default.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ import_react7.default.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ import_react7.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ import_react7.default.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ import_react7.default.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ import_react7.default.createElement("br", null), "was sent"), /* @__PURE__ */ import_react7.default.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ import_react7.default.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ import_react7.default.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
1202
1204
  ))));
1203
1205
  }
1204
1206
 
@@ -2280,6 +2282,25 @@ var ErrorCardMessage = ({ onClose, error }) => {
2280
2282
  };
2281
2283
  var ErrorCardMessage_default = ErrorCardMessage;
2282
2284
 
2285
+ // src/app/components/socketClient.js
2286
+ var import_socket = require("socket.io-client");
2287
+ var socket = (0, import_socket.io)(baseUrl, {
2288
+ transports: ["websocket"],
2289
+ // Optional: force WebSocket
2290
+ withCredentials: false
2291
+ });
2292
+ var socketClient_default = socket;
2293
+
2294
+ // src/app/utils/Common.js
2295
+ var isValidJson = (jsonString) => {
2296
+ try {
2297
+ const parsed = JSON.parse(jsonString);
2298
+ return typeof parsed === "object" && parsed !== null;
2299
+ } catch (e) {
2300
+ return false;
2301
+ }
2302
+ };
2303
+
2283
2304
  // src/app/components/Charge/GetPaymentPage.tsx
2284
2305
  function GetPaymentPage(props) {
2285
2306
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
@@ -2489,7 +2510,7 @@ function GetPaymentPage(props) {
2489
2510
  return Object.keys(errors).length > 0;
2490
2511
  };
2491
2512
  const submitFunc = async (e) => {
2492
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
2513
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
2493
2514
  e.preventDefault();
2494
2515
  if (activetab !== "ach") {
2495
2516
  const hasError = validateCardData();
@@ -2517,7 +2538,6 @@ function GetPaymentPage(props) {
2517
2538
  });
2518
2539
  const result = await import_axios3.default.post(`${baseUrl}create-widget-order`, formData);
2519
2540
  let tokenCallback = async function(response) {
2520
- var _a3, _b3, _c3;
2521
2541
  if (response.Error) {
2522
2542
  setError(response.Error);
2523
2543
  setLoading2(false);
@@ -2527,25 +2547,38 @@ function GetPaymentPage(props) {
2527
2547
  response.name = name;
2528
2548
  response.postal_code = postal_code;
2529
2549
  response.isCardSave = `${saveCardInfo}`;
2530
- try {
2531
- let apiResponse = await import_axios3.default.post(`${masterBaseUrl}quick-pay/${result == null ? void 0 : result.data.data.posSalesIdEncode}`, response);
2532
- setCardData({
2533
- cardName: "",
2534
- cardNumber: "",
2535
- expiryMonth: "",
2536
- expiryYear: "",
2537
- cvv: "",
2538
- orderId: "",
2539
- zipCode: ""
2540
- });
2541
- setSaveCardInfo(false);
2542
- setTranId((_a3 = apiResponse == null ? void 0 : apiResponse.data) == null ? void 0 : _a3.transactionId);
2543
- setSuccess(true);
2544
- setLoading2(false);
2545
- } catch (err) {
2546
- setLoading2(false);
2547
- setError(((_c3 = (_b3 = err == null ? void 0 : err.response) == null ? void 0 : _b3.data) == null ? void 0 : _c3.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2548
- }
2550
+ response.isCharge = true;
2551
+ response.posSalesIdEncode = result == null ? void 0 : result.data.data.posSalesIdEncode;
2552
+ console.log(response, "resppp");
2553
+ console.log(result == null ? void 0 : result.data.data.posSalesIdEncode, "fkjdashgfuh");
2554
+ socketClient_default.emit("sendMessage", response);
2555
+ socketClient_default.on(result == null ? void 0 : result.data.data.posSalesIdEncode, (data) => {
2556
+ console.log(data, "socket data");
2557
+ if (isValidJson(data == null ? void 0 : data.data)) {
2558
+ let apiResponse = JSON.parse(data.data);
2559
+ console.log("return data : ", apiResponse);
2560
+ if (apiResponse == null ? void 0 : apiResponse.result) {
2561
+ setCardData({
2562
+ cardName: "",
2563
+ cardNumber: "",
2564
+ expiryMonth: "",
2565
+ expiryYear: "",
2566
+ cvv: "",
2567
+ orderId: "",
2568
+ zipCode: ""
2569
+ });
2570
+ setSaveCardInfo(false);
2571
+ setTranId(apiResponse == null ? void 0 : apiResponse.transactionId);
2572
+ setSuccess(true);
2573
+ setLoading2(false);
2574
+ } else {
2575
+ setLoading2(false);
2576
+ setError((apiResponse == null ? void 0 : apiResponse.message) || "Something went wrong.");
2577
+ }
2578
+ } else {
2579
+ setError("Something went wrong.");
2580
+ }
2581
+ });
2549
2582
  }
2550
2583
  };
2551
2584
  if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
@@ -2577,48 +2610,54 @@ function GetPaymentPage(props) {
2577
2610
  session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
2578
2611
  });
2579
2612
  try {
2580
- const tokenizeData = await import_axios3.default.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
2613
+ const tokenizeData = await import_axios3.default.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
2581
2614
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
2582
2615
  isSaveCardChecked: saveCardInfo,
2583
2616
  name: cardData == null ? void 0 : cardData.cardName,
2584
2617
  postal_code: cardData == null ? void 0 : cardData.zipCode,
2585
2618
  customer_id: props == null ? void 0 : props.customerId
2586
2619
  }));
2587
- const reqData2 = {
2620
+ const reqData2 = JSON.stringify({
2588
2621
  "pre_sales_id": `${(_i2 = (_h2 = result == null ? void 0 : result.data) == null ? void 0 : _h2.data) == null ? void 0 : _i2.posSalesIdEncode}`,
2589
2622
  "token": `${(_j2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _j2.data.token}`,
2590
2623
  "json_response": `${reqData}`
2591
- };
2592
- let myHeaders2 = {
2624
+ });
2625
+ let myHeaders2 = JSON.stringify({
2593
2626
  "Content-Type": "application/json"
2594
- };
2595
- const requestOptions2 = __spreadProps(__spreadValues({}, reqData2), {
2596
- isChargeviafractal: true
2597
2627
  });
2598
- try {
2599
- let paymentRes = await import_axios3.default.post(
2600
- `${masterBaseUrl}api/v1/payment-gateway/charge`,
2601
- requestOptions2,
2602
- {
2603
- headers: myHeaders2
2628
+ const requestOptions2 = {
2629
+ method: "POST",
2630
+ headers: myHeaders2,
2631
+ body: reqData2,
2632
+ redirect: "follow",
2633
+ isChargeviafractal: true
2634
+ };
2635
+ socketClient_default.emit("sendMessage", requestOptions2);
2636
+ socketClient_default.on("chargeviafractalgateway", (data) => {
2637
+ var _a3;
2638
+ console.log(data, "socket data");
2639
+ if (isValidJson(data == null ? void 0 : data.data)) {
2640
+ let paymentRes = JSON.parse(data == null ? void 0 : data.data);
2641
+ console.log(paymentRes, "dfuigdasuf");
2642
+ if (paymentRes == null ? void 0 : paymentRes.result) {
2643
+ setTranId((_a3 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _a3.transactionId);
2644
+ setSuccess(true);
2645
+ setLoading2(false);
2646
+ } else {
2647
+ setLoading2(false);
2648
+ setError((paymentRes == null ? void 0 : paymentRes.message) || "Something went wrong.");
2604
2649
  }
2605
- );
2606
- if ((_k2 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _k2.result) {
2607
- setTranId((_m2 = (_l2 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _l2.data) == null ? void 0 : _m2.transactionId);
2608
- setSuccess(true);
2609
- setLoading2(false);
2650
+ } else {
2651
+ setError("Something went wrong.");
2610
2652
  }
2611
- } catch (err) {
2612
- setLoading2(false);
2613
- setError(((_o2 = (_n2 = err == null ? void 0 : err.response) == null ? void 0 : _n2.data) == null ? void 0 : _o2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2614
- }
2653
+ });
2615
2654
  } catch (err) {
2616
2655
  setLoading2(false);
2617
- setError(((_q = (_p2 = err == null ? void 0 : err.response) == null ? void 0 : _p2.data) == null ? void 0 : _q.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2656
+ setError(((_l2 = (_k2 = err == null ? void 0 : err.response) == null ? void 0 : _k2.data) == null ? void 0 : _l2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2618
2657
  }
2619
2658
  } catch (err) {
2620
2659
  setLoading2(false);
2621
- setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2660
+ setError(((_n2 = (_m2 = err == null ? void 0 : err.response) == null ? void 0 : _m2.data) == null ? void 0 : _n2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2622
2661
  }
2623
2662
  } else {
2624
2663
  if (typeof DatacapWebToken !== "undefined") {
@@ -2627,7 +2666,7 @@ function GetPaymentPage(props) {
2627
2666
  }
2628
2667
  } catch (err) {
2629
2668
  setLoading2(false);
2630
- setError(((_u = (_t = err == null ? void 0 : err.response) == null ? void 0 : _t.data) == null ? void 0 : _u.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2669
+ setError(((_p2 = (_o2 = err == null ? void 0 : err.response) == null ? void 0 : _o2.data) == null ? void 0 : _p2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2631
2670
  }
2632
2671
  }
2633
2672
  }
@@ -2649,28 +2688,28 @@ function GetPaymentPage(props) {
2649
2688
  order_id: props == null ? void 0 : props.orderID,
2650
2689
  tax: props == null ? void 0 : props.tax,
2651
2690
  discount: props == null ? void 0 : props.discount,
2652
- surcharge: props == null ? void 0 : props.surcharge
2691
+ surcharge: props == null ? void 0 : props.surcharge,
2692
+ isChargeACH: true
2653
2693
  };
2654
- try {
2655
- let result = await import_axios3.default.post(`${baseUrl}ach-incoming`, dataForm);
2656
- setLoading2(false);
2657
- import_sweetalert2.default.fire({
2658
- icon: "success",
2659
- title: "Congrats...",
2660
- text: (_v = result == null ? void 0 : result.data) == null ? void 0 : _v.message
2661
- }).then((res) => {
2662
- if (res.isConfirmed) {
2663
- handleClose();
2694
+ socketClient_default.emit("sendMessage", dataForm);
2695
+ socketClient_default.on("ach-incoming", (data) => {
2696
+ var _a3;
2697
+ debugger;
2698
+ console.log(data, "sfhdwhf");
2699
+ if ((data == null ? void 0 : data.status) == "Failed") {
2700
+ if (typeof (data == null ? void 0 : data.message) == "object") {
2701
+ Object.values(data == null ? void 0 : data.message).forEach((message) => {
2702
+ setError(message || "Something went wrong");
2703
+ });
2704
+ } else {
2705
+ setError((data == null ? void 0 : data.message) || "Something went wrong");
2664
2706
  }
2665
- });
2666
- } catch (error2) {
2667
- if (import_axios3.default.isAxiosError(error2)) {
2668
- setLoading2(false);
2669
- setError((_D = (_C = (_y = (_x = (_w = error2.response) == null ? void 0 : _w.data) == null ? void 0 : _x.message) == null ? void 0 : _y.error) != null ? _C : (_B = (_A = (_z = error2.response) == null ? void 0 : _z.data) == null ? void 0 : _A.message) == null ? void 0 : _B.amount) != null ? _D : "Something went wrong");
2670
2707
  } else {
2671
- console.error("Unexpected error", error2);
2708
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
2709
+ setSuccess(true);
2710
+ setLoading2(false);
2672
2711
  }
2673
- }
2712
+ });
2674
2713
  }
2675
2714
  }
2676
2715
  };
@@ -2706,7 +2745,6 @@ function GetPaymentPage(props) {
2706
2745
  }
2707
2746
  };
2708
2747
  const handlechargeCustomer = async () => {
2709
- var _b2, _c2, _d2, _e2, _f2, _g2, _h2;
2710
2748
  let customer_id = props == null ? void 0 : props.customerId;
2711
2749
  let discount = String(props == null ? void 0 : props.discount);
2712
2750
  let surcharge = String(props == null ? void 0 : props.surcharge);
@@ -2737,17 +2775,19 @@ function GetPaymentPage(props) {
2737
2775
  "Content-Type": "application/json"
2738
2776
  };
2739
2777
  setLoading2(true);
2740
- try {
2741
- let result = await import_axios3.default.post(chargeurl, card_type == "Bank" ? rest : chargeobj, { headers });
2742
- if ((_b2 = result == null ? void 0 : result.data) == null ? void 0 : _b2.result) {
2743
- setTranId((_d2 = (_c2 = result == null ? void 0 : result.data) == null ? void 0 : _c2.data) == null ? void 0 : _d2.transaction_id);
2778
+ socketClient_default.emit("sendMessage", { url: chargeurl, body: chargeobj, isChargebycard: true });
2779
+ socketClient_default.on("charge-by-card", (response) => {
2780
+ var _a3;
2781
+ debugger;
2782
+ console.log(response, "response");
2783
+ if ((response == null ? void 0 : response.result) == true || (response == null ? void 0 : response.status) == true) {
2784
+ setTranId((_a3 = response.data) == null ? void 0 : _a3.transaction_id);
2744
2785
  setSuccess(true);
2745
2786
  setLoading2(false);
2787
+ } else {
2788
+ setError((response == null ? void 0 : response.message) || "Something went wrong.");
2746
2789
  }
2747
- } catch (err) {
2748
- setLoading2(false);
2749
- setError(((_f2 = (_e2 = err == null ? void 0 : err.response) == null ? void 0 : _e2.data) == null ? void 0 : _f2.message) || ((_h2 = (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data) == null ? void 0 : _h2.status) || "Something went erong");
2750
- }
2790
+ });
2751
2791
  } else {
2752
2792
  setError("Please Select A Card/ACH");
2753
2793
  }
@@ -3121,7 +3161,7 @@ function PreAuthPayment(props) {
3121
3161
  return Object.keys(errors).length > 0;
3122
3162
  };
3123
3163
  const submitFunc = async (e) => {
3124
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
3164
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3125
3165
  e.preventDefault();
3126
3166
  if (activetab == "card") {
3127
3167
  const hasError = validateCardData();
@@ -3139,7 +3179,6 @@ function PreAuthPayment(props) {
3139
3179
  setLoading2(true);
3140
3180
  try {
3141
3181
  let tokenCallback = async function(response) {
3142
- var _a3, _b3, _c3, _d3;
3143
3182
  if (response.Error) {
3144
3183
  setError(response.Error);
3145
3184
  setLoading2(false);
@@ -3159,26 +3198,35 @@ function PreAuthPayment(props) {
3159
3198
  response.discount = props == null ? void 0 : props.discount;
3160
3199
  response.tax = props == null ? void 0 : props.tax;
3161
3200
  response.surcharge = props == null ? void 0 : props.surcharge;
3162
- try {
3163
- let apiResponse = await import_axios4.default.post(`${baseUrl}preauth`, response);
3164
- setCardData({
3165
- cardName: "",
3166
- cardNumber: "",
3167
- expiryMonth: "",
3168
- expiryYear: "",
3169
- cvv: "",
3170
- orderId: "",
3171
- zipCode: ""
3172
- });
3173
- console.log(apiResponse, "+++++++++++++++");
3174
- setSuccess(true);
3175
- setTranId((_b3 = (_a3 = apiResponse == null ? void 0 : apiResponse.data) == null ? void 0 : _a3.data) == null ? void 0 : _b3.transaction_id);
3176
- setLoading2(false);
3177
- } catch (err) {
3178
- console.log(err);
3179
- setLoading2(false);
3180
- setError(((_d3 = (_c3 = err == null ? void 0 : err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || (err == null ? void 0 : err.message) || "Something went wrong..");
3181
- }
3201
+ const myHeaders = new Headers();
3202
+ myHeaders.append("Content-Type", "application/json");
3203
+ const requestOptions = {
3204
+ method: "POST",
3205
+ body: JSON.stringify(response),
3206
+ redirect: "follow"
3207
+ };
3208
+ socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions), { "isChargePreauth": true }));
3209
+ socketClient_default.on("charge-preauth", (data) => {
3210
+ var _a3;
3211
+ console.log(data, "datdata");
3212
+ if ((data == null ? void 0 : data.status) == "Failed") {
3213
+ setLoading2(false);
3214
+ setError((data == null ? void 0 : data.message) || "Something went wrong. Please try again later.");
3215
+ } else {
3216
+ setSuccess(true);
3217
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3218
+ setLoading2(false);
3219
+ setCardData({
3220
+ cardName: "",
3221
+ cardNumber: "",
3222
+ expiryMonth: "",
3223
+ expiryYear: "",
3224
+ cvv: "",
3225
+ orderId: "",
3226
+ zipCode: ""
3227
+ });
3228
+ }
3229
+ });
3182
3230
  }
3183
3231
  };
3184
3232
  if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
@@ -3210,7 +3258,7 @@ function PreAuthPayment(props) {
3210
3258
  session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
3211
3259
  });
3212
3260
  try {
3213
- const tokenizeData = await import_axios4.default.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
3261
+ const tokenizeData = await import_axios4.default.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
3214
3262
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
3215
3263
  // isSaveCardChecked: saveCardInfo,
3216
3264
  name: cardData == null ? void 0 : cardData.cardName,
@@ -3236,39 +3284,39 @@ function PreAuthPayment(props) {
3236
3284
  let myHeaders2 = {
3237
3285
  "Content-Type": "application/json"
3238
3286
  };
3239
- try {
3240
- let paymentRes = await import_axios4.default.post(
3241
- `${baseUrl}preauth`,
3242
- reqData,
3243
- {
3244
- headers: myHeaders2
3245
- }
3246
- );
3247
- console.log(paymentRes);
3248
- if ((_n = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _n.result) {
3249
- setTranId((_p = (_o = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _o.data) == null ? void 0 : _p.transaction_id);
3287
+ const requestOptions2 = {
3288
+ method: "POST",
3289
+ headers: myHeaders2,
3290
+ body: reqData,
3291
+ redirect: "follow"
3292
+ };
3293
+ socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions2), { "isFractalPreauth": true }));
3294
+ socketClient_default.on("fractal-charge-preauth", (data) => {
3295
+ var _a3;
3296
+ if ((data == null ? void 0 : data.status) == "Failed") {
3297
+ setLoading2(false);
3298
+ setError((data == null ? void 0 : data.message) || "Something went wrong , Try again later");
3299
+ } else {
3300
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3250
3301
  setSuccess(true);
3251
3302
  setLoading2(false);
3252
3303
  }
3253
- } catch (err) {
3254
- setLoading2(false);
3255
- setError(((_r = (_q = err == null ? void 0 : err.response) == null ? void 0 : _q.data) == null ? void 0 : _r.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3256
- }
3304
+ });
3257
3305
  } catch (err) {
3258
3306
  console.log(err);
3259
3307
  setLoading2(false);
3260
- setError(((_t = (_s = err == null ? void 0 : err.response) == null ? void 0 : _s.data) == null ? void 0 : _t.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3308
+ setError(((_o = (_n = err == null ? void 0 : err.response) == null ? void 0 : _n.data) == null ? void 0 : _o.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3261
3309
  }
3262
3310
  } catch (err) {
3263
3311
  setLoading2(false);
3264
- setError(((_v = (_u = err == null ? void 0 : err.response) == null ? void 0 : _u.data) == null ? void 0 : _v.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3312
+ setError(((_q = (_p = err == null ? void 0 : err.response) == null ? void 0 : _p.data) == null ? void 0 : _q.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3265
3313
  }
3266
3314
  } else {
3267
3315
  DatacapWebToken.requestToken(paymentData == null ? void 0 : paymentData.dctoken, "PaymentForm", tokenCallback);
3268
3316
  }
3269
3317
  } catch (err) {
3270
3318
  setLoading2(false);
3271
- setError(((_x = (_w = err == null ? void 0 : err.response) == null ? void 0 : _w.data) == null ? void 0 : _x.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
3319
+ setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
3272
3320
  }
3273
3321
  }
3274
3322
  }
@@ -4164,7 +4212,7 @@ function AddCard(props) {
4164
4212
  session_key: `${(_f = (_e = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e.data) == null ? void 0 : _f.session_key}`
4165
4213
  });
4166
4214
  try {
4167
- const tokenizeData = await import_axios5.default.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
4215
+ const tokenizeData = await import_axios5.default.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
4168
4216
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g.data), {
4169
4217
  cvv: cardData == null ? void 0 : cardData.cvv,
4170
4218
  cardName: cardData == null ? void 0 : cardData.cardName,
@@ -4565,7 +4613,7 @@ function AddCardEasyPay(props) {
4565
4613
  session_key: `${(_f = (_e = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e.data) == null ? void 0 : _f.session_key}`
4566
4614
  });
4567
4615
  try {
4568
- const tokenizeData = await import_axios6.default.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
4616
+ const tokenizeData = await import_axios6.default.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
4569
4617
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g.data), {
4570
4618
  cvv: cardData == null ? void 0 : cardData.cvv,
4571
4619
  cardName: cardData == null ? void 0 : cardData.cardName,
package/dist/index.mjs CHANGED
@@ -135,6 +135,7 @@ var Loader_default = Loader;
135
135
  // src/app/components/baseurl.ts
136
136
  var masterBaseUrl = "https://dev-sky-node.fractalpay.com/";
137
137
  var baseUrl = "https://dev-widget.fractalpay.com/";
138
+ var fractalGatewayUrl = "https://api-dev.merchant-trends.com/";
138
139
 
139
140
  // src/app/components/Errortext.ts
140
141
  var ErrorText = {
@@ -433,7 +434,6 @@ var CustomModal2 = ({
433
434
  maxWidth
434
435
  }) => {
435
436
  if (!open) return null;
436
- console.log(maxWidth);
437
437
  return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(CustomModal2styles_default, null), /* @__PURE__ */ React4.createElement("div", { className: "fractal-popup" }, /* @__PURE__ */ React4.createElement("div", { className: "fractal-popup-content request-payment-popup-container", style: { maxWidth: `${maxWidth != null ? maxWidth : "auto"}` } }, children)));
438
438
  };
439
439
  var CustomModal2_default = CustomModal2;
@@ -769,7 +769,8 @@ function RequestPayment(props) {
769
769
  customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
770
770
  discount,
771
771
  surcharge,
772
- tax
772
+ tax,
773
+ require_3ds: props == null ? void 0 : props.require_3ds
773
774
  };
774
775
  let response = await axios.post(`${baseUrl}create-widget-order`, formData);
775
776
  if ((response == null ? void 0 : response.status) === 200) {
@@ -1007,7 +1008,8 @@ function RequestPreAuthPayment(props) {
1007
1008
  customer_id: (props == null ? void 0 : props.customerId) ? props == null ? void 0 : props.customerId : "",
1008
1009
  discount,
1009
1010
  surcharge,
1010
- tax
1011
+ tax,
1012
+ require_3ds: props == null ? void 0 : props.require_3ds
1011
1013
  };
1012
1014
  let response = await axios2.post(`${baseUrl}send-request-pre-auth-payment`, formData);
1013
1015
  if ((response == null ? void 0 : response.status) === 200) {
@@ -1160,7 +1162,7 @@ function RequestPreAuthPayment(props) {
1160
1162
  onClose: handleCloseConfirmationModal,
1161
1163
  maxWidth: "500px"
1162
1164
  },
1163
- /* @__PURE__ */ React7.createElement("div", { className: "fractal-popup-content", style: { padding: "0px" } }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ React7.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React7.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React7.createElement("defs", null, /* @__PURE__ */ React7.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React7.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ React7.createElement("br", null), "was sent"), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ React7.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
1165
+ /* @__PURE__ */ React7.createElement("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" } }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-container" }, /* @__PURE__ */ React7.createElement("span", { className: "request-payment-close-popup", onClick: handleCloseConfirmationModal }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("g", { clipPath: "url(#clip0_12425_52336)" }, /* @__PURE__ */ React7.createElement("path", { d: "M9.46585 8.01168L15.6959 1.7814C16.1014 1.37615 16.1014 0.720912 15.6959 0.315659C15.2907 -0.0895946 14.6354 -0.0895946 14.2302 0.315659L7.99991 6.54593L1.76983 0.315659C1.36438 -0.0895946 0.709336 -0.0895946 0.304082 0.315659C-0.101361 0.720912 -0.101361 1.37615 0.304082 1.7814L6.53416 8.01168L0.304082 14.2419C-0.101361 14.6472 -0.101361 15.3024 0.304082 15.7077C0.506045 15.9098 0.771595 16.0114 1.03695 16.0114C1.30232 16.0114 1.56768 15.9098 1.76983 15.7077L7.99991 9.47742L14.2302 15.7077C14.4323 15.9098 14.6977 16.0114 14.9631 16.0114C15.2284 16.0114 15.4938 15.9098 15.6959 15.7077C16.1014 15.3024 16.1014 14.6472 15.6959 14.2419L9.46585 8.01168Z", fill: "#727272" })), /* @__PURE__ */ React7.createElement("defs", null, /* @__PURE__ */ React7.createElement("clipPath", { id: "clip0_12425_52336" }, /* @__PURE__ */ React7.createElement("rect", { width: "16", height: "16", fill: "white" }))))), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick-div" }, /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-tick" }, /* @__PURE__ */ React7.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none" }, /* @__PURE__ */ React7.createElement("path", { d: "M6.12669 13.9774C5.97396 14.131 5.76558 14.2167 5.54913 14.2167C5.33267 14.2167 5.1243 14.131 4.97157 13.9774L0.359012 9.36408C-0.119671 8.8854 -0.119671 8.10919 0.359012 7.6314L0.936573 7.05369C1.4154 6.57501 2.19072 6.57501 2.6694 7.05369L5.54913 9.93357L13.3306 2.15198C13.8094 1.6733 14.5855 1.6733 15.0634 2.15198L15.641 2.72969C16.1196 3.20837 16.1196 3.98444 15.641 4.46237L6.12669 13.9774Z", fill: "#61C699" })))), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-text" }, "The request ", /* @__PURE__ */ React7.createElement("br", null), "was sent"), /* @__PURE__ */ React7.createElement("h6", { className: "request-payment-success-subtext" }, "Please wait for the customer to pay"), /* @__PURE__ */ React7.createElement("div", { className: "request-payment-success-btn-div" }, /* @__PURE__ */ React7.createElement("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2" }, "Close"))))
1164
1166
  ))));
1165
1167
  }
1166
1168
 
@@ -2242,6 +2244,25 @@ var ErrorCardMessage = ({ onClose, error }) => {
2242
2244
  };
2243
2245
  var ErrorCardMessage_default = ErrorCardMessage;
2244
2246
 
2247
+ // src/app/components/socketClient.js
2248
+ import { io } from "socket.io-client";
2249
+ var socket = io(baseUrl, {
2250
+ transports: ["websocket"],
2251
+ // Optional: force WebSocket
2252
+ withCredentials: false
2253
+ });
2254
+ var socketClient_default = socket;
2255
+
2256
+ // src/app/utils/Common.js
2257
+ var isValidJson = (jsonString) => {
2258
+ try {
2259
+ const parsed = JSON.parse(jsonString);
2260
+ return typeof parsed === "object" && parsed !== null;
2261
+ } catch (e) {
2262
+ return false;
2263
+ }
2264
+ };
2265
+
2245
2266
  // src/app/components/Charge/GetPaymentPage.tsx
2246
2267
  function GetPaymentPage(props) {
2247
2268
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
@@ -2451,7 +2472,7 @@ function GetPaymentPage(props) {
2451
2472
  return Object.keys(errors).length > 0;
2452
2473
  };
2453
2474
  const submitFunc = async (e) => {
2454
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
2475
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
2455
2476
  e.preventDefault();
2456
2477
  if (activetab !== "ach") {
2457
2478
  const hasError = validateCardData();
@@ -2479,7 +2500,6 @@ function GetPaymentPage(props) {
2479
2500
  });
2480
2501
  const result = await axios3.post(`${baseUrl}create-widget-order`, formData);
2481
2502
  let tokenCallback = async function(response) {
2482
- var _a3, _b3, _c3;
2483
2503
  if (response.Error) {
2484
2504
  setError(response.Error);
2485
2505
  setLoading2(false);
@@ -2489,25 +2509,38 @@ function GetPaymentPage(props) {
2489
2509
  response.name = name;
2490
2510
  response.postal_code = postal_code;
2491
2511
  response.isCardSave = `${saveCardInfo}`;
2492
- try {
2493
- let apiResponse = await axios3.post(`${masterBaseUrl}quick-pay/${result == null ? void 0 : result.data.data.posSalesIdEncode}`, response);
2494
- setCardData({
2495
- cardName: "",
2496
- cardNumber: "",
2497
- expiryMonth: "",
2498
- expiryYear: "",
2499
- cvv: "",
2500
- orderId: "",
2501
- zipCode: ""
2502
- });
2503
- setSaveCardInfo(false);
2504
- setTranId((_a3 = apiResponse == null ? void 0 : apiResponse.data) == null ? void 0 : _a3.transactionId);
2505
- setSuccess(true);
2506
- setLoading2(false);
2507
- } catch (err) {
2508
- setLoading2(false);
2509
- setError(((_c3 = (_b3 = err == null ? void 0 : err.response) == null ? void 0 : _b3.data) == null ? void 0 : _c3.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2510
- }
2512
+ response.isCharge = true;
2513
+ response.posSalesIdEncode = result == null ? void 0 : result.data.data.posSalesIdEncode;
2514
+ console.log(response, "resppp");
2515
+ console.log(result == null ? void 0 : result.data.data.posSalesIdEncode, "fkjdashgfuh");
2516
+ socketClient_default.emit("sendMessage", response);
2517
+ socketClient_default.on(result == null ? void 0 : result.data.data.posSalesIdEncode, (data) => {
2518
+ console.log(data, "socket data");
2519
+ if (isValidJson(data == null ? void 0 : data.data)) {
2520
+ let apiResponse = JSON.parse(data.data);
2521
+ console.log("return data : ", apiResponse);
2522
+ if (apiResponse == null ? void 0 : apiResponse.result) {
2523
+ setCardData({
2524
+ cardName: "",
2525
+ cardNumber: "",
2526
+ expiryMonth: "",
2527
+ expiryYear: "",
2528
+ cvv: "",
2529
+ orderId: "",
2530
+ zipCode: ""
2531
+ });
2532
+ setSaveCardInfo(false);
2533
+ setTranId(apiResponse == null ? void 0 : apiResponse.transactionId);
2534
+ setSuccess(true);
2535
+ setLoading2(false);
2536
+ } else {
2537
+ setLoading2(false);
2538
+ setError((apiResponse == null ? void 0 : apiResponse.message) || "Something went wrong.");
2539
+ }
2540
+ } else {
2541
+ setError("Something went wrong.");
2542
+ }
2543
+ });
2511
2544
  }
2512
2545
  };
2513
2546
  if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
@@ -2539,48 +2572,54 @@ function GetPaymentPage(props) {
2539
2572
  session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
2540
2573
  });
2541
2574
  try {
2542
- const tokenizeData = await axios3.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
2575
+ const tokenizeData = await axios3.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
2543
2576
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
2544
2577
  isSaveCardChecked: saveCardInfo,
2545
2578
  name: cardData == null ? void 0 : cardData.cardName,
2546
2579
  postal_code: cardData == null ? void 0 : cardData.zipCode,
2547
2580
  customer_id: props == null ? void 0 : props.customerId
2548
2581
  }));
2549
- const reqData2 = {
2582
+ const reqData2 = JSON.stringify({
2550
2583
  "pre_sales_id": `${(_i2 = (_h2 = result == null ? void 0 : result.data) == null ? void 0 : _h2.data) == null ? void 0 : _i2.posSalesIdEncode}`,
2551
2584
  "token": `${(_j2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _j2.data.token}`,
2552
2585
  "json_response": `${reqData}`
2553
- };
2554
- let myHeaders2 = {
2586
+ });
2587
+ let myHeaders2 = JSON.stringify({
2555
2588
  "Content-Type": "application/json"
2556
- };
2557
- const requestOptions2 = __spreadProps(__spreadValues({}, reqData2), {
2558
- isChargeviafractal: true
2559
2589
  });
2560
- try {
2561
- let paymentRes = await axios3.post(
2562
- `${masterBaseUrl}api/v1/payment-gateway/charge`,
2563
- requestOptions2,
2564
- {
2565
- headers: myHeaders2
2590
+ const requestOptions2 = {
2591
+ method: "POST",
2592
+ headers: myHeaders2,
2593
+ body: reqData2,
2594
+ redirect: "follow",
2595
+ isChargeviafractal: true
2596
+ };
2597
+ socketClient_default.emit("sendMessage", requestOptions2);
2598
+ socketClient_default.on("chargeviafractalgateway", (data) => {
2599
+ var _a3;
2600
+ console.log(data, "socket data");
2601
+ if (isValidJson(data == null ? void 0 : data.data)) {
2602
+ let paymentRes = JSON.parse(data == null ? void 0 : data.data);
2603
+ console.log(paymentRes, "dfuigdasuf");
2604
+ if (paymentRes == null ? void 0 : paymentRes.result) {
2605
+ setTranId((_a3 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _a3.transactionId);
2606
+ setSuccess(true);
2607
+ setLoading2(false);
2608
+ } else {
2609
+ setLoading2(false);
2610
+ setError((paymentRes == null ? void 0 : paymentRes.message) || "Something went wrong.");
2566
2611
  }
2567
- );
2568
- if ((_k2 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _k2.result) {
2569
- setTranId((_m2 = (_l2 = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _l2.data) == null ? void 0 : _m2.transactionId);
2570
- setSuccess(true);
2571
- setLoading2(false);
2612
+ } else {
2613
+ setError("Something went wrong.");
2572
2614
  }
2573
- } catch (err) {
2574
- setLoading2(false);
2575
- setError(((_o2 = (_n2 = err == null ? void 0 : err.response) == null ? void 0 : _n2.data) == null ? void 0 : _o2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2576
- }
2615
+ });
2577
2616
  } catch (err) {
2578
2617
  setLoading2(false);
2579
- setError(((_q = (_p2 = err == null ? void 0 : err.response) == null ? void 0 : _p2.data) == null ? void 0 : _q.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2618
+ setError(((_l2 = (_k2 = err == null ? void 0 : err.response) == null ? void 0 : _k2.data) == null ? void 0 : _l2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2580
2619
  }
2581
2620
  } catch (err) {
2582
2621
  setLoading2(false);
2583
- setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2622
+ setError(((_n2 = (_m2 = err == null ? void 0 : err.response) == null ? void 0 : _m2.data) == null ? void 0 : _n2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2584
2623
  }
2585
2624
  } else {
2586
2625
  if (typeof DatacapWebToken !== "undefined") {
@@ -2589,7 +2628,7 @@ function GetPaymentPage(props) {
2589
2628
  }
2590
2629
  } catch (err) {
2591
2630
  setLoading2(false);
2592
- setError(((_u = (_t = err == null ? void 0 : err.response) == null ? void 0 : _t.data) == null ? void 0 : _u.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2631
+ setError(((_p2 = (_o2 = err == null ? void 0 : err.response) == null ? void 0 : _o2.data) == null ? void 0 : _p2.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
2593
2632
  }
2594
2633
  }
2595
2634
  }
@@ -2611,28 +2650,28 @@ function GetPaymentPage(props) {
2611
2650
  order_id: props == null ? void 0 : props.orderID,
2612
2651
  tax: props == null ? void 0 : props.tax,
2613
2652
  discount: props == null ? void 0 : props.discount,
2614
- surcharge: props == null ? void 0 : props.surcharge
2653
+ surcharge: props == null ? void 0 : props.surcharge,
2654
+ isChargeACH: true
2615
2655
  };
2616
- try {
2617
- let result = await axios3.post(`${baseUrl}ach-incoming`, dataForm);
2618
- setLoading2(false);
2619
- Swal.fire({
2620
- icon: "success",
2621
- title: "Congrats...",
2622
- text: (_v = result == null ? void 0 : result.data) == null ? void 0 : _v.message
2623
- }).then((res) => {
2624
- if (res.isConfirmed) {
2625
- handleClose();
2656
+ socketClient_default.emit("sendMessage", dataForm);
2657
+ socketClient_default.on("ach-incoming", (data) => {
2658
+ var _a3;
2659
+ debugger;
2660
+ console.log(data, "sfhdwhf");
2661
+ if ((data == null ? void 0 : data.status) == "Failed") {
2662
+ if (typeof (data == null ? void 0 : data.message) == "object") {
2663
+ Object.values(data == null ? void 0 : data.message).forEach((message) => {
2664
+ setError(message || "Something went wrong");
2665
+ });
2666
+ } else {
2667
+ setError((data == null ? void 0 : data.message) || "Something went wrong");
2626
2668
  }
2627
- });
2628
- } catch (error2) {
2629
- if (axios3.isAxiosError(error2)) {
2630
- setLoading2(false);
2631
- setError((_D = (_C = (_y = (_x = (_w = error2.response) == null ? void 0 : _w.data) == null ? void 0 : _x.message) == null ? void 0 : _y.error) != null ? _C : (_B = (_A = (_z = error2.response) == null ? void 0 : _z.data) == null ? void 0 : _A.message) == null ? void 0 : _B.amount) != null ? _D : "Something went wrong");
2632
2669
  } else {
2633
- console.error("Unexpected error", error2);
2670
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
2671
+ setSuccess(true);
2672
+ setLoading2(false);
2634
2673
  }
2635
- }
2674
+ });
2636
2675
  }
2637
2676
  }
2638
2677
  };
@@ -2668,7 +2707,6 @@ function GetPaymentPage(props) {
2668
2707
  }
2669
2708
  };
2670
2709
  const handlechargeCustomer = async () => {
2671
- var _b2, _c2, _d2, _e2, _f2, _g2, _h2;
2672
2710
  let customer_id = props == null ? void 0 : props.customerId;
2673
2711
  let discount = String(props == null ? void 0 : props.discount);
2674
2712
  let surcharge = String(props == null ? void 0 : props.surcharge);
@@ -2699,17 +2737,19 @@ function GetPaymentPage(props) {
2699
2737
  "Content-Type": "application/json"
2700
2738
  };
2701
2739
  setLoading2(true);
2702
- try {
2703
- let result = await axios3.post(chargeurl, card_type == "Bank" ? rest : chargeobj, { headers });
2704
- if ((_b2 = result == null ? void 0 : result.data) == null ? void 0 : _b2.result) {
2705
- setTranId((_d2 = (_c2 = result == null ? void 0 : result.data) == null ? void 0 : _c2.data) == null ? void 0 : _d2.transaction_id);
2740
+ socketClient_default.emit("sendMessage", { url: chargeurl, body: chargeobj, isChargebycard: true });
2741
+ socketClient_default.on("charge-by-card", (response) => {
2742
+ var _a3;
2743
+ debugger;
2744
+ console.log(response, "response");
2745
+ if ((response == null ? void 0 : response.result) == true || (response == null ? void 0 : response.status) == true) {
2746
+ setTranId((_a3 = response.data) == null ? void 0 : _a3.transaction_id);
2706
2747
  setSuccess(true);
2707
2748
  setLoading2(false);
2749
+ } else {
2750
+ setError((response == null ? void 0 : response.message) || "Something went wrong.");
2708
2751
  }
2709
- } catch (err) {
2710
- setLoading2(false);
2711
- setError(((_f2 = (_e2 = err == null ? void 0 : err.response) == null ? void 0 : _e2.data) == null ? void 0 : _f2.message) || ((_h2 = (_g2 = err == null ? void 0 : err.response) == null ? void 0 : _g2.data) == null ? void 0 : _h2.status) || "Something went erong");
2712
- }
2752
+ });
2713
2753
  } else {
2714
2754
  setError("Please Select A Card/ACH");
2715
2755
  }
@@ -3083,7 +3123,7 @@ function PreAuthPayment(props) {
3083
3123
  return Object.keys(errors).length > 0;
3084
3124
  };
3085
3125
  const submitFunc = async (e) => {
3086
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
3126
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3087
3127
  e.preventDefault();
3088
3128
  if (activetab == "card") {
3089
3129
  const hasError = validateCardData();
@@ -3101,7 +3141,6 @@ function PreAuthPayment(props) {
3101
3141
  setLoading2(true);
3102
3142
  try {
3103
3143
  let tokenCallback = async function(response) {
3104
- var _a3, _b3, _c3, _d3;
3105
3144
  if (response.Error) {
3106
3145
  setError(response.Error);
3107
3146
  setLoading2(false);
@@ -3121,26 +3160,35 @@ function PreAuthPayment(props) {
3121
3160
  response.discount = props == null ? void 0 : props.discount;
3122
3161
  response.tax = props == null ? void 0 : props.tax;
3123
3162
  response.surcharge = props == null ? void 0 : props.surcharge;
3124
- try {
3125
- let apiResponse = await axios4.post(`${baseUrl}preauth`, response);
3126
- setCardData({
3127
- cardName: "",
3128
- cardNumber: "",
3129
- expiryMonth: "",
3130
- expiryYear: "",
3131
- cvv: "",
3132
- orderId: "",
3133
- zipCode: ""
3134
- });
3135
- console.log(apiResponse, "+++++++++++++++");
3136
- setSuccess(true);
3137
- setTranId((_b3 = (_a3 = apiResponse == null ? void 0 : apiResponse.data) == null ? void 0 : _a3.data) == null ? void 0 : _b3.transaction_id);
3138
- setLoading2(false);
3139
- } catch (err) {
3140
- console.log(err);
3141
- setLoading2(false);
3142
- setError(((_d3 = (_c3 = err == null ? void 0 : err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || (err == null ? void 0 : err.message) || "Something went wrong..");
3143
- }
3163
+ const myHeaders = new Headers();
3164
+ myHeaders.append("Content-Type", "application/json");
3165
+ const requestOptions = {
3166
+ method: "POST",
3167
+ body: JSON.stringify(response),
3168
+ redirect: "follow"
3169
+ };
3170
+ socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions), { "isChargePreauth": true }));
3171
+ socketClient_default.on("charge-preauth", (data) => {
3172
+ var _a3;
3173
+ console.log(data, "datdata");
3174
+ if ((data == null ? void 0 : data.status) == "Failed") {
3175
+ setLoading2(false);
3176
+ setError((data == null ? void 0 : data.message) || "Something went wrong. Please try again later.");
3177
+ } else {
3178
+ setSuccess(true);
3179
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3180
+ setLoading2(false);
3181
+ setCardData({
3182
+ cardName: "",
3183
+ cardNumber: "",
3184
+ expiryMonth: "",
3185
+ expiryYear: "",
3186
+ cvv: "",
3187
+ orderId: "",
3188
+ zipCode: ""
3189
+ });
3190
+ }
3191
+ });
3144
3192
  }
3145
3193
  };
3146
3194
  if ((paymentData == null ? void 0 : paymentData.paymentGateway) === 32) {
@@ -3172,7 +3220,7 @@ function PreAuthPayment(props) {
3172
3220
  session_key: `${(_f2 = (_e2 = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e2.data) == null ? void 0 : _f2.session_key}`
3173
3221
  });
3174
3222
  try {
3175
- const tokenizeData = await axios4.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
3223
+ const tokenizeData = await axios4.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
3176
3224
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g2 = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g2.data), {
3177
3225
  // isSaveCardChecked: saveCardInfo,
3178
3226
  name: cardData == null ? void 0 : cardData.cardName,
@@ -3198,39 +3246,39 @@ function PreAuthPayment(props) {
3198
3246
  let myHeaders2 = {
3199
3247
  "Content-Type": "application/json"
3200
3248
  };
3201
- try {
3202
- let paymentRes = await axios4.post(
3203
- `${baseUrl}preauth`,
3204
- reqData,
3205
- {
3206
- headers: myHeaders2
3207
- }
3208
- );
3209
- console.log(paymentRes);
3210
- if ((_n = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _n.result) {
3211
- setTranId((_p = (_o = paymentRes == null ? void 0 : paymentRes.data) == null ? void 0 : _o.data) == null ? void 0 : _p.transaction_id);
3249
+ const requestOptions2 = {
3250
+ method: "POST",
3251
+ headers: myHeaders2,
3252
+ body: reqData,
3253
+ redirect: "follow"
3254
+ };
3255
+ socketClient_default.emit("sendMessage", __spreadProps(__spreadValues({}, requestOptions2), { "isFractalPreauth": true }));
3256
+ socketClient_default.on("fractal-charge-preauth", (data) => {
3257
+ var _a3;
3258
+ if ((data == null ? void 0 : data.status) == "Failed") {
3259
+ setLoading2(false);
3260
+ setError((data == null ? void 0 : data.message) || "Something went wrong , Try again later");
3261
+ } else {
3262
+ setTranId((_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.transaction_id);
3212
3263
  setSuccess(true);
3213
3264
  setLoading2(false);
3214
3265
  }
3215
- } catch (err) {
3216
- setLoading2(false);
3217
- setError(((_r = (_q = err == null ? void 0 : err.response) == null ? void 0 : _q.data) == null ? void 0 : _r.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3218
- }
3266
+ });
3219
3267
  } catch (err) {
3220
3268
  console.log(err);
3221
3269
  setLoading2(false);
3222
- setError(((_t = (_s = err == null ? void 0 : err.response) == null ? void 0 : _s.data) == null ? void 0 : _t.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3270
+ setError(((_o = (_n = err == null ? void 0 : err.response) == null ? void 0 : _n.data) == null ? void 0 : _o.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3223
3271
  }
3224
3272
  } catch (err) {
3225
3273
  setLoading2(false);
3226
- setError(((_v = (_u = err == null ? void 0 : err.response) == null ? void 0 : _u.data) == null ? void 0 : _v.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3274
+ setError(((_q = (_p = err == null ? void 0 : err.response) == null ? void 0 : _p.data) == null ? void 0 : _q.message) || (err == null ? void 0 : err.message) || "Something went wrong , Try again later");
3227
3275
  }
3228
3276
  } else {
3229
3277
  DatacapWebToken.requestToken(paymentData == null ? void 0 : paymentData.dctoken, "PaymentForm", tokenCallback);
3230
3278
  }
3231
3279
  } catch (err) {
3232
3280
  setLoading2(false);
3233
- setError(((_x = (_w = err == null ? void 0 : err.response) == null ? void 0 : _w.data) == null ? void 0 : _x.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
3281
+ setError(((_s = (_r = err == null ? void 0 : err.response) == null ? void 0 : _r.data) == null ? void 0 : _s.message) || (err == null ? void 0 : err.message) || "Something went wrong.");
3234
3282
  }
3235
3283
  }
3236
3284
  }
@@ -4126,7 +4174,7 @@ function AddCard(props) {
4126
4174
  session_key: `${(_f = (_e = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e.data) == null ? void 0 : _f.session_key}`
4127
4175
  });
4128
4176
  try {
4129
- const tokenizeData = await axios5.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
4177
+ const tokenizeData = await axios5.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
4130
4178
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g.data), {
4131
4179
  cvv: cardData == null ? void 0 : cardData.cvv,
4132
4180
  cardName: cardData == null ? void 0 : cardData.cardName,
@@ -4527,7 +4575,7 @@ function AddCardEasyPay(props) {
4527
4575
  session_key: `${(_f = (_e = sesionResult == null ? void 0 : sesionResult.data) == null ? void 0 : _e.data) == null ? void 0 : _f.session_key}`
4528
4576
  });
4529
4577
  try {
4530
- const tokenizeData = await axios6.post("https://api-dev.merchant-trends.com/tokenizer/tokenize", raw, { headers: myHeaders });
4578
+ const tokenizeData = await axios6.post(`${fractalGatewayUrl}tokenizer/tokenize`, raw, { headers: myHeaders });
4531
4579
  const reqData = JSON.stringify(__spreadProps(__spreadValues({}, (_g = tokenizeData == null ? void 0 : tokenizeData.data) == null ? void 0 : _g.data), {
4532
4580
  cvv: cardData == null ? void 0 : cardData.cvv,
4533
4581
  cardName: cardData == null ? void 0 : cardData.cardName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinerohit11/testwidget",
3
- "version": "0.2.123",
3
+ "version": "0.2.125",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "next dev -p 4001",
@@ -25,6 +25,7 @@
25
25
  "react-icons": "^5.5.0",
26
26
  "react-number-format": "^5.4.3",
27
27
  "react-toastify": "^10.0.6",
28
+ "socket.io-client": "^4.8.1",
28
29
  "styled-components": "^6.1.15",
29
30
  "sweetalert2": "^11.22.0",
30
31
  "yup": "^1.6.1"