2020-03-25 12:05:53 +08:00
|
|
|
|
# 微信&支付宝方式充电
|
|
|
|
|
|
2020-05-13 21:53:25 +08:00
|
|
|
|
**本页所有操作均需登录(SESSDATA)**
|
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-03-25 12:05:53 +08:00
|
|
|
|
操作流程:
|
|
|
|
|
|
|
|
|
|
1.申请充电二维码及扫码秘钥,秘钥临时保存备用
|
|
|
|
|
|
|
|
|
|
2.使用`qr_code_url`中的值生成二维码
|
|
|
|
|
|
|
|
|
|
3.用支付宝或微信扫描
|
|
|
|
|
|
|
|
|
|
4.以扫码秘钥作为参数轮询检查扫码支付结果
|
|
|
|
|
|
|
|
|
|
## 申请充电二维码及扫码秘钥
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/ugcpay/trade/elec/pay/qr_code/create
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:POST*
|
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
|
|
|
|
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
|
|
|
|
| ------------------- | ---- | ------------------------ | ------ | ------------------------------------------------------------ |
|
|
|
|
|
| up_mid | num | 充电对象用户UID | 必要 | |
|
|
|
|
|
| elec_num | num | 充电电池数量 | 必要 | 必须在20-99990之间<br />1-19区间视为充值B币 |
|
|
|
|
|
| is_bp_remains_prior | bool | 是否优先扣除B币 | 必要 | true:是<br />false:否<br />在B币不足时剩余的部分利用支付平台支付 |
|
|
|
|
|
| otype | str | 充电来源 | 必要 | up:空间充电<br />archive:视频充电 |
|
|
|
|
|
| oid | num | 充电来源代码 | 必要 | 空间充电:充电对象用户UID<br />视频充电:视频avID |
|
|
|
|
|
| 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 |
|
|
|
|
|
| ttl | num | 1 | 作用尚不明确 |
|
|
|
|
|
| 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币的支付二维码
|
|
|
|
|
|
|
|
|
|
curl -b "SESSDATA=xxx" -d "up_mid=23215368&elec_num=10&is_bp_remains_prior=false&otype=up&oid=23215368&csrf=xxx" "http://api.bilibili.com/x/ugcpay/trade/elec/pay/qr_code/create"
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code": 0,
|
|
|
|
|
"message": "0",
|
|
|
|
|
"ttl": 1,
|
|
|
|
|
"data": {
|
|
|
|
|
"qr_code_url": "http://api.bilibili.com/x/ugcpay/trade/elec/pay/qr_code/gateway?mid=293793435\u0026token=c1cb1d95d2194ba58df6bb0f24ae1aaa",
|
|
|
|
|
"qr_token": "c1cb1d95d2194ba58df6bb0f24ae1aaa",
|
|
|
|
|
"exp": 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 检查扫码支付结果
|
|
|
|
|
|
|
|
|
|
> http://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status
|
|
|
|
|
|
2020-07-14 18:44:44 +08:00
|
|
|
|
*请求方式:GET*
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
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 |
|
|
|
|
|
| ttl | num | 1 | 作用尚不明确 |
|
|
|
|
|
| data | obj | 信息本体 | |
|
|
|
|
|
|
|
|
|
|
`data`对象:
|
|
|
|
|
|
|
|
|
|
| 字段 | 类型 | 内容 | 备注 |
|
|
|
|
|
| -------- | ---- | ----------- | ------------------------------------------------------------ |
|
|
|
|
|
| qr_token | str | 扫码秘钥 | |
|
2020-06-08 22:44:46 +08:00
|
|
|
|
| order_no | str | 留言token | 未成功则无此项<br />用于添加充电留言 |
|
2020-03-25 12:05:53 +08:00
|
|
|
|
| mid | num | 当前用户UID | |
|
|
|
|
|
| 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`
|
|
|
|
|
|
|
|
|
|
http://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status?qr_token=c7cbdc47fc424cd18f2146db653597b8
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"c7cbdc47fc424cd18f2146db653597b8",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
当申请到的支付二维码已扫描但未确认时,`data`.`ststus`的值为`3`
|
|
|
|
|
|
|
|
|
|
http://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status?qr_token=c7cbdc47fc424cd18f2146db653597b8
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"c7cbdc47fc424cd18f2146db653597b8",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":3
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-06-08 22:44:46 +08:00
|
|
|
|
成功支付后,`data`.`ststus`的值为`1`,且`data`.`order_no`存在留言token
|
2020-03-25 12:05:53 +08:00
|
|
|
|
|
|
|
|
|
http://api.bilibili.com/x/ugcpay/trade/elec/pay/order/status?qr_token=bd649c836c524550bfe22a369334fc05
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"code":0,
|
|
|
|
|
"message":"0",
|
|
|
|
|
"ttl":1,
|
|
|
|
|
"data":{
|
|
|
|
|
"qr_token":"bd649c836c524550bfe22a369334fc05",
|
|
|
|
|
"order_no":"BPTD36U3KP82I31RSSLG",
|
|
|
|
|
"mid":293793435,
|
|
|
|
|
"status":1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|