# Orders

This section describes methods for creating orders and obtaining order information

Orders functionality allows you to accept payments in a specified coin and network

## API Interaction Scheme

{% @mermaid/diagram content="sequenceDiagram
Client ->> Merchant: Payment request
Merchant ->> Onchainpay: Creating order
Onchainpay ->> Merchant: Order
Merchant ->> Client: Payment address of payment link

```
Note over Client: Sending coins

Onchainpay -->> Merchant: Payment webhook" %}
```

## Possible statuses

| Status      | Description                                          |
| ----------- | ---------------------------------------------------- |
| `init`      | Order created                                        |
| `error`     | Error during creation or execution                   |
| `processed` | Successful order payment                             |
| `pending`   | Upon receipt of the first payment                    |
| `expired`   | Order lifetime expired                               |
| `partial`   | The warrant expired, but was partially paid          |
| `overpaid`  | The order was paid in excess of the specified amount |

When the status changes or a new transaction arrives, you will be sent a webhook to the URL specified when creating the order.

More information about webhooks can be found in the **Webhooks** section

> #### Attention
>
> Please note that the statuses `processed`, `expired`, `partial`, `overpaid` \*\* are not final\*\*
>
> When processing a webhook, you should separately process the array of received transactions to correctly process the payment amount

## Order lifetime

When creating an order, selects an address from the pool of `PAY_IN` addresses of the organization.\
This address will not be available for other transactions during the entire life of the order.

Depending on the payment network, the minimum and maximum lifetime of an order may vary.

Minimum and maximum values for networks:

| Network       | Minimum value | Maximum value |
| ------------- | ------------- | ------------- |
| `ton`         | 1800          | 43200         |
| `bitcoin`     | 7200          | 43200         |
| `bitcoincash` | 7200          | 43200         |
| `bsc`         | 1800          | 43200         |
| `tron`        | 1800          | 43200         |
| `ethereum`    | 1800          | 43200         |
| `fantom`      | 1800          | 43200         |
| `litecoin`    | 3600          | 43200         |

## Lost transactions

In some cases, the payer may send to a coin address on another network or coin.\
Such transactions will be displayed in a separate `orphanDeposits` field when receiving a webhook\
or receiving order information via API.

You can see these transactions in your personal account in the **Payments -> Orphan Transactions** section.\
In this section, withdrawal of these coins to a third-party address will be available.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onchainpay.io/api-reference/05orders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
