Bank Debit
概要
使用游戏内虚拟货币购买物品所需的API。进行事务创建和取消处理。
信息
关于梦宝币物品收费的详情,请同时参见教程。
注意
请在imageUrl 中指定https 协议的图片。指定http 协议后,浏览器可能会出现警告。
Bank Debit 对象字段
向Bank Debit API 发送请求后,会反馈Bank Debit 对象。
| 参数名 | 说明 |
|---|---|
| published | 事务创建的时间 |
| comment | 对事务的备注 |
| id | 事务 ID |
| updated | 事务更新的时间 |
| items | 物品数组。目前只能指定1件物品 |
| items[].item | 带有下述参数的对象 |
| items[].item.imageUrl | 物品图片的 URL (https) |
| items[].item.name | 物品名 |
| items[].item.id | 购买对象物品 ID |
| items[].item.price | 物品价格 |
| items[].item.description | 物品的说明 |
| items[].quantity | 本事务购买的物品件数 |
| state | 事务的状态 |
端点URL
Sandbox环境
https://sb-app.mobage.jp/social/api/restful/v2.02/bank/debit/{appid}/{transactionId}
正式环境
https://app.mobage.jp/social/api/restful/v2.02/bank/debit/{appid}/{transactionId}
API请求
HTTP 方法
- Authorization Code Grant
- POST 新建事务。
- PUT 更新已创建事务的状态。(只能更改为取消)
- GET 获取指定事务的信息。
- Client Credentials Grant
- 不支持
签名方式
OAuth2
请求报头
- Authorization 为必须。请在HTTP报头中添加示例 "Authorization: Bearer oauth2_token" 。
- Content-Type: application/json; charset=utf-8
API响应
| HTTP状态代码 | HTTP 状态信息 | 说明 |
|---|---|---|
| 200 | OK | 获取数据成功时 |
| 201 | Created | 数据获取已生成时 |
| 202 | Accepted | 更新数据成功时 |
| 400 | Bad Request | 客户端的请求数据不当 |
| 401 | Unauthorized | 认证错误 |
| 403 | Forbidden | 资源存在,但由于认证错误以外的原因导致不能访问的情况 |
| 404 | Not Found | 资源不存在 |
| 500 | Internal Server Error | API 服务器端的错误 |
| 503 | Service Unavailable | API 暂时不可用时 |
样例
为了购买游戏物品而新建事务
请求格式
POST /social/api/restful/v2.02/bank/debit/@app
Authorization: Bearer 1126d0ba1d9e48ed3542c450318811b3
Content-Type: application/json; charset=utf-8
{
"items":[{
"item":{
"id":"item_1",
"name":"Sample Item",
"price":100,
"description":"This is a sample item",
"imageUrl":"https://mobage.com/homepage-assets/images/icon.png"
},
"quantity":2
}],
"comment":"Purchase of 2 Sample Item(s)",
"state":"new"
}
响应格式
201 Created
取消已创建的事务。
请求格式
PUT /social/api/restful/v2.02/bank/debit/@app/EBF8C5E8-D722-3F49-8F2F-60595A4C6F30?fields=state
Authorization: Bearer 1126d0ba1d9e48ed3542c450318811b3
Content-Type: application/json; charset=utf-8
{"state":"canceled"}
响应格式
202 Accepted
{
"published":"2013-09-29T12:28:26",
"comment":"Purchase of 2 Sample Item(s)",
"id":"EBF8C5E8-D722-3F49-8F2F-60595A4C6F30",
"updated":"2013-09-29T12:29:36",
"items":[{
"item":{
"imageUrl":"https://mobage.com/homepage-assets/images/icon.png",
"name":"Sample Item",
"id":"item_1",
"price":100,
"description":"This is a sample item"
},
"quantity":2
}],
"state":"canceled"
}
获取多个指定事务的信息。
请求格式
GET /social/api/restful/v2.02/bank/debit/@app/72FECA23-7E18-3E2B-BF81-305ED540DC39,5E61A3EB-8DCA-385C-94CE-A18294560F4B
Authorization: bearer 6d796a30388f217db3dcff0d513e4206
响应格式
200 OK
{
"entry":[
{
"published":"2013-09-29T13:02:30",
"comment":"Purchase of 2 Sample Item(s)",
"id":"72FECA23-7E18-3E2B-BF81-305ED540DC39",
"updated":"2013-09-29T13:02:30",
"items":[{
"item":{
"imageUrl":"https://mobage.com/homepage-assets/images/icon.png",
"name":"Sample Item",
"id":"item_1",
"price":100,
"description":"This is a sample item"
},
"quantity":2
}],
"state":"new"
},
{
"published":"2013-09-29T13:01:10",
"comment":"Purchase of 2 Sample Item(s)",
"id":"5E61A3EB-8DCA-385C-94CE-A18294560F4B",
"updated":"2013-09-29T13:01:10",
"items":[{
"item":{
"imageUrl":"https://mobage.com/homepage-assets/images/icon.png",
"name":"Sample Item",
"id":"item_1",
"price":100,
"description":"This is a sample item"
},
"quantity":2
}],
"state":"new"
}
],
"startIndex":1,
"sorted":false,
"itemsPerPage":2,
"updatedSince":false,
"totalResults":2,
"filtered":false
}
更新履历
- 2016/03/16
- PUT 请求只能使用取消,故修改文档
- 2015/06/30
- 需要在imageUrl 中设置 https 图片,故修改文档