> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opencharge.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Order Status

> Return the current payment status of an order

<Info>
  Payment apps and customers poll this endpoint to check if an order has been paid.
</Info>

## Status Values

| Status      | Description                     |
| ----------- | ------------------------------- |
| `pending`   | Order created, awaiting payment |
| `paid`      | Payment received and verified   |
| `expired`   | Order expired before payment    |
| `cancelled` | Order was cancelled             |

## Implementation

When you receive a transfer webhook notification, update your order status to `paid` and store the transaction ID. This endpoint should return that status.

```javascript theme={null}
app.get('/orders/:orderId/status', (req, res) => {
  const order = db.getOrder(req.params.orderId);

  if (!order) {
    return res.status(404).json({
      error: { code: 'ORDER_NOT_FOUND', message: 'Order not found' }
    });
  }

  res.json({
    orderId: order.id,
    status: order.status,
    paidAt: order.paidAt,
    txid: order.txid
  });
});
```

## Example Response

**Pending order:**

```json theme={null}
{
  "orderId": "ord_abc123",
  "status": "pending"
}
```

**Paid order:**

```json theme={null}
{
  "orderId": "ord_abc123",
  "status": "paid",
  "paidAt": 1706313900,
  "txid": "tx_xyz789"
}
```


## OpenAPI

````yaml merchant-api/endpoint/merchant-api/openapi.json get /orders/{orderId}/status
openapi: 3.1.0
info:
  title: Opencharge Merchant API
  description: >-
    API specification for merchants integrating with the Opencharge protocol.
    These endpoints are implemented by merchants and called by payment apps and
    gateways.
  version: 0.1.0
  license:
    name: MIT
servers:
  - url: https://api.merchant.example/opencharge
    description: Example merchant Opencharge endpoint
security: []
paths:
  /orders/{orderId}/status:
    get:
      summary: Get order status
      description: >-
        Return the current payment status of an order. Payment apps and
        customers call this endpoint to check if an order has been paid.
      operationId: getOrderStatus
      parameters:
        - name: orderId
          in: path
          required: true
          description: The order ID from the signed order object
          schema:
            type: string
      responses:
        '200':
          description: Order status retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderStatusResponse'
              example:
                orderId: ord_abc123
                status: paid
                paidAt: 1706313900
                txid: tx_xyz789
        '404':
          description: Order not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    OrderStatusResponse:
      type: object
      required:
        - orderId
        - status
      description: Current payment status of an order
      properties:
        orderId:
          type: string
          description: The order ID
        status:
          type: string
          enum:
            - pending
            - paid
            - expired
            - cancelled
          description: Current payment status
        paidAt:
          type: integer
          description: Unix timestamp when order was paid
        txid:
          type: string
          description: Transaction ID of the payment
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Error code
              enum:
                - INVALID_SIGNATURE
                - TIMESTAMP_EXPIRED
                - NONCE_REUSED
                - UNKNOWN_OCID
                - INVALID_PROOF
                - PROOF_SIGNATURE_INVALID
                - ISSUER_NOT_ACCEPTED
                - ORDER_NOT_FOUND
                - ORDER_EXPIRED
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              description: Additional error context

````