Skip to main content

Refund Order

POST /api/admin/orders/:id/refund
Processes a refund for a completed order by sending TRX from the admin wallet back to the customer’s wallet address. Creates a pending transaction record that will be confirmed by the blockchain. Authentication: Admin access required

Path Parameters

id
string
required
Order ID to refund

Requirements

  • Order must exist and have status completed
  • Order cannot already be refunded
  • Admin wallet must be configured with private key and address
  • Admin wallet must have sufficient TRX balance to cover the refund amount

Response

success
boolean
Indicates if the refund was successfully initiated
message
string
Status message (“Refund sent. Waiting for blockchain confirmation.”)
orderId
string
The ID of the refunded order
transaction
object

Response Example

{
  "success": true,
  "message": "Refund sent. Waiting for blockchain confirmation.",
  "orderId": "order123",
  "transaction": {
    "hash": "0xabc123def456...",
    "from": "TAdminWallet123...",
    "to": "TCustomerWallet456...",
    "amount": 299.99,
    "status": "pending"
  }
}

Error Responses

Order Not Found
{
  "error": "Order not found"
}
Order Already Refunded
{
  "error": "Order already refunded"
}
Order Not Completed
{
  "error": "Only completed orders can be refunded"
}
Admin Wallet Not Configured
{
  "error": "Admin wallet not configured"
}
Insufficient Admin Balance
{
  "error": "Insufficient admin balance for refund",
  "code": "INSUFFICIENT_ADMIN_BALANCE",
  "adminBalance": 100.50,
  "requiredAmount": 299.99
}
General Error
{
  "error": "Error message"
}

Notes

  • The refund creates a Transaction record with type refund, currency TRX, and network TRC-20
  • The transaction status is initially set to pending with 0 confirmations
  • The blockchain confirmation process will update the transaction status asynchronously
  • The order status will be updated to refunded once the blockchain transaction is confirmed

Build docs developers (and LLMs) love