> 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/shou-quan-authorization.md).

# 授权 (Authorization)

## 1. 签名计算

所有请求必须包含签名。请求的签名是对以下字段按正确顺序进行哈希计算的结果：

### Validate 和 Topup API 请求：

`id + jsonrpc + method + serviceProvider + txnId + orderId + userId + zoneId + currency + amount + sku + quantity + paymentChannelId + isForTest (+ roleId)`

#### 示例

{% tabs %}
{% tab title="示例" %}
id = “4123456789012345678”\
jsonrpc = "2.0"\
method = "topup"\
serviceProvider = "Coda"\
txnId = “4123456789012345678"\
orderId = "4876543210987654321"\
userId "1002356"\
zoneId": "101"\
currency = "IDR"\
amount = "200000.0"\
sku = "diamonds\_1"\
quantity = 1\
paymentChannelId = 0\
isForTest = 0\
roleId="111"\
secretKey = 1234567890ABCDE
{% endtab %}
{% endtabs %}

### 如果不需要 roleId：

*Hmac 值应按如下方式计算：*\
hmac.encode（“1234567890ABCDE”，“41234567890123456782.0topupCoda412345678901234567848765432109876543211002356101IDR200000.0diamonds\_1100”，'SHA256'）

*生成的签名值等于：*

78c0e1335a95b9b0bd2b8c24f34f15c2b5d51b860487aa1a5d0e84ad4bf3c09b

### **如需 roleId：**

*Hmac 值应按如下方式计算：*\
\_hmac.encode("1234567890ABCDE", "41234567890123456782.0 充值代码 412345678901234567848765432109876543211002356101 印尼盾 200000.0 钻石\_1100111", 'SHA256')

*生成的签名值等于：*

9a648682c00726535f3c0c7db15cdb795bf6138378ff3478625eca260dcfe3dd

*使用 python 生成签名的示例 bash 脚本：*\
\#-------------------------------------------------------------\
echo -e "import hashlib,hmac\nprint hmac.new('secretKey', '41234567890123456782.0topupCoda412345678901234567848765432109876543211002356101IDR200000.0diamonds\_112270', hashlib.sha256).hexdigest()" | python\
\#-------------------------------------------------------------

[签名生成的示例代码](https://gist.github.com/thewheat/7342c76ade46e7322c3e)

\*secretKey: 商户定义此值并与 Coda 共享。

### 2. IP 白名单

#### Codashop 正式环境：

```
13.234.53.196
18.157.174.255
3.67.106.122
3.124.87.28
3.66.45.174
3.67.18.195
52.59.102.227
52.76.150.186
54.251.135.133
52.74.55.183
13.250.255.93
18.142.36.246
50.18.121.79
184.72.22.6
54.193.247.199
13.214.67.12
52.76.74.182
52.58.86.118
18.193.13.203
52.8.55.169
52.53.94.1
```

#### Codashop 预发布环境：

```
18.198.54.187
52.28.188.153
18.142.92.36
```

#### xShop

```
18.139.211.151
52.28.188.153
18.198.54.187
```


---

# 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/shou-quan-authorization.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.
