Skip to content
Last updated

6. API Documentation (Hosted Checkout Mode)

Hosted Checkout mode is Infini's most recommended integration method. Merchants only need to create orders, redirect to checkout_url, and handle Webhooks to complete payment integration. This chapter only contains API documentation and corresponding field descriptions for Hosted Checkout mode.

All API prefix:

/v1/acquiring

6.1 Create Order

POST /v1/acquiring/order

Used to create an order and return the hosted checkout access URL (checkout_url).

Headers

Content-Type: application/json
Date: {GMT Time}
Authorization: Signature ...

Request Body

FieldTypeRequiredDescription
amountstring/numberYesOrder fiat amount (up to 6 decimal places)
currencystringYesFiat currency, e.g. "USD"
request_idstringYesMerchant-generated idempotency key, UUID "a759b99a-9d22-433d-bced-ab1d2e1bea1d"
client_referencestringNoMerchant custom order number, recommended to be unique
descriptionstringNoOrder description
expires_innumberNoOrder expiration relative time (Unix seconds); use backend default if not provided
merchant_aliasstringNoMerchant display name (overrides backend configuration)
success_urlstringNoRedirect address after successful order payment
failure_urlstringNoRedirect address after failed order payment

Response Example

{
  "order_id": "10290d05-xxxx",
  "amount": "100",
  "currency": "USD",
  "checkout_url": "https://checkout.infini.money/pay/xxxx",
  "expires_in": 3600
}

6.2 Query Order

GET /v1/acquiring/order?order_id ={order_id}

Returns real-time order status information.

Order Status Field Description

status - Payment Progress Status

Real-time calculated field reflecting the order's current payment progress (based on amount_confirmed vs order_amount).

ValueDescription
pendingAwaiting payment, no funds received
partial_paidPartial payment, received partial funds but insufficient
paidPaid, received sufficient funds
overpaidOverpaid, received funds exceed order amount
expiredExpired
closedExpired with only partial funds received
pay_status - Order Processing Status

Database stored field recording the order's processing status.

ValueDescription
pendingAwaiting payment
processingProcessing (partial funds received)
paidPaid
partial_paidPartial payment expired
expiredExpired without payment

Webhook Events The status field in Webhook is consistent with pay_status in the query interface.

Response Example

{
  "order_id": "ord-123",
  "status": "processing",
  "pay_status": "processing",
  "amount": "100",
  "currency": "USD",
  "amount_confirming": "0",
  "amount_confirmed": "0.5",
  "expires_at": 1763512195,
  "created_at": 1763512000,
  "exception_tags": ["wrong_currency"],
  "client_reference": "ORDER-001"
}

6.3 Reissue Checkout Token

POST /v1/acquiring/token/reissue

Used to regenerate the hosted checkout URL, suitable for scenarios such as payment page closure or Token expiration.

Request Body

FieldTypeRequiredDescription
order_idstringYesUnique order ID

Response

{
  "order_id": "ord-123",
  "checkout_url": "https://checkout.infini.money/pay/xxxx"
}

6.4 Webhook (Order Status Callback)

Merchants can configure Webhook receiving address in the backend. When order status changes, Infini will actively push the following events:

  • order.created
  • order.processing
  • order.completed
  • order.expired
  • order.late_payment

Webhook Headers

HeaderDescription
X-Webhook-TimestampUnix timestamp
X-Webhook-Event-IdUnique event ID
X-Webhook-SignatureWebhook HMAC signature

Webhook Payload Example

{
  "event": "order.completed",
  "order_id": "ord-123",
  "client_reference": "ORDER-001",
  "amount": "100",
  "currency": "USD",
  "status": "paid",
  "amount_confirmed": "100",
  "amount_confirming": "0",
  "created_at": 1763512195,
  "updated_at": 1763512573,
  "exception_tags": []
}

For Webhook signature verification methods, please refer to Chapter 4: Authorization and Security Mechanisms.

6.5 Error Codes

All error response format:

{
  "code": 40001,
  "message": "Invalid request",
  "detail": "expires_at must be greater than current timestamp"
}

Common Error Codes

HTTPCodeDescription
40040003amount must be positive
40040006amount must be greater than 0.01
401401Invalid HMAC signature
40440401Order does not exist
40940902client_reference duplicate
40940906Order expired

6.6 Python Example (Hosted Checkout Mode)

The following example demonstrates the complete flow: Create Order → Redirect to Checkout → Webhook → Reissue Token.

6.6.1 Create Order

import hmac, hashlib, base64, time
from datetime import datetime, timezone
import requests

key_id = "merchant-001-prod"
secret_key = b"your-secret-key"

def create_order(amount):
    method = "POST"
    path = "/v1/acquiring/order"
    gmt_time = datetime.now(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S GMT')

    signing_string = f"{key_id}\n{method} {path}\ndate: {gmt_time}\n"
    signature = base64.b64encode(
        hmac.new(secret_key, signing_string.encode(), hashlib.sha256).digest()
    ).decode()

    response = requests.post(
        f"https://openapi.infini.money{path}",
        json={
            "amount": amount,
            "currency": "USD",
            "client_reference": "ORDER-2024-001",
            "description": "Product purchase",
            "expires_at": int(time.time()) + 3600
        },
        headers={
            "Date": gmt_time,
            "Authorization": f'Signature keyId="{key_id}",algorithm="hmac-sha256",headers="@request-target date",signature="{signature}"',
            "Content-Type": "application/json"
        }
    )

    response.raise_for_status()
    return response.json()

6.6.2 Frontend Redirect to Checkout

@app.route('/create-payment', methods=['POST'])
def create_payment():
    order = create_order(amount=request.json['amount'])
    return {"checkout_url": order["checkout_url"]}

6.6.3 Webhook Callback Handling

@app.route('/webhook', methods=['POST'])
def handle_webhook():
    event = request.json

    if event['event'] == 'order.completed':
        process_fulfillment(event['order_id'], event['amount_confirmed'])
    elif event['event'] == 'order.processing':
        update_order_progress(event['order_id'], event['status'])
    elif event['event'] == 'order.expired':
        mark_order_expired(event['order_id'])

    return {"status": "ok"}

6.6.4 Reissue Checkout Token

def reissue_checkout_token(order_id):
    method = "POST"
    path = "/v1/acquiring/token/reissue"
    gmt_time = datetime.now(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S GMT')

    signing_string = f"{key_id}\n{method} {path}\ndate: {gmt_time}\n"
    signature = base64.b64encode(
        hmac.new(secret_key, signing_string.encode(), hashlib.sha256).digest()
    ).decode()

    response = requests.post(
        f"https://api.infini.money{path}",
        json={"order_id": order_id},
        headers={
            "Date": gmt_time,
            "Authorization": f'Signature keyId="{key_id}",algorithm="hmac-sha256",headers="@request-target date",signature="{signature}"',
            "Content-Type": "application/json"
        }
    )

    response.raise_for_status()
    return response.json()