> 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/codapay/hou-duan-api-ji-cheng/hou-duan-fei-ka-pian-api-ji-cheng/hou-tai-api-diao-yong-liu-cheng-gai-lan/dai-jin-quan-xian-jin-ka.md).

# 代金券（现金卡）

## 代金券调用流程

代金券支付方式允许客户在商家的网站通过 Codapay 兑换代金券代码。Codapay 会实时记录已完成的支付，并立即通知商家。有关代金券的详细信息，请参阅请求表中Profile字段的代金券部分。

对于代金券交易，代金券的金额仅在兑换后确认；商家需要验证 Coda API 响应中返回的净金额，并能够处理所有可用面额的兑换。

<figure><img src="/files/h1J69Fc7McKrFVintCIV" alt=""><figcaption></figcaption></figure>

## 请求参数

<table><thead><tr><th width="148">参数</th><th width="95">类型</th><th width="116">长度</th><th>描述</th></tr></thead><tbody><tr><td>api_key</td><td>String</td><td>256</td><td><strong>必填</strong><br>Coda提供的API密钥 - 请参考 <a data-mention href="/pages/Knn2G4Gd1ZPSUbSS0PUS">/pages/Knn2G4Gd1ZPSUbSS0PUS</a> 了解如何获取。</td></tr><tr><td>project_id</td><td>String</td><td>10</td><td><strong>此字段仅适用于 v2.0 API，必填项</strong><br>由 Coda 提供的 Project ID，对每个标题产品都是唯一的。<br>请参阅 <a data-mention href="/pages/Knn2G4Gd1ZPSUbSS0PUS">/pages/Knn2G4Gd1ZPSUbSS0PUS</a> 了解</td></tr><tr><td>order_id</td><td>String</td><td>64</td><td><p><strong>必填</strong></p><p>您在支付请求发起时传递的订单ID</p></td></tr><tr><td>country</td><td>Number</td><td>N/A</td><td><strong>必填</strong><br>ISO 3166 的国家代码 <a data-mention href="/pages/7B3qZnefeSwkSs84sKuB">/pages/7B3qZnefeSwkSs84sKuB</a></td></tr><tr><td>lang</td><td>String</td><td>2</td><td><p><strong>必填</strong></p><p><a data-mention href="/pages/lumiE4ZV7er3NqdusLTc">/pages/lumiE4ZV7er3NqdusLTc</a></p></td></tr><tr><td>type</td><td>Number</td><td>1</td><td><p>1：数字内容物品</p><p>2：非数字内容物品</p></td></tr><tr><td>pay_type</td><td>Number</td><td>1</td><td><p><strong>必填</strong></p><p>代金券使用 <code>pay_type = 4</code>。</p><p><br>更多详情请参阅 <a data-mention href="/pages/9qMfw9ltzzDp2UjOhCld">/pages/9qMfw9ltzzDp2UjOhCld</a></p></td></tr><tr><td>pay_channel</td><td>Number</td><td>3</td><td>每个支付渠道的代码。</td></tr><tr><td>merchant_name</td><td>String</td><td>128</td><td><p><strong>可选</strong><br>如果您希望指定商家名称，请在此字段中输入名称。</p><p><br>默认值为空。</p></td></tr><tr><td>items</td><td>ItemInfo</td><td>N/A</td><td><p><strong>必填</strong></p><p>用户购买的商品列表</p></td></tr><tr><td>items[].code</td><td>String</td><td>128</td><td><p><strong>必填</strong></p><p>商家的商品代码</p></td></tr><tr><td>items[].name</td><td>String</td><td>128</td><td><p><strong>必填</strong></p><p>商品名称，仅支持拉丁字符</p></td></tr><tr><td>items[].price</td><td>Number</td><td>N/A</td><td><strong>必填</strong><br>已含税的商品价格（已含税），以请求中指定的货币计价</td></tr><tr><td>items[].type</td><td>Number</td><td>N/A</td><td><strong>必填</strong><br>默认值=1</td></tr><tr><td>profile</td><td>Map</td><td>N/A</td><td><strong>必填</strong><br><a data-mention href="#profile-zi-duan">#profile-zi-duan</a></td></tr></tbody></table>

## Profile 字段

<table data-full-width="false"><thead><tr><th width="168">参数</th><th width="117">类型</th><th width="109">长度</th><th width="285">描述</th></tr></thead><tbody><tr><td>voucher_code</td><td>String</td><td>20</td><td><strong>必填</strong><br>代金券代码。</td></tr><tr><td>voucher_pin</td><td>String</td><td>20</td><td><strong>必填</strong><br>代金券 PIN。</td></tr><tr><td>card_type</td><td>String</td><td>N/A</td><td><strong>可选</strong><br>默认使用 <code>"card_type":"0"</code></td></tr></tbody></table>

### 请求示例

