Get Order Details

By order ID, you can obtain detailed information about a specific order, including payment status, payment link, etc.

This interface requires authentication, for details please refer to Platform Token.

Interface Description

  • Request Method: GET
  • Request URL: https://platform.acedata.cloud/api/v1/orders/{order_id}/
  • Request Headers:
    • accept: application/json
    • authorization: Bearer {token}

Where {order_id} is the UUID of the order.

CURL Request Example

curl -X GET \
  -H "accept: application/json" \
  -H "authorization: Bearer {token}" \
  "https://platform.acedata.cloud/api/v1/orders/order-uuid-1234/"

Return Result Example

{
  "id": "order-uuid-1234",
  "user_id": "b87f67c1-b04f-4332-99a1-7a5e651331c6",
  "application_id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2",
  "package_id": "pkg-uuid",
  "amount": 500,
  "price": 49.99,
  "discount": 1.0,
  "pay_way": "Stripe",
  "pay_id": "pi_xxxxxx",
  "pay_url": null,
  "state": "Finished",
  "remaining_amount": 500,
  "applications": [
    {
      "id": "107f8d0f-e465-4a7e-a49e-d633d26f7aa2",
      "service_id": "d87e5e99-b797-4ade-9e73-b896896b0461",
      "remaining_amount": 993.221
    }
  ],
  "packages": [
    {
      "id": "pkg-uuid",
      "name": "500 Times Package",
      "type": "Usage",
      "price": 49.99,
      "amount": 500
    }
  ],
  "tags": null,
  "metadata": null,
  "created_at": "2024-06-15T10:00:00.000000Z",
  "updated_at": "2024-06-15T10:05:00.000000Z"
}

Applicable Scenarios

This interface is commonly used for:

  1. Querying Payment Status: Poll this interface after creating an order to check the state field to determine if the payment was successful.
  2. Getting Payment Link: When the order status is Pending, the pay_url field contains a valid payment link.
  3. Verifying Transaction Information: View order amount, package details, etc.

Code Example

Python:

import requests
import time

order_id = "order-uuid-1234"
url = f"https://platform.acedata.cloud/api/v1/orders/{order_id}/"
headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}"
}

# Polling to query order status
while True:
    response = requests.get(url, headers=headers)
    order = response.json()

    print(f"Order Status: {order['state']}")

    if order["state"] == "Finished":
        print("Payment successful, amount has been credited!")
        break
    elif order["state"] in ["Expired", "Failed"]:
        print("Order has expired or failed")
        break

    time.sleep(5)  # Query every 5 seconds