@fractalpay/fractalpay-next-dev 0.0.293 → 0.0.294

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.293",
42
+ version: "0.0.294",
43
43
  private: false,
44
44
  type: "module",
45
45
  scripts: {
@@ -236,9 +236,8 @@ var Loader_default = Loader;
236
236
  var { name } = require_package();
237
237
  var S3Url = "https://fractal-userdata-upload.s3.us-east-1.amazonaws.com/";
238
238
  if (name === "@fractalpay/fractalpay-next-dev") {
239
+ masterBaseUrl = "https://api.dev.fractalpay.com/";
239
240
  baseUrl = "https://widget.dev.fractalpay.com/";
240
- baseUrl = "http://192.168.1.64:8083/";
241
- masterBaseUrl = "http://192.168.1.64:8082/";
242
241
  fractalGatewayUrl = "https://api-dev.merchant-trends.com/";
243
242
  datacapUrl = "https://token-cert.dcap.com/v1/client";
244
243
  threedsSecurePublicKey = "pk_test_51RH5Wc2SlJvyNZ80hpUDy88r4rVdpijfKbNaWaUyQEE6rOrPmG2JQyAj7G5amBD5z5daC56WaeT4jfNhrrPcGOEP00UyKu6AOw";
@@ -775,6 +774,16 @@ var RequestPaymentstyles = (props) => {
775
774
  align-items: center;
776
775
  }
777
776
 
777
+ .request-payment-error-tick {
778
+ border-radius: 1000px;
779
+ background: #f1000024;
780
+ display: flex;
781
+ width: 60px;
782
+ height: 60px;
783
+ justify-content: center;
784
+ align-items: center;
785
+ }
786
+
778
787
  .request-payment-success-text {
779
788
  color: #161616;
780
789
  text-align: center;
@@ -1044,6 +1053,8 @@ function RequestPayment(props) {
1044
1053
  const [cashDiscount, setCashDiscount] = useState(void 0);
1045
1054
  const [amount, setAmount] = useState("");
1046
1055
  const [showConfirmationModal, setShowConfirmationModal] = useState(false);
1056
+ const [showErrorModal, setShowErrorModal] = useState(false);
1057
+ const [apiError, setApiError] = useState("");
1047
1058
  const [apiResponse, setApiResponse] = useState(null);
1048
1059
  const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
1049
1060
  const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
@@ -1071,6 +1082,11 @@ function RequestPayment(props) {
1071
1082
  handleSubmit(apiResponse);
1072
1083
  setShowConfirmationModal(false);
1073
1084
  };
1085
+ const handleCloseErrorModal = () => {
1086
+ console.log(apiResponse, "apiresponse");
1087
+ handleSubmit(apiResponse);
1088
+ setShowErrorModal(false);
1089
+ };
1074
1090
  function emptyFields() {
1075
1091
  setRequestDetails({
1076
1092
  email: "",
@@ -1089,6 +1105,7 @@ function RequestPayment(props) {
1089
1105
  window.parent.postMessage(message, "*");
1090
1106
  }
1091
1107
  const sendRequestPayment = async (e) => {
1108
+ var _a, _b;
1092
1109
  e.currentTarget.blur();
1093
1110
  if (loading) return;
1094
1111
  if (Object.keys(errors).length > 0) {
@@ -1125,13 +1142,19 @@ function RequestPayment(props) {
1125
1142
  let response = await axios.post(`${baseUrl}create-widget-order`, formData, {
1126
1143
  headers: __spreadValues({}, (props == null ? void 0 : props.sessionToken) && { "X-Session-Token": props.sessionToken })
1127
1144
  });
1128
- if ((response == null ? void 0 : response.status) === 200) {
1145
+ if ((response == null ? void 0 : response.status) === 200 && ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.result)) {
1129
1146
  setShowConfirmationModal(true);
1130
1147
  setShow(false);
1131
1148
  emptyFields();
1132
1149
  setApiResponse(response == null ? void 0 : response.data);
1150
+ setLoading(false);
1151
+ } else {
1152
+ console.log(response);
1153
+ setShowErrorModal(true);
1154
+ setShow(false);
1155
+ setApiError(((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.message) || "Something went wrong!");
1156
+ setLoading(false);
1133
1157
  }
1134
- setLoading(false);
1135
1158
  } catch (error) {
1136
1159
  console.log(error);
1137
1160
  setLoading(false);
@@ -1243,7 +1266,7 @@ function RequestPayment(props) {
1243
1266
  /* @__PURE__ */ jsx6("p", { className: "request-payment-amount", children: formatAmount(props == null ? void 0 : props.amount) }),
1244
1267
  cashDiscount && cashDiscount > 0 && /* @__PURE__ */ jsxs3("div", { className: "frac-req-cash-discount", children: [
1245
1268
  /* @__PURE__ */ jsxs3("div", { className: "frac-cashlabel", children: [
1246
- numberToBoolean(props == null ? void 0 : props.showSurcharge) ? "Surcharge" : "Cash Discount",
1269
+ (props == null ? void 0 : props.showSurcharge) == 1 ? "3% Card Fee" : "Cash Discount",
1247
1270
  " :"
1248
1271
  ] }),
1249
1272
  /* @__PURE__ */ jsx6("div", { children: formatUSD((Number(props.amount) - cashDiscount).toFixed(2)) })
@@ -1384,6 +1407,56 @@ function RequestPayment(props) {
1384
1407
  /* @__PURE__ */ jsx6("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx6("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2", children: "Close" }) })
1385
1408
  ] }) })
1386
1409
  }
1410
+ ),
1411
+ /* @__PURE__ */ jsx6(
1412
+ CustomModal2_default,
1413
+ {
1414
+ open: showErrorModal,
1415
+ onClose: handleCloseErrorModal,
1416
+ maxWidth: "500px",
1417
+ children: /* @__PURE__ */ jsx6("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" }, children: /* @__PURE__ */ jsxs3("div", { className: "request-payment-success-container", children: [
1418
+ /* @__PURE__ */ jsx6("span", { className: "request-payment-close-popup", onClick: handleCloseErrorModal, children: /* @__PURE__ */ jsxs3("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: [
1419
+ /* @__PURE__ */ jsx6("g", { clipPath: "url(#clip0_12425_52336)", children: /* @__PURE__ */ jsx6("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" }) }),
1420
+ /* @__PURE__ */ jsx6("defs", { children: /* @__PURE__ */ jsx6("clipPath", { id: "clip0_12425_52336", children: /* @__PURE__ */ jsx6("rect", { width: "16", height: "16", fill: "white" }) }) })
1421
+ ] }) }),
1422
+ /* @__PURE__ */ jsx6("div", { className: "request-payment-success-tick-div", children: /* @__PURE__ */ jsx6("div", { className: "request-payment-error-tick", children: /* @__PURE__ */ jsx6(
1423
+ "svg",
1424
+ {
1425
+ xmlns: "http://www.w3.org/2000/svg",
1426
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
1427
+ width: 16,
1428
+ height: 16,
1429
+ x: 0,
1430
+ y: 0,
1431
+ viewBox: "0 0 21 21",
1432
+ xmlSpace: "preserve",
1433
+ fillRule: "evenodd",
1434
+ className: "",
1435
+ children: /* @__PURE__ */ jsx6("g", { children: /* @__PURE__ */ jsxs3("g", { fill: "red", children: [
1436
+ /* @__PURE__ */ jsx6(
1437
+ "path",
1438
+ {
1439
+ d: "m3.486 16.029 12.41-12.41a.183.183 0 0 1 .258 0l.326.326.004.004.702.702.003.004.327.326a.183.183 0 0 1 0 .258L5.106 17.65a.183.183 0 0 1-.258 0l-.326-.327-.004-.003-.702-.702-.004-.004-.326-.326a.183.183 0 0 1 0-.258z",
1440
+ fill: "",
1441
+ opacity: 1
1442
+ }
1443
+ ),
1444
+ /* @__PURE__ */ jsx6(
1445
+ "path",
1446
+ {
1447
+ d: "M15.896 17.649 3.486 5.239a.183.183 0 0 1 0-.258l.327-.326.003-.004.702-.702.004-.004.326-.326a.183.183 0 0 1 .258 0l12.41 12.41a.183.183 0 0 1 0 .258l-.326.326-.004.004-.702.702-.004.003-.326.327a.183.183 0 0 1-.258 0z",
1448
+ fill: "",
1449
+ opacity: 1
1450
+ }
1451
+ )
1452
+ ] }) })
1453
+ }
1454
+ ) }) }),
1455
+ /* @__PURE__ */ jsx6("h6", { className: "request-payment-success-text", children: apiError }),
1456
+ /* @__PURE__ */ jsx6("h6", { className: "request-payment-success-subtext", children: "Please try again later" }),
1457
+ /* @__PURE__ */ jsx6("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx6("button", { onClick: handleCloseErrorModal, className: "request-payment-success-btn2", children: "Close" }) })
1458
+ ] }) })
1459
+ }
1387
1460
  )
1388
1461
  ] })
1389
1462
  ] });
