> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codashop-yu-distrubution/ji-cheng-zhi-nan/validation-api-qing-qiu/validation-api-qing-qiu-shi-li-yu-xiang-ying.md).

# Validation API 请求示例与响应

## **Codashop 交易验证请求** <a href="#codashop-transaction-validation-request" id="codashop-transaction-validation-request"></a>

示例\
JSON-RPC 格式\
<https://www.jsonrpc.org/specification>

```javascript
// {
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "method": "validate",
  "params": [
    {
      "isForTest": 1,
      "price": {
        "amount": "50000",
        "currency": "IDR"
      },
      "serviceProvider": "Coda",
      "quantity": 1,
      "paymentChannelId": 227,
      "sku": "Diamonds_10",
      "purchaseOrigin": "TH",
      "user": {
        "userId": "111111",
        "zoneId": "101"
      },
      "signature": "4646fbd3363ab452f40187f8744cd321f71968ed01cdc19c416203832cddd76e",
      "txnId": "6164695159717629913",
      "orderId": "6164695159719894644"
    }
  ]
}
```

<table><thead><tr><th width="229.67535400390625">参数</th><th width="131.30908203125">类型</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>标识 API 调用的唯一 ID</td></tr><tr><td>jsonrpc</td><td>String</td><td>固定值为 <code>"2.0"</code>，符合 JSON-RPC 标准</td></tr><tr><td>method</td><td>String</td><td>固定值为 <code>"validate"</code></td></tr><tr><td>params.serviceProvider</td><td>String</td><td>支付服务提供商名称，默认值为 <code>"Coda"</code>，也可由合作伙伴自定义</td></tr><tr><td>params.isForTest</td><td>Integer</td><td>用于指示此订单是沙盒测试订单还是真实订单。如果 isForTest=1，此订单为沙盒测试订单；反之，isForTest=0，则为真实订单。</td></tr><tr><td>params.signature</td><td>String</td><td>根据请求内容生成的签名。详见“签名生成”部分。</td></tr><tr><td>params.user.userId</td><td>String</td><td>合作伙伴系统中客户账户的用户 ID / 玩家 ID</td></tr><tr><td>params.user.zoneId</td><td>String</td><td>合作伙伴系统中客户账户的区域 ID/服务器 ID。<br>如果不需要 zoneId，默认值为“”。</td></tr><tr><td>params.price.currency</td><td>String</td><td>货币代码，符合 ISO 4217 标准</td></tr><tr><td>params.price.amount</td><td>String</td><td>用户支付金额，货币单位由 params.price.currency 定义。</td></tr><tr><td>params.sku</td><td>String</td><td>表示所购买商品的商品 ID，例如 <code>"Diamonds_123"</code>。</td></tr><tr><td>params.purchaseOrigin</td><td>String</td><td>购买发起地区，采用 ISO 两位国家代码标准。Codashop 用户进行购买时所处的地区。<br><br>参考：<a href="https://www.iban.com/country-codes">https://www.iban.com/country-codes</a></td></tr><tr><td>params.quantity</td><td>Integer</td><td>待购买的 SKU 数量，通常为 1</td></tr><tr><td>params.paymentChannelId</td><td>Integer</td><td>支付渠道 ID，请查阅第 6 节</td></tr><tr><td>params.txnId</td><td>String</td><td>支付交易 ID</td></tr><tr><td>params.orderId</td><td>String</td><td>Codashop 订单 ID</td></tr></tbody></table>

## Codashop 验证请求响应

Codashop 验证响应描述了合作伙伴对验证请求的响应。

下方提供了[<mark style="color:blue;">有效</mark>](#you-xiao-de-yan-zheng-xiang-ying)和[<mark style="color:blue;">无效</mark>](#wu-xiao-de-yan-zheng-xiang-ying)验证响应的示例。

### 有效的验证响应

#### 示例 1

格式：JSON-RPC

```javascript
// 
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "merchantTransactionId": "816176257914769",
    "username": "Test User",
    "accountRegionCode": "SG"
  }
}
```

#### 示例 2

若每个账户下存在多个角色或子账户，且用户需选择充值对象，应将这些选项以 roleList 形式共享。仅包含可充值的角色。Coda 将在用户进行支付前展示这些选项。

```javascript
// 
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "roleList": [
      {
        "roleName": "roleA",
        "roleId": "111"
      },
      {
        "roleName": "roleB",
        "roleId": "222"
      },
      {
        "roleName": "roleC",
        "roleId": "333"
      }
    ],
    "merchantTransactionId": "816176257914769",
    "accountRegionCode": "SG"
  }
}
```

<table><thead><tr><th width="278.5181884765625">参数</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>与该响应关联的消息 ID</td></tr><tr><td>jsonrpc</td><td>固定为 "2.0"，符合 JSON-RPC 标准</td></tr><tr><td>result</td><td>表示请求成功的对象</td></tr><tr><td>result.username</td><td>玩家用户名、昵称或其他可用作用户身份确认的标识，用于帮助用户确认正在为正确的账户充值。例如，唯一的玩家 ID 可能是 “123456789”，其用户名（不一定唯一）可能是 “Terminator123”。</td></tr><tr><td>result.roleList</td><td>列出用户账户下的所有角色或子账户（如适用）</td></tr><tr><td>result.roleList.roleName</td><td>角色名称</td></tr><tr><td>result.roleList.roleId</td><td>角色 ID</td></tr><tr><td>result.merchantTransactionId</td><td>（可选）由合作伙伴生成的唯一订单号</td></tr><tr><td>result.accountRegionCode</td><td><p>注意：accountRegionCode 必须以 2 位国家代码的 ISO 标准返回。这将是创建 userId 的账户所属地区名称。</p><p><br>例如：TH 代表泰国，SG 代表新加坡 <a href="https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes">https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes</a></p></td></tr></tbody></table>

### 无效的验证响应

格式：JSON-RPC

```javascript
// 
{
    "id": "6164695159717629913",
    "jsonrpc": "2.0",
    "error": {
        "code": -100,
        "message": "Invalid user ID"
    }
}
```

<table><thead><tr><th width="200">参数</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>与该响应关联的消息 ID</td></tr><tr><td>jsonrpc</td><td>固定为 "2.0"，符合 JSON-RPC 标准</td></tr><tr><td>error.code</td><td>错误代码</td></tr><tr><td>error.message</td><td>错误描述</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codashop-yu-distrubution/ji-cheng-zhi-nan/validation-api-qing-qiu/validation-api-qing-qiu-shi-li-yu-xiang-ying.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
