Payment Order

After the user creates an order, this interface needs to be called to complete the payment process. The system supports WeChat Pay, Alipay, Stripe, and X402 cryptocurrency payments.

Prerequisites

  1. Register and log in to the Ace Data Cloud platform.
  2. Obtain the Platform Token, for details please refer to the Platform Token Documentation.
  3. An order with a Pending status has been generated through the create order interface.

Interface Description

  • Request Method: POST
  • Request URL: https://platform.acedata.cloud/api/v1/orders/{id}/pay/
  • Request Headers:
    • accept: application/json
    • authorization: Bearer {token}
    • content-type: application/json

Where {id} is the order UUID, and {token} is the Platform Token.

Request Parameters

Parameter Type Required Description
pay_way string Yes (required when amount > 0) Payment method, optional values: WECHATPAY, ALIPAY, STRIPE, X402
surface string No Payment scenario, such as native (QR code), h5 (mobile), different pay_way supports different scenarios

Note: If the order amount is 0 (for example, using a free plan), there is no need to pass in pay_way, the system will automatically complete the payment.

CURL Request Example

curl -X POST \
  -H "accept: application/json" \
  -H "authorization: Bearer {token}" \
  -H "content-type: application/json" \
  -d '{"pay_way": "STRIPE"}' \
  "https://platform.acedata.cloud/api/v1/orders/{id}/pay/"

Response Result Example

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "state": "Pending",
  "pay_way": "STRIPE",
  "pay_url": "https://buy.stripe.com/xxxxxxxxxxxx",
  "pay_id": "plink_xxxxxxxxxxxx",
  "price": "9.90",
  "currency": "USD",
  "service": {
    "id": "xxxx-xxxx-xxxx",
    "name": "ChatGPT",
    "alias": "chatgpt"
  },
  "packages": [...],
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:05Z"
}

Response Field Description

Field Type Description
id string Unique identifier for the order
state string Order status: Pending (waiting for payment), Paid (paid), Finished (completed)
pay_way string Payment method
pay_url string Payment link (the user needs to redirect to this link to complete the payment)
pay_id string Payment identifier from the third-party payment system
price string Order amount
currency string Currency type

Payment Method Description

pay_way Description Currency
STRIPE Stripe international payment, supports credit/debit cards USD
WECHATPAY WeChat Pay CNY (automatic exchange rate conversion)
ALIPAY Alipay CNY (automatic exchange rate conversion)
X402 Cryptocurrency payment (USDC), supports Base/Solana chain USDC

Payment Process

  1. Create Order: Call POST /api/v1/orders/ to create an order.
  2. Initiate Payment: Call this interface, pass in pay_way, and obtain pay_url.
  3. User Payment: Guide the user to pay_url to complete the payment.
  4. Check Status: Call POST /api/v1/orders/{id}/refresh/ to check the latest status, or wait for the Webhook callback to update automatically.

Code Example

Python:

import requests

token = "your-platform-token"
order_id = "your-order-id"
url = f"https://platform.acedata.cloud/api/v1/orders/{order_id}/pay/"
headers = {
    "accept": "application/json",
    "authorization": f"Bearer {token}",
    "content-type": "application/json",
}
data = {"pay_way": "STRIPE"}

response = requests.post(url, json=data, headers=headers)
result = response.json()

if result.get("pay_url"):
    print(f"Please visit the following link to complete the payment: {result['pay_url']}")
else:
    print(f"Order status: {result['state']}")

Node.js:

const axios = require("axios");

const token = "your-platform-token";
const orderId = "your-order-id";
const url = `https://platform.acedata.cloud/api/v1/orders/${orderId}/pay/`;

const response = await axios.post(
  url,
  { pay_way: "STRIPE" },
  {
    headers: {
      accept: "application/json",
      authorization: `Bearer ${token}`,
      "content-type": "application/json",
    },
  },
);

if (response.data.pay_url) {
  console.log(`Please visit the following link to complete the payment: ${response.data.pay_url}`);
}