Przejdź do głównej zawartości

Create Payment

POST
/payments/

Creates a new cryptocurrency payment request. This endpoint generates a unique EVM address for your customer to send ERC20 tokens to.

Authentication

Requires OAuth 2.0 authentication with read and write scopes.

Request Body

Specify the cryptocurrency using either:

  • pay_currency - Combined currency code (e.g., "USDTERC20")
  • blockchain + token - Separate fields (e.g., "ethereum" + "USDT")
ParameterTypeRequiredDescription
price_amountdecimalYesAmount to charge in price currency (e.g., 100.00)
price_currencystringYesCurrency for the price amount. Currently only "USD" supported
pay_currencystringConditionalCryptocurrency code (e.g., "USDTERC20", "USDCERC20", "DAIERC20"). Required if blockchain/token not provided
blockchainstringConditionalBlockchain network (e.g., "ethereum", "polygon", "bsc"). Required with token if pay_currency not provided
tokenstringConditionalToken symbol (e.g., "USDT", "USDC", "DAI"). Required with blockchain if pay_currency not provided
order_idstringNoYour internal order ID. Auto-generated if not provided. Max 100 characters
order_descriptionstringNoDescription of the order/payment
callback_urlstringNoURL for webhook notifications about payment status changes
success_urlstringNoURL to redirect customer after successful payment
cancel_urlstringNoURL to redirect customer if payment is cancelled
partially_payments_allowbooleanNoAllow partial payments. Default: false
is_fixed_ratebooleanNoUse fixed exchange rate. Default: true
is_fee_paid_by_userbooleanNoWhether user pays network fees. Default: true

Example Request

Using pay_currency:

curl -X POST https://api.cryptofuse.io/payments/ \
-H "Authorization: Bearer your_access_token" \
-H "Content-Type: application/json" \
-d '{
"price_amount": 100.00,
"price_currency": "USD",
"pay_currency": "USDTERC20",
"order_id": "ORDER-12345",
"order_description": "Premium subscription",
"callback_url": "https://your-site.com/webhook/payment"
}'

Using blockchain + token:

curl -X POST https://api.cryptofuse.io/payments/ \
-H "Authorization: Bearer your_access_token" \
-H "Content-Type: application/json" \
-d '{
"price_amount": 100.00,
"price_currency": "USD",
"blockchain": "ethereum",
"token": "USDT",
"order_id": "ORDER-12345",
"callback_url": "https://your-site.com/webhook/payment"
}'

Response

Success Response (201 Created)

{
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "waiting",
"provider": "transaction_manager",
"price_amount": "100.00",
"price_currency": "USD",
"pay_amount": "100.050000",
"pay_currency": "USDTERC20",
"blockchain_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f8b8E0",
"blockchain_network": "ETH",
"token": "USDT",
"expiry_time": "2025-01-15T10:30:00Z",
"order_id": "ORDER-12345",
"order_description": "Premium subscription",
"callback_url": "https://your-site.com/webhook/payment",
"is_fixed_rate": true,
"is_fee_paid_by_user": true,
"created_at": "2025-01-15T10:00:00Z",
"updated_at": "2025-01-15T10:00:00Z"
}

Response Fields

FieldTypeDescription
transaction_iduuidUnique payment identifier. Store this for status checks
statusstringCurrent payment status. Initially "waiting"
blockchain_addressstringEVM address where customer should send payment
pay_amountstringExact amount customer must send (includes fees if user pays)
pay_currencystringFull currency code for the payment
expiry_timedatetimeISO 8601 timestamp when payment expires

Error Responses

400 Bad Request

{
"error": {
"code": "invalid_request",
"message": "Invalid request parameters",
"details": {
"price_amount": ["This field is required."]
}
}
}

422 Unprocessable Entity

{
"error": {
"code": "invalid_currency",
"message": "Currency FAKECOIN is not supported",
"details": {
"supported_currencies": ["USDTERC20", "USDCERC20", "DAIERC20"]
}
}
}

Payment Status Values

StatusDescription
waitingWaiting for payment from customer
confirmingPayment received, waiting for blockchain confirmations
confirmedPayment confirmed on blockchain
sendingProcessing payment to merchant wallet
completedPayment successfully completed
expiredPayment window expired without payment
failedPayment failed

Supported Currencies

ERC20 Tokens (Ethereum)

  • USDTERC20 - Tether USD
  • USDCERC20 - USD Coin
  • DAIERC20 - DAI Stablecoin

Other Networks

Use blockchain + token combination for other networks:

  • Polygon: blockchain="polygon", token="USDT"
  • BSC: blockchain="bsc", token="USDT"
  • Arbitrum: blockchain="arbitrum", token="USDT"

Important Notes

  • Payments expire after 30 minutes by default
  • Each payment generates a unique EVM address
  • Addresses are single-use and monitored only until expiry
  • Store the transaction_id to track payment status
  • Implement webhook handler for real-time status updates
  • All amounts are in decimal format with up to 8 decimal places

Testing

In the staging environment, use these amounts for testing:

  • 123.45 USD - Instant success
  • 666.66 USD - Instant failure
  • 100.00 USD - Normal flow with confirmations

Next Steps