Creating payment link payment
POST /api/public/v1/payment_links/:id/payment
Creates the child invoice of an invoice payment link with a cryptocurrency and network you choose, instead of letting the end user choose on the hosted page. Use it when your own checkout collects that choice. The invoice takes the link's amount, currency, reference, payment methods and redirect URLs, and the response returns it together with its deposit address.
After the call the payment link is pending and the invoice follows the invoice status flow. The invoice expires after your account's payment-link invoice period (20 minutes by default), independently of the link's own expiresAt. A link accepts one payment: once its invoice exists, further calls return 422.
Headers
Content-Type
application/vnd.api+json
Authorization
Bearer <api_key>
Path Parameters
id
Payment link ID. The link must have status created or pending.
Request Body
data.type
string
Yes
Always payment_links.
data.attributes.chargedCurrency
string
Yes
Cryptocurrency the customer pays with. Must be one of the link's payCurrencies.
data.attributes.network
string
Yes
Network code for chargedCurrency. See Listing invoice currencies and networks.
cURL
curl -X "POST" "https://api.sandbox.txn.io/api/public/v1/payment_links/3b1896d1-326b-4a39-9dd5-36aeb9ef3058/payment" \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer <api_key>' \
-d $'{
"data": {
"type": "payment_links",
"attributes": {
"chargedCurrency": "USDT",
"network": "ttrx:usdt"
}
}
}'Response Body
data
object
The payment link, with the same attributes as Reading payment link. status is pending, network and networkName are set, and relationships.target.data points at the invoice.
data.relationships.target
object
The child invoice. data.type is invoices; the entity is returned in included[].
included[].type(invoices)
object
The child invoice (data.relationships.target), with the same attributes as Reading invoice. Its hostedPageUrl is the invoice payment page.
included[].type(invoices).relationships
object
address, invoiceTransactions and coinDeposits are expanded; their entities are returned in included[] and described below (coinDeposits is empty, no payment has been received yet). targetAccount, binanceOrder and refundLinks are not expanded (meta.included is false); read the invoice to get them.
included[].type(addresses)
object
The receiving address of the invoice (included[].type(invoices).relationships.address).
included[].type(addresses).attributes.value
string
The address the end user must send the payment to. For XRP the destination tag is appended as ?dt=<tag>; display both parts, see the invoice integration guide.
included[].type(addresses).attributes.label
string
Address label. For invoice addresses this is the network name, e.g. Tron (TRC20).
included[].type(addresses).attributes.createdAt
string
When the address was created. Invoice addresses are allocated from a pool, so this can predate the invoice.
included[].type(addresses).relationships
object
account and network: not expanded (meta.included is false); use data.attributes.network and data.attributes.networkName.
included[].type(invoiceTransactions)
object
The settlement record of the invoice: the amounts to settle and the fees charged. Created with the invoice and updated when the payment is applied. Its id equals the id of the related transactions entity.
included[].type(invoiceTransactions).attributes.amountBilled
string
The actual payment amount in billedCurrency, reflecting what the end-user's crypto payment converted to. Use this field to credit the end-user's balance on your platform. In a full payment it equals the original invoice amount; for underpayments and overpayments, Txn applies the spot exchange rate to the crypto actually received, so this value will differ. Pre-fee — see transactionFee and targetTransactionFee for the fee breakdown.
included[].type(invoiceTransactions).attributes.billedChargedRate
string
Rate used to convert billedCurrency into chargedCurrency, including your spread. Same value as included[].type(invoices).attributes.exchangeRate.
included[].type(invoiceTransactions).attributes.billedChargedRateCurrency
string
Currency the rate is quoted in. Equals billedCurrency.
included[].type(invoiceTransactions).attributes.transactionFee
string
Txn processing fee in transactionFeeCurrency: amountBilled multiplied by your invoice fee percentage, subject to the minimum fee configured for your account.
included[].type(invoiceTransactions).attributes.transactionFeeCurrency
string
Equals billedCurrency.
included[].type(invoiceTransactions).attributes.consolidationFee
string
Network fee for consolidating the received funds from the invoice address, quoted in billedCurrency. 0.00 when your account is not charged consolidation fees.
included[].type(invoiceTransactions).attributes.targetTransactionFee
string
transactionFee converted into targetCurrency. This is the amount deducted from what is credited to the target account.
included[].type(invoiceTransactions).attributes.targetTransactionFeeCurrency
string
Equals targetCurrency.
included[].type(invoiceTransactions).attributes.simplifiedState
string
Status of the settlement on the target account: pending until a payment is applied (it stays pending for invoices that expire or are cancelled unpaid), on_hold while a received payment is under review, completed once credited, cancelled when a received payment was rejected. Same value as the related transactions entity. See Transaction statuses.
included[].type(invoiceTransactions).relationships.txn
object
The account transaction crediting the target account. data.type is transactions; the entity is returned in included[].
included[].type(invoiceTransactions).relationships.exchangeQuote
object
The conversion of the received crypto into targetCurrency; data.type is exchangeQuotes. data is null here: the quote is created when the invoice completes, and only when chargedCurrency differs from targetCurrency.
included[].type(invoiceTransactions).relationships
object
account, invoice and author: not expanded (meta.included is false).
included[].type(transactions)
object
The balance movement on the target account for this invoice, in the shape returned by Listing transactions. Its id equals the invoiceTransactions id.
included[].type(transactions).attributes.amount
string
Amount credited to the target account in currency, net of fees. Equals included[].type(invoices).attributes.targetAmount until a payment is applied and is then set to the settled amount, so it differs from targetAmount on underpayment and overpayment.
included[].type(transactions).attributes.currency
string
Equals included[].type(invoices).attributes.targetCurrency.
included[].type(transactions).attributes.simplifiedState
string
Same value as included[].type(invoiceTransactions).attributes.simplifiedState.
included[].type(transactions).attributes.transactionType
string
Always InvoiceTransaction.
included[].type(transactions).attributes.balance
string
Always null here. The running balance is only computed by the transaction listings.
included[].type(transactions).attributes.reference
string
The invoice reference.
included[].type(transactions).attributes.accountId
string
ID of the target account.
included[].type(transactions).attributes.createdAt
string
When the invoice was created.
included[].type(transactions).relationships
object
account, transactionDetails and author: not expanded (meta.included is false).
Response
Last updated