@fractalpay/fractalpay-next-dev 0.0.292 → 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.292",
42
+ version: "0.0.294",
43
43
  private: false,
44
44
  type: "module",
45
45
  scripts: {
@@ -774,6 +774,16 @@ var RequestPaymentstyles = (props) => {
774
774
  align-items: center;
775
775
  }
776
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
+
777
787
  .request-payment-success-text {
778
788
  color: #161616;
779
789
  text-align: center;
@@ -1043,6 +1053,8 @@ function RequestPayment(props) {
1043
1053
  const [cashDiscount, setCashDiscount] = useState(void 0);
1044
1054
  const [amount, setAmount] = useState("");
1045
1055
  const [showConfirmationModal, setShowConfirmationModal] = useState(false);
1056
+ const [showErrorModal, setShowErrorModal] = useState(false);
1057
+ const [apiError, setApiError] = useState("");
1046
1058
  const [apiResponse, setApiResponse] = useState(null);
1047
1059
  const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
1048
1060
  const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
@@ -1070,6 +1082,11 @@ function RequestPayment(props) {
1070
1082
  handleSubmit(apiResponse);
1071
1083
  setShowConfirmationModal(false);
1072
1084
  };
1085
+ const handleCloseErrorModal = () => {
1086
+ console.log(apiResponse, "apiresponse");
1087
+ handleSubmit(apiResponse);
1088
+ setShowErrorModal(false);
1089
+ };
1073
1090
  function emptyFields() {
1074
1091
  setRequestDetails({
1075
1092
  email: "",
@@ -1088,6 +1105,7 @@ function RequestPayment(props) {
1088
1105
  window.parent.postMessage(message, "*");
1089
1106
  }
1090
1107
  const sendRequestPayment = async (e) => {
1108
+ var _a, _b;
1091
1109
  e.currentTarget.blur();
1092
1110
  if (loading) return;
1093
1111
  if (Object.keys(errors).length > 0) {
@@ -1124,13 +1142,19 @@ function RequestPayment(props) {
1124
1142
  let response = await axios.post(`${baseUrl}create-widget-order`, formData, {
1125
1143
  headers: __spreadValues({}, (props == null ? void 0 : props.sessionToken) && { "X-Session-Token": props.sessionToken })
1126
1144
  });
1127
- 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)) {
1128
1146
  setShowConfirmationModal(true);
1129
1147
  setShow(false);
1130
1148
  emptyFields();
1131
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);
1132
1157
  }
1133
- setLoading(false);
1134
1158
  } catch (error) {
1135
1159
  console.log(error);
1136
1160
  setLoading(false);
@@ -1242,7 +1266,7 @@ function RequestPayment(props) {
1242
1266
  /* @__PURE__ */ jsx6("p", { className: "request-payment-amount", children: formatAmount(props == null ? void 0 : props.amount) }),
1243
1267
  cashDiscount && cashDiscount > 0 && /* @__PURE__ */ jsxs3("div", { className: "frac-req-cash-discount", children: [
1244
1268
  /* @__PURE__ */ jsxs3("div", { className: "frac-cashlabel", children: [
1245
- numberToBoolean(props == null ? void 0 : props.showSurcharge) ? "Surcharge" : "Cash Discount",
1269
+ (props == null ? void 0 : props.showSurcharge) == 1 ? "3% Card Fee" : "Cash Discount",
1246
1270
  " :"
1247
1271
  ] }),
1248
1272
  /* @__PURE__ */ jsx6("div", { children: formatUSD((Number(props.amount) - cashDiscount).toFixed(2)) })
@@ -1383,6 +1407,56 @@ function RequestPayment(props) {
1383
1407
  /* @__PURE__ */ jsx6("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx6("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2", children: "Close" }) })
1384
1408
  ] }) })
1385
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
+ }
1386
1460
  )
1387
1461
  ] })
1388
1462
  ] });
@@ -1413,6 +1487,8 @@ function RequestPreAuthPayment(props) {
1413
1487
  const [amount, setAmount] = useState2("");
1414
1488
  const [showConfirmationModal, setShowConfirmationModal] = useState2(false);
1415
1489
  const [apiResponse, setApiResponse] = useState2(null);
1490
+ const [showErrorModal, setShowErrorModal] = useState2(false);
1491
+ const [apiError, setApiError] = useState2("");
1416
1492
  const phoneNumberRegex = (value) => /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/.test(value);
1417
1493
  const amoutRegex = /[+-]?([0-9]*[.])?[0-9]+/;
1418
1494
  const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
@@ -1444,6 +1520,7 @@ function RequestPreAuthPayment(props) {
1444
1520
  window.parent.postMessage(message, "*");
1445
1521
  }
1446
1522
  const sendRequestPayment = async (e) => {
1523
+ var _a, _b;
1447
1524
  e.currentTarget.blur();
1448
1525
  if (loading) return;
1449
1526
  if (Object.keys(errors).length > 0) {
@@ -1478,11 +1555,17 @@ function RequestPreAuthPayment(props) {
1478
1555
  let response = await axios2.post(`${baseUrl}send-request-pre-auth-payment`, formData, {
1479
1556
  headers: __spreadValues({}, (props == null ? void 0 : props.sessionToken) && { "X-Session-Token": props.sessionToken })
1480
1557
  });
1481
- 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)) {
1482
1559
  setShowConfirmationModal(true);
1483
1560
  setShow(false);
1484
1561
  emptyFields();
1485
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);
1486
1569
  }
1487
1570
  setLoading(false);
1488
1571
  } catch (error) {
@@ -1572,6 +1655,11 @@ function RequestPreAuthPayment(props) {
1572
1655
  maximumFractionDigits: 2
1573
1656
  }).format(Number(amount2));
1574
1657
  }
1658
+ const handleCloseErrorModal = () => {
1659
+ console.log(apiResponse, "apiresponse");
1660
+ handleSubmit(apiResponse);
1661
+ setShowErrorModal(false);
1662
+ };
1575
1663
  return /* @__PURE__ */ jsxs4(Fragment4, { children: [
1576
1664
  /* @__PURE__ */ jsx7(RequestPaymentstyles_default, {}),
1577
1665
  /* @__PURE__ */ jsx7(Loader_default, { loading }),
@@ -1705,6 +1793,56 @@ function RequestPreAuthPayment(props) {
1705
1793
  /* @__PURE__ */ jsx7("div", { className: "request-payment-success-btn-div", children: /* @__PURE__ */ jsx7("button", { onClick: handleCloseConfirmationModal, className: "request-payment-success-btn2", children: "Close" }) })
1706
1794
  ] }) })
1707
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
+ }
1708
1846
  )
1709
1847
  ] })
1710
1848
  ] })