type Chain = 'mainnet' | 'testnet'; type APIOptions = { chain?: Chain; apiKey?: string; }; /** * @param amount - in human readable format, 10.5 for example * @param asset - jetton master address or TON coin address for TON transfer * @param recipientAddr - recipient wallet address. Optional if API key is provided - defaults to the merchant's wallet address from the admin panel * @param senderAddr - payer wallet address * @param queryId - only for Jetton * @param commentToSender - a comment that will be displayed in the user's wallet when signing a transaction * @param commentToRecipient - a comment that will be displayed in the recipient's wallet when receiving a transaction */ type CreateTonPayTransferParams = { amount: number; asset: string; recipientAddr?: string; senderAddr: string; queryId?: number; commentToSender?: string; commentToRecipient?: string; }; /** * @param message - a built message that will be sent to the recipient's wallet * @param bodyBase64Hash - a hash of the transaction message content in Base64 format * @param reference - a reference ID for the transaction, used for tracking the transaction */ type CreateTonPayTransferResponse = { message: { address: string; amount: string; payload: string; }; bodyBase64Hash: string; reference: string; }; /** * Creates a message for TON Pay transfer * @param params - the parameters for the transfer * @param options - the options for the transfer * @returns the message for the transfer and data for tracking the transfer */ declare const createTonPayTransfer: (params: CreateTonPayTransferParams, options?: APIOptions) => Promise; /** * MoonPay geo location result */ type MoonpayGeoResult = { alpha2: string; alpha3: string; country: string; state: string; ipAddress: string; isAllowed: boolean; isBuyAllowed: boolean; isNftAllowed: boolean; isSellAllowed: boolean; isBalanceLedgerWithdrawAllowed: boolean; isFiatBalanceAllowed: boolean; isMoonPayBalanceAllowed: boolean; isLowLimitEnabled: boolean; }; /** * MoonPay amount limits */ type MoonpayAmountLimits = { paymentMethod: string; quoteCurrency: { code: string; minBuyAmount: number; maxBuyAmount: number; }; baseCurrency: { code: string; minBuyAmount: number; maxBuyAmount: number; }; areFeesIncluded: boolean; }; /** * @param amount - in human readable format, 10.5 for example * @param asset - jetton master address or TON coin address for TON transfer * @param recipientAddr - recipient wallet address. Optional if API key is provided - defaults to the merchant's wallet address from the admin panel * @param userIp - user's IP address (required for geo verification) * @param redirectURL - redirect URL after Moonpay purchase */ type CreateMoonpayTransferParams = { amount: number; asset: string; recipientAddr?: string; userIp: string; redirectURL: string; /** If true, funds go directly to recipientAddr without proxy contract or memo tag */ directTopUp?: boolean; }; /** * @param link - MoonPay payment link * @param geo - MoonPay geo location result * @param limits - MoonPay amount limits */ type CreateMoonpayTransferResponse = { link: string; reference: string; geo?: MoonpayGeoResult; limits: MoonpayAmountLimits; }; /** * Creates a MoonPay payment link for buying crypto * @param params - the parameters for the MoonPay transfer * @param options - the options for the transfer (requires API key) * @returns the payment link, geo restrictions, and amount limits */ declare const createMoonpayTransfer: (params: CreateMoonpayTransferParams, options?: APIOptions) => Promise; /** * @param ipAddress - IP address to check for geo restrictions */ type CheckMoonpayGeoParams = { ipAddress: string; }; /** * MoonPay geo check response */ type CheckMoonpayGeoResponse = MoonpayGeoResult; /** * Checks MoonPay geo restrictions for an IP address * @param params - the IP address to check * @param options - optional API options * @returns the geo location and restrictions */ declare const checkMoonpayGeo: (params: CheckMoonpayGeoParams, options?: APIOptions) => Promise; /** * @param asset - jetton master address or TON coin address for TON */ type CheckMoonpayLimitsParams = { asset: string; }; /** * MoonPay limits check response */ type CheckMoonpayLimitsResponse = MoonpayAmountLimits; /** * Gets MoonPay amount limits for an asset * @param params - the asset to check limits for * @param options - optional API options * @returns the amount limits for the asset */ declare const checkMoonpayLimits: (params: CheckMoonpayLimitsParams, options?: APIOptions) => Promise; type CheckMoonpayAvailabilityParams = { asset: string; ipAddress?: string; }; type CheckMoonpayAvailabilityResponse = { geo: MoonpayGeoResult; limits: MoonpayAmountLimits; currencyCode: string; }; declare const checkMoonpayAvailability: (params: CheckMoonpayAvailabilityParams, options?: APIOptions) => Promise; /** * @param amount - the amount of the transfer in human readable format * @param rawAmount - the amount of the transfer in base units * @param senderAddr - the address of the sender wallet * @param recipientAddr - the address of the recipient wallet * @param asset - the address of the asset * @param assetTicker - the ticker of the asset (e.g. "USDT") * @param status - the status of the transfer ("success" or "failed") * @param reference - the reference of the transfer * @param bodyBase64Hash - the hash of the body of the transfer in Base64 format * @param txHash - the hash of the transaction * @param traceId - the id of the trace * @param commentToSender - the comment to the sender wallet * @param commentToRecipient - the comment to the recipient wallet * @param date - the date of the transfer * @param errorCode - the error code of the transfer * @param errorMessage - the error message of the transfer */ type CompletedTonPayTransferInfo = { amount: string; rawAmount: string; senderAddr: string; recipientAddr: string; asset: string; assetTicker?: string; status: string; reference: string; bodyBase64Hash: string; txHash: string; traceId: string; commentToSender?: string; commentToRecipient?: string; date: string; errorCode?: number; errorMessage?: string; }; /** * Gets a TON Pay transfer by reference * @param reference - the reference of the transfer * @param options - the options for the transfer * @returns the transfer information */ declare const getTonPayTransferByBodyHash: (bodyHash: string, options?: APIOptions) => Promise; /** * Gets a TON Pay transfer by reference * @param reference - the reference of the transfer * @param options - the options for the transfer * @returns the transfer information */ declare const getTonPayTransferByReference: (reference: string, options?: APIOptions) => Promise; /** * @param bodyHash - the hash of the transaction message content */ type GetTonPayTransferByBodyHashParams = { bodyHash: string; }; /** * @param reference - the reference of the transfer */ type GetTonPayTransferByReferenceParams = { reference: string; }; /** * Webhook event types * * @remarks * - `transfer.completed` - Transfer completed (check `data.status` for success/failed) * - `transfer.refunded` - Transfer was refunded (Coming Soon) */ type WebhookEventType = 'transfer.completed' | 'transfer.refunded'; /** * Base webhook payload structure */ interface BaseWebhookPayload { event: WebhookEventType; timestamp: string; } /** * Webhook payload for transfer.completed event * * @remarks * Sent when a transfer is completed on the blockchain. * Check `data.status` field to determine if transfer was "success" or "failed". */ interface TransferCompletedWebhookPayload extends BaseWebhookPayload { event: 'transfer.completed'; data: CompletedTonPayTransferInfo; } /** * Webhook payload for transfer.refunded event * * @remarks * Coming Soon - Sent when a transfer is refunded */ interface TransferRefundedWebhookPayload extends BaseWebhookPayload { event: 'transfer.refunded'; data: unknown; } /** * Union type for all webhook payloads * * @remarks * Currently only transfer.completed is supported. * Additional events will be added in future updates. */ type WebhookPayload = TransferCompletedWebhookPayload | TransferRefundedWebhookPayload; declare const USDT = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"; declare const TON = "TON"; /** * Verifies the HMAC-SHA256 signature of a payload * @param payload - Raw JSON string or object to verify * @param signature - The signature from X-TON Pay-Signature header * @param apiSecret - Your TON Pay webhook API secret * @returns true if signature is valid, false otherwise * * @example * ```typescript * import { verifySignature } from "@ton-pay/api"; * * // With raw string * app.post("/webhook", (req, res) => { * const signature = req.headers["x-tonpay-signature"] as string; * const payload = JSON.stringify(req.body); * * if (!verifySignature(payload, signature, YOUR_API_SECRET)) { * return res.status(401).json({ error: "Invalid signature" }); * } * * res.status(200).json({ received: true }); * }); * * // With object (will be stringified automatically) * app.post("/webhook", (req, res) => { * const signature = req.headers["x-tonpay-signature"] as string; * * if (!verifySignature(req.body, signature, YOUR_API_SECRET)) { * return res.status(401).json({ error: "Invalid signature" }); * } * * res.status(200).json({ received: true }); * }); * ``` */ declare function verifySignature(payload: string | object, signature: string, apiSecret: string): boolean; export { type APIOptions, type Chain, type CheckMoonpayGeoParams, type CheckMoonpayGeoResponse, type CheckMoonpayLimitsParams, type CheckMoonpayLimitsResponse, type CompletedTonPayTransferInfo, type CreateMoonpayTransferParams, type CreateMoonpayTransferResponse, type CreateTonPayTransferParams, type CreateTonPayTransferResponse, type GetTonPayTransferByBodyHashParams, type GetTonPayTransferByReferenceParams, type MoonpayAmountLimits, type MoonpayGeoResult, TON, type TransferCompletedWebhookPayload, type TransferRefundedWebhookPayload, USDT, type WebhookEventType, type WebhookPayload, checkMoonpayAvailability, checkMoonpayGeo, checkMoonpayLimits, createMoonpayTransfer, createTonPayTransfer, getTonPayTransferByBodyHash, getTonPayTransferByReference, verifySignature };