Skip to main content

Creating crypto payment

Preparation

Before you can start accepting payments automatically, you need to make settings and specify callback URL. Also you need get API token

Creating an invoice

Request at crypto currency

An example of a request to create an invoice in processing

POST https://api.xamax.io/v1/transaction/invoice HTTP/1.1
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json

{
"txId": "400",
"code": "usdt",
"amount": "20000000"
}
ParameterTypeDescriptionDefault valueExample
txId *stringUnique end-to-end transaction identifier of the merchant (platform). Used to map a transaction in processing to a transaction in the merchant system100
code *stringCrypto codeusdt
amount *string

Requested amount in blockchain units
1 ETH = 1000000000000000000 wei
1 BTC = 100000000 satoshi
1 USDT = 1000000 units


There are restrictions on the minimum replenishment amount
100000000
expiredAtstringThe maximum lifetime of a transaction. It is recommended to do no more than 30 minutes to avoid a sharp change in cryptocurrency rates30 minutes2022-12-01T11:31:30.685Z
* - Required parameter

Response

ParameterTypeDescription
txIdstringMerchant internal transaction id
walletAddressstringWallet address
walletTypestringAllowed values:
wallet_type_unknown
wallet_type_operation
wallet_type_user
wallet_type_invoice
wallet_type_cold
wallet_type_system

Default:wallet_type_unknown
codeRequestedstringCryptocurrency code requested
amountRequiredstringMerchant transaction required amount. Your amount should be greater then amountRequired. Check the minimum limit
amountRequiredUnitstringMerchant transaction required amount. Your amountUnit should be greater then amountRequiredUnit. Check the minimum limit
expiredAtstringTransaction expiration date. RFC3339 format. It is empty for invoice_type_user
statusstringTransaction status
txHash *stringTransaction hash
amount *stringReceived amount from client
amountUnit *stringReceived amount from client. Human readable
confirmations *stringTransaction confirmation in blockchain
createdAtstringTransaction creation date. RFC3339 format
processingFeePercentstringProcessing fee in percent
processingFeestringProcessing fee
ExchangeRate.currencystringCurrency name
ExchangeRate.exchangeRatestringExchange rate from currency to crypto
ExchangeRate.currencyAmountstringMultiply exchange rate to cryptocurrency
ExchangeRate.codestringCryptocurrency code
ExchangeRate *stringMerchant internal transaction id
Link *stringMerchant internal transaction id
Link.walletstringWallet address for this transaction
Link.payment_linkstringGenerated payment link for client's payment of the transaction
Link.onramp_linkstringGenerated link to "Pay by card" for client's payment of the transaction. Available only for Bitcoin, Ethereum, Tether USD (ERC-20 and TRC-20), BSCUSD (BEP-20), Litecoin, Tron, Bitcoin Cash
id *stringInternal ID
* - Returns only at waiting or completed transactions

Request at fiat currency

An example of a request to create an invoice in processing

POST https://api.xamax.io/v1/transaction/invoice HTTP/1.1
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json

{
"txId": "150201",
"code": "eth",
"type": "invoice_type_default",
"fiat": {
"amount": 1000,
"currnecy": "usd"
}
}
ParameterTypeDescriptionDefault valueExample
txId *stringUnique end-to-end transaction identifier of the merchant (platform). Used to map a transaction in processing to a transaction in the merchant system100
code *stringCrypto code of currency, which You want to receiveusdt
type *stringType of invoice. More details is hereinvoice_type_default
Fiat.Amount *stringRequested amount in FIAT currency1000
Fiat.Currency *stringRequested FIAT currencyusd
* - Required parameter

Response

ParameterTypeDescription
txIdstringMerchant internal transaction id
walletAddressstringWallet address
walletTypestringAllowed values:
wallet_type_unknown
wallet_type_operation
wallet_type_user
wallet_type_invoice
wallet_type_cold
wallet_type_system

Default:wallet_type_unknown
codeRequestedstringCryptocurrency code requested
amountRequiredstringMerchant transaction required amount. Your amount should be greater then amountRequired. Check the minimum limit
amountRequiredUnitstringMerchant transaction required amount. Your amountUnit should be greater then amountRequiredUnit. Check the minimum limit
expiredAtstringTransaction expiration date. RFC3339 format. It is empty for invoice_type_user
statusstringTransaction status
txHash *stringTransaction hash
amount *stringReceived amount from client
amountUnit *stringReceived amount from client. Human readable
confirmations *stringTransaction confirmation in blockchain
createdAtstringTransaction creation date. RFC3339 format
processingFeePercentstringProcessing fee in percent
processingFeestringProcessing fee
ExchangeRate.currencystringCurrency name
ExchangeRate.exchangeRatestringExchange rate from currency to crypto
ExchangeRate.currencyAmountstringMultiply exchange rate to cryptocurrency
ExchangeRate.codestringCryptocurrency code
ExchangeRate *stringMerchant internal transaction id
Link *stringMerchant internal transaction id
id *stringInternal ID
Link.walletstringWallet address for this transaction
Link.payment_linkstringGenerated payment link for client's payment of the transaction
Link.onramp_linkstringGenerated link to "Pay by card" for client's payment of the transaction. Available only for Bitcoin, Ethereum, Tether USD (ERC-20 and TRC-20), BSCUSD (BEP-20), Litecoin, Tron, Bitcoin Cash
* - Returns only at waiting or completed transactions

Transaction status

StatusValueDescription
Pendingtransaction_status_pendingNew transaction
Sendingtransaction_status_sendingTransaction sending to blockchain
Waitingtransaction_status_waitingTransaction in blockchain, wait confirmation
Confirmedtransaction_status_confirmedTransaction confirmed in blockchain
Failedtransaction_status_failedTransaction failed in blockchain. In case of problems on the part of the blockchain, the transaction from waiting can go to failed.
Processingtransaction_status_processingTransaction processing *reserved
Cancelledtransaction_status_canceledTransaction cancelled in processing. The cancelled status is not used, since it is necessary to catch the transaction before it goes to the blockchain, and this is a fairly short period of time. so not used yet. *reserved
Skippedtransaction_status_skippedTransaction processing is skipped. *reserved
Dusttransaction_status_dustTransaction incoming amount is small.
Check requiredtransaction_status_check_requiredNeed some manual check. The status of a manual check by support or a check before a refund.
Approve requiredtransaction_status_approve_requiredRequired manual approve for new transactions from merchant
Processedtransaction_status_processedTransaction processed
Refundtransaction_status_refundTransaction marked for refund. *reserved
Refundingtransaction_status_refundingTransaction in refund process
Refundedtransaction_status_refundedTransaction refunded
Expiredtransaction_status_expiredTransaction expired

Customer payment

After creating an invoice, the client needs to show:

  • or the address from the walletAddress field and the replenishment amount from amountRequired or amountRequiredUnit. The client must make the payment in single transaction that contains the requested amount to the last decimal place;
  • or send URL of payment link and client pay the transaction
  • or send URL of onramp link (if available)

After the client completes the transaction, a callback will be sent to the backend of the merchant. How to process them, see the section Transaction confirmation and callback processing

tip

The requested amount may differ from the amount specified by the processing in the amountRequired field. The amount may differ by the minimum blockchain units and may not exceed 1 cent in dollar terms.