import { CryptoAsset, FiatAsset, EstimatedExchange, EstimatedExchangeWithdraw, ExchangeDirection, Balance, Ipn, IpnReplenish, IpnInvoice, IpnWithdraw, IpnExchange, IpnWithdrawBatch, IpnWithdrawExchangeCrypto, IpnWithdrawExchangeFiat, IpnCryptoInvoice } from './interfaces'; import { IpnKind, IpnStatus, Blockchain } from './enums'; /** * 0xPay API SDK with methods and utilities * * @category SDK Client */ export declare class XPay { private readonly merchantId; private readonly privateKey; /** Shortcut for IpnKind enum */ static readonly IPN_KIND: typeof IpnKind; /** Shortcut for IpnStatus enum */ static readonly IPN_STATUS: typeof IpnStatus; private readonly url; private readonly signatureTTL; /** * @param merchantId - Merchant ID * @param privateKey - Merchant private key * @param options - Sdk options * @param options.signatureTTL - Time to live for webhook notifiations signature. Must be greater than 1 if provided * @param options.url - Url of public api */ constructor(merchantId: string, privateKey: string, options?: { signatureTTL?: number; url?: string; }); private generateSignature; private fetchWithAuthentication; /** * Get balances info * * This method is used to get merchants balances. * * @param tickers - Tickers of balances to get * * @returns Balances * * @throws {@link XPayApiError} if validation failed * * @category Merchant Info */ getBalances(tickers: string[]): Promise; /** * Create a deposit wallet address * * As said previously, you can generate new deposit addresses with receiving addresses feature. * For BEP20 & ERC20 networks: on creation, one wallet address will be generated and assigned for both networks, * and monitored for incoming transactions. * * @remarks * Deposit Updates: After a receiving address is created on a dedicated blockchain, * 0xPay will notify you about incoming transactions for all the assets supported on this blockchain. * * @param body - Request body * @param body.blockchain - Blockchain in which address will be created * @param body.meta - Metadata to catch it back later with a notification * @param body.target.ticker - The currency to which 0xPay will try to exchange all funds deposited to created address * @param body.target.address - The address, to which 0xPay will withdraw deposited funds in the currency specified in body.target.ticker (optional) * @param body.target.blockchain - Network in which withdrawal will be made, this field is required if body.target.address is provided (optional) * * @returns Receive address * * @throws {@link XPayApiError} if validation failed or exceed limit(not verified merchant) * * @category Basic Crypto Operations */ createReceiveAddress(body: { blockchain: Blockchain; meta?: string; target?: { ticker: string; } | { ticker: string; blockchain: Blockchain; address: string; }; }): Promise; /** * Reserve rotating address * * @param body.blockchain - Blockchain in which withdraw rotating address will be reserved * @param body.meta - Metadata to catch it back later with a notification * @param body.duration - Reservation time for address (in ms). Default duration equal to 1 day * @param body.durationAfterReplenishment - Reservation time after any replenishment (ex. if replenishment_time = n, then rotating_address.expiredAt = n + durationAfterReplenishment). Default value equal to 2 hours * @param body.target.ticker - The currency to which 0xPay will try to exchange the deposited funds * @param body.target.address - The address, to which 0xPay will withdraw invoice funds in the currency specified in body.target.ticker * @param body.target.blockchain - Network in which withdrawal will be made, this field is required if body.target.address is provided * @returns - Reserved address with expiration timestamp and metadata */ createRotatingAddress(body: { blockchain: Blockchain; meta: string; duration?: number; durationAfterReplenishment?: number; target?: { ticker: string; } | { ticker: string; blockchain: Blockchain; address: string; }; }): Promise<{ address: string; meta: string; expiredAt: number; }>; /** * Send cryptocurrency transaction * * Creates an outgoing cryptocurrency transaction. * * @remarks * 0xpay API will produce notifications according to status updates on your withdrawal. * * @param body - Request body * @param body.ticker - Currency ticker to withdraw * @param body.blockchain - Blockchain in which withdraw transaction will be created * @param body.to - Destination wallet address * @param body.amount - Amount in decimal format * @param body.fee - Precalculated fee. If not the specified – fee will be set automatically * @param body.localId - If was specified - error will be thrown if not unique * @param body.meta - Metadata to catch it back later with a notification * * @returns Withdraw id * * @throws {@link XPayApiError} if validation failed, not enough balance or not enough fee * * @category Basic Crypto Operations */ withdrawCrypto(body: { localId?: string; amount: string; to: string; ticker: string; blockchain: Blockchain; meta?: string; fee?: string; }): Promise; /** * Get crypto withdraw fee * * This method is used to get a fee for sending a desired amount of assets (ticker) on a chosen blockchain. * * @param amount - Withdraw amount in decimal format * @param ticker - Currency ticker to withdraw * @param blockchain - Blockchain in which withdraw transaction will be created * @param address - Destination wallet address(if you fill it in, we'll check if the transaction might be an internal transfer) * * @returns Withdraw fee * * @throws {@link XPayApiError} if validation failed * * @category Basic Crypto Operations */ getCryptoWithdrawalFee(amount: string, ticker: string, blockchain: Blockchain, address?: string): Promise; /** * List all supported crypto assets * * This method is used to fetch all available crypto assets of your merchant. * * @returns Array of all crypto assets with their ticker, name, price, and blockchain network * * @category Basic Crypto Operations */ getAvailableCryptoAssets(): Promise; /** * Send single fiat withdraw * * Creates an outgoing fiat transaction (for example, UAH payment to a banking card). * * @remarks * Amount limits: Min: 1000 UAH; Max: 14500 UAH. * After creation, 0xpay API will produce notifications according to status updates on your withdrawal. * * @param body - Request body * @param body.ticker - Currency ticker to withdraw(UAH) * @param body.to - Destination card number * @param body.amount - Amount in decimal format * @param body.fee - Precalculated fee. If not the specified – fee will be set automatically * @param body.localId - If was specified - error will be thrown if not unique * @param body.meta - Metadata to catch it back later with a notification * * @returns Withdraw id * * @throws {@link XPayApiError} if validation failed or not enough balance * * @category Basic Fiat Operations */ withdrawFiat(body: { localId?: string; amount: string; to: string; ticker: string; meta?: string; fee?: string; }): Promise; /** * Send fiat withdraws as batch * * Splits large fiat transactions into several smaller payments and sends them to destination. * * @remarks * Minimal limit: UAH 1000. * After creation, 0xpay API will produce notifications according to status updates on your withdrawal. * * Example: You want to send UAH 100,000 to a banking card. * Normally, that'd require creating 7 different requests of ~UAH 14,500. * With batched payments, your transaction amount will be automatically split into smaller portions: * (13800 + 13611 + 14120 + 13900 + 13831 + 13822 + 8447 + 8469 = 100 000), then sent as a batch of payments. * * @param body - Request body * @param body.ticker - Currency ticker to withdraw(UAH) * @param body.to - Destination card number * @param body.amount - Amount in decimal format * @param body.fee - Precalculated fee. If not the specified – fee will be set automatically * @param body.localId - If was specified - error will be thrown if not unique * @param body.meta - Metadata to catch it back later with a notification * * @returns Withdraw batch id * * @throws {@link XPayApiError} if validation failed, not enough balance or not enough fee * * @category Basic Fiat Operations */ withdrawFiatBatch(body: { localId?: string; amount: string; to: string; ticker: string; meta?: string; fee?: string; }): Promise; /** * Get fiat withdraw fee * * This method is used to get a fee for sending a desired amount of assets (ticker) on a chosen blockchain. * * @param amount - Amount in decimal format * @param ticker - Currency ticker to withdraw(UAH) * * @returns Withdraw fee * * @throws {@link XPayApiError} if validation failed * * @category Basic Fiat Operations */ getFiatWithdrawalFee(amount: string, ticker: string): Promise; /** * List all supported fiat assets * * This method is used to fetch all available fiat assets of your merchant. * * @returns Array of all crypto fiat with their ticker, name and price * * @category Basic Fiat Operations */ getAvailableFiatAssets(): Promise; /** * Create fiat invoice * * Creates a webpage with your fiat invoice details on 0xpay.app domain, usable for a one-time payment. * Currently, the only supported fiat ticker is UAH. * * @remarks * Payment limits: Min — 25 UAH, Max — 29999 UAH. * Status Updates: After creation, every invoice update will produce an invoice notification. * * @param body - Request body * @param body.email - User email * @param body.name - Descriptional field, name of your invoice. For example: "Order payment" * @param body.amount - Amount of invoice in decimal format with ticker * @param body.toPendingImmediate - Jump immediately to pending status, it can be useful if you want to skip fist "user prompt" status. * @param body.target.ticker - The currency to which 0xPay will try to exchange the received funds * @param body.target.address - The address, to which 0xPay will withdraw invoice funds in the currency specified in body.target.ticker * @param body.target.blockchain - Network in which withdrawal will be made, this field is required if body.target.address is provided * @returns Invoice url * * @throws {@link XPayApiError} if validation failed * * @category Fiat Invoices */ createFiatInvoice(body: { email?: string; name: string; amount?: { value: string; ticker: string; }; toPendingImmediate?: boolean; meta?: string; target?: { ticker: string; } | { ticker: string; blockchain: Blockchain; address: string; }; }): Promise; /** * Create crypto invoice * * Creates a webpage with your crypto invoice details on 0xpay.app domain, usable for a one-time payment. * * @remarks * Payment limits: Min — 25 UAH, Max — 29999 UAH. * Status Updates: After creation, every invoice update will produce an invoice notification. * * @param body - Request body * @param body.email - User email * @param body.name - Descriptional field, name of your invoice. For example: "Order payment" * @param body.baseAmount - If specified baseAmount.amount will be converted to the amount after a user clicks the "Continue" button on the invoice page. Useful when you want to bill your user with fiat assets but pay an invoice in crypto * @param body.baseAmount.ticker - Only fiat tickers supported now, available values: "UAH", "USD", "EUR" * @param body.baseAmount.value - Invoice amount in fiat currency * @param body.amount - Amount of invoice in decimal format with ticker and blockchain * @param body.amount.ticker - Crypto ticker of pay currency * @param body.amount.value - Invoice amount you want to receive from user, this value is optional if `baseAmount` provided * @param body.amount.blockchain - Blockchain network to pay * @param body.duration - The lifetime of crypto invoice in ms. Default: 72 hours * @param body.clientDuration - The lifetime of crypto invoice in ms on the frontend. Default: duration / 2 * @param body.toPendingImmediate - Jump immediately to pending status, it can be useful if you want to skip fist "user prompt" status. * @param body.target.ticker - The currency to which 0xPay will try to exchange the received funds * @param body.target.address - The address, to which 0xPay will withdraw invoice funds in the currency specified in body.target.ticker * @param body.target.blockchain - Network in which withdrawal will be made, this field is required if body.target.address is provided * * @returns Invoice url * * @throws {@link XPayApiError} if validation failed * * @category Crypto Invoices */ createCryptoInvoice(body: { email?: string; name: string; amount?: { value: string; ticker: string; }; duration?: number; clientDuration?: number; toPendingImmediate?: boolean; meta?: string; target?: { ticker: string; } | { ticker: string; blockchain: Blockchain; address: string; }; }): Promise; /** * Get available exchange directions * * Returned available directions to exchange with price and limits. * * @remarks * 1.Get available directions for exchange through 0xpay (tickers). * 2.Get 0xpay exchange limitations (min, max). * 3.Find the way how you should format your swaps (precision, step). * * @returns Exchange directions * * @category Exchange */ getAvailableExchangeDirections(): Promise; /** * Estimate exchange * * Estimate your exchange for later creation. * * @param body - Request body * @param body.targetTicker - Asset that you want to receive to your balance * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or receive * @param body.side - Your chosen direction, two possible values: target or spend * @param body.price - Actual price of the pair * * @returns Estimated exchange * * @throws {@link XPayApiError} if validation failed or not enough liquidity * * @category Exchange */ estimateExchange(body: { spendTicker: string; targetTicker: string; amount: string; side: 'spend' | 'target'; price?: string; }): Promise; /** * Exchange * * Create an exchange of two assets. * * @remark * Status Notifications: After the Success response, 0xpay API will produce notifications according to status updates on your exchange. * * @param body - Request body * @param body.targetTicker - Asset that you want to receive to your balance * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or receive * @param body.side - Your chosen direction, two possible values: target or spend * @param body.fee - Precalculated exchange fee * @param body.price - Actual price of the pair * @param body.meta - Metadata to catch it back later with a notification * @param body.localId - If was specified - error will be thrown if not unique * * @returns Exchange id * * @throws {@link XPayApiError} if validation failed, not enough liquidity, not enough balance or not enough fee * * @category Exchange */ exchange(body: { amount: string; side: 'spend' | 'target'; meta: string; spendTicker: string; fee: string; targetTicker: string; localId: string; price: string; }): Promise; /** * Estimate crypto withdrawal with exchange * * @param body - Request body * @param body.ticker - Ticker for withdrawal. Example: You want to spend (exchange) USDT and make a withdrawal in BTC (ticker value) * @param body.blockchain - Blockchain network for withdrawal * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or withdraw * @param body.side - Impacts amount field. When you want to withdraw the exact amount – specify the "withdraw" side. When you want to spend (exchange) an exact amount specify "exchange" * @param body.to - Destination wallet address(if you fill it in, we'll check if the transaction might be an internal transfer) * @param body.price - Actual price of the pair * * @returns Estimated crypto withdraw with exchange * * @throws {@link XPayApiError} if validation failed, not enough liquidity * * @category Withdraw With Exchange */ estimateExchangeWithdrawalCrypto(body: { price?: string; spendTicker: string; ticker: string; blockchain: Blockchain; amount: string; side: 'spend' | 'withdraw'; to?: string; }): Promise; /** * Estimate fiat withdrawal with exchange * * @param body - Request body * @param body.ticker - Ticker for withdrawal(only UAH available) * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or withdraw * @param body.side - Impacts amount field. When you want to withdraw the exact amount – specify the "withdraw" side. When you want to spend (exchange) an exact amount specify "exchange" * @param body.price - Actual price of the pair * * @returns Estimated fiat withdraw with exchange * * @throws {@link XPayApiError} if validation failed, not enough liquidity * * @category Withdraw With Exchange */ estimateExchangeWithdrawalFiat(body: { price?: string; spendTicker: string; ticker: string; amount: string; side: 'spend' | 'withdraw'; }): Promise; /** * Crypto Withdraw With Exchange * * @remark * Status Notifications: After the Success response, 0xpay API will produce notifications according to status updates on your exchange. * * @param body - Request body * @param body.ticker - Ticker for withdrawal. Example: You want to spend (exchange) USDT and make a withdrawal in BTC (ticker value) * @param body.blockchain - Blockchain network for withdrawal * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or withdraw * @param body.side - Impacts amount field. When you want to withdraw the exact amount – specify the "withdraw" side. When you want to spend (exchange) an exact amount specify "exchange" * @param body.to - Destination wallet address * @param body.price - Actual price of the pair * @param body.fee - Withdrawal fee * @param body.exchangeFee - Fee for exchange operation * @param body.meta - Metadata to catch it back later with a notification * @param body.localId - If was specified - error will be thrown if not unique * * @returns Crypto withdrawal with exchange id * * @throws {@link XPayApiError} if validation failed, not enough liquidity, not enough balance or not enough fee * * @category Withdraw With Exchange */ withdrawExchangeCrypto(body: { amount: string; side: 'spend' | 'withdraw'; localId: string; spendTicker: string; to: string; blockchain: Blockchain; fee: string; exchangeFee: string; ticker: string; meta: string; price: string; }): Promise; /** * Fiat Withdraw With Exchange * * @remark * Status Notifications: After the Success response, 0xpay API will produce notifications according to status updates on your exchange. * * @param body - Request body * @param body.ticker - Ticker for withdrawal(only UAh available) * @param body.spendTicker - Asset that you want to spend from your balance * @param body.amount - Amount you want to spend or withdraw * @param body.side - Impacts amount field. When you want to withdraw the exact amount – specify the "withdraw" side. When you want to spend (exchange) an exact amount specify "exchange" * @param body.to - Credit card number * @param body.price - Actual price of the pair * @param body.fee - Withdrawal fee * @param body.exchangeFee - Fee for exchange operation * @param body.meta - Metadata to catch it back later with a notification * @param body.localId - If was specified - error will be thrown if not unique * * @returns Crypto withdrawal with exchange id * * @throws {@link XPayApiError} if validation failed, not enough liquidity, not enough balance, not enough fee * * @category Withdraw With Exchange */ withdrawExchangeFiat(body: { amount: string; side: 'spend' | 'withdraw'; meta: string; spendTicker: string; to: string; fee: string; exchangeFee: string; ticker: string; localId: string; price: string; }): Promise; /** * Validate Webhook Requests * * @param payload - Request required payload * @param payload.method - Request method * @param payload.url - Request url * @param payload.rawBody - Request raw unparsed body * @param payload.signature - Request `signature` header * * @returns Code and description of validation error if failed * * @category Utilities */ validateWebhookRequest(payload: { method: string; url: string; rawBody: string; timestamp: number | string; signature: string; }): { code: -1 | -2 | -3; description: string; } | void; /** @category Utilities */ isIpnReplenish(ipn: Ipn): ipn is IpnReplenish; /** @category Utilities */ isIpnInvoice(ipn: Ipn): ipn is IpnInvoice; /** @category Utilities */ isIpnCryptoInvoice(ipn: Ipn): ipn is IpnCryptoInvoice; /** @category Utilities */ isIpnWithdraw(ipn: Ipn): ipn is IpnWithdraw; /** @category Utilities */ isIpnExchange(ipn: Ipn): ipn is IpnExchange; /** @category Utilities */ isIpnWithdrawBatch(ipn: Ipn): ipn is IpnWithdrawBatch; /** @category Utilities */ isIpnWithdrawExchangeCrypto(ipn: Ipn): ipn is IpnWithdrawExchangeCrypto; /** @category Utilities */ isIpnWithdrawExchangeFiat(ipn: Ipn): ipn is IpnWithdrawExchangeFiat; }