astra-sdk-web 1.1.17 → 1.1.19

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.
@@ -59,6 +59,36 @@ var KycApiService = class {
59
59
  throw new Error(`Status fetch failed: ${message}`);
60
60
  }
61
61
  }
62
+ /**
63
+ * Get session result (kyc result)
64
+ */
65
+ async getResult() {
66
+ const deviceType = this.config.deviceType || this.detectDeviceType();
67
+ try {
68
+ const response = await fetch(
69
+ `${this.config.apiBaseUrl}/api/v2/dashboard/merchant/onsite/session/${this.config.sessionId}/result`,
70
+ {
71
+ method: "GET",
72
+ headers: {
73
+ "x-server-key": this.config.serverKey,
74
+ "device-type": deviceType,
75
+ "Content-Type": "application/json"
76
+ },
77
+ credentials: "include"
78
+ }
79
+ );
80
+ if (!response.ok) {
81
+ const errorData = await response.json().catch(() => ({}));
82
+ const message = errorData?.message || `Result fetch failed with status ${response.status}`;
83
+ throw new Error(message);
84
+ }
85
+ const data = await response.json();
86
+ return data;
87
+ } catch (error) {
88
+ const message = error?.message || "Result fetch failed";
89
+ throw new Error(`Result fetch failed: ${message}`);
90
+ }
91
+ }
62
92
  /**
63
93
  * Upload face scan image
64
94
  */
@@ -1699,7 +1729,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1699
1729
  ] }) });
1700
1730
  }
1701
1731
  var MobileRoute_default = MobileRoute;
1702
- function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stage.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
1732
+ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk-stage.astraprotocol.com", sessionId, apiBaseUrl, serverKey } = {}) {
1703
1733
  const [qrUrl, setQrUrl] = useState("");
1704
1734
  const [copied, setCopied] = useState(false);
1705
1735
  useEffect(() => {
@@ -1734,8 +1764,25 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
1734
1764
  onClose();
1735
1765
  }
1736
1766
  };
1737
- const handleRefresh = () => {
1738
- window.location.reload();
1767
+ const handleCheckResult = async () => {
1768
+ if (!apiBaseUrl || !sessionId || !serverKey) {
1769
+ alert("Missing configuration to check KYC result.");
1770
+ return;
1771
+ }
1772
+ try {
1773
+ const svc = new KycApiService({ apiBaseUrl, sessionId, serverKey });
1774
+ const payload = await svc.getResult();
1775
+ const first = Array.isArray(payload?.data) && payload.data.length > 0 ? payload.data[0] : null;
1776
+ if (first && first.kyc_status === "success" && first.redirectUrl) {
1777
+ window.location.href = "https://astra-pro-business.astraprotocol.com/pricing-plans";
1778
+ return;
1779
+ }
1780
+ alert("Please complete your KYC first.");
1781
+ } catch (error) {
1782
+ const msg = error?.message || "Result fetch failed";
1783
+ console.error("getResult:error", msg);
1784
+ alert(`Result fetch failed: ${msg}`);
1785
+ }
1739
1786
  };
1740
1787
  return /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center bg-gradient-to-br from-gray-900 via-gray-800 to-black p-4 sm:p-6 md:p-8 z-[1000]", children: [
1741
1788
  /* @__PURE__ */ jsx("div", { className: "absolute inset-0 opacity-10", style: {
@@ -1792,8 +1839,8 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://kyc-sdk-stag
1792
1839
  "button",
1793
1840
  {
1794
1841
  className: "w-full py-3 sm:py-4 px-6 bg-gradient-to-r from-[#FF842D] to-[#FF2D55] border-none rounded-lg text-white text-sm sm:text-base font-semibold cursor-pointer transition-all hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(255,107,53,0.4)] active:translate-y-0",
1795
- onClick: handleRefresh,
1796
- children: "I've completed on mobile - Refresh"
1842
+ onClick: handleCheckResult,
1843
+ children: "I've completed on mobile - Move to next step"
1797
1844
  }
1798
1845
  )
1799
1846
  ] })