@rozoai/intent-common 0.1.5 → 0.1.6-beta.1
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/api/fee.d.ts +1 -1
- package/dist/api/fee.js +2 -2
- package/dist/api/fee.js.map +1 -1
- package/dist/api/payment.d.ts +31 -288
- package/dist/api/payment.js +63 -41
- package/dist/api/payment.js.map +1 -1
- package/dist/api/types.d.ts +289 -0
- package/dist/api/types.js +43 -0
- package/dist/api/types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/rozoPay.d.ts +6 -6
- package/package.json +1 -1
package/dist/api/fee.d.ts
CHANGED
package/dist/api/fee.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFee = void 0;
|
|
4
4
|
const chain_1 = require("../chain");
|
|
5
|
-
const
|
|
5
|
+
const types_1 = require("./types");
|
|
6
6
|
/**
|
|
7
7
|
* Gets fee calculation for a payment amount
|
|
8
8
|
* @param params - Fee calculation parameters (amount is required)
|
|
@@ -15,7 +15,7 @@ const getFee = async (params) => {
|
|
|
15
15
|
const toChainName = chain.name.toLowerCase();
|
|
16
16
|
const queryParams = new URLSearchParams({
|
|
17
17
|
...(appId ? { appId } : {}),
|
|
18
|
-
...(type ===
|
|
18
|
+
...(type === types_1.FeeType.ExactIn
|
|
19
19
|
? { type: "exactIn" }
|
|
20
20
|
: { type: "exactOut" }),
|
|
21
21
|
amount: toUnits,
|
package/dist/api/fee.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee.js","sourceRoot":"","sources":["../../src/api/fee.ts"],"names":[],"mappings":";;;AAAA,oCAAwC;AAExC,
|
|
1
|
+
{"version":3,"file":"fee.js","sourceRoot":"","sources":["../../src/api/fee.ts"],"names":[],"mappings":";;;AAAA,oCAAwC;AAExC,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uB;YAC7B,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChE,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AA/CW,QAAA,MAAM,UA+CjB"}
|
package/dist/api/payment.d.ts
CHANGED
|
@@ -1,292 +1,5 @@
|
|
|
1
1
|
import { ApiResponse, ApiVersion } from "./base";
|
|
2
|
-
|
|
3
|
-
* FeeType, Fee calculation type:
|
|
4
|
-
* - exactIn (default): Fee deducted from input, recipient receives amount - fee
|
|
5
|
-
* - exactOut: Fee added to input, recipient receives exact amount
|
|
6
|
-
*/
|
|
7
|
-
export declare enum FeeType {
|
|
8
|
-
ExactIn = "exactIn",
|
|
9
|
-
ExactOut = "exactOut"
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* PaymentStatus, Payment status
|
|
13
|
-
*/
|
|
14
|
-
export declare enum PaymentStatus {
|
|
15
|
-
PaymentBounced = "payment_bounced",
|
|
16
|
-
PaymentCompleted = "payment_completed",
|
|
17
|
-
PaymentExpired = "payment_expired",
|
|
18
|
-
PaymentPayinCompleted = "payment_payin_completed",
|
|
19
|
-
PaymentPayoutCompleted = "payment_payout_completed",
|
|
20
|
-
PaymentRefunded = "payment_refunded",
|
|
21
|
-
PaymentStarted = "payment_started",
|
|
22
|
-
PaymentUnpaid = "payment_unpaid"
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* PaymentErrorCode, Error code (only present when status is payment_bounced)
|
|
26
|
-
*/
|
|
27
|
-
export declare enum PaymentErrorCode {
|
|
28
|
-
AmountTooHigh = "amountTooHigh",
|
|
29
|
-
AmountTooLow = "amountTooLow",
|
|
30
|
-
ChainUnavailable = "chainUnavailable",
|
|
31
|
-
InsufficientLiquidity = "insufficientLiquidity",
|
|
32
|
-
InvalidRecipient = "invalidRecipient",
|
|
33
|
-
MissingTrustline = "missingTrustline",
|
|
34
|
-
NetworkError = "networkError",
|
|
35
|
-
ProviderError = "providerError",
|
|
36
|
-
ServiceMaintenance = "serviceMaintenance"
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* DestinationRequest
|
|
40
|
-
*/
|
|
41
|
-
export interface DestinationRequest {
|
|
42
|
-
/**
|
|
43
|
-
* Receive amount (required for type=exactOut).
|
|
44
|
-
* For exactIn, this field is omitted in request and calculated in response.
|
|
45
|
-
*/
|
|
46
|
-
amount?: string;
|
|
47
|
-
chainId: number;
|
|
48
|
-
/**
|
|
49
|
-
* Final recipient's wallet address
|
|
50
|
-
*/
|
|
51
|
-
receiverAddress: string;
|
|
52
|
-
/**
|
|
53
|
-
* Memo for Stellar/Solana destinations
|
|
54
|
-
*/
|
|
55
|
-
receiverMemo?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Override default token address
|
|
58
|
-
*/
|
|
59
|
-
tokenAddress?: string;
|
|
60
|
-
tokenSymbol: string;
|
|
61
|
-
[property: string]: any;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* DisplayInfo
|
|
65
|
-
*/
|
|
66
|
-
export interface DisplayInfo {
|
|
67
|
-
/**
|
|
68
|
-
* Display currency
|
|
69
|
-
*/
|
|
70
|
-
currency: string;
|
|
71
|
-
/**
|
|
72
|
-
* Detailed description
|
|
73
|
-
*/
|
|
74
|
-
description?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Short title
|
|
77
|
-
*/
|
|
78
|
-
title: string;
|
|
79
|
-
[property: string]: any;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* SourceRequest
|
|
83
|
-
*/
|
|
84
|
-
export interface SourceRequest {
|
|
85
|
-
/**
|
|
86
|
-
* Pay-in amount (required for type=exactIn).
|
|
87
|
-
* For exactOut, this field is omitted in request and calculated in response.
|
|
88
|
-
*/
|
|
89
|
-
amount?: string;
|
|
90
|
-
chainId: number;
|
|
91
|
-
/**
|
|
92
|
-
* Override default token address
|
|
93
|
-
*/
|
|
94
|
-
tokenAddress?: string;
|
|
95
|
-
tokenSymbol: string;
|
|
96
|
-
[property: string]: any;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* PaymentRequest
|
|
100
|
-
*/
|
|
101
|
-
export interface CreatePaymentRequest {
|
|
102
|
-
/**
|
|
103
|
-
* Your application ID
|
|
104
|
-
*/
|
|
105
|
-
appId: string;
|
|
106
|
-
destination: DestinationRequest;
|
|
107
|
-
display: DisplayInfo;
|
|
108
|
-
/**
|
|
109
|
-
* Custom metadata (max 4 KB recommended)
|
|
110
|
-
*/
|
|
111
|
-
metadata?: {
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Your order reference ID (for idempotency)
|
|
116
|
-
*/
|
|
117
|
-
orderId?: string;
|
|
118
|
-
source: SourceRequest;
|
|
119
|
-
type?: FeeType;
|
|
120
|
-
/**
|
|
121
|
-
* Secret for HMAC-SHA256 signature verification.
|
|
122
|
-
* If not provided, a unique secret is auto-generated.
|
|
123
|
-
* The secret is returned in the response for you to store and use for verification.
|
|
124
|
-
*/
|
|
125
|
-
webhookSecret?: string;
|
|
126
|
-
/**
|
|
127
|
-
* URL to receive payment status updates
|
|
128
|
-
*/
|
|
129
|
-
webhookUrl?: string;
|
|
130
|
-
[property: string]: any;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* DestinationResponse
|
|
134
|
-
*/
|
|
135
|
-
export interface DestinationResponse {
|
|
136
|
-
/**
|
|
137
|
-
* Amount to be sent to recipient
|
|
138
|
-
*/
|
|
139
|
-
amount?: string;
|
|
140
|
-
chainId?: number;
|
|
141
|
-
/**
|
|
142
|
-
* Withdrawal confirmation time
|
|
143
|
-
*/
|
|
144
|
-
confirmedAt?: Date;
|
|
145
|
-
/**
|
|
146
|
-
* Final recipient's wallet
|
|
147
|
-
*/
|
|
148
|
-
receiverAddress?: string;
|
|
149
|
-
/**
|
|
150
|
-
* Memo for Stellar/Solana
|
|
151
|
-
*/
|
|
152
|
-
receiverMemo?: string;
|
|
153
|
-
/**
|
|
154
|
-
* Token contract address
|
|
155
|
-
*/
|
|
156
|
-
tokenAddress?: string;
|
|
157
|
-
tokenSymbol?: string;
|
|
158
|
-
/**
|
|
159
|
-
* Withdrawal transaction hash
|
|
160
|
-
*/
|
|
161
|
-
txHash?: string;
|
|
162
|
-
[property: string]: any;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* SourceResponse
|
|
166
|
-
*/
|
|
167
|
-
export interface SourceResponse {
|
|
168
|
-
/**
|
|
169
|
-
* Amount payer must send
|
|
170
|
-
*/
|
|
171
|
-
amount?: string;
|
|
172
|
-
/**
|
|
173
|
-
* Actual amount received
|
|
174
|
-
*/
|
|
175
|
-
amountReceived?: string;
|
|
176
|
-
chainId?: number;
|
|
177
|
-
/**
|
|
178
|
-
* Deposit confirmation time
|
|
179
|
-
*/
|
|
180
|
-
confirmedAt?: Date;
|
|
181
|
-
/**
|
|
182
|
-
* Fee amount
|
|
183
|
-
*/
|
|
184
|
-
fee?: string;
|
|
185
|
-
/**
|
|
186
|
-
* Deposit address (where payer sends funds)
|
|
187
|
-
*/
|
|
188
|
-
receiverAddress?: string;
|
|
189
|
-
/**
|
|
190
|
-
* Memo for Stellar/Solana deposits
|
|
191
|
-
*/
|
|
192
|
-
receiverMemo?: string;
|
|
193
|
-
/**
|
|
194
|
-
* Payer's wallet address (populated after deposit)
|
|
195
|
-
*/
|
|
196
|
-
senderAddress?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Token contract address
|
|
199
|
-
*/
|
|
200
|
-
tokenAddress?: string;
|
|
201
|
-
tokenSymbol?: string;
|
|
202
|
-
/**
|
|
203
|
-
* Deposit transaction hash
|
|
204
|
-
*/
|
|
205
|
-
txHash?: string;
|
|
206
|
-
[property: string]: any;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* PaymentResponse
|
|
210
|
-
*/
|
|
211
|
-
export interface PaymentResponse {
|
|
212
|
-
/**
|
|
213
|
-
* Your application ID
|
|
214
|
-
*/
|
|
215
|
-
appId: string;
|
|
216
|
-
/**
|
|
217
|
-
* ISO 8601 timestamp
|
|
218
|
-
*/
|
|
219
|
-
createdAt: Date;
|
|
220
|
-
destination: DestinationResponse;
|
|
221
|
-
display: DisplayInfo;
|
|
222
|
-
errorCode: PaymentErrorCode | null;
|
|
223
|
-
/**
|
|
224
|
-
* ISO 8601 timestamp (when payment expires)
|
|
225
|
-
*/
|
|
226
|
-
expiresAt: Date;
|
|
227
|
-
/**
|
|
228
|
-
* Payment ID
|
|
229
|
-
*/
|
|
230
|
-
id: string;
|
|
231
|
-
metadata: {
|
|
232
|
-
[key: string]: any;
|
|
233
|
-
} | null;
|
|
234
|
-
/**
|
|
235
|
-
* Your order reference ID
|
|
236
|
-
*/
|
|
237
|
-
orderId: string | null;
|
|
238
|
-
source: SourceResponse;
|
|
239
|
-
status: PaymentStatus;
|
|
240
|
-
type: FeeType;
|
|
241
|
-
/**
|
|
242
|
-
* ISO 8601 timestamp
|
|
243
|
-
*/
|
|
244
|
-
updatedAt: Date;
|
|
245
|
-
/**
|
|
246
|
-
* Secret for webhook signature verification.
|
|
247
|
-
* Only present when webhookUrl was provided in the request.
|
|
248
|
-
* Store this securely to verify incoming webhook signatures.
|
|
249
|
-
*/
|
|
250
|
-
webhookSecret: string | null;
|
|
251
|
-
[property: string]: any;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Parameters for creating a new payment using the new backend interface
|
|
255
|
-
*/
|
|
256
|
-
export interface CreateNewPaymentParams {
|
|
257
|
-
/** App ID for authentication */
|
|
258
|
-
appId: string;
|
|
259
|
-
/** Destination chain ID (e.g., 8453 for Base, 900 for Solana, 1500 for Stellar) */
|
|
260
|
-
toChain: number;
|
|
261
|
-
/** Destination token address */
|
|
262
|
-
toToken: string;
|
|
263
|
-
/** Destination address - Can be EVM, Solana, or Stellar address */
|
|
264
|
-
toAddress: string;
|
|
265
|
-
/** Chain ID where user will pay from (e.g., 137 for Polygon, 8453 for Base) */
|
|
266
|
-
preferredChain: number;
|
|
267
|
-
/** Token address user will pay with */
|
|
268
|
-
preferredTokenAddress: string;
|
|
269
|
-
/** Amount in human-readable units (e.g., "1" for 1 USDC, "0.5" for half a USDC) */
|
|
270
|
-
toUnits?: string;
|
|
271
|
-
/** Additional metadata to include */
|
|
272
|
-
metadata?: Record<string, unknown>;
|
|
273
|
-
/** Display title for the payment */
|
|
274
|
-
title?: string;
|
|
275
|
-
/** Display description for the payment */
|
|
276
|
-
description?: string;
|
|
277
|
-
/** Order reference ID (for idempotency) */
|
|
278
|
-
orderId?: string;
|
|
279
|
-
/** Fee calculation type (exactIn or exactOut) */
|
|
280
|
-
feeType?: FeeType;
|
|
281
|
-
/** Webhook URL to receive payment status updates */
|
|
282
|
-
webhookUrl?: string;
|
|
283
|
-
/** Secret for HMAC-SHA256 signature verification */
|
|
284
|
-
webhookSecret?: string;
|
|
285
|
-
/** Memo for Stellar/Solana destinations */
|
|
286
|
-
receiverMemo?: string;
|
|
287
|
-
/** API version to use (v2 or v4). Defaults to v4 */
|
|
288
|
-
apiVersion?: ApiVersion;
|
|
289
|
-
}
|
|
2
|
+
import { CreateNewPaymentParams, PaymentResponse } from "./types";
|
|
290
3
|
/**
|
|
291
4
|
* Creates a payment using the new backend interface
|
|
292
5
|
*
|
|
@@ -320,3 +33,33 @@ export declare function createPayment(params: CreateNewPaymentParams): Promise<P
|
|
|
320
33
|
* @returns Promise with payment response
|
|
321
34
|
*/
|
|
322
35
|
export declare const getPayment: (paymentId: string, apiVersion?: ApiVersion) => Promise<ApiResponse<PaymentResponse>>;
|
|
36
|
+
/**
|
|
37
|
+
* Updates the Pay In TxHash for a payment.
|
|
38
|
+
*
|
|
39
|
+
* Only available on v2 (not supported on v1).
|
|
40
|
+
*
|
|
41
|
+
* @param paymentId - The payment ID to update (e.g., "pay_abc123")
|
|
42
|
+
* @param txHash - The transaction hash to associate with the payment
|
|
43
|
+
* @param apiVersion - Optional API version ("v2" or "v4"), defaults to "v4" if not specified
|
|
44
|
+
* @returns Promise with updated payment response
|
|
45
|
+
*
|
|
46
|
+
* Example usage:
|
|
47
|
+
* await updatePaymentPayInTxHash("pay_abc123", "0x1234567890abcdef...");
|
|
48
|
+
*/
|
|
49
|
+
export declare const updatePaymentPayInTxHash: (paymentId: string, txHash: string, apiVersion?: ApiVersion) => Promise<ApiResponse<PaymentResponse>>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates the contact email associated with a payment.
|
|
52
|
+
*
|
|
53
|
+
* Allows an admin or integrator to associate or update the email for a given payment so support staff can contact the user.
|
|
54
|
+
*
|
|
55
|
+
* Only available on v2/v4 API (not v1).
|
|
56
|
+
*
|
|
57
|
+
* @param paymentId - The payment ID to update (e.g., "pay_abc123")
|
|
58
|
+
* @param email - The contact email to associate with the payment
|
|
59
|
+
* @param apiVersion - Optional API version ("v2" or "v4"), defaults to "v4" if not specified
|
|
60
|
+
* @returns Promise with updated payment response
|
|
61
|
+
*
|
|
62
|
+
* Example usage:
|
|
63
|
+
* await updatePaymentEmail("pay_abc123", "user@example.com")
|
|
64
|
+
*/
|
|
65
|
+
export declare const updatePaymentEmail: (paymentId: string, email: string, apiVersion?: ApiVersion) => Promise<ApiResponse<PaymentResponse>>;
|
package/dist/api/payment.js
CHANGED
|
@@ -1,50 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updatePaymentEmail = exports.updatePaymentPayInTxHash = exports.getPayment = void 0;
|
|
4
4
|
exports.createPayment = createPayment;
|
|
5
5
|
const bridge_utils_1 = require("../bridge-utils");
|
|
6
6
|
const chain_1 = require("../chain");
|
|
7
7
|
const token_1 = require("../token");
|
|
8
8
|
const base_1 = require("./base");
|
|
9
|
-
|
|
10
|
-
* FeeType, Fee calculation type:
|
|
11
|
-
* - exactIn (default): Fee deducted from input, recipient receives amount - fee
|
|
12
|
-
* - exactOut: Fee added to input, recipient receives exact amount
|
|
13
|
-
*/
|
|
14
|
-
var FeeType;
|
|
15
|
-
(function (FeeType) {
|
|
16
|
-
FeeType["ExactIn"] = "exactIn";
|
|
17
|
-
FeeType["ExactOut"] = "exactOut";
|
|
18
|
-
})(FeeType || (exports.FeeType = FeeType = {}));
|
|
19
|
-
/**
|
|
20
|
-
* PaymentStatus, Payment status
|
|
21
|
-
*/
|
|
22
|
-
var PaymentStatus;
|
|
23
|
-
(function (PaymentStatus) {
|
|
24
|
-
PaymentStatus["PaymentBounced"] = "payment_bounced";
|
|
25
|
-
PaymentStatus["PaymentCompleted"] = "payment_completed";
|
|
26
|
-
PaymentStatus["PaymentExpired"] = "payment_expired";
|
|
27
|
-
PaymentStatus["PaymentPayinCompleted"] = "payment_payin_completed";
|
|
28
|
-
PaymentStatus["PaymentPayoutCompleted"] = "payment_payout_completed";
|
|
29
|
-
PaymentStatus["PaymentRefunded"] = "payment_refunded";
|
|
30
|
-
PaymentStatus["PaymentStarted"] = "payment_started";
|
|
31
|
-
PaymentStatus["PaymentUnpaid"] = "payment_unpaid";
|
|
32
|
-
})(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
|
|
33
|
-
/**
|
|
34
|
-
* PaymentErrorCode, Error code (only present when status is payment_bounced)
|
|
35
|
-
*/
|
|
36
|
-
var PaymentErrorCode;
|
|
37
|
-
(function (PaymentErrorCode) {
|
|
38
|
-
PaymentErrorCode["AmountTooHigh"] = "amountTooHigh";
|
|
39
|
-
PaymentErrorCode["AmountTooLow"] = "amountTooLow";
|
|
40
|
-
PaymentErrorCode["ChainUnavailable"] = "chainUnavailable";
|
|
41
|
-
PaymentErrorCode["InsufficientLiquidity"] = "insufficientLiquidity";
|
|
42
|
-
PaymentErrorCode["InvalidRecipient"] = "invalidRecipient";
|
|
43
|
-
PaymentErrorCode["MissingTrustline"] = "missingTrustline";
|
|
44
|
-
PaymentErrorCode["NetworkError"] = "networkError";
|
|
45
|
-
PaymentErrorCode["ProviderError"] = "providerError";
|
|
46
|
-
PaymentErrorCode["ServiceMaintenance"] = "serviceMaintenance";
|
|
47
|
-
})(PaymentErrorCode || (exports.PaymentErrorCode = PaymentErrorCode = {}));
|
|
9
|
+
const types_1 = require("./types");
|
|
48
10
|
/**
|
|
49
11
|
* Creates a payment using the new backend interface
|
|
50
12
|
*
|
|
@@ -97,7 +59,7 @@ async function createPayment(params) {
|
|
|
97
59
|
// Build payment request data matching new backend interface
|
|
98
60
|
const paymentData = {
|
|
99
61
|
appId,
|
|
100
|
-
type: feeType ?? FeeType.ExactIn,
|
|
62
|
+
type: feeType ?? types_1.FeeType.ExactIn,
|
|
101
63
|
...(orderId ? { orderId } : {}),
|
|
102
64
|
source: {
|
|
103
65
|
chainId: sourceChain.chainId,
|
|
@@ -165,4 +127,64 @@ const getPayment = (paymentId, apiVersion) => {
|
|
|
165
127
|
return base_1.apiClient.get(`/payment-api/payments/${paymentId}`);
|
|
166
128
|
};
|
|
167
129
|
exports.getPayment = getPayment;
|
|
130
|
+
/**
|
|
131
|
+
* Updates the Pay In TxHash for a payment.
|
|
132
|
+
*
|
|
133
|
+
* Only available on v2 (not supported on v1).
|
|
134
|
+
*
|
|
135
|
+
* @param paymentId - The payment ID to update (e.g., "pay_abc123")
|
|
136
|
+
* @param txHash - The transaction hash to associate with the payment
|
|
137
|
+
* @param apiVersion - Optional API version ("v2" or "v4"), defaults to "v4" if not specified
|
|
138
|
+
* @returns Promise with updated payment response
|
|
139
|
+
*
|
|
140
|
+
* Example usage:
|
|
141
|
+
* await updatePaymentPayInTxHash("pay_abc123", "0x1234567890abcdef...");
|
|
142
|
+
*/
|
|
143
|
+
const updatePaymentPayInTxHash = async (paymentId, txHash, apiVersion) => {
|
|
144
|
+
// Set API version if provided
|
|
145
|
+
if (apiVersion) {
|
|
146
|
+
(0, base_1.setApiConfig)({ version: apiVersion });
|
|
147
|
+
}
|
|
148
|
+
// Only support v2/v4 (not v1)
|
|
149
|
+
if (apiVersion === "v1") {
|
|
150
|
+
throw new Error("updatePaymentPayInTxHash is only available on API version v2 or later.");
|
|
151
|
+
}
|
|
152
|
+
const endpoint = `/payment-api/payments/${paymentId}/payin`;
|
|
153
|
+
const payload = {
|
|
154
|
+
txHash,
|
|
155
|
+
};
|
|
156
|
+
return base_1.apiClient.post(endpoint, payload);
|
|
157
|
+
};
|
|
158
|
+
exports.updatePaymentPayInTxHash = updatePaymentPayInTxHash;
|
|
159
|
+
/**
|
|
160
|
+
* Updates the contact email associated with a payment.
|
|
161
|
+
*
|
|
162
|
+
* Allows an admin or integrator to associate or update the email for a given payment so support staff can contact the user.
|
|
163
|
+
*
|
|
164
|
+
* Only available on v2/v4 API (not v1).
|
|
165
|
+
*
|
|
166
|
+
* @param paymentId - The payment ID to update (e.g., "pay_abc123")
|
|
167
|
+
* @param email - The contact email to associate with the payment
|
|
168
|
+
* @param apiVersion - Optional API version ("v2" or "v4"), defaults to "v4" if not specified
|
|
169
|
+
* @returns Promise with updated payment response
|
|
170
|
+
*
|
|
171
|
+
* Example usage:
|
|
172
|
+
* await updatePaymentEmail("pay_abc123", "user@example.com")
|
|
173
|
+
*/
|
|
174
|
+
const updatePaymentEmail = async (paymentId, email, apiVersion) => {
|
|
175
|
+
// Set API version if provided
|
|
176
|
+
if (apiVersion) {
|
|
177
|
+
(0, base_1.setApiConfig)({ version: apiVersion });
|
|
178
|
+
}
|
|
179
|
+
// Only support v2/v4 (not v1)
|
|
180
|
+
if (apiVersion === "v1") {
|
|
181
|
+
throw new Error("updatePaymentEmail is only available on API version v2 or later.");
|
|
182
|
+
}
|
|
183
|
+
const endpoint = `/payment-api/payments/${paymentId}/email`;
|
|
184
|
+
const payload = {
|
|
185
|
+
email,
|
|
186
|
+
};
|
|
187
|
+
return base_1.apiClient.post(endpoint, payload);
|
|
188
|
+
};
|
|
189
|
+
exports.updatePaymentEmail = updatePaymentEmail;
|
|
168
190
|
//# sourceMappingURL=payment.js.map
|
package/dist/api/payment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/api/payment.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/api/payment.ts"],"names":[],"mappings":";;;AAoCA,sCA+GC;AAnJD,kDAA4D;AAC5D,oCAAwC;AACxC,oCAAyC;AACzC,iCAA0E;AAC1E,mCAKiB;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,aAAa,CACjC,MAA8B;IAE9B,MAAM,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,WAAW,EACX,OAAO,EACP,OAAO,EACP,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,GACX,GAAG,MAAM,CAAC;IAEX,8BAA8B;IAC9B,IAAI,UAAU,EAAE,CAAC;QACf,IAAA,mBAAY,EAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,sCAAsC;IACtC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,IAAA,wCAAyB,EAAC;QAC3D,OAAO;QACP,OAAO;QACP,SAAS;QACT,OAAO,EAAE,OAAO,IAAI,GAAG;QACvB,qDAAqD;QACrD,cAAc;QACd,qBAAqB;KACtB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAA,oBAAY,EAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;IACnE,MAAM,WAAW,GAAG,IAAA,qBAAa,EAC/B,MAAM,CAAC,SAAS,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kBAAkB,GAAG,KAAK,EACrC,SAAiB,EACjB,KAAa,EACb,UAAuB,EACgB,EAAE;IACzC,8BAA8B;IAC9B,IAAI,UAAU,EAAE,CAAC;QACf,IAAA,mBAAY,EAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,8BAA8B;IAC9B,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,yBAAyB,SAAS,QAAQ,CAAC;IAC5D,MAAM,OAAO,GAAG;QACd,KAAK;KACN,CAAC;IAEF,OAAO,gBAAS,CAAC,IAAI,CAAkB,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC,CAAC;AAvBW,QAAA,kBAAkB,sBAuB7B"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { ApiVersion } from "./base";
|
|
2
|
+
/**
|
|
3
|
+
* FeeType, Fee calculation type:
|
|
4
|
+
* - exactIn (default): Fee deducted from input, recipient receives amount - fee
|
|
5
|
+
* - exactOut: Fee added to input, recipient receives exact amount
|
|
6
|
+
*/
|
|
7
|
+
export declare enum FeeType {
|
|
8
|
+
ExactIn = "exactIn",
|
|
9
|
+
ExactOut = "exactOut"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* PaymentStatus, Payment status
|
|
13
|
+
*/
|
|
14
|
+
export declare enum PaymentStatus {
|
|
15
|
+
PaymentBounced = "payment_bounced",
|
|
16
|
+
PaymentCompleted = "payment_completed",
|
|
17
|
+
PaymentExpired = "payment_expired",
|
|
18
|
+
PaymentPayinCompleted = "payment_payin_completed",
|
|
19
|
+
PaymentPayoutCompleted = "payment_payout_completed",
|
|
20
|
+
PaymentRefunded = "payment_refunded",
|
|
21
|
+
PaymentStarted = "payment_started",
|
|
22
|
+
PaymentUnpaid = "payment_unpaid"
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* PaymentErrorCode, Error code (only present when status is payment_bounced)
|
|
26
|
+
*/
|
|
27
|
+
export declare enum PaymentErrorCode {
|
|
28
|
+
AmountTooHigh = "amountTooHigh",
|
|
29
|
+
AmountTooLow = "amountTooLow",
|
|
30
|
+
ChainUnavailable = "chainUnavailable",
|
|
31
|
+
InsufficientLiquidity = "insufficientLiquidity",
|
|
32
|
+
InvalidRecipient = "invalidRecipient",
|
|
33
|
+
MissingTrustline = "missingTrustline",
|
|
34
|
+
NetworkError = "networkError",
|
|
35
|
+
ProviderError = "providerError",
|
|
36
|
+
ServiceMaintenance = "serviceMaintenance"
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* DestinationRequest
|
|
40
|
+
*/
|
|
41
|
+
export interface DestinationRequest {
|
|
42
|
+
/**
|
|
43
|
+
* Receive amount (required for type=exactOut).
|
|
44
|
+
* For exactIn, this field is omitted in request and calculated in response.
|
|
45
|
+
*/
|
|
46
|
+
amount?: string;
|
|
47
|
+
chainId: number;
|
|
48
|
+
/**
|
|
49
|
+
* Final recipient's wallet address
|
|
50
|
+
*/
|
|
51
|
+
receiverAddress: string;
|
|
52
|
+
/**
|
|
53
|
+
* Memo for Stellar/Solana destinations
|
|
54
|
+
*/
|
|
55
|
+
receiverMemo?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Override default token address
|
|
58
|
+
*/
|
|
59
|
+
tokenAddress?: string;
|
|
60
|
+
tokenSymbol: string;
|
|
61
|
+
[property: string]: any;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* DisplayInfo
|
|
65
|
+
*/
|
|
66
|
+
export interface DisplayInfo {
|
|
67
|
+
/**
|
|
68
|
+
* Display currency
|
|
69
|
+
*/
|
|
70
|
+
currency: string;
|
|
71
|
+
/**
|
|
72
|
+
* Detailed description
|
|
73
|
+
*/
|
|
74
|
+
description?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Short title
|
|
77
|
+
*/
|
|
78
|
+
title: string;
|
|
79
|
+
[property: string]: any;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* SourceRequest
|
|
83
|
+
*/
|
|
84
|
+
export interface SourceRequest {
|
|
85
|
+
/**
|
|
86
|
+
* Pay-in amount (required for type=exactIn).
|
|
87
|
+
* For exactOut, this field is omitted in request and calculated in response.
|
|
88
|
+
*/
|
|
89
|
+
amount?: string;
|
|
90
|
+
chainId: number;
|
|
91
|
+
/**
|
|
92
|
+
* Override default token address
|
|
93
|
+
*/
|
|
94
|
+
tokenAddress?: string;
|
|
95
|
+
tokenSymbol: string;
|
|
96
|
+
[property: string]: any;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* PaymentRequest
|
|
100
|
+
*/
|
|
101
|
+
export interface CreatePaymentRequest {
|
|
102
|
+
/**
|
|
103
|
+
* Your application ID
|
|
104
|
+
*/
|
|
105
|
+
appId: string;
|
|
106
|
+
destination: DestinationRequest;
|
|
107
|
+
display: DisplayInfo;
|
|
108
|
+
/**
|
|
109
|
+
* Custom metadata (max 4 KB recommended)
|
|
110
|
+
*/
|
|
111
|
+
metadata?: {
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Your order reference ID (for idempotency)
|
|
116
|
+
*/
|
|
117
|
+
orderId?: string;
|
|
118
|
+
source: SourceRequest;
|
|
119
|
+
type?: FeeType;
|
|
120
|
+
/**
|
|
121
|
+
* Secret for HMAC-SHA256 signature verification.
|
|
122
|
+
* If not provided, a unique secret is auto-generated.
|
|
123
|
+
* The secret is returned in the response for you to store and use for verification.
|
|
124
|
+
*/
|
|
125
|
+
webhookSecret?: string;
|
|
126
|
+
/**
|
|
127
|
+
* URL to receive payment status updates
|
|
128
|
+
*/
|
|
129
|
+
webhookUrl?: string;
|
|
130
|
+
[property: string]: any;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* DestinationResponse
|
|
134
|
+
*/
|
|
135
|
+
export interface DestinationResponse {
|
|
136
|
+
/**
|
|
137
|
+
* Amount to be sent to recipient
|
|
138
|
+
*/
|
|
139
|
+
amount?: string;
|
|
140
|
+
chainId?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Withdrawal confirmation time
|
|
143
|
+
*/
|
|
144
|
+
confirmedAt?: Date;
|
|
145
|
+
/**
|
|
146
|
+
* Final recipient's wallet
|
|
147
|
+
*/
|
|
148
|
+
receiverAddress?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Memo for Stellar/Solana
|
|
151
|
+
*/
|
|
152
|
+
receiverMemo?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Token contract address
|
|
155
|
+
*/
|
|
156
|
+
tokenAddress?: string;
|
|
157
|
+
tokenSymbol?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Withdrawal transaction hash
|
|
160
|
+
*/
|
|
161
|
+
txHash?: string;
|
|
162
|
+
[property: string]: any;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* SourceResponse
|
|
166
|
+
*/
|
|
167
|
+
export interface SourceResponse {
|
|
168
|
+
/**
|
|
169
|
+
* Amount payer must send
|
|
170
|
+
*/
|
|
171
|
+
amount?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Actual amount received
|
|
174
|
+
*/
|
|
175
|
+
amountReceived?: string;
|
|
176
|
+
chainId?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Deposit confirmation time
|
|
179
|
+
*/
|
|
180
|
+
confirmedAt?: Date;
|
|
181
|
+
/**
|
|
182
|
+
* Fee amount
|
|
183
|
+
*/
|
|
184
|
+
fee?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Deposit address (where payer sends funds)
|
|
187
|
+
*/
|
|
188
|
+
receiverAddress?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Memo for Stellar/Solana deposits
|
|
191
|
+
*/
|
|
192
|
+
receiverMemo?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Payer's wallet address (populated after deposit)
|
|
195
|
+
*/
|
|
196
|
+
senderAddress?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Token contract address
|
|
199
|
+
*/
|
|
200
|
+
tokenAddress?: string;
|
|
201
|
+
tokenSymbol?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Deposit transaction hash
|
|
204
|
+
*/
|
|
205
|
+
txHash?: string;
|
|
206
|
+
[property: string]: any;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* PaymentResponse
|
|
210
|
+
*/
|
|
211
|
+
export interface PaymentResponse {
|
|
212
|
+
/**
|
|
213
|
+
* Your application ID
|
|
214
|
+
*/
|
|
215
|
+
appId: string;
|
|
216
|
+
/**
|
|
217
|
+
* ISO 8601 timestamp
|
|
218
|
+
*/
|
|
219
|
+
createdAt: Date;
|
|
220
|
+
destination: DestinationResponse;
|
|
221
|
+
display: DisplayInfo;
|
|
222
|
+
errorCode: PaymentErrorCode | null;
|
|
223
|
+
/**
|
|
224
|
+
* ISO 8601 timestamp (when payment expires)
|
|
225
|
+
*/
|
|
226
|
+
expiresAt: Date;
|
|
227
|
+
/**
|
|
228
|
+
* Payment ID
|
|
229
|
+
*/
|
|
230
|
+
id: string;
|
|
231
|
+
metadata: {
|
|
232
|
+
[key: string]: any;
|
|
233
|
+
} | null;
|
|
234
|
+
/**
|
|
235
|
+
* Your order reference ID
|
|
236
|
+
*/
|
|
237
|
+
orderId: string | null;
|
|
238
|
+
source: SourceResponse;
|
|
239
|
+
status: PaymentStatus;
|
|
240
|
+
type: FeeType;
|
|
241
|
+
/**
|
|
242
|
+
* ISO 8601 timestamp
|
|
243
|
+
*/
|
|
244
|
+
updatedAt: Date;
|
|
245
|
+
/**
|
|
246
|
+
* Secret for webhook signature verification.
|
|
247
|
+
* Only present when webhookUrl was provided in the request.
|
|
248
|
+
* Store this securely to verify incoming webhook signatures.
|
|
249
|
+
*/
|
|
250
|
+
webhookSecret: string | null;
|
|
251
|
+
[property: string]: any;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Parameters for creating a new payment using the new backend interface
|
|
255
|
+
*/
|
|
256
|
+
export interface CreateNewPaymentParams {
|
|
257
|
+
/** App ID for authentication */
|
|
258
|
+
appId: string;
|
|
259
|
+
/** Destination chain ID (e.g., 8453 for Base, 900 for Solana, 1500 for Stellar) */
|
|
260
|
+
toChain: number;
|
|
261
|
+
/** Destination token address */
|
|
262
|
+
toToken: string;
|
|
263
|
+
/** Destination address - Can be EVM, Solana, or Stellar address */
|
|
264
|
+
toAddress: string;
|
|
265
|
+
/** Chain ID where user will pay from (e.g., 137 for Polygon, 8453 for Base) */
|
|
266
|
+
preferredChain: number;
|
|
267
|
+
/** Token address user will pay with */
|
|
268
|
+
preferredTokenAddress: string;
|
|
269
|
+
/** Amount in human-readable units (e.g., "1" for 1 USDC, "0.5" for half a USDC) */
|
|
270
|
+
toUnits?: string;
|
|
271
|
+
/** Additional metadata to include */
|
|
272
|
+
metadata?: Record<string, unknown>;
|
|
273
|
+
/** Display title for the payment */
|
|
274
|
+
title?: string;
|
|
275
|
+
/** Display description for the payment */
|
|
276
|
+
description?: string;
|
|
277
|
+
/** Order reference ID (for idempotency) */
|
|
278
|
+
orderId?: string;
|
|
279
|
+
/** Fee calculation type (exactIn or exactOut) */
|
|
280
|
+
feeType?: FeeType;
|
|
281
|
+
/** Webhook URL to receive payment status updates */
|
|
282
|
+
webhookUrl?: string;
|
|
283
|
+
/** Secret for HMAC-SHA256 signature verification */
|
|
284
|
+
webhookSecret?: string;
|
|
285
|
+
/** Memo for Stellar/Solana destinations */
|
|
286
|
+
receiverMemo?: string;
|
|
287
|
+
/** API version to use (v2 or v4). Defaults to v4 */
|
|
288
|
+
apiVersion?: ApiVersion;
|
|
289
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentErrorCode = exports.PaymentStatus = exports.FeeType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* FeeType, Fee calculation type:
|
|
6
|
+
* - exactIn (default): Fee deducted from input, recipient receives amount - fee
|
|
7
|
+
* - exactOut: Fee added to input, recipient receives exact amount
|
|
8
|
+
*/
|
|
9
|
+
var FeeType;
|
|
10
|
+
(function (FeeType) {
|
|
11
|
+
FeeType["ExactIn"] = "exactIn";
|
|
12
|
+
FeeType["ExactOut"] = "exactOut";
|
|
13
|
+
})(FeeType || (exports.FeeType = FeeType = {}));
|
|
14
|
+
/**
|
|
15
|
+
* PaymentStatus, Payment status
|
|
16
|
+
*/
|
|
17
|
+
var PaymentStatus;
|
|
18
|
+
(function (PaymentStatus) {
|
|
19
|
+
PaymentStatus["PaymentBounced"] = "payment_bounced";
|
|
20
|
+
PaymentStatus["PaymentCompleted"] = "payment_completed";
|
|
21
|
+
PaymentStatus["PaymentExpired"] = "payment_expired";
|
|
22
|
+
PaymentStatus["PaymentPayinCompleted"] = "payment_payin_completed";
|
|
23
|
+
PaymentStatus["PaymentPayoutCompleted"] = "payment_payout_completed";
|
|
24
|
+
PaymentStatus["PaymentRefunded"] = "payment_refunded";
|
|
25
|
+
PaymentStatus["PaymentStarted"] = "payment_started";
|
|
26
|
+
PaymentStatus["PaymentUnpaid"] = "payment_unpaid";
|
|
27
|
+
})(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
|
|
28
|
+
/**
|
|
29
|
+
* PaymentErrorCode, Error code (only present when status is payment_bounced)
|
|
30
|
+
*/
|
|
31
|
+
var PaymentErrorCode;
|
|
32
|
+
(function (PaymentErrorCode) {
|
|
33
|
+
PaymentErrorCode["AmountTooHigh"] = "amountTooHigh";
|
|
34
|
+
PaymentErrorCode["AmountTooLow"] = "amountTooLow";
|
|
35
|
+
PaymentErrorCode["ChainUnavailable"] = "chainUnavailable";
|
|
36
|
+
PaymentErrorCode["InsufficientLiquidity"] = "insufficientLiquidity";
|
|
37
|
+
PaymentErrorCode["InvalidRecipient"] = "invalidRecipient";
|
|
38
|
+
PaymentErrorCode["MissingTrustline"] = "missingTrustline";
|
|
39
|
+
PaymentErrorCode["NetworkError"] = "networkError";
|
|
40
|
+
PaymentErrorCode["ProviderError"] = "providerError";
|
|
41
|
+
PaymentErrorCode["ServiceMaintenance"] = "serviceMaintenance";
|
|
42
|
+
})(PaymentErrorCode || (exports.PaymentErrorCode = PaymentErrorCode = {}));
|
|
43
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;AACvB,CAAC,EAHW,OAAO,uBAAP,OAAO,QAGlB;AAED;;GAEG;AACH,IAAY,aASX;AATD,WAAY,aAAa;IACvB,mDAAkC,CAAA;IAClC,uDAAsC,CAAA;IACtC,mDAAkC,CAAA;IAClC,kEAAiD,CAAA;IACjD,oEAAmD,CAAA;IACnD,qDAAoC,CAAA;IACpC,mDAAkC,CAAA;IAClC,iDAAgC,CAAA;AAClC,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB;AAED;;GAEG;AACH,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,mDAA+B,CAAA;IAC/B,iDAA6B,CAAA;IAC7B,yDAAqC,CAAA;IACrC,mEAA+C,CAAA;IAC/C,yDAAqC,CAAA;IACrC,yDAAqC,CAAA;IACrC,iDAA6B,CAAA;IAC7B,mDAA+B,CAAA;IAC/B,6DAAyC,CAAA;AAC3C,CAAC,EAVW,gBAAgB,gCAAhB,gBAAgB,QAU3B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var base_1 = require("./api/base");
|
|
|
19
19
|
Object.defineProperty(exports, "setApiConfig", { enumerable: true, get: function () { return base_1.setApiConfig; } });
|
|
20
20
|
__exportStar(require("./api/fee"), exports);
|
|
21
21
|
__exportStar(require("./api/payment"), exports);
|
|
22
|
+
__exportStar(require("./api/types"), exports);
|
|
22
23
|
__exportStar(require("./assert"), exports);
|
|
23
24
|
__exportStar(require("./bridge-utils"), exports);
|
|
24
25
|
__exportStar(require("./chain"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA2D;AAAlD,oGAAA,YAAY,OAAA;AACrB,4CAA0B;AAC1B,gDAA8B;AAC9B,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,0CAAwB;AACxB,wCAAsB;AACtB,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA2D;AAAlD,oGAAA,YAAY,OAAA;AACrB,4CAA0B;AAC1B,gDAA8B;AAC9B,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB;AACxB,0CAAwB;AACxB,2CAAyB;AACzB,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,0CAAwB;AACxB,wCAAsB;AACtB,+CAA6B"}
|
package/dist/rozoPay.d.ts
CHANGED
|
@@ -44,11 +44,11 @@ export declare const zBridgeTokenOutOptions: z.ZodArray<z.ZodObject<{
|
|
|
44
44
|
token: z.ZodEffects<z.ZodString, `0x${string}`, string>;
|
|
45
45
|
amount: z.ZodEffects<z.ZodEffects<z.ZodString, `${bigint}`, string>, bigint, string>;
|
|
46
46
|
}, "strip", z.ZodTypeAny, {
|
|
47
|
-
token: `0x${string}`;
|
|
48
47
|
amount: bigint;
|
|
48
|
+
token: `0x${string}`;
|
|
49
49
|
}, {
|
|
50
|
-
token: string;
|
|
51
50
|
amount: string;
|
|
51
|
+
token: string;
|
|
52
52
|
}>, "many">;
|
|
53
53
|
export type BridgeTokenOutOptions = z.infer<typeof zBridgeTokenOutOptions>;
|
|
54
54
|
export declare const zRozoPayOrderMetadata: z.ZodObject<{
|
|
@@ -68,14 +68,14 @@ export declare const zRozoPayOrderMetadata: z.ZodObject<{
|
|
|
68
68
|
price: z.ZodOptional<z.ZodString>;
|
|
69
69
|
priceDetails: z.ZodOptional<z.ZodString>;
|
|
70
70
|
}, "strip", z.ZodTypeAny, {
|
|
71
|
-
name: string;
|
|
72
71
|
description: string;
|
|
72
|
+
name: string;
|
|
73
73
|
image?: string | undefined;
|
|
74
74
|
price?: string | undefined;
|
|
75
75
|
priceDetails?: string | undefined;
|
|
76
76
|
}, {
|
|
77
|
-
name: string;
|
|
78
77
|
description: string;
|
|
78
|
+
name: string;
|
|
79
79
|
image?: string | undefined;
|
|
80
80
|
price?: string | undefined;
|
|
81
81
|
priceDetails?: string | undefined;
|
|
@@ -116,8 +116,8 @@ export declare const zRozoPayOrderMetadata: z.ZodObject<{
|
|
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
|
117
117
|
intent: string;
|
|
118
118
|
items: {
|
|
119
|
-
name: string;
|
|
120
119
|
description: string;
|
|
120
|
+
name: string;
|
|
121
121
|
image?: string | undefined;
|
|
122
122
|
price?: string | undefined;
|
|
123
123
|
priceDetails?: string | undefined;
|
|
@@ -140,8 +140,8 @@ export declare const zRozoPayOrderMetadata: z.ZodObject<{
|
|
|
140
140
|
}, {
|
|
141
141
|
intent: string;
|
|
142
142
|
items: {
|
|
143
|
-
name: string;
|
|
144
143
|
description: string;
|
|
144
|
+
name: string;
|
|
145
145
|
image?: string | undefined;
|
|
146
146
|
price?: string | undefined;
|
|
147
147
|
priceDetails?: string | undefined;
|