@@ -1414,6 +1487,8 @@ function RequestPreAuthPayment(props) {
1414
1487
  const [amount, setAmount] = useState2("");
1415
1488
  const [showConfirmationModal, setShowConfirmationModal] = useState2(false);
1416
1489
  const [apiResponse, setApiResponse] = useState2(null);
1490
+ const [showErrorModal, setShowErrorModal] = useState2(false);
1491
+ const [apiError, setApiError] = useState2("");
1417
1492
  const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
1418
1493
  const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
1419
1494
  const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
@@ -1445,6 +1520,7 @@ function RequestPreAuthPayment(props) {
1445
1520
  window.parent.postMessage(message, "*");
1446
1521
  }
1447
1522
  const sendRequestPayment = async (e) => {
1523
+ var _a, _b;
1448
1524
  e.currentTarget.blur();
1449
1525
  if (loading) return;
1450
1526
  if (Object.keys(errors).length > 0) {
@@ -1479,11 +1555,17 @@ function RequestPreAuthPayment(props) {
1479
1555
  let response = await axios2.post(`${baseUrl}send-request-pre-auth-payment`, formData, {
1480
1556
  headers: __spreadValues({}, (props == null ? void 0 : props.sessionToken) && { "X-Session-Token": props.sessionToken })
1481
1557
  });
1482
- if ((response == null ? void 0 : response.status) === 200) {
1558
+ if ((response == null ? void 0 : response.status) === 200 && ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.result)) {
1483
1559
  setShowConfirmationModal(true);
1484
1560
  setShow(false);
1485
1561
  emptyFields();
1486
1562
  setApiResponse(response == null ? void 0 : response.data);
1563
+ setLoading(false);
1564
+ } else {
1565
+ setShowErrorModal(true);
1566
+ setShow(false);
1567
+ setApiError(((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.message) || "Something went wrong!");
1568
+ setLoading(false);
1487
1569
  }
1488
1570
  setLoading(false);
1489
1571
  } catch (error) {
@@ -1573,6 +1655,11 @@ function RequestPreAuthPayment(props) {
1573
1655
  maximumFractionDigits: 2
1574
1656
  }).format(Number(amount2));
1575
1657
  }
1658
+ const handleCloseErrorModal = () => {
1659
+ console.log(apiResponse, "apiresponse");
1660
+ handleSubmit(apiResponse);
1661
+ setShowErrorModal(false);
1662
+ };
1576
1663
  return /* @__PURE__ */ jsxs4(Fragment4, { children: [
1577
1664
  /* @__PURE__ */ jsx7(RequestPaymentstyles_default, {}),
1578
1665
  /* @__PURE__ */ jsx7(Loader_default, { loading }),
@@ -1706,6 +1793,56 @@ function RequestPreAuthPayment(props) {
1706
1793
  /* @__PURE__ */ jsx7("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx7("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2", children: "Close" }) })
1707
1794
  ] }) })
1708
1795
  }
1796
+ ),
1797
+ /* @__PURE__ */ jsx7(
1798
+ CustomModal2_default,
1799
+ {
1800
+ open: showErrorModal,
1801
+ onClose: handleCloseErrorModal,
1802
+ maxWidth: "500px",
1803
+ children: /* @__PURE__ */ jsx7("div", { className: "fractal-popup-content", style: { padding: "0px", maxWidth: "500px" }, children: /* @__PURE__ */ jsxs4("div", { className: "request-payment-success-container", children: [
1804
+ /* @__PURE__ */ jsx7("span", { className: "request-payment-close-popup", onClick: handleCloseErrorModal, children: /* @__PURE__ */ jsxs4("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: [
1805
+ /* @__PURE__ */ jsx7("g", { clipPath: "url(#clip0_12425_52336)", children: /* @__PURE__ */ jsx7("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" }) }),
1806
+ /* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsx7("clipPath", { id: "clip0_12425_52336", children: /* @__PURE__ */ jsx7("rect", { width: "16", height: "16", fill: "white" }) }) })
1807
+ ] }) }),
1808
+ /* @__PURE__ */ jsx7("div", { className: "request-payment-success-tick-div", children: /* @__PURE__ */ jsx7("div", { className: "request-payment-error-tick", children: /* @__PURE__ */ jsx7(
1809
+ "svg",
1810
+ {
1811
+ xmlns: "http://www.w3.org/2000/svg",
1812
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
1813
+ width: 16,
1814
+ height: 16,
1815
+ x: 0,
1816
+ y: 0,
1817
+ viewBox: "0 0 21 21",
1818
+ xmlSpace: "preserve",
1819
+ fillRule: "evenodd",
1820
+ className: "",
1821
+ children: /* @__PURE__ */ jsx7("g", { children: /* @__PURE__ */ jsxs4("g", { fill: "red", children: [
1822
+ /* @__PURE__ */ jsx7(
1823
+ "path",
1824
+ {
1825
+ d: "m3.486 16.029 12.41-12.41a.183.183 0 0 1 .258 0l.326.326.004.004.702.702.003.004.327.326a.183.183 0 0 1 0 .258L5.106 17.65a.183.183 0 0 1-.258 0l-.326-.327-.004-.003-.702-.702-.004-.004-.326-.326a.183.183 0 0 1 0-.258z",
1826
+ fill: "",
1827
+ opacity: 1
1828
+ }
1829
+ ),
1830
+ /* @__PURE__ */ jsx7(
1831
+ "path",
1832
+ {
1833
+ d: "M15.896 17.649 3.486 5.239a.183.183 0 0 1 0-.258l.327-.326.003-.004.702-.702.004-.004.326-.326a.183.183 0 0 1 .258 0l12.41 12.41a.183.183 0 0 1 0 .258l-.326.326-.004.004-.702.702-.004.003-.326.327a.183.183 0 0 1-.258 0z",
1834
+ fill: "",
1835
+ opacity: 1
1836
+ }
1837
+ )
1838
+ ] }) })
1839
+ }
1840
+ ) }) }),
1841
+ /* @__PURE__ */ jsx7("h6", { className: "request-payment-success-text", children: apiError }),
1842
+ /* @__PURE__ */ jsx7("h6", { className: "request-payment-success-subtext", children: "Please try again later" }),
1843
+ /* @__PURE__ */ jsx7("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx7("button", { onClick: handleCloseErrorModal, className: "request-payment-success-btn2", children: "Close" }) })
1844
+ ] }) })
1845
+ }
1709
1846
  )
1710
1847
  ] })
1711
1848
  ] })