> 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/ji-cheng-zhi-nan/an-quan-zhi-nan.md).

# 安全指南

无论选择静态还是动态的回调通知 URL(Complete Notification URL)，优先考虑安全性至关重要。未经授权访问该 URL 可能使恶意行为者伪造支付交易，导致潜在的财务损失。为防范此类风险，务必按照下列安全措施保护回调通知 URL。

***

{% hint style="danger" %} <mark style="color:red;">**请确保您的回调通知 URL 是安全的！**</mark>
{% endhint %}

## 校验和机制

{% hint style="success" %}
Codapay 的校验和是通过将 `TxnID`、`API 密钥`、`OrderId` 和 `ResultCode` 组合在一起计算得出的。这个校验和能够确保消息在传输过程中没有被篡改。如果 API 密钥发生更新，商户需要相应地重新生成并更新校验和，以保证安全性。
{% endhint %}

### 校验和计算步骤

1. **构建字符串**：将以下值按顺序连接：“TxnID + API 密钥 + OrderId + ResultCode”。

{% tabs %}
{% tab title="示例" %}
TxnId = `3381290433880074215`\
ApiKey = `5a8ca8f31f19a23c41edd14b29a74fd2`\
OrderId = `8ae6ffee169b`\
ResultCode = `0`\
结果字符串：`"33812904338800742155a8ca8f31f19a23c41edd14b29a74fd28ae6ffee169b0"`
{% endtab %}
{% endtabs %}

2. 计算字符串 (**checksumString**) 的 **MD5 hash**。MD5 算法将返回一个 **字节数组** 作为结果。
3. 将 **字节数组** 转换为 **十六进制字符串**。转换后的结果字符串示例如下：

   **"5cb948816af0b5b61516fd71a17d271b"**。

{% hint style="info" %}
**通过对比以上 MD5 生成的校验和和通知中的校验和值，可以确保数据的完整性和安全性。**
{% endhint %}

***

## HTTPS 加密

为了防止第三方窃听，必须启用 HTTPS 加密。这会确保所有传输的数据都通过安全通道进行，避免信息泄露或篡改。

***

{% hint style="info" %} <mark style="color:green;">IP 过滤 -> 只允许 Codapay 发送回调通知</mark>

为了确保只有 Codapay 能够向您发送交易完成通知，您需要配置防火墙，过滤掉任何未经授权的 IP 地址。以下是 Codapay 的 IP 地址列表，您可以将这些地址添加到您的防火墙白名单中：

* 54.251.135.133
* 3.111.59.175
* 3.110.250.201
* 65.1.187.239
* 54.193.247.199
* 18.198.204.13
* 3.121.251.156
* 3.67.31.16
* 52.76.150.186
* 18.140.224.133
* 13.213.84.158
* 13.228.141.160
* 54.151.121.97
* 54.219.48.129
  {% endhint %}

## IP 过滤

{% hint style="success" %}
只允许 Codapay 发送回调通知
{% endhint %}

为了确保只有 Codapay 能够向您发送交易完成通知，您需要配置防火墙，过滤掉任何未经授权的 IP 地址。以下是 Codapay 的 IP 地址列表，您可以将这些地址添加到您的防火墙白名单中：

* 54.251.135.133
* 3.111.59.175
* 3.110.250.201
* 65.1.187.239
* 54.193.247.199
* 18.198.204.13
* 3.121.251.156
* 3.67.31.16
* 52.76.150.186
* 18.140.224.133
* 13.213.84.158
* 13.228.141.160
* 54.151.121.97
* 54.219.48.129

***

## **商户 IP 白名单**

为了进一步加强安全性，您还可以设置 IP 白名单，确保只有指定的 IP 地址能够访问 Codapay 的订单请求接口。

操作路径：**Coda后台** -> **集成** -> **Codapay** -> **API Keys** -> **行动** -> **编辑**

***


---

# 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/ji-cheng-zhi-nan/an-quan-zhi-nan.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.
