@rozoai/intent-common 0.1.0-beta.2 → 0.1.0-beta.3
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/payment.d.ts +264 -139
- package/dist/api/payment.js +95 -89
- package/dist/api/payment.js.map +1 -1
- package/dist/{bridge.d.ts → bridge-utils.d.ts} +37 -55
- package/dist/{bridge.js → bridge-utils.js} +53 -131
- package/dist/bridge-utils.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/{daimoPay.js → rozoPay.js} +1 -1
- package/dist/rozoPay.js.map +1 -0
- package/package.json +1 -1
- package/src/api/payment.ts +336 -174
- package/src/{bridge.ts → bridge-utils.ts} +56 -139
- package/src/index.ts +2 -3
- package/test/bridge.test.ts +4 -1
- package/dist/api/new-payment.d.ts +0 -319
- package/dist/api/new-payment.js +0 -140
- package/dist/api/new-payment.js.map +0 -1
- package/dist/bridge.js.map +0 -1
- package/dist/daimoPay.js.map +0 -1
- package/src/api/README.md +0 -554
- package/src/api/new-payment.ts +0 -433
- package/dist/{daimoPay.d.ts → rozoPay.d.ts} +8 -8
- /package/src/{daimoPay.ts → rozoPay.ts} +0 -0
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
rozoStellarUSDC,
|
|
17
17
|
validateAddressForChain,
|
|
18
18
|
} from ".";
|
|
19
|
-
import type { PaymentResponseData } from "./api/payment";
|
|
20
19
|
|
|
21
20
|
export interface PaymentBridgeConfig {
|
|
22
21
|
toChain: number;
|
|
@@ -236,114 +235,78 @@ export function createPaymentBridgeConfig({
|
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
/**
|
|
239
|
-
*
|
|
238
|
+
* Converts a RozoAI payment API response to a fully hydrated RozoPay order.
|
|
240
239
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
240
|
+
* This utility transforms the low-level {@link PaymentResponse} object returned by the RozoAI Intent Pay API
|
|
241
|
+
* into a {@link RozoPayHydratedOrderWithOrg}, containing all values needed for UI display, order tracking,
|
|
242
|
+
* and multi-chain cross-payment logic. Fields are normalized and token metadata is resolved in order to
|
|
243
|
+
* standardize data from different chains and token types.
|
|
244
244
|
*
|
|
245
|
-
*
|
|
245
|
+
* Key steps performed:
|
|
246
246
|
*
|
|
247
|
-
* 1. **Token
|
|
248
|
-
*
|
|
249
|
-
*
|
|
247
|
+
* 1. **Token Metadata Lookup**: Uses {@link getKnownToken} to identify the correct token
|
|
248
|
+
* for the payment, including decimals, symbol, logo, and chain details.
|
|
249
|
+
* Special handling is applied for Stellar and Solana tokens based on how they're encoded in the backend.
|
|
250
250
|
*
|
|
251
|
-
* 2. **Order
|
|
252
|
-
*
|
|
253
|
-
* - Sets up intent, handoff, and contract addresses
|
|
254
|
-
* - Configures bridge token options and destination amounts
|
|
251
|
+
* 2. **Order Hydration**: Generates a unique (random BigInt) internal order ID for frontend usage, sets the
|
|
252
|
+
* payment mode as HYDRATED, and resolves all destination call and amount fields from the payment response.
|
|
255
253
|
*
|
|
256
|
-
* 3. **Status Initialization**:
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* - Intent status: UNPAID (payment not initiated)
|
|
254
|
+
* 3. **Status Initialization**: Initializes the payment, source, and destination status fields
|
|
255
|
+
* with their correct values based on the payment's progress in the state machine. The returned object is
|
|
256
|
+
* ready for status tracking and user notification.
|
|
260
257
|
*
|
|
261
|
-
* 4. **Metadata
|
|
262
|
-
*
|
|
263
|
-
* - Preserves external ID and organization information
|
|
258
|
+
* 4. **Metadata Consolidation**: Merges core order metadata, user metadata (if provided by the payer),
|
|
259
|
+
* and any external references such as org info. Ensures all details needed for order display and analytics are available.
|
|
264
260
|
*
|
|
265
|
-
* @param order -
|
|
266
|
-
* @param
|
|
267
|
-
* @param order.destination - Destination configuration (chain, token, amount, address)
|
|
268
|
-
* @param order.source - Source transaction info (if payment has been initiated)
|
|
269
|
-
* @param order.orgId - Organization ID for the payment
|
|
270
|
-
* @param order.externalId - External reference ID (if provided by merchant)
|
|
261
|
+
* @param order - Low-level API payment response (from RozoAI Intent Pay backend)
|
|
262
|
+
* @param feeType - Optional: Fee deduction mode (ExactIn/ExactOut); determines which side's amount is shown as source. Defaults to ExactIn.
|
|
271
263
|
*
|
|
272
|
-
* @returns
|
|
273
|
-
*
|
|
274
|
-
* @returns mode - Order mode (HYDRATED)
|
|
275
|
-
* @returns sourceStatus - Source transaction status
|
|
276
|
-
* @returns destStatus - Destination transaction status
|
|
277
|
-
* @returns intentStatus - Overall payment intent status
|
|
278
|
-
* @returns metadata - Merged metadata from all sources
|
|
279
|
-
* @returns org - Organization information
|
|
264
|
+
* @returns {RozoPayHydratedOrderWithOrg} A normalized, display-ready order representation containing all tracking, status,
|
|
265
|
+
* token, org, and routing information for frontend use.
|
|
280
266
|
*
|
|
281
267
|
* @example
|
|
282
268
|
* ```typescript
|
|
283
|
-
* const paymentResponse = await
|
|
284
|
-
*
|
|
285
|
-
* const hydratedOrder = formatPaymentResponseDataToHydratedOrder(
|
|
286
|
-
* paymentResponse.data,
|
|
287
|
-
* 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN'
|
|
288
|
-
* );
|
|
289
|
-
*
|
|
269
|
+
* const paymentResponse = await getPayment(paymentId);
|
|
270
|
+
* const hydratedOrder = formatPaymentResponseToHydratedOrder(paymentResponse.data);
|
|
290
271
|
* console.log(hydratedOrder.sourceStatus); // 'WAITING_PAYMENT'
|
|
291
272
|
* console.log(hydratedOrder.destFinalCallTokenAmount.token.symbol); // 'USDC'
|
|
292
273
|
* console.log(hydratedOrder.usdValue); // 10.00
|
|
293
274
|
* ```
|
|
294
275
|
*
|
|
295
|
-
* @
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
276
|
+
* @remarks
|
|
277
|
+
* - The returned `id` (BigInt) is generated randomly and is client-side only; always use
|
|
278
|
+
* `order.orderId` or the API reference for backend/server reconciliation.
|
|
279
|
+
* - The expiration timestamp and org info are carried over if present on the API response.
|
|
280
|
+
* - Decimals, token symbol, and display metadata for the amount and destination chain
|
|
281
|
+
* are resolved so the result is immediately usable for UI.
|
|
299
282
|
*
|
|
300
|
-
* @see
|
|
283
|
+
* @see PaymentResponse
|
|
301
284
|
* @see RozoPayHydratedOrderWithOrg
|
|
302
285
|
* @see getKnownToken
|
|
303
286
|
*/
|
|
304
|
-
export function
|
|
305
|
-
order:
|
|
287
|
+
export function formatPaymentResponseToHydratedOrder(
|
|
288
|
+
order: PaymentResponse
|
|
306
289
|
): RozoPayHydratedOrderWithOrg {
|
|
307
|
-
|
|
290
|
+
// Source amount is in the same units as the destination amount without fee
|
|
291
|
+
const sourceAmountUnits = order.source?.amount ?? "0";
|
|
292
|
+
|
|
293
|
+
// Destination address is where the payment will be received
|
|
294
|
+
const destAddress = order.source?.receiverAddress;
|
|
308
295
|
|
|
309
|
-
|
|
296
|
+
// Determine the chain from metadata or default to the source chain
|
|
297
|
+
const requiredChain = order.source?.chainId || baseUSDC.chainId;
|
|
310
298
|
|
|
311
299
|
const token = getKnownToken(
|
|
312
300
|
Number(requiredChain),
|
|
313
301
|
Number(requiredChain) === rozoStellarUSDC.chainId
|
|
314
302
|
? rozoStellarUSDC.token
|
|
315
|
-
: order.
|
|
303
|
+
: order.source?.tokenAddress || ""
|
|
316
304
|
);
|
|
317
305
|
|
|
318
306
|
return {
|
|
319
307
|
id: BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)),
|
|
320
308
|
mode: RozoPayOrderMode.HYDRATED,
|
|
321
|
-
intentAddr: destAddress,
|
|
322
|
-
// @TODO: use correct destination token
|
|
323
|
-
// bridgeTokenOutOptions: [
|
|
324
|
-
// {
|
|
325
|
-
// token: {
|
|
326
|
-
// chainId: baseUSDC.chainId,
|
|
327
|
-
// token: baseUSDC.token,
|
|
328
|
-
// symbol: baseUSDC.symbol,
|
|
329
|
-
// usd: 1,
|
|
330
|
-
// priceFromUsd: 1,
|
|
331
|
-
// decimals: baseUSDC.decimals,
|
|
332
|
-
// displayDecimals: 2,
|
|
333
|
-
// logoSourceURI: baseUSDC.logoSourceURI,
|
|
334
|
-
// logoURI: baseUSDC.logoURI,
|
|
335
|
-
// maxAcceptUsd: 100000,
|
|
336
|
-
// maxSendUsd: 0,
|
|
337
|
-
// },
|
|
338
|
-
// amount: parseUnits(
|
|
339
|
-
// order.destination.amountUnits,
|
|
340
|
-
// baseUSDC.decimals
|
|
341
|
-
// ).toString() as `${bigint}`,
|
|
342
|
-
// usd: Number(order.destination.amountUnits),
|
|
343
|
-
// },
|
|
344
|
-
// ],
|
|
345
|
-
// selectedBridgeTokenOutAddr: null,
|
|
346
|
-
// selectedBridgeTokenOutAmount: null,
|
|
309
|
+
intentAddr: destAddress ?? "",
|
|
347
310
|
destFinalCallTokenAmount: {
|
|
348
311
|
token: {
|
|
349
312
|
chainId: token ? token.chainId : baseUSDC.chainId,
|
|
@@ -359,90 +322,44 @@ export function formatResponseToHydratedOrder(
|
|
|
359
322
|
maxSendUsd: 0,
|
|
360
323
|
},
|
|
361
324
|
amount: parseUnits(
|
|
362
|
-
|
|
325
|
+
sourceAmountUnits,
|
|
363
326
|
token ? token.decimals : baseUSDC.decimals
|
|
364
327
|
).toString() as `${bigint}`,
|
|
365
|
-
usd: Number(
|
|
328
|
+
usd: Number(sourceAmountUnits),
|
|
366
329
|
},
|
|
367
|
-
usdValue: Number(
|
|
330
|
+
usdValue: Number(sourceAmountUnits),
|
|
368
331
|
destFinalCall: {
|
|
369
|
-
to: destAddress,
|
|
332
|
+
to: destAddress ?? "",
|
|
370
333
|
value: BigInt("0"),
|
|
371
334
|
data: "0x",
|
|
372
335
|
},
|
|
373
|
-
refundAddr: (order.source?.
|
|
374
|
-
nonce: order.nonce
|
|
336
|
+
refundAddr: (order.source?.senderAddress as `0x${string}`) || null,
|
|
337
|
+
nonce: BigInt(order.nonce ?? 0),
|
|
375
338
|
sourceFulfillerAddr: null,
|
|
376
339
|
sourceTokenAmount: null,
|
|
377
340
|
sourceInitiateTxHash: null,
|
|
378
|
-
// sourceStartTxHash: null,
|
|
379
341
|
sourceStatus: RozoPayOrderStatusSource.WAITING_PAYMENT,
|
|
380
342
|
destStatus: RozoPayOrderStatusDest.PENDING,
|
|
381
343
|
intentStatus: RozoPayIntentStatus.UNPAID,
|
|
382
344
|
destFastFinishTxHash: null,
|
|
383
345
|
destClaimTxHash: null,
|
|
384
346
|
redirectUri: null,
|
|
385
|
-
createdAt: Math.floor(Date.
|
|
386
|
-
lastUpdatedAt: Math.floor(Date.
|
|
387
|
-
orgId: order.orgId
|
|
347
|
+
createdAt: Math.floor(new Date(order.createdAt).getTime() / 1000),
|
|
348
|
+
lastUpdatedAt: Math.floor(new Date(order.updatedAt).getTime() / 1000),
|
|
349
|
+
orgId: order.orgId ?? "",
|
|
388
350
|
metadata: {
|
|
389
351
|
...(order?.metadata ?? {}),
|
|
390
|
-
|
|
391
|
-
|
|
352
|
+
receivingAddress: order.source?.receiverAddress,
|
|
353
|
+
memo: order.source?.receiverMemo ?? null,
|
|
392
354
|
} as any,
|
|
393
|
-
externalId: order.externalId
|
|
355
|
+
externalId: order.externalId ?? null,
|
|
394
356
|
userMetadata: order.userMetadata as RozoPayUserMetadata | null,
|
|
395
|
-
expirationTs:
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
new Date(String(order.expiresAt)).getTime() / 1000
|
|
399
|
-
).toString()
|
|
400
|
-
)
|
|
401
|
-
: BigInt(Math.floor(Date.now() / 1000 + 5 * 60).toString()),
|
|
357
|
+
expirationTs: BigInt(
|
|
358
|
+
Math.floor(new Date(order.expiresAt).getTime() / 1000).toString()
|
|
359
|
+
),
|
|
402
360
|
org: {
|
|
403
|
-
orgId: order.orgId
|
|
361
|
+
orgId: order.orgId ?? "",
|
|
404
362
|
name: "",
|
|
405
363
|
},
|
|
406
364
|
};
|
|
407
365
|
}
|
|
408
|
-
|
|
409
|
-
export function formatPaymentResponseToHydratedOrder(
|
|
410
|
-
order: PaymentResponse
|
|
411
|
-
): RozoPayHydratedOrderWithOrg {
|
|
412
|
-
// Source amount is in the same units as the destination amount without fee
|
|
413
|
-
const sourceAmountUnits = order.source?.amount ?? "0";
|
|
414
|
-
|
|
415
|
-
return formatResponseToHydratedOrder({
|
|
416
|
-
id: order.id,
|
|
417
|
-
expiresAt: new Date(order.expiresAt).toISOString(),
|
|
418
|
-
updatedAt: new Date(order.updatedAt).toISOString(),
|
|
419
|
-
createdAt: new Date(order.createdAt).toISOString(),
|
|
420
|
-
status: RozoPayOrderMode.HYDRATED,
|
|
421
|
-
display: order.display,
|
|
422
|
-
metadata: {
|
|
423
|
-
...order.metadata,
|
|
424
|
-
receivingAddress: order.source?.receiverAddress,
|
|
425
|
-
memo: order.source?.receiverMemo ?? null,
|
|
426
|
-
} as any,
|
|
427
|
-
destination: {
|
|
428
|
-
destinationAddress: order.destination?.receiverAddress ?? "",
|
|
429
|
-
chainId: String(order.destination?.chainId ?? ""),
|
|
430
|
-
amountUnits: sourceAmountUnits,
|
|
431
|
-
tokenSymbol: order.destination?.tokenSymbol ?? "",
|
|
432
|
-
tokenAddress: order.destination?.tokenAddress ?? "",
|
|
433
|
-
txHash: order.destination?.txHash ?? null,
|
|
434
|
-
},
|
|
435
|
-
source: {
|
|
436
|
-
sourceAddress: order.source?.senderAddress ?? undefined,
|
|
437
|
-
chainId: String(order.source?.chainId ?? ""),
|
|
438
|
-
amountUnits: sourceAmountUnits,
|
|
439
|
-
tokenSymbol: order.source?.tokenSymbol ?? "",
|
|
440
|
-
tokenAddress: order.source?.tokenAddress ?? "",
|
|
441
|
-
},
|
|
442
|
-
url: order.url,
|
|
443
|
-
externalId: order.externalId,
|
|
444
|
-
userMetadata: order.userMetadata,
|
|
445
|
-
nonce: order.nonce,
|
|
446
|
-
orgId: order.orgId,
|
|
447
|
-
});
|
|
448
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export * from "./api/fee";
|
|
2
|
-
export * from "./api/new-payment";
|
|
3
2
|
export * from "./api/payment";
|
|
4
3
|
export * from "./assert";
|
|
5
|
-
export * from "./bridge";
|
|
4
|
+
export * from "./bridge-utils";
|
|
6
5
|
export * from "./chain";
|
|
7
|
-
export * from "./daimoPay";
|
|
8
6
|
export * from "./debug";
|
|
9
7
|
export * from "./format";
|
|
10
8
|
export * from "./primitiveTypes";
|
|
11
9
|
export * from "./retryBackoff";
|
|
10
|
+
export * from "./rozoPay";
|
|
12
11
|
export * from "./token";
|
|
13
12
|
export * from "./try";
|
|
14
13
|
export * from "./validation";
|
package/test/bridge.test.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import test from "tape";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createPaymentBridgeConfig,
|
|
4
|
+
PaymentBridgeConfig,
|
|
5
|
+
} from "../src/bridge-utils";
|
|
3
6
|
import { base, polygon, rozoSolana, rozoStellar } from "../src/chain";
|
|
4
7
|
import {
|
|
5
8
|
baseUSDC,
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { ApiResponse } 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
|
-
type?: 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
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Creates a payment using the new backend interface
|
|
290
|
-
*
|
|
291
|
-
* This function creates a payment using the new backend API structure with
|
|
292
|
-
* separate source and destination objects, enum-based chain IDs and token symbols.
|
|
293
|
-
*
|
|
294
|
-
* @param params - Payment creation parameters
|
|
295
|
-
* @returns Promise resolving to the payment response data
|
|
296
|
-
* @throws Error if payment creation fails or required parameters are missing
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* ```typescript
|
|
300
|
-
* // Simple same-chain payment
|
|
301
|
-
* const payment = await createNewPayment({
|
|
302
|
-
* toChain: 8453, // Base
|
|
303
|
-
* toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
|
|
304
|
-
* toAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
|
|
305
|
-
* preferredChain: 8453, // User pays from Base
|
|
306
|
-
* preferredTokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // Base USDC
|
|
307
|
-
* toUnits: "1", // 1 USDC
|
|
308
|
-
* appId: "my-app-id",
|
|
309
|
-
* title: "Payment",
|
|
310
|
-
* });
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
export declare function createNewPayment(params: CreateNewPaymentParams): Promise<PaymentResponse>;
|
|
314
|
-
/**
|
|
315
|
-
* Gets payment details by ID using the new backend API
|
|
316
|
-
* @param paymentId - Payment ID
|
|
317
|
-
* @returns Promise with payment response
|
|
318
|
-
*/
|
|
319
|
-
export declare const getNewPayment: (paymentId: string) => Promise<ApiResponse<PaymentResponse>>;
|