This page describes how to work with orders in the Two-Coin payment system. Orders represent cryptocurrency purchase transactions with their entire lifecycle.

Order Lifecycle

An order goes through several states during its lifecycle:

1

Created

Order is initially created with an offer selected

2

Payment Pending

Waiting for customer to complete payment

3

Payment Received

Payment has been received but not yet processed

4

Final Status

Completed
Failed
Expired

Creating an Order

To create an order, you need to make a POST request to the /orders endpoint with the following information:

POST https://api.dev2coin.space/orders
{
  "offer_id": "ofr_123456",
  "target_address": "bc1q...",
  "customer_email": "[email protected]",
  "redirect_url": "https://your-site.com/order-complete"
}

The response will include the order details and a payment URL where the customer should be redirected to complete the payment.

Retrieving Order Details

You can retrieve details for a specific order by making a GET request to the /orders/{orderId} endpoint:

GET https://api.dev2coin.space/orders/ord_123456

Response:
{
  "order_id": "ord_123456",
  "status": "payment_pending",
  "created_at": 1673452800,
  "expires_at": 1673456400,
  "source_amount": 100,
  "source_currency": "USD",
  "target_amount": 0.003,
  "target_currency": "BTC",
  "target_address": "bc1q...",
  "payment_url": "https://payment.two-coin.com/pay/ord_123456",
  "payment_details": {
    // Payment method specific details
  }
}

Order Expiration

Orders have an expiration time, typically 60 minutes from creation. If payment is not completed within this timeframe, the order will expire and a new one will need to be created.

Order Notifications

You'll receive real-time updates about order status changes through webhooks. See the Webhooks section for more details.

Order History

You can retrieve a list of all orders for your merchant account by making a GET request to the /orders endpoint:

GET /orders?limit=10&offset=0

Response:
{
  "total": 42,
  "orders": [
    {
      "order_id": "ord_123456",
      "status": "completed",
      "created_at": 1673452800,
      "source_amount": 100,
      "source_currency": "USD",
      "target_amount": 0.003,
      "target_currency": "BTC"
    },
    // More orders...
  ]
}

Support

If you encounter any issues or have questions not addressed in this documentation, please contact our support team on Telegram at https://t.me/cs_2coin (@cs_2coin).