@rozoai/intent-pay 0.0.36 → 0.0.37-beta.2

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.
Files changed (63) hide show
  1. package/build/constants/rozoConfig.d.ts +2 -11
  2. package/build/hooks/useDaimoPay.d.ts +3 -1
  3. package/build/hooks/usePaymentState.d.ts +5 -4
  4. package/build/hooks/useSolanaDestination.d.ts +0 -1
  5. package/build/hooks/useSolanaPaymentOptions.d.ts +3 -1
  6. package/build/hooks/useStellarDestination.d.ts +0 -1
  7. package/build/hooks/useStellarPaymentOptions.d.ts +3 -1
  8. package/build/package.json.js +2 -2
  9. package/build/src/components/Common/PaymentBreakdown/index.js +2 -2
  10. package/build/src/components/Common/PaymentBreakdown/index.js.map +1 -1
  11. package/build/src/components/Pages/Confirmation/index.js +4 -4
  12. package/build/src/components/Pages/Confirmation/index.js.map +1 -1
  13. package/build/src/components/Pages/Error/index.js +104 -12
  14. package/build/src/components/Pages/Error/index.js.map +1 -1
  15. package/build/src/components/Pages/PayWithToken/index.js +10 -4
  16. package/build/src/components/Pages/PayWithToken/index.js.map +1 -1
  17. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +17 -9
  18. package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +1 -1
  19. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +13 -5
  20. package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
  21. package/build/src/components/Pages/WaitingDepositAddress/index.js +8 -36
  22. package/build/src/components/Pages/WaitingDepositAddress/index.js.map +1 -1
  23. package/build/src/constants/rozoConfig.js +5 -13
  24. package/build/src/constants/rozoConfig.js.map +1 -1
  25. package/build/src/hooks/useDaimoPay.js +5 -2
  26. package/build/src/hooks/useDaimoPay.js.map +1 -1
  27. package/build/src/hooks/usePaymentState.js +24 -31
  28. package/build/src/hooks/usePaymentState.js.map +1 -1
  29. package/build/src/hooks/useSolanaDestination.js +13 -3
  30. package/build/src/hooks/useSolanaDestination.js.map +1 -1
  31. package/build/src/hooks/useSolanaPaymentOptions.js +7 -3
  32. package/build/src/hooks/useSolanaPaymentOptions.js.map +1 -1
  33. package/build/src/hooks/useStellarDestination.js +0 -1
  34. package/build/src/hooks/useStellarDestination.js.map +1 -1
  35. package/build/src/hooks/useStellarPaymentOptions.js +10 -15
  36. package/build/src/hooks/useStellarPaymentOptions.js.map +1 -1
  37. package/build/src/hooks/useWalletPaymentOptions.js +3 -2
  38. package/build/src/hooks/useWalletPaymentOptions.js.map +1 -1
  39. package/build/src/index.js +1 -0
  40. package/build/src/index.js.map +1 -1
  41. package/build/src/payment/paymentEffects.js +43 -27
  42. package/build/src/payment/paymentEffects.js.map +1 -1
  43. package/build/src/provider/StellarContextProvider.js +3 -2
  44. package/build/src/provider/StellarContextProvider.js.map +1 -1
  45. package/build/src/utils/errorParser.js +72 -0
  46. package/build/src/utils/errorParser.js.map +1 -0
  47. package/build/src/utils/exports.js +1 -0
  48. package/build/src/utils/exports.js.map +1 -1
  49. package/build/src/utils/format.js +24 -1
  50. package/build/src/utils/format.js.map +1 -1
  51. package/build/utils/errorParser.d.ts +24 -0
  52. package/build/utils/exports.d.ts +1 -0
  53. package/package.json +2 -2
  54. package/build/src/utils/api/base.js +0 -117
  55. package/build/src/utils/api/base.js.map +0 -1
  56. package/build/src/utils/api/payment.js +0 -40
  57. package/build/src/utils/api/payment.js.map +0 -1
  58. package/build/src/utils/bridge.js +0 -199
  59. package/build/src/utils/bridge.js.map +0 -1
  60. package/build/utils/api/base.d.ts +0 -76
  61. package/build/utils/api/index.d.ts +0 -5
  62. package/build/utils/api/payment.d.ts +0 -170
  63. package/build/utils/bridge.d.ts +0 -43
