> 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/tuo-guan-zu-jian-ji-cheng/qi-ta-zhi-fu-fang-shi/fa-qi-fu-kuan-qing-qiu.md).

# 发起付款请求

#### 先决条件 <a href="#pre-requisite" id="pre-requisite"></a>

在与 Codapay API 集成时，请确保遵守以下标准：

1. 请使用HTTPS协议。
2. TLS 1.2 或更高版本

请注意，Codapay API 有两个版本，请参阅[Codapay API 版本](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/integration-guides/codapay-api-versions)了解更多详情，以确保您已选择正确的版本进行集成。

#### 参考 <a href="#reference" id="reference"></a>

沙盒

| v2.0 | <https://sandbox.codapayments.com/airtime/api/restful/v2.0/Payment/ComponentURL> |
| ---- | -------------------------------------------------------------------------------- |

生产

| v2.0 | <https://airtime.codapayments.com/airtime/api/restful/v2.0/Payment/Component> |
| ---- | ----------------------------------------------------------------------------- |

**端点**

**POST {基本 URL}/init.json**

Codapay 的 API 支持 REST Web 服务。默认情况下，显示的端点是 RESTful 的。

#### 请求参数 <a href="#request-parameters" id="request-parameters"></a>

| initRequest                        | Object  | **必填：**&#x5FC5;须是有效的 JSON 对象                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| initRequest.country                | String  | **必填：** ISO 3166 国家代码 - 请参阅[国家和货币代码](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/integration-guides/country-and-currency-codes)                                                                                                                                                                                                                                                                  |
| initRequest.payType                | String  | **必填：** 您要使用的支付渠道 ID - 请参阅[此处](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/references/supported-payment-channels)提供的完整列表。如果您想使用渠道选择页面，请设置为 0；如果您想使用 DCB 页面，请设置为 1 - 更多详情请点击[此处](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/hosted-payment-page-integration/payment-channel-integration-options)。                                                               |
| initRequest.apiKey                 | String  | **必填：**&#x43;oda 提供的**API 密钥 - 请参阅**[入门指南](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/getting-started/set-up-payments)了解如何获取该密钥。                                                                                                                                                                                                                                                                |
| initRequest.projectId              | String  | **必填：** Coda 提供的**项目 ID，每个标题产品都有唯一的项目 ID - 请参阅**[入门指南](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/getting-started/set-up-payments)了解如何获取                                                                                                                                                                                                                                                        |
| initRequest.isTaxInclusiveAmount   | Boolean | <p>\*<strong>仅支持美国市场</strong></p><p>此参数影响<code>items\[].price</code> 的总金额是否包含税费。此参数仅适用于 Coda 作为 MoR（Merchant of Record） 且支持税务的市场（目前仅支持美国）。</p><p></p><p>当设置为 true 时，商品总金额将视为含税价格，并按该金额直接收费。</p><p></p><p>当设置为 false（或未提供该参数）时，商品总金额将视为未含税价格，系统会在此基础上额外加收税费。</p><p></p><p>若未提供此参数，默认值为 false并保存原有配置</p><p></p><p>当 Coda 不是 MoR 时，此参数将被忽略。</p><p>→ 有关此参数如何影响响应结果及税费明细，请参阅 【<a href="/pages/LdHIBqO5WNJswC5LTKyq">查询订单-税务处理</a>】</p> |
| initRequest.orderId                | String  | **必填：** 您的交易唯一标识符                                                                                                                                                                                                                                                                                                                                                                                                                 |
| initRequest.currency               | String  | **必填：**&#x49;SO 4217 货币代码 - 请参阅[国家和货币代码](https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/integration-guides/country-and-currency-codes)                                                                                                                                                                                                                                                              |
| initRequest.items                  | Array   | **必填：**&#x7528;户购买的物品**清单**                                                                                                                                                                                                                                                                                                                                                                                                       |
| initRequest.items\[].code          | String  | <p>可选：您这边与该项目关联的<strong>代码</strong></p><p></p>                                                                                                                                                                                                                                                                                                                                                                                    |
| initRequest.items\[].price         | Number  | **必填：**&#x5546;品价格（含税），以询价单中指定的货币为准。                                                                                                                                                                                                                                                                                                                                                                                              |
| initRequest.items\[].name          | String  | **必填：**&#x6240;购商品的名称 **。仅支持拉丁字符。**                                                                                                                                                                                                                                                                                                                                                                                               |
| initRequest.profile                | Object  | **必填：**&#x8D2D;买用户的**用户个人资料信息**                                                                                                                                                                                                                                                                                                                                                                                                   |
| initRequest.profile.entry          | Array   | **必填：个人资料信息** 键值对列表。以下列出了当前可用于处理的特定键值。                                                                                                                                                                                                                                                                                                                                                                                            |
| initRequest.profile.entry\[].key   | String  | 个人资料条目的键                                                                                                                                                                                                                                                                                                                                                                                                                          |
| initRequest.profile.entry\[].value | String  | 个人资料条目的值                                                                                                                                                                                                                                                                                                                                                                                                                          |

