POST
/
v1
/
order
/
pay
curl --location --request POST 'https://api.stateset.network/v1/order/pay' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token <token>' \
--data-raw '{
  "order_id": "ord_abc123def456",
  "payment_method": {
    "type": "usdc",
    "wallet_address": "cosmos1abc123def456...",
    "amount": {
      "value": "149.99",
      "denom": "usdc"
    }
  },
  "metadata": {
    "memo": "Payment for Order #12345",
    "reference_number": "INV-2024-001"
  }
}'
{
  "success": true,
  "transaction": {
    "tx_hash": "B8C6F2E4D9A1F3E5C7B9D1A3E5F7C9B1D3E5F7A9C1B3E5D7F9A1C3E5B7D9F1A3",
    "block_height": 1234567,
    "timestamp": "2024-01-15T10:30:45Z",
    "gas_used": "85432"
  },
  "payment": {
    "payment_id": "pay_xyz789ghi012",
    "order_id": "ord_abc123def456",
    "amount": {
      "value": "149.99",
      "denom": "usdc"
    },
    "status": "completed",
    "from_address": "cosmos1abc123def456...",
    "to_address": "cosmos1merchant789..."
  },
  "order": {
    "id": "ord_abc123def456",
    "status": "PAID",
    "payment_status": "paid",
    "paid_at": "2024-01-15T10:30:45Z"
  }
}

Overview

This endpoint processes USDC payments for orders on the StateSet Commerce Network. The payment is executed through smart contracts, ensuring secure and transparent transactions.

Body

order_id
string
required

The unique identifier of the order to be paid

payment_method
object
required

Payment method details for USDC payment

metadata
object

Additional metadata for the payment

Response

success
boolean

Indicates whether the payment was successful

transaction
object

Transaction details

payment
object

Payment details

order
object

Updated order details

Request Example

curl --location --request POST 'https://api.stateset.network/v1/order/pay' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token <token>' \
--data-raw '{
  "order_id": "ord_abc123def456",
  "payment_method": {
    "type": "usdc",
    "wallet_address": "cosmos1abc123def456...",
    "amount": {
      "value": "149.99",
      "denom": "usdc"
    }
  },
  "metadata": {
    "memo": "Payment for Order #12345",
    "reference_number": "INV-2024-001"
  }
}'

Response Example

{
  "success": true,
  "transaction": {
    "tx_hash": "B8C6F2E4D9A1F3E5C7B9D1A3E5F7C9B1D3E5F7A9C1B3E5D7F9A1C3E5B7D9F1A3",
    "block_height": 1234567,
    "timestamp": "2024-01-15T10:30:45Z",
    "gas_used": "85432"
  },
  "payment": {
    "payment_id": "pay_xyz789ghi012",
    "order_id": "ord_abc123def456",
    "amount": {
      "value": "149.99",
      "denom": "usdc"
    },
    "status": "completed",
    "from_address": "cosmos1abc123def456...",
    "to_address": "cosmos1merchant789..."
  },
  "order": {
    "id": "ord_abc123def456",
    "status": "PAID",
    "payment_status": "paid",
    "paid_at": "2024-01-15T10:30:45Z"
  }
}

Error Codes

CodeDescription
INSUFFICIENT_FUNDSThe wallet does not have enough USDC to complete the payment
ORDER_NOT_FOUNDThe specified order ID does not exist
ORDER_ALREADY_PAIDThe order has already been paid
INVALID_WALLET_ADDRESSThe provided wallet address is invalid
PAYMENT_EXPIREDThe payment window for this order has expired
NETWORK_ERRORThere was an error communicating with the blockchain
SMART_CONTRACT_ERRORThe smart contract execution failed

Notes

  • All payments are processed on the StateSet Commerce Network blockchain
  • USDC amounts must be specified as strings to avoid floating-point precision issues
  • The payment is atomic - either the entire payment succeeds or it fails completely
  • Gas fees are paid in STATE tokens, not USDC
  • Payments are final and cannot be reversed through the API (refunds must be processed separately)