124 lines
3.8 KiB
Markdown
124 lines
3.8 KiB
Markdown
## 回调函数
|
||
|
||
1. ceg支付回调
|
||
|
||
地址: <https://game2006api-test.kingsome.cn/webapp/index.php?c=Callback&a=dispatch&action=gameItemMallBuyOk>
|
||
|
||
调用方: web3server
|
||
|
||
参数说明:
|
||
|
||
| 参数名 | 类型 | 必填 | 说明 |
|
||
| ----------- | ------ | ---- | ------------------------ |
|
||
| trans\_id | string | 是 | 事务id |
|
||
| order\_id | string | 是 | 订单id |
|
||
|
||
返回说明:
|
||
|
||
```javascript
|
||
{
|
||
"errcode": 0, //0成功 1:已发货 2:订单不存在
|
||
"errmsg": ""
|
||
}
|
||
```
|
||
|
||
2. 购买ceg回调
|
||
|
||
地址: <https://game2006api-test.kingsome.cn/webapp/index.php?c=Shop&a=buyGoodsDirect>
|
||
|
||
调用方: 链上购买服务(hongliang)
|
||
|
||
请求方法: [GET]
|
||
|
||
参数说明:
|
||
|
||
| 参数名 | 类型 |必填 | 说明 |
|
||
| ----------- | ------- | ----- | --------------------------------------------------------- |
|
||
| account_id | string | 是 | 账户id (中心化游戏账号,充值成功后会给绑定的账号一些奖励) |
|
||
| oreder_id | string | 是 | 订单id |
|
||
| status | string | 是 | 订单状态 |
|
||
| id | string | 是 | goods_id |
|
||
| txhash | string | 是 | txhash |
|
||
| sign | string | 是 | 签名 |
|
||
|
||
|
||
调用说明:
|
||
```
|
||
// let repdata = {
|
||
// account_id: string
|
||
// order_id: string
|
||
// status: string
|
||
// id: string
|
||
// txhash: string
|
||
// }
|
||
// 我返回给你这些数据和一个sign字段,
|
||
// sign使用上面 repdata 按key 顺序排后, 组成key1=val1&key2=val2后, 使用hmac_sha256 hash, key是 iG4Rpsa)6U31$H#^T85$^^3
|
||
// PENDING = 0, // 初始状态
|
||
// TRANSFERING = 1, //只有国库模式才会有该状态
|
||
// TRANSFERED = 2, //只有国库模式才会有该状态
|
||
// SUCCESS = 9, // 成功的最终状态
|
||
// TRANSFER_FAIL = 98, // 转账错误
|
||
// FAIL = 99, // 也是错误
|
||
//
|
||
```
|
||
|
||
返回说明:
|
||
```
|
||
{
|
||
"errcode": 0, // 0 操作成功
|
||
"errmsg" : ""
|
||
}
|
||
```
|
||
|
||
3. 内购回调
|
||
|
||
调用方: 内购服务(hongliang)
|
||
|
||
地址: <https://https://game2006api-test.kingsome.cn/webapp/index.php?c=Shop&a=inappPurchaseDiamonds>
|
||
|
||
请求方法 [POST]
|
||
|
||
参数说明:
|
||
|
||
| 参数名 | 类型 |必填 | 说明 |
|
||
| ----------- | ------- | ---- | ------------------------------------------------- |
|
||
| channel | string | 是 | google or apple |
|
||
| records | array | 是 | 订单表,一次返回多个 |
|
||
| sign | string | 是 | 签名 |
|
||
|
||
|
||
调用说明:
|
||
```
|
||
// {
|
||
// channel: 'google',
|
||
// sign: '123456677' // 签名字段
|
||
// records: [{
|
||
// productId: '2999', // 从google play console获取的product id
|
||
// gameOrderId: '1231321312', // 开始支付时, 从游戏相关服务那获得的订单id
|
||
// orderId: 'GPA.3355-1172-9416-16839', // 从google develope API 获取的订单id
|
||
// status: 9, // 订单状态, 上报的订单状态一般只有2种情况, 9: 支付成功, 96: 用户退款
|
||
// }]
|
||
// }
|
||
// let reportData: any = {
|
||
// channel: 'google',
|
||
// records,
|
||
// }
|
||
// const hashSort = 'iG4Rpsa)6U31$H#^T85$^^3'
|
||
// const signStr = 'channel=google&' + records.map(record =>Object.keys(record).sort().map(key => `${key}=${record[key]}`).join('&')).join('&')
|
||
|
||
// const sign = hmacsha256(signStr, hashSort)
|
||
|
||
// 定义一个空数组,用来存放每个记录的键值对字符串
|
||
```
|
||
返回说明:
|
||
```
|
||
{
|
||
"errcode": 0, // 0 操作成功
|
||
"errmsg" : ""
|
||
}
|
||
```
|
||
|
||
[^1]
|
||
|
||
|
||
[^1]: this |