@paykit-sdk/react 1.1.96 → 1.1.97

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.
@@ -28,9 +28,46 @@ var PaykitContext = React__namespace.createContext(void 0);
28
28
  var usePaykitContext = () => {
29
29
  const ctx = React__namespace.useContext(PaykitContext);
30
30
  if (!ctx)
31
- throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
31
+ throw new Error(
32
+ "Your app must be wrapped in PayKitProvider to use PayKit hooks."
33
+ );
32
34
  return ctx;
33
35
  };
36
+
37
+ // src/util.ts
38
+ var PayKitClientError = class extends Error {
39
+ constructor(errorData) {
40
+ super(errorData.message);
41
+ this.name = "PayKitClientError";
42
+ this.code = errorData.code;
43
+ this.statusCode = errorData.statusCode;
44
+ this.provider = errorData.provider;
45
+ this.method = errorData.method;
46
+ this.context = errorData.context;
47
+ }
48
+ };
49
+ var parsePayKitClientError = (response, errorData) => {
50
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
51
+ const data = errorData;
52
+ return new PayKitClientError({
53
+ message: data.message,
54
+ code: data.code,
55
+ statusCode: data.statusCode || response.status,
56
+ provider: data.provider,
57
+ method: data.method,
58
+ context: data.context
59
+ });
60
+ }
61
+ return new PayKitClientError({
62
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
63
+ statusCode: response.status,
64
+ provider: errorData == null ? void 0 : errorData.provider,
65
+ method: errorData == null ? void 0 : errorData.method,
66
+ context: errorData == null ? void 0 : errorData.context
67
+ });
68
+ };
69
+
70
+ // src/hooks/use-async-fn.ts
34
71
  var useAsyncFn = (path, apiUrl, headersEsque) => {
35
72
  const [loading, setLoading] = React__namespace.useState(false);
36
73
  const run = React__namespace.useCallback(
@@ -38,22 +75,37 @@ var useAsyncFn = (path, apiUrl, headersEsque) => {
38
75
  setLoading(true);
39
76
  try {
40
77
  const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
41
- const response = await fetch(`${apiUrl}${path}`, {
78
+ const res = await fetch(`${apiUrl}${path}`, {
42
79
  method: "POST",
43
80
  headers: { "Content-Type": "application/json", ...headers },
44
81
  credentials: "include",
45
82
  body: JSON.stringify({ args })
46
83
  });
47
- if (!response.ok) {
48
- const errorData = await response.json().catch(() => ({ message: "Request failed" }));
49
- throw new Error(errorData.message || `HTTP ${response.status}`);
84
+ if (!res.ok) {
85
+ const errorData = await res.json().catch(() => ({
86
+ message: res.statusText || "Request failed"
87
+ }));
88
+ throw parsePayKitClientError(res, errorData);
50
89
  }
51
- const data = await response.json();
52
- setLoading(false);
53
- return [data.result, void 0];
54
- } catch (error) {
90
+ const response = await res.json();
91
+ if (typeof response === "object" && "result" in response) {
92
+ return [response.result, void 0];
93
+ }
94
+ throw new PayKitClientError({
95
+ message: "Unknown response format (API must return JSON with a top-level 'result' property)",
96
+ statusCode: 500,
97
+ context: {
98
+ response: JSON.stringify(response, null, 2)
99
+ }
100
+ });
101
+ } catch (err) {
102
+ const error = err instanceof PayKitClientError ? err : new PayKitClientError({
103
+ message: err instanceof Error ? err.message : "An unexpected error occurred",
104
+ statusCode: err instanceof Error ? 0 : 500
105
+ });
106
+ return [void 0, error];
107
+ } finally {
55
108
  setLoading(false);
56
- return [void 0, error instanceof Error ? error : new Error(String(error))];
57
109
  }
58
110
  },
59
111
  [path, apiUrl, headersEsque]
@@ -6,9 +6,46 @@ var PaykitContext = React.createContext(void 0);
6
6
  var usePaykitContext = () => {
7
7
  const ctx = React.useContext(PaykitContext);
8
8
  if (!ctx)
9
- throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
9
+ throw new Error(
10
+ "Your app must be wrapped in PayKitProvider to use PayKit hooks."
11
+ );
10
12
  return ctx;
11
13
  };
14
+
15
+ // src/util.ts
16
+ var PayKitClientError = class extends Error {
17
+ constructor(errorData) {
18
+ super(errorData.message);
19
+ this.name = "PayKitClientError";
20
+ this.code = errorData.code;
21
+ this.statusCode = errorData.statusCode;
22
+ this.provider = errorData.provider;
23
+ this.method = errorData.method;
24
+ this.context = errorData.context;
25
+ }
26
+ };
27
+ var parsePayKitClientError = (response, errorData) => {
28
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
29
+ const data = errorData;
30
+ return new PayKitClientError({
31
+ message: data.message,
32
+ code: data.code,
33
+ statusCode: data.statusCode || response.status,
34
+ provider: data.provider,
35
+ method: data.method,
36
+ context: data.context
37
+ });
38
+ }
39
+ return new PayKitClientError({
40
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
41
+ statusCode: response.status,
42
+ provider: errorData == null ? void 0 : errorData.provider,
43
+ method: errorData == null ? void 0 : errorData.method,
44
+ context: errorData == null ? void 0 : errorData.context
45
+ });
46
+ };
47
+
48
+ // src/hooks/use-async-fn.ts
12
49
  var useAsyncFn = (path, apiUrl, headersEsque) => {
13
50
  const [loading, setLoading] = React.useState(false);
14
51
  const run = React.useCallback(
@@ -16,22 +53,37 @@ var useAsyncFn = (path, apiUrl, headersEsque) => {
16
53
  setLoading(true);
17
54
  try {
18
55
  const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
19
- const response = await fetch(`${apiUrl}${path}`, {
56
+ const res = await fetch(`${apiUrl}${path}`, {
20
57
  method: "POST",
21
58
  headers: { "Content-Type": "application/json", ...headers },
22
59
  credentials: "include",
23
60
  body: JSON.stringify({ args })
24
61
  });
25
- if (!response.ok) {
26
- const errorData = await response.json().catch(() => ({ message: "Request failed" }));
27
- throw new Error(errorData.message || `HTTP ${response.status}`);
62
+ if (!res.ok) {
63
+ const errorData = await res.json().catch(() => ({
64
+ message: res.statusText || "Request failed"
65
+ }));
66
+ throw parsePayKitClientError(res, errorData);
28
67
  }
29
- const data = await response.json();
30
- setLoading(false);
31
- return [data.result, void 0];
32
- } catch (error) {
68
+ const response = await res.json();
69
+ if (typeof response === "object" && "result" in response) {
70
+ return [response.result, void 0];
71
+ }
72
+ throw new PayKitClientError({
73
+ message: "Unknown response format (API must return JSON with a top-level 'result' property)",
74
+ statusCode: 500,
75
+ context: {
76
+ response: JSON.stringify(response, null, 2)
77
+ }
78
+ });
79
+ } catch (err) {
80
+ const error = err instanceof PayKitClientError ? err : new PayKitClientError({
81
+ message: err instanceof Error ? err.message : "An unexpected error occurred",
82
+ statusCode: err instanceof Error ? 0 : 500
83
+ });
84
+ return [void 0, error];
85
+ } finally {
33
86
  setLoading(false);
34
- return [void 0, error instanceof Error ? error : new Error(String(error))];
35
87
  }
36
88
  },
37
89
  [path, apiUrl, headersEsque]
@@ -1,24 +1,25 @@
1
+ import { PayKitClientError } from '../util.mjs';
1
2
  import * as _paykit_sdk_core from '@paykit-sdk/core';
2
3
 
3
4
  declare const useSubscription: () => {
4
5
  create: {
5
- run: (params: _paykit_sdk_core.CreateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
+ run: (params: _paykit_sdk_core.CreateSubscriptionSchema<Record<string, unknown>>) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
7
  loading: boolean;
7
8
  };
8
9
  update: {
9
- run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
+ run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema<Record<string, unknown>>) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
11
  loading: boolean;
11
12
  };
12
13
  retrieve: {
13
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
15
  loading: boolean;
15
16
  };
16
17
  cancel: {
17
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
19
  loading: boolean;
19
20
  };
20
21
  remove: {
21
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
22
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: null, error: undefined]>;
22
23
  loading: boolean;
23
24
  };
24
25
  };
@@ -1,24 +1,25 @@
1
+ import { PayKitClientError } from '../util.js';
1
2
  import * as _paykit_sdk_core from '@paykit-sdk/core';
2
3
 
3
4
  declare const useSubscription: () => {
4
5
  create: {
5
- run: (params: _paykit_sdk_core.CreateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
+ run: (params: _paykit_sdk_core.CreateSubscriptionSchema<Record<string, unknown>>) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
7
  loading: boolean;
7
8
  };
8
9
  update: {
9
- run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
+ run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema<Record<string, unknown>>) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
11
  loading: boolean;
11
12
  };
12
13
  retrieve: {
13
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
15
  loading: boolean;
15
16
  };
16
17
  cancel: {
17
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
19
  loading: boolean;
19
20
  };
20
21
  remove: {
21
- run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
22
+ run: (id: string) => Promise<[data: undefined, error: PayKitClientError] | [data: null, error: undefined]>;
22
23
  loading: boolean;
23
24
  };
24
25
  };
@@ -28,9 +28,46 @@ var PaykitContext = React__namespace.createContext(void 0);
28
28
  var usePaykitContext = () => {
29
29
  const ctx = React__namespace.useContext(PaykitContext);
30
30
  if (!ctx)
31
- throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
31
+ throw new Error(
32
+ "Your app must be wrapped in PayKitProvider to use PayKit hooks."
33
+ );
32
34
  return ctx;
33
35
  };
36
+
37
+ // src/util.ts
38
+ var PayKitClientError = class extends Error {
39
+ constructor(errorData) {
40
+ super(errorData.message);
41
+ this.name = "PayKitClientError";
42
+ this.code = errorData.code;
43
+ this.statusCode = errorData.statusCode;
44
+ this.provider = errorData.provider;
45
+ this.method = errorData.method;
46
+ this.context = errorData.context;
47
+ }
48
+ };
49
+ var parsePayKitClientError = (response, errorData) => {
50
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
51
+ const data = errorData;
52
+ return new PayKitClientError({
53
+ message: data.message,
54
+ code: data.code,
55
+ statusCode: data.statusCode || response.status,
56
+ provider: data.provider,
57
+ method: data.method,
58
+ context: data.context
59
+ });
60
+ }
61
+ return new PayKitClientError({
62
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
63
+ statusCode: response.status,
64
+ provider: errorData == null ? void 0 : errorData.provider,
65
+ method: errorData == null ? void 0 : errorData.method,
66
+ context: errorData == null ? void 0 : errorData.context
67
+ });
68
+ };
69
+
70
+ // src/hooks/use-async-fn.ts
34
71
  var useAsyncFn = (path, apiUrl, headersEsque) => {
35
72
  const [loading, setLoading] = React__namespace.useState(false);
36
73
  const run = React__namespace.useCallback(
@@ -38,22 +75,37 @@ var useAsyncFn = (path, apiUrl, headersEsque) => {
38
75
  setLoading(true);
39
76
  try {
40
77
  const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
41
- const response = await fetch(`${apiUrl}${path}`, {
78
+ const res = await fetch(`${apiUrl}${path}`, {
42
79
  method: "POST",
43
80
  headers: { "Content-Type": "application/json", ...headers },
44
81
  credentials: "include",
45
82
  body: JSON.stringify({ args })
46
83
  });
47
- if (!response.ok) {
48
- const errorData = await response.json().catch(() => ({ message: "Request failed" }));
49
- throw new Error(errorData.message || `HTTP ${response.status}`);
84
+ if (!res.ok) {
85
+ const errorData = await res.json().catch(() => ({
86
+ message: res.statusText || "Request failed"
87
+ }));
88
+ throw parsePayKitClientError(res, errorData);
50
89
  }
51
- const data = await response.json();
52
- setLoading(false);
53
- return [data.result, void 0];
54
- } catch (error) {
90
+ const response = await res.json();
91
+ if (typeof response === "object" && "result" in response) {
92
+ return [response.result, void 0];
93
+ }
94
+ throw new PayKitClientError({
95
+ message: "Unknown response format (API must return JSON with a top-level 'result' property)",
96
+ statusCode: 500,
97
+ context: {
98
+ response: JSON.stringify(response, null, 2)
99
+ }
100
+ });
101
+ } catch (err) {
102
+ const error = err instanceof PayKitClientError ? err : new PayKitClientError({
103
+ message: err instanceof Error ? err.message : "An unexpected error occurred",
104
+ statusCode: err instanceof Error ? 0 : 500
105
+ });
106
+ return [void 0, error];
107
+ } finally {
55
108
  setLoading(false);
56
- return [void 0, error instanceof Error ? error : new Error(String(error))];
57
109
  }
58
110
  },
59
111
  [path, apiUrl, headersEsque]
@@ -6,9 +6,46 @@ var PaykitContext = React.createContext(void 0);
6
6
  var usePaykitContext = () => {
7
7
  const ctx = React.useContext(PaykitContext);
8
8
  if (!ctx)
9
- throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
9
+ throw new Error(
10
+ "Your app must be wrapped in PayKitProvider to use PayKit hooks."
11
+ );
10
12
  return ctx;
11
13
  };
14
+
15
+ // src/util.ts
16
+ var PayKitClientError = class extends Error {
17
+ constructor(errorData) {
18
+ super(errorData.message);
19
+ this.name = "PayKitClientError";
20
+ this.code = errorData.code;
21
+ this.statusCode = errorData.statusCode;
22
+ this.provider = errorData.provider;
23
+ this.method = errorData.method;
24
+ this.context = errorData.context;
25
+ }
26
+ };
27
+ var parsePayKitClientError = (response, errorData) => {
28
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
29
+ const data = errorData;
30
+ return new PayKitClientError({
31
+ message: data.message,
32
+ code: data.code,
33
+ statusCode: data.statusCode || response.status,
34
+ provider: data.provider,
35
+ method: data.method,
36
+ context: data.context
37
+ });
38
+ }
39
+ return new PayKitClientError({
40
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
41
+ statusCode: response.status,
42
+ provider: errorData == null ? void 0 : errorData.provider,
43
+ method: errorData == null ? void 0 : errorData.method,
44
+ context: errorData == null ? void 0 : errorData.context
45
+ });
46
+ };
47
+
48
+ // src/hooks/use-async-fn.ts
12
49
  var useAsyncFn = (path, apiUrl, headersEsque) => {
13
50
  const [loading, setLoading] = React.useState(false);
14
51
  const run = React.useCallback(
@@ -16,22 +53,37 @@ var useAsyncFn = (path, apiUrl, headersEsque) => {
16
53
  setLoading(true);
17
54
  try {
18
55
  const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
19
- const response = await fetch(`${apiUrl}${path}`, {
56
+ const res = await fetch(`${apiUrl}${path}`, {
20
57
  method: "POST",
21
58
  headers: { "Content-Type": "application/json", ...headers },
22
59
  credentials: "include",
23
60
  body: JSON.stringify({ args })
24
61
  });
25
- if (!response.ok) {
26
- const errorData = await response.json().catch(() => ({ message: "Request failed" }));
27
- throw new Error(errorData.message || `HTTP ${response.status}`);
62
+ if (!res.ok) {
63
+ const errorData = await res.json().catch(() => ({
64
+ message: res.statusText || "Request failed"
65
+ }));
66
+ throw parsePayKitClientError(res, errorData);
28
67
  }
29
- const data = await response.json();
30
- setLoading(false);
31
- return [data.result, void 0];
32
- } catch (error) {
68
+ const response = await res.json();
69
+ if (typeof response === "object" && "result" in response) {
70
+ return [response.result, void 0];
71
+ }
72
+ throw new PayKitClientError({
73
+ message: "Unknown response format (API must return JSON with a top-level 'result' property)",
74
+ statusCode: 500,
75
+ context: {
76
+ response: JSON.stringify(response, null, 2)
77
+ }
78
+ });
79
+ } catch (err) {
80
+ const error = err instanceof PayKitClientError ? err : new PayKitClientError({
81
+ message: err instanceof Error ? err.message : "An unexpected error occurred",
82
+ statusCode: err instanceof Error ? 0 : 500
83
+ });
84
+ return [void 0, error];
85
+ } finally {
33
86
  setLoading(false);
34
- return [void 0, error instanceof Error ? error : new Error(String(error))];
35
87
  }
36
88
  },
37
89
  [path, apiUrl, headersEsque]
@@ -0,0 +1,19 @@
1
+ interface PayKitClientErrorData {
2
+ message: string;
3
+ code?: string;
4
+ statusCode: number;
5
+ provider?: string;
6
+ method?: string;
7
+ context?: Record<string, unknown>;
8
+ }
9
+ declare class PayKitClientError extends Error {
10
+ readonly code?: string;
11
+ readonly statusCode: number;
12
+ readonly provider?: string;
13
+ readonly method?: string;
14
+ readonly context?: Record<string, unknown>;
15
+ constructor(errorData: PayKitClientErrorData);
16
+ }
17
+ declare const parsePayKitClientError: (response: Response, errorData: unknown) => PayKitClientError;
18
+
19
+ export { PayKitClientError, type PayKitClientErrorData, parsePayKitClientError };
package/dist/util.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ interface PayKitClientErrorData {
2
+ message: string;
3
+ code?: string;
4
+ statusCode: number;
5
+ provider?: string;
6
+ method?: string;
7
+ context?: Record<string, unknown>;
8
+ }
9
+ declare class PayKitClientError extends Error {
10
+ readonly code?: string;
11
+ readonly statusCode: number;
12
+ readonly provider?: string;
13
+ readonly method?: string;
14
+ readonly context?: Record<string, unknown>;
15
+ constructor(errorData: PayKitClientErrorData);
16
+ }
17
+ declare const parsePayKitClientError: (response: Response, errorData: unknown) => PayKitClientError;
18
+
19
+ export { PayKitClientError, type PayKitClientErrorData, parsePayKitClientError };
package/dist/util.js ADDED
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ // src/util.ts
4
+ var PayKitClientError = class extends Error {
5
+ constructor(errorData) {
6
+ super(errorData.message);
7
+ this.name = "PayKitClientError";
8
+ this.code = errorData.code;
9
+ this.statusCode = errorData.statusCode;
10
+ this.provider = errorData.provider;
11
+ this.method = errorData.method;
12
+ this.context = errorData.context;
13
+ }
14
+ };
15
+ var parsePayKitClientError = (response, errorData) => {
16
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
17
+ const data = errorData;
18
+ return new PayKitClientError({
19
+ message: data.message,
20
+ code: data.code,
21
+ statusCode: data.statusCode || response.status,
22
+ provider: data.provider,
23
+ method: data.method,
24
+ context: data.context
25
+ });
26
+ }
27
+ return new PayKitClientError({
28
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
29
+ statusCode: response.status,
30
+ provider: errorData == null ? void 0 : errorData.provider,
31
+ method: errorData == null ? void 0 : errorData.method,
32
+ context: errorData == null ? void 0 : errorData.context
33
+ });
34
+ };
35
+
36
+ exports.PayKitClientError = PayKitClientError;
37
+ exports.parsePayKitClientError = parsePayKitClientError;
package/dist/util.mjs ADDED
@@ -0,0 +1,34 @@
1
+ // src/util.ts
2
+ var PayKitClientError = class extends Error {
3
+ constructor(errorData) {
4
+ super(errorData.message);
5
+ this.name = "PayKitClientError";
6
+ this.code = errorData.code;
7
+ this.statusCode = errorData.statusCode;
8
+ this.provider = errorData.provider;
9
+ this.method = errorData.method;
10
+ this.context = errorData.context;
11
+ }
12
+ };
13
+ var parsePayKitClientError = (response, errorData) => {
14
+ if (errorData && typeof errorData === "object" && "message" in errorData) {
15
+ const data = errorData;
16
+ return new PayKitClientError({
17
+ message: data.message,
18
+ code: data.code,
19
+ statusCode: data.statusCode || response.status,
20
+ provider: data.provider,
21
+ method: data.method,
22
+ context: data.context
23
+ });
24
+ }
25
+ return new PayKitClientError({
26
+ message: typeof errorData === "string" ? errorData : (errorData == null ? void 0 : errorData.message) || `HTTP ${response.status}: ${response.statusText}`,
27
+ statusCode: response.status,
28
+ provider: errorData == null ? void 0 : errorData.provider,
29
+ method: errorData == null ? void 0 : errorData.method,
30
+ context: errorData == null ? void 0 : errorData.context
31
+ });
32
+ };
33
+
34
+ export { PayKitClientError, parsePayKitClientError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/react",
3
- "version": "1.1.96",
3
+ "version": "1.1.97",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "peerDependencies": {
21
21
  "react": ">=16.8.0",
22
22
  "react-dom": ">=16.8.0",
23
- "@paykit-sdk/core": ">=1.1.97"
23
+ "@paykit-sdk/core": ">=1.2.3"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@swc/core": "^1.12.9",
@@ -30,7 +30,7 @@
30
30
  "react-dom": "^19.2.0",
31
31
  "tsup": "^8.0.0",
32
32
  "typescript": "^5.0.0",
33
- "@paykit-sdk/core": "1.1.97"
33
+ "@paykit-sdk/core": "1.2.3"
34
34
  },
35
35
  "description": "React hooks and components for PayKit SDK - Universal payment processing with Stripe, Polar, and more",
36
36
  "keywords": [