2020-03-25 12:05:53 +08:00
|
|
|
|
# 微信&支付宝方式充电
|
|
|
|
|
|
2020-04-02 16:53:01 +08:00
|
|
|
|
<img src="/imgs/battery-100.png" width="100" height="100"/>
|
|
|
|
|
|
2020-11-20 20:13:12 +08:00
|
|
|
|
- [申请充电二维码及扫码秘钥](#申请充电二维码及扫码秘钥)
|
|
|
|
|
|
|
|
|
|
- [检查扫码支付结果](#检查扫码支付结果)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
操作流程:
|
|
|
|
|
|
|
|
|
|
1.申请充电二维码及扫码秘钥,秘钥临时保存备用
|
|
|
|
|
|
|
|
|
|
2.使用`qr_code_url`中的值生成二维码
|
|
|
|
|
|
|
|
|
|
3.用支付宝或微信扫描
|
|
|
|
|
|
|
|
|
|
4.以扫码秘钥作为参数轮询检查扫码支付结果
|
|
|
|
|
|
|
|
|
|
## 申请充电二维码及扫码秘钥
|
|
|
|
|
|
2023-01-17 15:23:59 +08:00
|
|
|
|
> https://api.bilibili.com/x/ugcpay/web/v2/trade/elec/pay/qr_code/create
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
秘钥有效时间为10分钟
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**正文参数( application/x-www-form-urlencoded ):**
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------------------- | ---- | ------------------------ | ------ | ------------------------------------------------------------ |
|
2021-09-24 01:19:01 +08:00
|
|
|
|
| bp_num | num | 充电B币数量 | 必要 | 必须在2-9999之间 |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| up_mid | num | 充电对象用户mid | 必要 | |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| is_bp_remains_prior | bool | 是否优先扣除B币 | 必要 | true:是<br />false:否<br />在B币不足时剩余的部分利用支付平台支付 |
|
|
|
|
|
| otype | str | 充电来源 | 必要 | up:空间充电<br />archive:视频充电 |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| oid | num | 充电来源代码 | 必要 | 空间充电:充电对象用户mid<br />视频充电:稿件avid |
|
2020-07-09 16:34:50 +08:00
|
|
|
|
| csrf | str | CSRF Token(位于cookie) | 必要 | |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
2020-04-16 18:47:19 +08:00
|
|
|
|
根对象:
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
2020-05-08 18:32:38 +08:00
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-111:csrf校验失败<br />-400:请求错误<br />-500:服务器错误 |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ----------- | ---- | ------------------ | -------- |
|
|
|
|
|
| qr_code_url | str | 支付二维码生成内容 | 存在转义 |
|
|
|
|
|
| qr_token | str | 扫码秘钥 | |
|
|
|
|
|
| exp | num | 获得经验数 | |
|
|
|
|
|
|
2020-04-16 18:47:19 +08:00
|
|
|
|
**示例:**
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
|
|
|
|
申请空间的方式向用户23215368充电10电池且不使用B币的支付二维码
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl 'https://api.bilibili.com/x/ugcpay/trade/elec/pay/qr_code/create' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'elec_num=10' \
|
|
|
|
|
--data-urlencode 'up_mid=23215368' \
|
|
|
|
|
--data-urlencode 'is_bp_remains_prior=false' \
|
|
|
|
|
--data-urlencode 'otype=up' \
|
|
|
|
|
--data-urlencode 'oid=23215368' \
|
|
|
|
|
--data-urlencode 'csrf=xxx' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "0",
|
|
|
|
|
"ttl": 1,
|
|
|
|
|
"data": {
|
2020-07-18 23:56:10 +08:00
|
|
|
|
"qr_code_url": "http://api.bilibili.com/x/ugcpay/trade/elec/pay/qr_code/gateway?mid=293793435&token=c1cb1d95d2194ba58df6bb0f24ae1aaa",
|
2020-03-25 12:05:53 +08:00
|
|
|
|
"qr_token": "c1cb1d95d2194ba58df6bb0f24ae1aaa",
|
|
|
|
|
"exp": 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
## 检查扫码支付结果
|
|
|
|
|
|
2023-01-17 15:23:59 +08:00
|
|
|
|
> https://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:GET*
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
认证方式:Cookie(SESSDATA)
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
**url参数:**
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-04-02 16:53:01 +08:00
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| -------- | ---- | -------- | ------ | ---- |
|
2020-06-08 22:44:46 +08:00
|
|
|
|
| qr_token | str | 扫码秘钥 | 必要 | |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
|
|
|
|
**json回复:**
|
|
|
|
|
|
2020-04-16 18:47:19 +08:00
|
|
|
|
根对象:
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| ------- | ---- | -------- | ----------------------------- |
|
|
|
|
|
| code | num | 返回值 | 0:成功<br />-101:账号未登录 |
|
|
|
|
|
| message | str | 错误信息 | 默认为0 |
|
2020-07-17 23:50:28 +08:00
|
|
|
|
| ttl | num | 1 | |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| -------- | ---- | ----------- | ------------------------------------------------------------ |
|
|
|
|
|
| qr_token | str | 扫码秘钥 | |
|
2020-06-08 22:44:46 +08:00
|
|
|
|
| order_no | str | 留言token | 未成功则无此项<br />用于添加充电留言 |
|
2021-07-12 21:31:27 +08:00
|
|
|
|
| mid | num | 当前用户mid | |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| status | num | 状态值 | 若秘钥错误则无此项<br />1:已支付<br />2:未扫描<br />3:未确认 |
|
|
|
|
|
|
2020-04-16 18:47:19 +08:00
|
|
|
|
**示例:**
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
|
|
|
|
当申请到的支付二维码未被扫描时,`data`.`ststus`的值为`2`
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl -G 'https://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'qr_token=c7cbdc47fc424cd18f2146db653597b8' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"c7cbdc47fc424cd18f2146db653597b8",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
当申请到的支付二维码已扫描但未确认时,`data`.`ststus`的值为`3`
|
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl -G 'https://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'qr_token=c7cbdc47fc424cd18f2146db653597b8' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"c7cbdc47fc424cd18f2146db653597b8",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":3
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
成功支付后,`data`.`ststus`的值为`1`,且`data`.`order_no`存在留言token
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-07-18 23:56:10 +08:00
|
|
|
|
```shell
|
2023-01-17 15:23:59 +08:00
|
|
|
|
curl -G 'https://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status' \
|
2020-10-16 19:31:41 +08:00
|
|
|
|
--data-urlencode 'qr_token=c7cbdc47fc424cd18f2146db653597b8' \
|
2020-07-18 23:56:10 +08:00
|
|
|
|
-b 'SESSDATA=xxx'
|
|
|
|
|
```
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
<details>
|
|
|
|
|
<summary>查看响应示例:</summary>
|
|
|
|
|
|
2020-03-25 12:05:53 +08:00
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"bd649c836c524550bfe22a369334fc05",
|
|
|
|
|
"order_no":"BPTD36U3KP82I31RSSLG",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-08-31 16:37:38 +08:00
|
|
|
|
</details>
|