Profile 个人资料

| user\_id | String | **必填：**&#x60A8;的用户唯一标识符 |
| -------- | ------ | ----------------------- |

#### 响应参数 <a href="#response-parameters" id="response-parameters"></a>

| initResult              | Object  | 包含发起请求的结果                                                                                                                                                                                                    |
| ----------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| initResult.resultCode   | Integer | <p>发起请求的结果代码。</p><p><code>resultCode = 0</code>如果请求成功，则返回 true。否则，resultCode 值为错误。完整的错误代码列表请参见<a href="https://coda-payments.gitbook.io/coda-public-technical-documentation/codapay/error-codes">此处</a>。</p> |
| initResult.resultDesc   | String  | 错误描述：resultCode 不为 0。                                                                                                                                                                                        |
| initResult.txnId        | Integer | 已发起请求的交易 ID。如果交易发起失败，则此值为 0。                                                                                                                                                                                 |
| initResult.clientSecret | String  | 此信息仅在托管组件集成时返回。客户端密钥授权 SDK 加载此特定交易的卡片字段                                                                                                                                                                      |

### 示例

{% tabs %}
{% tab title="请求" %}

```
{
  "initRequest": {
    "country": 840,
    "payType": 1006,
    "apiKey": "live_CVcqKHR12es0UHRvSsdHnTOizCIq",
    "projectId": 102,
    "orderId": "12321312321314",
    "currency": 840,
    "items": [
      {
        "code": "1",
        "price": 3,
        "name": "Item Name"
      }
    ],
    "profile": {
      "entry": [
        {
          "key": "user_id",
          "value": "105"
        }
      ]
    }
  }
}
```

{% endtab %}

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

```
{
    "initResult": {
        "resultCode": 0,
        "txnId": 7726919418568084576,
        "clientSecret": "eyJhbGciIU4zI1NiIsI8nR5cCI6IkpXVCJ9.eyJpYXQiOjE3NzI2OTE5NDMsImV4cCI6MTc3MjY5MzE0MywiaXNzIjoiaHR0cHM6Ly9hcGktdGMtY2FyZC5jb2RhcGF5bWVudHMuY29tLyIsInBhcnRuZXJfaWQiOiJwYXJfc2cxOTJhZDE4MGY2MDAwMDEiLCJkYXRhIjoiQ2dFeEVnbEpkR1Z0SUU1aGJXVWFBek11TUNJRFZWTkVLZzR4TWpNeU1UTXhNak15TVRNeE5Eb0NWVk5DRXpjM01qWTVNVGswTVRnMU5qZ3dPRFExTnpaS2ZIc2liV1Z5WTJoaGJuUmZjMlYwZEd4bGJXVnVkRjlwWkNJNk5URXlPU3dpYldWeVkyaGhiblJmYm1GdFpTSTZJbFZ1YVhSNUlGUmxjM1FpTENKdFpYSmphR0Z1ZEY5cFpDSTZNalkzTkRZc0luQmpjRjlwWkNJNk5ESXNJbTF1YjE5cFpDSTZNVEF3Tml3aWJXVnlZMmhoYm5SZmRIbHdaU0k2TVgxYUFIQUIifQ.3UqtMwDZQx8gfyNPFNd3gA7BqiNBRc-z33fEfz4L8cU"
    }
}
```

{% endtab %}

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

```
{
    "initResult": {
        "resultCode": 103,
        "resultDesc": "This transaction has been cancelled. No charges were made. (error:103)",
        "txnId": 0
    }
}
```

{% endtab %}
{% endtabs %}

### [Profile ](#profile)

```
"profile": {
            "entry": [
                {
                    "key": "user_id",
                    "value": "test105"
                }
            ]
        }
```


---

# 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/tuo-guan-zu-jian-ji-cheng/qi-ta-zhi-fu-fang-shi/fa-qi-fu-kuan-qing-qiu.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.
