@paykit-sdk/react 1.1.9 → 1.1.91

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.
@@ -0,0 +1,22 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+
3
+ declare const useCustomer: () => {
4
+ retrieve: {
5
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Customer | null, error: undefined]>;
6
+ loading: boolean;
7
+ };
8
+ create: {
9
+ run: (params: _paykit_sdk_core.CreateCustomerParams) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Customer, error: undefined]>;
10
+ loading: boolean;
11
+ };
12
+ update: {
13
+ run: (id: string, params: _paykit_sdk_core.UpdateCustomerParams) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Customer, error: undefined]>;
14
+ loading: boolean;
15
+ };
16
+ remove: {
17
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
18
+ loading: boolean;
19
+ };
20
+ };
21
+
22
+ export { useCustomer };
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('react/jsx-runtime');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ // src/context.tsx
27
+ var PaykitContext = React__namespace.createContext(void 0);
28
+ var usePaykitContext = () => {
29
+ const ctx = React__namespace.useContext(PaykitContext);
30
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
31
+ return ctx;
32
+ };
33
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
34
+ const [loading, setLoading] = React__namespace.useState(false);
35
+ const run = React__namespace.useCallback(
36
+ async (...args) => {
37
+ setLoading(true);
38
+ try {
39
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
40
+ const response = await fetch(`${apiUrl}${path}`, {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json", ...headers },
43
+ credentials: "include",
44
+ body: JSON.stringify({ args })
45
+ });
46
+ if (!response.ok) {
47
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
48
+ throw new Error(errorData.message || `HTTP ${response.status}`);
49
+ }
50
+ const data = await response.json();
51
+ setLoading(false);
52
+ return [data.result, void 0];
53
+ } catch (error) {
54
+ setLoading(false);
55
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
56
+ }
57
+ },
58
+ [path, apiUrl, headersEsque]
59
+ );
60
+ return { run, loading };
61
+ };
62
+
63
+ // src/resources/customer.ts
64
+ var useCustomer = () => {
65
+ const ctx = usePaykitContext();
66
+ const retrieve = useAsyncFn(
67
+ "/customer/retrieve",
68
+ ctx.apiUrl,
69
+ ctx.headers
70
+ );
71
+ const create = useAsyncFn(
72
+ "/customer/create",
73
+ ctx.apiUrl,
74
+ ctx.headers
75
+ );
76
+ const update = useAsyncFn(
77
+ "/customer/update",
78
+ ctx.apiUrl,
79
+ ctx.headers
80
+ );
81
+ const remove = useAsyncFn(
82
+ "/customer/delete",
83
+ ctx.apiUrl,
84
+ ctx.headers
85
+ );
86
+ return { retrieve, create, update, remove };
87
+ };
88
+
89
+ exports.useCustomer = useCustomer;
@@ -0,0 +1,67 @@
1
+ import * as React from 'react';
2
+ import 'react/jsx-runtime';
3
+
4
+ // src/context.tsx
5
+ var PaykitContext = React.createContext(void 0);
6
+ var usePaykitContext = () => {
7
+ const ctx = React.useContext(PaykitContext);
8
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
9
+ return ctx;
10
+ };
11
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
12
+ const [loading, setLoading] = React.useState(false);
13
+ const run = React.useCallback(
14
+ async (...args) => {
15
+ setLoading(true);
16
+ try {
17
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
18
+ const response = await fetch(`${apiUrl}${path}`, {
19
+ method: "POST",
20
+ headers: { "Content-Type": "application/json", ...headers },
21
+ credentials: "include",
22
+ body: JSON.stringify({ args })
23
+ });
24
+ if (!response.ok) {
25
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
26
+ throw new Error(errorData.message || `HTTP ${response.status}`);
27
+ }
28
+ const data = await response.json();
29
+ setLoading(false);
30
+ return [data.result, void 0];
31
+ } catch (error) {
32
+ setLoading(false);
33
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
34
+ }
35
+ },
36
+ [path, apiUrl, headersEsque]
37
+ );
38
+ return { run, loading };
39
+ };
40
+
41
+ // src/resources/customer.ts
42
+ var useCustomer = () => {
43
+ const ctx = usePaykitContext();
44
+ const retrieve = useAsyncFn(
45
+ "/customer/retrieve",
46
+ ctx.apiUrl,
47
+ ctx.headers
48
+ );
49
+ const create = useAsyncFn(
50
+ "/customer/create",
51
+ ctx.apiUrl,
52
+ ctx.headers
53
+ );
54
+ const update = useAsyncFn(
55
+ "/customer/update",
56
+ ctx.apiUrl,
57
+ ctx.headers
58
+ );
59
+ const remove = useAsyncFn(
60
+ "/customer/delete",
61
+ ctx.apiUrl,
62
+ ctx.headers
63
+ );
64
+ return { retrieve, create, update, remove };
65
+ };
66
+
67
+ export { useCustomer };
@@ -0,0 +1,31 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+ import { Payment } from '@paykit-sdk/core';
3
+
4
+ declare const usePayment: () => {
5
+ create: {
6
+ run: (params: _paykit_sdk_core.CreatePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
7
+ loading: boolean;
8
+ };
9
+ retrieve: {
10
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: Payment | null, error: undefined]>;
11
+ loading: boolean;
12
+ };
13
+ update: {
14
+ run: (id: string, params: _paykit_sdk_core.UpdatePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
15
+ loading: boolean;
16
+ };
17
+ remove: {
18
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
19
+ loading: boolean;
20
+ };
21
+ capture: {
22
+ run: (id: string, params: _paykit_sdk_core.CapturePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
23
+ loading: boolean;
24
+ };
25
+ cancel: {
26
+ run: (args_0: string) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
27
+ loading: boolean;
28
+ };
29
+ };
30
+
31
+ export { usePayment };
@@ -0,0 +1,31 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+ import { Payment } from '@paykit-sdk/core';
3
+
4
+ declare const usePayment: () => {
5
+ create: {
6
+ run: (params: _paykit_sdk_core.CreatePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
7
+ loading: boolean;
8
+ };
9
+ retrieve: {
10
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: Payment | null, error: undefined]>;
11
+ loading: boolean;
12
+ };
13
+ update: {
14
+ run: (id: string, params: _paykit_sdk_core.UpdatePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
15
+ loading: boolean;
16
+ };
17
+ remove: {
18
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
19
+ loading: boolean;
20
+ };
21
+ capture: {
22
+ run: (id: string, params: _paykit_sdk_core.CapturePaymentSchema) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
23
+ loading: boolean;
24
+ };
25
+ cancel: {
26
+ run: (args_0: string) => Promise<[data: undefined, error: Error] | [data: Payment, error: undefined]>;
27
+ loading: boolean;
28
+ };
29
+ };
30
+
31
+ export { usePayment };
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('react/jsx-runtime');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ // src/context.tsx
27
+ var PaykitContext = React__namespace.createContext(void 0);
28
+ var usePaykitContext = () => {
29
+ const ctx = React__namespace.useContext(PaykitContext);
30
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
31
+ return ctx;
32
+ };
33
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
34
+ const [loading, setLoading] = React__namespace.useState(false);
35
+ const run = React__namespace.useCallback(
36
+ async (...args) => {
37
+ setLoading(true);
38
+ try {
39
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
40
+ const response = await fetch(`${apiUrl}${path}`, {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json", ...headers },
43
+ credentials: "include",
44
+ body: JSON.stringify({ args })
45
+ });
46
+ if (!response.ok) {
47
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
48
+ throw new Error(errorData.message || `HTTP ${response.status}`);
49
+ }
50
+ const data = await response.json();
51
+ setLoading(false);
52
+ return [data.result, void 0];
53
+ } catch (error) {
54
+ setLoading(false);
55
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
56
+ }
57
+ },
58
+ [path, apiUrl, headersEsque]
59
+ );
60
+ return { run, loading };
61
+ };
62
+
63
+ // src/resources/payment.ts
64
+ var usePayment = () => {
65
+ const ctx = usePaykitContext();
66
+ const create = useAsyncFn(
67
+ "/payment/create",
68
+ ctx.apiUrl,
69
+ ctx.headers
70
+ );
71
+ const retrieve = useAsyncFn(
72
+ "/payment/retrieve",
73
+ ctx.apiUrl,
74
+ ctx.headers
75
+ );
76
+ const update = useAsyncFn(
77
+ "/payment/update",
78
+ ctx.apiUrl,
79
+ ctx.headers
80
+ );
81
+ const remove = useAsyncFn(
82
+ "/payment/delete",
83
+ ctx.apiUrl,
84
+ ctx.headers
85
+ );
86
+ const capture = useAsyncFn(
87
+ "/payment/capture",
88
+ ctx.apiUrl,
89
+ ctx.headers
90
+ );
91
+ const cancel = useAsyncFn("/payment/cancel", ctx.apiUrl, ctx.headers);
92
+ return { create, retrieve, update, remove, capture, cancel };
93
+ };
94
+
95
+ exports.usePayment = usePayment;
@@ -0,0 +1,73 @@
1
+ import * as React from 'react';
2
+ import 'react/jsx-runtime';
3
+
4
+ // src/context.tsx
5
+ var PaykitContext = React.createContext(void 0);
6
+ var usePaykitContext = () => {
7
+ const ctx = React.useContext(PaykitContext);
8
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
9
+ return ctx;
10
+ };
11
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
12
+ const [loading, setLoading] = React.useState(false);
13
+ const run = React.useCallback(
14
+ async (...args) => {
15
+ setLoading(true);
16
+ try {
17
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
18
+ const response = await fetch(`${apiUrl}${path}`, {
19
+ method: "POST",
20
+ headers: { "Content-Type": "application/json", ...headers },
21
+ credentials: "include",
22
+ body: JSON.stringify({ args })
23
+ });
24
+ if (!response.ok) {
25
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
26
+ throw new Error(errorData.message || `HTTP ${response.status}`);
27
+ }
28
+ const data = await response.json();
29
+ setLoading(false);
30
+ return [data.result, void 0];
31
+ } catch (error) {
32
+ setLoading(false);
33
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
34
+ }
35
+ },
36
+ [path, apiUrl, headersEsque]
37
+ );
38
+ return { run, loading };
39
+ };
40
+
41
+ // src/resources/payment.ts
42
+ var usePayment = () => {
43
+ const ctx = usePaykitContext();
44
+ const create = useAsyncFn(
45
+ "/payment/create",
46
+ ctx.apiUrl,
47
+ ctx.headers
48
+ );
49
+ const retrieve = useAsyncFn(
50
+ "/payment/retrieve",
51
+ ctx.apiUrl,
52
+ ctx.headers
53
+ );
54
+ const update = useAsyncFn(
55
+ "/payment/update",
56
+ ctx.apiUrl,
57
+ ctx.headers
58
+ );
59
+ const remove = useAsyncFn(
60
+ "/payment/delete",
61
+ ctx.apiUrl,
62
+ ctx.headers
63
+ );
64
+ const capture = useAsyncFn(
65
+ "/payment/capture",
66
+ ctx.apiUrl,
67
+ ctx.headers
68
+ );
69
+ const cancel = useAsyncFn("/payment/cancel", ctx.apiUrl, ctx.headers);
70
+ return { create, retrieve, update, remove, capture, cancel };
71
+ };
72
+
73
+ export { usePayment };
@@ -0,0 +1,10 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+
3
+ declare const useRefund: () => {
4
+ create: {
5
+ run: (params: _paykit_sdk_core.CreateRefundSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Refund, error: undefined]>;
6
+ loading: boolean;
7
+ };
8
+ };
9
+
10
+ export { useRefund };
@@ -0,0 +1,10 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+
3
+ declare const useRefund: () => {
4
+ create: {
5
+ run: (params: _paykit_sdk_core.CreateRefundSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Refund, error: undefined]>;
6
+ loading: boolean;
7
+ };
8
+ };
9
+
10
+ export { useRefund };
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('react/jsx-runtime');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+
26
+ // src/context.tsx
27
+ var PaykitContext = React__namespace.createContext(void 0);
28
+ var usePaykitContext = () => {
29
+ const ctx = React__namespace.useContext(PaykitContext);
30
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
31
+ return ctx;
32
+ };
33
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
34
+ const [loading, setLoading] = React__namespace.useState(false);
35
+ const run = React__namespace.useCallback(
36
+ async (...args) => {
37
+ setLoading(true);
38
+ try {
39
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
40
+ const response = await fetch(`${apiUrl}${path}`, {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json", ...headers },
43
+ credentials: "include",
44
+ body: JSON.stringify({ args })
45
+ });
46
+ if (!response.ok) {
47
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
48
+ throw new Error(errorData.message || `HTTP ${response.status}`);
49
+ }
50
+ const data = await response.json();
51
+ setLoading(false);
52
+ return [data.result, void 0];
53
+ } catch (error) {
54
+ setLoading(false);
55
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
56
+ }
57
+ },
58
+ [path, apiUrl, headersEsque]
59
+ );
60
+ return { run, loading };
61
+ };
62
+
63
+ // src/resources/refund.ts
64
+ var useRefund = () => {
65
+ const ctx = usePaykitContext();
66
+ const create = useAsyncFn(
67
+ "/refund/create",
68
+ ctx.apiUrl,
69
+ ctx.headers
70
+ );
71
+ return { create };
72
+ };
73
+
74
+ exports.useRefund = useRefund;
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import 'react/jsx-runtime';
3
+
4
+ // src/context.tsx
5
+ var PaykitContext = React.createContext(void 0);
6
+ var usePaykitContext = () => {
7
+ const ctx = React.useContext(PaykitContext);
8
+ if (!ctx) throw new Error("Your app must be wrapped in PayKitProvider to use PayKit hooks.");
9
+ return ctx;
10
+ };
11
+ var useAsyncFn = (path, apiUrl, headersEsque) => {
12
+ const [loading, setLoading] = React.useState(false);
13
+ const run = React.useCallback(
14
+ async (...args) => {
15
+ setLoading(true);
16
+ try {
17
+ const headers = typeof headersEsque === "function" ? headersEsque() : headersEsque != null ? headersEsque : {};
18
+ const response = await fetch(`${apiUrl}${path}`, {
19
+ method: "POST",
20
+ headers: { "Content-Type": "application/json", ...headers },
21
+ credentials: "include",
22
+ body: JSON.stringify({ args })
23
+ });
24
+ if (!response.ok) {
25
+ const errorData = await response.json().catch(() => ({ message: "Request failed" }));
26
+ throw new Error(errorData.message || `HTTP ${response.status}`);
27
+ }
28
+ const data = await response.json();
29
+ setLoading(false);
30
+ return [data.result, void 0];
31
+ } catch (error) {
32
+ setLoading(false);
33
+ return [void 0, error instanceof Error ? error : new Error(String(error))];
34
+ }
35
+ },
36
+ [path, apiUrl, headersEsque]
37
+ );
38
+ return { run, loading };
39
+ };
40
+
41
+ // src/resources/refund.ts
42
+ var useRefund = () => {
43
+ const ctx = usePaykitContext();
44
+ const create = useAsyncFn(
45
+ "/refund/create",
46
+ ctx.apiUrl,
47
+ ctx.headers
48
+ );
49
+ return { create };
50
+ };
51
+
52
+ export { useRefund };
@@ -0,0 +1,26 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+
3
+ declare const useSubscription: () => {
4
+ create: {
5
+ run: (params: _paykit_sdk_core.CreateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
+ loading: boolean;
7
+ };
8
+ update: {
9
+ run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
+ loading: boolean;
11
+ };
12
+ retrieve: {
13
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
+ loading: boolean;
15
+ };
16
+ cancel: {
17
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
+ loading: boolean;
19
+ };
20
+ remove: {
21
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
22
+ loading: boolean;
23
+ };
24
+ };
25
+
26
+ export { useSubscription };
@@ -0,0 +1,26 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+
3
+ declare const useSubscription: () => {
4
+ create: {
5
+ run: (params: _paykit_sdk_core.CreateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
6
+ loading: boolean;
7
+ };
8
+ update: {
9
+ run: (id: string, params: _paykit_sdk_core.UpdateSubscriptionSchema) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
10
+ loading: boolean;
11
+ };
12
+ retrieve: {
13
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription | null, error: undefined]>;
14
+ loading: boolean;
15
+ };
16
+ cancel: {
17
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: _paykit_sdk_core.Subscription, error: undefined]>;
18
+ loading: boolean;
19
+ };
20
+ remove: {
21
+ run: (id: string) => Promise<[data: undefined, error: Error] | [data: null, error: undefined]>;
22
+ loading: boolean;
23
+ };
24
+ };
25
+
26
+ export { useSubscription };