Creating invoice
POST /api/public/v1/invoices
This endpoint creates an invoice.
XRP Invoice Addresses Format:
For XRP invoices, addresses are returned in the following format:
rwCQVZLSMNY6DgMH61317qvH3nHYqm68PF?dt=xyzwhere xyz is a unique destination tag generated for each invoice.
A destination tag acts like a reference number in bank transfers, identifying the intended beneficiary of the transaction.
Displaying Invoice Deposit Addresses:
When showing the deposit address to your customers, separate the address and the destination tag, and ensure both are clearly viewable and copyable
Warning: If XRP is sent to the invoice address without specifying the destination tag, the deposit will not be processed.
cURL
curl -X "POST" "https://api.sandbox.txn.io/api/public/v1/invoices" \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer <api_key>' \
-d $'{
"data": {
"type": "invoices",
"attributes": {
"amountBilled": "10000",
"billedCurrency": "TRY",
"chargedCurrency": "USDT",
"network": "TTRX:USDT",
"targetCurrency": "EUR",
"targetAccountId": "13a85b45-8543-41c7-b963-394d4ea128ae",
"reference": "bc32c092-8979-4435-b176-ae1b790b1ca6",
"successRedirectUrl": "https://example.com/success",
"unsuccessRedirectUrl": "https://example.com/fail",
"paymentMethods": [
"on_chain"
]
}
}
}'Headers
Content-Type
application/vnd.api+json
Authorization
Bearer <api_key>
Request Body
data.type
string
Yes
Can only be invoices.
data.attributes.amountBilled
string
Yes
Invoice amount to display to end users. Determines the amount due after conversion.
data.attributes.billedCurrency
string
Yes
Invoice currency to display to end users. Refer to supported currencies.
data.attributes.chargedCurrency
string
Yes
Cryptocurrency that the customer must pay in. Refer to supported currencies.
data.attributes.targetCurrency
string
No
Specifies the account currency to which the invoice payment should be credited. Must be a tradable fiat or cryptocurrency listed on the Supported currencies page — display fiat currencies are not accepted. If omitted, defaults to the value of billedCurrency — in which case billedCurrency must itself be a tradable fiat or cryptocurrency, otherwise the request returns an error.
data.attributes.targetAccountId
string
No
Specifies the ID of the account to which the invoice payment should be credited. Can be a master or subaccount ID. If not present, the payment will be credited to your master account by default. Requires data.attributes.targetCurrency.
data.attributes.reference
string
No
The custom reference ID to tie the invoice to end-user who pays. This can be anything you choose. Must be a unique value for each invoice you create.
data.attributes.successRedirectUrl
string
No
URL you want your customer to be redirected from our hosted page to if the invoice completes.
data.attributes.unsuccessRedirectUrl
string
No
URL you want your customer to be redirected from our hosted page to if the invoice gets expired, cancelled or rejected.
data.attributes.paymentMethods
array
No
An array listing the supported payment methods for a particular invoice. The array currently accepts exactly one value (multi-method support is reserved for future use).
Allowed values:
"on_chain"- Generates a deposit wallet address for receiving an on-chain cryptocurrency transaction. Users can send crypto directly from their wallet."binance_pay"- Generates payment instructions for an off-chain payment via the Binance app, allowing users to complete the transaction within Binance."nft"- Generates payment instructions for purchasing an NFT. See the NFT invoice integration guide.
If omitted, defaults to ["on_chain"].
Response Body
data.id
string
Invoice ID.
data.type
string
Entity type returned. Always invoices.
data.attributes
object
Set of invoice attributes.
data.attributes.amountBilled
string
Invoice amount to display to end users. Determines the amount due after conversion.
data.attributes.amountCharged
string
Amount due. Determines the amount of cryptocurrency the end-user is required to pay.
data.attributes.targetAmount
string
Amount you will receive into your target currency account.
data.attributes.billedCurrency
string
Invoice currency to display to end users. Determines the currency due after conversion. Refer to supported currencies.
data.attributes.chargedCurrency
string
Cryptocurrency that the customer must pay in. Refer to supported currencies.
data.attributes.targetCurrency
string
Settlement currency. This is the currency you will receive in your account after the payment is processed.
data.attributes.targetAccountId
string
The ID of the account to which the invoice payment is credited.
data.attributes.chargedTargetRate
string
Charged currency to target currency exchange rate.
data.attributes.chargedTargetRateCurrency
string
Currency in which chargedTargetRate is quoted.
data.attributes.reference
string
The custom reference ID to tie the invoice to end-user who pays. This can be anything you choose.
data.attributes.statusContext
string
Indicates whether the end-user paid in full, underpaid, overpaid, or has not paid (unpaid) the invoice. Refer to Invoice status flow.
data.attributes.networkName
string
Network name to display.
data.attributes.paymentMethods
array
Invoice payment methods.
data.attributes.successRedirectUrl
string
URL your customer will be redirected from our hosted page to if the invoice completes.
data.attributes.unsuccessRedirectUrl
string
URL your customer will be redirected from our hosted page to if the invoice gets expired, cancelled or rejected.
data.attributes.exchangeRate
string
Invoice exchange rate valid for 20 minutes.
data.attributes.expiresAt
string
Invoice expiry date and time.
data.attributes.createdAt
string
Date and time invoice was created at.
data.attributes.hostedPageUrl
string
Invoice hosted page.
data.attributes.scAddress
string
Smart contract address configured for the NFT payment feature. Returns null if the feature is not enabled on the merchant account.
included.type(addresses).attributes
object
Invoice receiving address. This is the address the end-user must send their cryptocurrency payment to.
included.type(binanceOrders).attributes
object
Payment instructions for an off-chain payment via the Binance application.
included.type(accounts).attributes
object
The target account the invoice payment is credited to. Includes standard account fields: currencyCode, balance, bankWithdrawalAvailable, bankDepositAvailable, transferAvailable, etc.
Response
Amount too low.
Amount too high.
Duplicate reference.
Last updated