Skip to content

API 参考

Merchant API 用于由商家服务端创建和查询支付订单。API key 必须保存在服务端。

Base URL

text
https://api.tariapay.com/v1

认证

推荐使用 Bearer token:

text
Authorization: Bearer tpk_...

兼容写法:

text
x-api-key: tpk_...

API key 缺失、无效或已撤销时,接口会返回 401

核心接口

方法路径作用
POST/payment-intents创建新的支付订单
GET/payment-intents列出订单,或按 orderId 查询
GET/payment-intents/:paymentId获取单个支付订单

创建支付订单

bash
curl -X POST "https://api.tariapay.com/v1/payment-intents" \
  -H "Authorization: Bearer tpk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": "order_1001",
    "amount": "12.50",
    "currency": "USDC",
    "successUrl": "https://merchant.example/success",
    "cancelUrl": "https://merchant.example/cancel",
    "customer": {
      "email": "buyer@example.com"
    },
    "metadata": {
      "cartId": "cart_12"
    }
  }'

请求字段

字段是否必填说明
orderId必填商户业务系统订单号
amount必填订单金额,建议使用字符串
currency必填USDCUSDTEURC
customer可选{ email?, name? }
successUrl推荐支付后返回商家网站的地址
cancelUrl推荐取消支付后返回商家网站的地址
metadata可选商户自定义键值对
expiresAt可选ISO-8601 时间戳

响应结构

json
{
  "paymentIntent": {
    "paymentId": "pi_123",
    "id": "pi_123",
    "status": "requires_payment",
    "orderId": "order_1001",
    "amount": "12.50",
    "currency": "USDC",
    "checkoutUrl": "https://checkout.tariapay.com/checkout/payment-intents/pi_123",
    "successUrl": "https://merchant.example/success",
    "cancelUrl": "https://merchant.example/cancel",
    "customer": {
      "email": "buyer@example.com",
      "name": "Alice"
    },
    "metadata": {
      "cartId": "cart_12"
    },
    "txHash": null,
    "paidAt": null,
    "expiresAt": null,
    "createdAt": "2026-03-30T00:00:00.000Z",
    "updatedAt": "2026-03-30T00:00:00.000Z"
  }
}

错误结构

json
{
  "error": {
    "type": "invalid_request_error",
    "code": "order_id_conflict",
    "message": "orderId already exists for merchant",
    "requestId": "req_123"
  }
}

常见错误

状态码常见原因
400请求字段缺失或格式不正确
401API key 缺失、无效或已撤销
409orderId 已存在
500服务端错误,请记录 requestId 后联系支持

下一步