> 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/usd-ding-dan-jiao-yi-gai-lan.md).

# USD 订单交易概览

{% hint style="warning" %} <mark style="color:orange;">**后端API USD交易**</mark>

请注意，USD 交易需要在货币代码上进行一些特定的配置。
{% endhint %}

## <mark style="color:purple;">请求参数</mark>

| 参数             | 类型       | 长度  | 描述                                                                                                                                                                                                                           |
| -------------- | -------- | --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| api\_key       | String   | 256 | <p><strong>必填</strong><br>Coda提供的API密钥 - 请参“<a href="https://coda-payments.gitbook.io/zhong-wen-coda-private-technical-documentation/codapay/codapay-ru-men-zhi-nan/kai-shi-zhi-fu-qu-dao-she-zhi">入门指南</a>”了解如何获取。</p>      |
| project\_id    | String   | 10  | <p><strong>此字段仅适用于此字段仅适用于 v2.0 API，必填项</strong><br>由 Coda 提供的 Project ID，对每个标题产品都是唯一的。<br>请参阅 <a data-mention href="/pages/Knn2G4Gd1ZPSUbSS0PUS">/pages/Knn2G4Gd1ZPSUbSS0PUS</a> 了解</p>                                      |
| order\_id      | String   | 64  | <p><strong>必填</strong><br>您在支付请求发起时传递的订单ID</p>                                                                                                                                                                               |
| lang           | String   | 2   | <p><strong>必填</strong><br>请参阅<a href="https://coda-payments.gitbook.io/zhong-wen-coda-private-technical-documentation/codapay/hou-duan-api-ji-cheng/language-can-shu-de-ge-ge-guo-jia-xuan-xiang-lie-biao">此处</a>以查看可选项。</p> |
| country        | Number   | N/A | <p><strong>必填</strong><br>ISO 3166 的国家代码 <a data-mention href="/pages/7B3qZnefeSwkSs84sKuB">/pages/7B3qZnefeSwkSs84sKuB</a></p>                                                                                              |
| type           | Number   | 1   | <p>1：数字内容物品。</p><p>2：非数字内容物品。</p>                                                                                                                                                                                            |
| pay\_type      | Number   | 1   | <p><strong>必填</strong><br>运营商支付使用 <code>pay\_type = 1</code>。</p><p>对于运营商计费，如果客户输入的 MSISDN 与请求消息中的运营商计费不符，交易将因错误 240 而失败。<br><br>请参阅<a href="/pages/tjhHBnF7LMk5IYPAlCEW">此处</a>查看更多信息。</p>                                  |
| mno\_code      | Number   | N/A | <p><strong>必填</strong><br>移动网络代码。</p><p>如果为空，Coda 将选择可用的 MNO。</p>                                                                                                                                                            |
| msisdn         | Number   | 15  | <p><strong>可选</strong><br>MSISDN（未格式化；不包含国家代码）。</p><p>仅在需要 MSISDN 而非电子邮件时包含此项。</p>                                                                                                                                           |
| items          | ItemInfo | N/A | <p><strong>必填</strong><br>用户购买的商品列表</p>                                                                                                                                                                                      |
| items\[].code  | String   | 128 | <p><strong>必填</strong><br>商家管理的商品代码。</p>                                                                                                                                                                                     |
| items\[].name  | String   | 128 | <p><strong>必填</strong><br>所购买的商品名称。仅支持拉丁字符。</p>                                                                                                                                                                              |
| items\[].price | Number   | N/A | <p><strong>必填</strong><br>商品价格包含以请求中指定的货币计算的任何税费。</p>                                                                                                                                                                        |
| profile        | Map      | N/A | 请参考[此处](https://coda-payments.gitbook.io/zhong-wen-coda-private-technical-documentation/codapay/hou-duan-api-ji-cheng/hou-tai-api-diao-yong-liu-cheng-gai-lan/yun-ying-shang-zhi-fu-dcb#profile-field-li-de-other-details)   |

## <mark style="color:purple;">Profile字段</mark>

{% hint style="warning" %}
USD 交易需要在Profile参数中设置 "currency\_code = 840"。
{% endhint %}

| 参数             | 类型     | 长度  | 描述                                                             |
| -------------- | ------ | --- | -------------------------------------------------------------- |
| user\_id       | String | N/A | <p><strong>必填</strong><br>客戶的用戶ID</p>                          |
| currency\_code | Number | 3   | <p><strong>必填</strong><br>设置 USD 为 "currency\_code = 840"。</p> |

## <mark style="color:purple;">响应参数</mark>

<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>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>Map</td><td>N/A</td><td>请参阅以下 其他详细信 (Other details)。</td></tr></tbody></table>

## <mark style="color:purple;">Profile field里的Other details</mark>

<table><thead><tr><th width="205">参数</th><th width="95">类型</th><th width="91">长度</th><th>描述</th></tr></thead><tbody><tr><td>extInfoByte</td><td>Number</td><td>N/A</td><td>请忽略此字段。</td></tr><tr><td>foreign_currency_code</td><td>Number</td><td>3</td><td>货币用于用户实际支付的费用。</td></tr><tr><td>exchange_rate</td><td>Number</td><td>N/A</td><td>Coda 的 USD 汇率，汇率每天更新。</td></tr><tr><td>foreign_currency_amt</td><td>Number</td><td>N/A</td><td>在发起请求时提供的原始金额。</td></tr><tr><td>currency_code</td><td>Number</td><td>3</td><td>使用 USD 发起订单时，将返回 "currency_code":"840"。</td></tr><tr><td>local_currency_code</td><td>Number</td><td>3</td><td><p>各个地区的本地货币代码。</p><p></p><p>欲了解每种货币代码的详细信息，请参阅<a href="/pages/7B3qZnefeSwkSs84sKuB">此处</a></p></td></tr><tr><td>local_currency_amt</td><td>Number</td><td>N/A</td><td>用户为交易支付的总金额。此金额将始终以当地货币表示。</td></tr></tbody></table>

## <mark style="color:purple;">示例</mark>

{% tabs %}
{% tab title="v2.0 请求" %}

```
{
    "api_key": "test_e944d44f065eade8157737385a09",
    "order_id": "123456",
    "project_id": "1",//This field is only needed for v2.0 API
    "lang": "en",
    "merchant_name": "Codapay",
    "pay_type": "5",
    "pay_channel": -76,
    "pay_at": "4",
    "type": "1",
    "country": "702",
    "items": [
        {
            "code": "456789",
            "name": "Test Item",
            "price": 100
        }
    ],
    "profile": {
        "user_id": "12345"
    }
}
```

{% endtab %}

{% tab title="v1.0 请求" %}

```
{
    "api_key": "e944d44f065eade8157737385a094a",
    "order_id": "123456",
    "lang": "en",
    "merchant_name": "Amazon",
    "pay_type": "5",
    "pay_channel": -76,
    "pay_at": "4",
    "type": "1",
    "items": [
        {
            "code": "456789",
            "name": "GameCredit",
            "price": 100
        }
    ],
    "profile": {
        "user_id": "12345",
        "currency_code": "840"
    }
}
```

{% endtab %}

{% tab title="请求成功响应" %}

<pre><code>{
<strong>    "txn_id": 7395063022892074013,
</strong>    "txn_timeout": 19,
    "result_code": 0,
    "result_desc": null,
    "total_price": 135.33,
    "pay_instructions": "",
    "profile": {
        "extInfoByte": "0",
        "foreign_currency_code": "840",
        "exchange_rate": "1.3533",
        "foreign_currency_amt": "100.0",
        "local_currency_code": "702",
        "currency_code": "840",
        "local_currency_amt": "135.33",
        "user_id": "12345",
        "projectId": "1",
        "merchantType": "Codapay",
        "redirect_url": "https://partner-api.stg-myteksi.com/grabid/v1/oauth2/authorize?acr_values=consent_ctx%3AcountryCode%3DSG,currency%3DSGD&#x26;client_id=8488e516acc54f88bad99c435cc18fdd&#x26;redirect_uri=https%3A%2F%2Fmidas.codapayments.com%2Fepcgw%2Fgrab%2Fredirect&#x26;request=eyJhbGciOiAibm9uZSJ9.eyJjbGFpbXMiOnsidHJhbnNhY3Rpb24iOnsidHhJRCI6ImFkNzI5ZjA1NzQ0MzQyMTA4ODQ5ZDQyMzcyZTFlYWZiIn19fQ.&#x26;response_type=code&#x26;code_challenge=csKQlGqOEs5LVHsLEFRQemfNIu4inReam4wfysr8zZY&#x26;code_challenge_method=S256&#x26;scope=payment.one_time_charge&#x26;state=7395063022892074846&#x26;nonce=0r2bt4lD0oRHxh9B",
        "payment_code": ""
    }
}
</code></pre>

{% endtab %}

{% tab title="请求失败响应" %}

```
{
    "txn_id": 0,
    "txn_timeout": 0,
    "result_code": 103,
    "result_desc": "This transaction has been cancelled. No charges were made. (error:103)",
    "total_price": 0.0,
    "pay_instructions": null,
    "profile": null
}
```

{% endtab %}
{% endtabs %}


---

# 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/usd-ding-dan-jiao-yi-gai-lan.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.