<table><thead><tr><th width="153.33333333333331">参数</th><th width="141">类型</th><th width="94">长度</th><th>描述</th></tr></thead><tbody><tr><td>result_code</td><td>Number</td><td>N/A</td><td><p>ResultCode将帮助指示交易的状态。</p><p><code>ResultCode = 0</code> 表示交易成功。</p><p><code>ResultCode = 431 或 216</code> 表示交易待处理</p><p>所有其他ResultCode值表示交易失败。您可以在<a href="https://coda-payments.gitbook.io/zhong-wen-coda-private-technical-documentation/codapay/can-kao-zi-liao/chang-jian-cuo-wu-dai-ma">这里</a>找到完整的错误代码及其解释。</p></td></tr><tr><td>result_desc</td><td>String</td><td>512</td><td>如果resultCode返回错误，则该值描述错误信息。</td></tr><tr><td>txn_id</td><td>Number</td><td>N/A</td><td>从支付请求发起返回的Coda订单ID。</td></tr><tr><td>txn_timeout</td><td>Number</td><td>N/A</td><td>交易超时时间（分钟）。</td></tr><tr><td>total_price</td><td>Number</td><td>N/A</td><td><p>未格式化的数字值。</p><p></p><p>对于<strong>印度尼西亚、智利、韩国、台湾和越南的货币</strong>，不支持小数。</p></td></tr><tr><td>pay_instructions</td><td>String</td><td>15</td><td>如果响应返回了此值，商家应在页面上向客户显示提供的支付指引。</td></tr><tr><td>profile</td><td>Number</td><td>N/A</td><td>请参考<a href="#profile-field-li-de-other-details">此处</a></td></tr></tbody></table>

{% tabs %}
{% tab title="v2.0 示例" %}

```json
{
  "project_id": "1", //此字段仅适用于 2.0 API
  "country": "410",
  "api_key": "test_e944d44f065eade8157737385a09",
  "order_id": "<Your OrderID>",
  "lang": "ko",
  "merchant_name": "Codapay",
  "type": "1",
  "pay_type": "4",
  "pay_channel": "-148",
  "items": [
    {
      "code": "7",
      "name": "Test Item",
      "price": 500.0
    }
  ],
  "profile": {
    "voucher_code": "-",
    "voucher_pin": "-"
  }
}
```

{% endtab %}

{% tab title="v1.0 示例" %}

```json
{
    "api_key":"<YOUR API KEY>",
    "order_id":"<Your Order ID)",
    "lang":"en",
    "merchant_name":"ebooks",
    "pay_type":"4",
    "pay_channel":"340",
    "type":"1",
    "profile":{
        "voucher_code":"12345678901231",
        "voucher_pin":"",
        "card_type":"0",
        "user_id":"12345"
    }
}
```

{% endtab %}
{% endtabs %}

## 响应参数

<table><thead><tr><th width="153.33333333333331">参数</th><th width="141">类型</th><th width="94">长度</th><th>描述</th></tr></thead><tbody><tr><td>result_code</td><td>Number</td><td>N/A</td><td><p>ResultCode将帮助指示交易的状态。<br></p><p><code>ResultCode = 0</code> 表示交易成功。<br><br>错误代码列表请参阅 <a data-mention href="/pages/Ijfanb3Eb2mtXRsbF81n">/pages/Ijfanb3Eb2mtXRsbF81n</a></p></td></tr><tr><td>result_desc</td><td>String</td><td>512</td><td>如果resultCode返回错误，则该值描述错误信息。</td></tr><tr><td>txn_id</td><td>Number</td><td>N/A</td><td>支付请求发起返回的Coda订单ID。</td></tr><tr><td>txn_timeout</td><td>Number</td><td>N/A</td><td>交易超时时间（分钟）</td></tr><tr><td>total_price</td><td>Number</td><td>N/A</td><td>用户支付的总金额，以本地货币计价。</td></tr><tr><td>pay_instructions</td><td>String</td><td>15</td><td>如果响应返回了此值，商家应在页面上向客户显示提供的支付指引。</td></tr><tr><td>profile</td><td>Number</td><td>N/A</td><td>请参考 <a data-mention href="#profile-zi-duan-1">#profile-zi-duan-1</a></td></tr></tbody></table>

## Profile 字段

<table data-full-width="false"><thead><tr><th width="169">参数</th><th width="165">类型</th><th width="107.33333333333331">长度</th><th>描述</th></tr></thead><tbody><tr><td>redirect_url</td><td>String</td><td>128</td><td>仅当所选支付渠道遵循重定向 URL 流程时，才返回支付网关的重定向 URL。</td></tr><tr><td>extInfoByte</td><td>String</td><td>128</td><td>请忽略此字段。</td></tr><tr><td>name</td><td>String</td><td>128</td><td>客户姓名。</td></tr><tr><td>payment_code</td><td>Number</td><td>N/A</td><td>由支付渠道生成的代码。</td></tr></tbody></table>

### 响应示例

{% tabs %}
{% tab title="示例" %}

```json
{
   "txn_id": <Coda Transaction ID>,
   "txn_timeout": 0,
   "result_code": 0,
   "total_price": 150,
   "profile":{"user_id":"12345"}
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
&#x20;<mark style="color:orange;">**USD 订单交易参考**</mark>

请查看[此指南](https://coda-payments.gitbook.io/zhong-wen-coda-private-technical-documentation/codapay/hou-duan-api-ji-cheng/usd-mei-jin)，了解更多关于 USD 交易的信息。
{% endhint %}


---

# 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/codapay/hou-duan-api-ji-cheng/hou-duan-fei-ka-pian-api-ji-cheng/hou-tai-api-diao-yong-liu-cheng-gai-lan/dai-jin-quan-xian-jin-ka.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.