@@ -1,76 +0,0 @@
1
- export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
2
- export interface RequestOptions {
3
- method?: HttpMethod;
4
- headers?: Record<string, string>;
5
- body?: any;
6
- params?: Record<string, string>;
7
- signal?: AbortSignal;
8
- }
9
- export interface ApiResponse<T = any> {
10
- data: T | null;
11
- error: Error | null;
12
- status: number | null;
13
- }
14
- export interface RequestState<T = any> extends ApiResponse<T> {
15
- isLoading: boolean;
16
- isError: boolean;
17
- isSuccess: boolean;
18
- }
19
- /**
20
- * Core fetch function for making API requests
21
- * @param url - API endpoint path
22
- * @param options - Request options
23
- * @returns Promise with response data
24
- */
25
- export declare const fetchApi: <T = any>(url: string, options?: RequestOptions) => Promise<ApiResponse<T>>;
26
- /**
27
- * API client with methods for different HTTP verbs
28
- */
29
- export declare const apiClient: {
30
- /**
31
- * GET request
32
- * @param url - API endpoint path
33
- * @param options - Request options
34
- * @returns Promise with response data
35
- */
36
- get: <T = any>(url: string, options?: Omit<RequestOptions, "method" | "body">) => Promise<ApiResponse<T>>;
37
- /**
38
- * POST request
39
- * @param url - API endpoint path
40
- * @param body - Request body
41
- * @param options - Additional request options
42
- * @returns Promise with response data
43
- */
44
- post: <T = any>(url: string, body: any, options?: Omit<RequestOptions, "method" | "body">) => Promise<ApiResponse<T>>;
45
- /**
46
- * PUT request
47
- * @param url - API endpoint path
48
- * @param body - Request body
49
- * @param options - Additional request options
50
- * @returns Promise with response data
51
- */
52
- put: <T = any>(url: string, body: any, options?: Omit<RequestOptions, "method" | "body">) => Promise<ApiResponse<T>>;
53
- /**
54
- * PATCH request
55
- * @param url - API endpoint path
56
- * @param body - Request body
57
- * @param options - Additional request options
58
- * @returns Promise with response data
59
- */
60
- patch: <T = any>(url: string, body: any, options?: Omit<RequestOptions, "method" | "body">) => Promise<ApiResponse<T>>;
61
- /**
62
- * DELETE request
63
- * @param url - API endpoint path
64
- * @param options - Request options
65
- * @returns Promise with response data
66
- */
67
- delete: <T = any>(url: string, options?: Omit<RequestOptions, "method">) => Promise<ApiResponse<T>>;
68
- };
69
- /**
70
- * React hook for making API requests
71
- * @param url - API endpoint path
72
- * @param options - Request options
73
- * @param dependencies - Dependencies array to trigger request
74
- * @returns Request state and refetch function
75
- */
76
- export declare const useApiRequest: <T = any>(url: string, options?: RequestOptions, dependencies?: any[]) => [RequestState<T>, (newOptions?: RequestOptions) => Promise<void>];
@@ -1,5 +0,0 @@
1
- /**
2
- * API endpoints index file
3
- * Re-exports all API endpoints for easy importing
4
- */
5
- export * from './payment';
@@ -1,170 +0,0 @@
1
- import { ApiResponse, RequestState } from "./base";
2
- /**
3
- * Payment display information
4
- */
5
- export interface PaymentDisplay {
6
- intent: string;
7
- paymentValue: string;
8
- currency: string;
9
- }
10
- /**
11
- * Payment destination information
12
- */
13
- export interface PaymentDestination {
14
- destinationAddress?: string;
15
- chainId: string;
16
- amountUnits: string;
17
- tokenSymbol: string;
18
- tokenAddress?: string;
19
- txHash?: string | null;
20
- }
21
- /**
22
- * Payment source information
23
- */
24
- export interface PaymentSource {
25
- sourceAddress?: string;
26
- [key: string]: unknown;
27
- }
28
- /**
29
- * Payment request data type
30
- */
31
- export interface PaymentRequestData {
32
- appId: string;
33
- display: PaymentDisplay;
34
- destination: PaymentDestination;
35
- externalId?: string;
36
- metadata?: Record<string, unknown>;
37
- [key: string]: unknown;
38
- }
39
- /**
40
- * Payment response data type
41
- */
42
- export interface PaymentResponseData {
43
- id: string;
44
- status: "payment_unpaid" | string;
45
- createdAt: string;
46
- display: {
47
- intent: string;
48
- currency: string;
49
- paymentValue?: string;
50
- };
51
- source: PaymentSource | null;
52
- destination: {
53
- destinationAddress: string;
54
- txHash: string | null;
55
- chainId: string;
56
- amountUnits: string;
57
- tokenSymbol: string;
58
- tokenAddress: string;
59
- };
60
- metadata: {
61
- daimoOrderId?: string;
62
- intent: string;
63
- items: unknown[];
64
- payer: Record<string, unknown>;
65
- appId: string;
66
- orderDate: string;
67
- webhookUrl: string;
68
- provider: string;
69
- receivingAddress: string;
70
- memo: string | null;
71
- payinchainid: string;
72
- payintokenaddress: string;
73
- preferredChain: string;
74
- preferredToken: string;
75
- preferredTokenAddress: string;
76
- [key: string]: unknown;
77
- };
78
- url: string;
79
- [key: string]: unknown;
80
- }
81
- /**
82
- * Creates a new payment
83
- * @param paymentData - Payment data to send
84
- * @returns Promise with payment response
85
- */
86
- export declare const createRozoPayment: (paymentData: PaymentRequestData) => Promise<ApiResponse<PaymentResponseData>>;
87
- /**
88
- * Gets payment details by ID
89
- * @param paymentId - Payment ID
90
- * @returns Promise with payment response
91
- */
92
- export declare const getRozoPayment: (paymentId: string) => Promise<ApiResponse<PaymentResponseData>>;
93
- /**
94
- * Gets payment details by external ID
95
- * @param externalId - External payment ID
96
- * @returns Promise with payment response
97
- */
98
- export declare const getRozoPaymentByExternalId: (externalId: string) => Promise<ApiResponse<PaymentResponseData>>;
99
- /**
100
- * Updates an existing payment
101
- * @param paymentId - Payment ID
102
- * @param paymentData - Updated payment data
103
- * @returns Promise with payment response
104
- */
105
- export declare const updateRozoPayment: (paymentId: string, paymentData: Partial<PaymentRequestData>) => Promise<ApiResponse<PaymentResponseData>>;
106
- /**
107
- * Cancels a payment
108
- * @param paymentId - Payment ID
109
- * @returns Promise with payment response
110
- */
111
- export declare const cancelRozoPayment: (paymentId: string) => Promise<ApiResponse<PaymentResponseData>>;
112
- /**
113
- * Lists all payments with optional filtering
114
- * @param params - Query parameters for filtering
115
- * @returns Promise with payment list response
116
- */
117
- export declare const listRozoPayments: (params?: Record<string, string>) => Promise<ApiResponse<PaymentResponseData[]>>;
118
- /**
119
- * React hook for creating a payment
120
- * @param paymentData - Payment data to send
121
- * @param autoSubmit - Whether to submit automatically
122
- * @returns Request state and submit function
123
- */
124
- export declare const useCreateRozoPayment: (paymentData?: PaymentRequestData, autoSubmit?: boolean) => [RequestState<PaymentResponseData>, (data: PaymentRequestData) => Promise<ApiResponse<PaymentResponseData>>];
125
- /**
126
- * React hook for fetching payment details
127
- * @param paymentId - Payment ID
128
- * @param enabled - Whether to enable the fetch
129
- * @returns Request state and refetch function
130
- */
131
- export declare const useRozoPayment: (paymentId: string, enabled?: boolean) => [RequestState<PaymentResponseData>, () => Promise<ApiResponse<PaymentResponseData> | void>];
132
- /**
133
- * React hook for fetching payment details by external ID
134
- * @param externalId - External payment ID
135
- * @param enabled - Whether to enable the fetch
136
- * @returns Request state and refetch function
137
- */
138
- export declare const useRozoPaymentByExternalId: (externalId: string, enabled?: boolean) => [RequestState<PaymentResponseData>, () => Promise<ApiResponse<PaymentResponseData> | void>];
139
- /**
140
- * React hook for listing payments
141
- * @param params - Query parameters for filtering
142
- * @param enabled - Whether to enable the fetch
143
- * @returns Request state and refetch function
144
- */
145
- export declare const useRozoPayments: (params?: Record<string, string>, enabled?: boolean) => [RequestState<PaymentResponseData[]>, () => Promise<ApiResponse<PaymentResponseData[]> | void>];
146
- /**
147
- * Creates a payment request payload
148
- * @param options Payment options
149
- * @returns Payment request data
150
- */
151
- export declare const createRozoPaymentRequest: (options: {
152
- display: {
153
- intent: string;
154
- paymentValue: string;
155
- currency: string;
156
- };
157
- preferredChain?: string;
158
- preferredToken?: string;
159
- preferredTokenAddress?: string;
160
- destination: {
161
- destinationAddress?: string;
162
- chainId: string;
163
- amountUnits: string;
164
- tokenSymbol: string;
165
- tokenAddress?: string;
166
- };
167
- externalId?: string;
168
- metadata?: Record<string, unknown>;
169
- appId: string;
170
- }) => PaymentRequestData;
@@ -1,43 +0,0 @@
1
- import { RozoPayHydratedOrderWithOrg, WalletPaymentOption } from "@rozoai/intent-common";
2
- import { PaymentResponseData } from "./api";
3
- export interface PaymentBridgeConfig {
4
- toChain?: number;
5
- toToken?: string;
6
- toAddress?: string;
7
- toStellarAddress?: string;
8
- toSolanaAddress?: string;
9
- toUnits: string;
10
- walletPaymentOption?: WalletPaymentOption;
11
- log: (msg: string) => void;
12
- }
13
- export interface PreferredPaymentConfig {
14
- preferredChain: string;
15
- preferredToken: "USDC" | "USDT" | "XLM";
16
- preferredTokenAddress?: string;
17
- }
18
- export interface DestinationConfig {
19
- destinationAddress?: string;
20
- chainId: string;
21
- amountUnits: string;
22
- tokenSymbol: string;
23
- tokenAddress: string;
24
- }
25
- /**
26
- * Bridge helper for determining payment routing based on destination chain/token
27
- * and selected wallet payment option.
28
- *
29
- * This helper centralizes the logic for:
30
- * - Determining preferred payment chain/token based on wallet selection
31
- * - Setting up destination configuration for cross-chain payments
32
- * - Handling special cases for Stellar and Solana addresses
33
- */
34
- export declare function createPaymentBridgeConfig({ toChain, toToken, toAddress, toStellarAddress, toSolanaAddress, toUnits, walletPaymentOption, log, }: PaymentBridgeConfig): {
35
- preferred: PreferredPaymentConfig;
36
- destination: DestinationConfig;
37
- };
38
- /**
39
- * Format a payment response data to a hydrated order
40
- * @param order
41
- * @returns
42
- */
43
- export declare function formatPaymentResponseDataToHydratedOrder(order: PaymentResponseData): RozoPayHydratedOrderWithOrg;