Introspection API
概要
用于在物品结算完成时,对通知应用软件的 JWT 形式交易Token进行验证的 API 。
认****可方法
为了使用该 API ,需要在 Authorization 请求头中指定表中所示按 grant_type, scope 获取的 access token 。
- 认可类型
- Bearer
- 支持的 grant_type
- client_credentials_grant
- 需要的 scope
- transactionToken:introspect
终点 URL
各环境中的终点 URL 如下所述。
| item | description |
|---|---|
| HTTP Method | POST |
| Request URI | sandbox java https://sb-api.andapp.jp/1.0.0/payment/introspection 正式环境 java https://api.andapp.jp/1.0.0/payment/introspection |
请求头
请求头如下。
| name | value | required | description |
|---|---|---|---|
| Content-Type | application/json | true |
请求正文
可设置带有下述参数的 JSON 字符串。
| property | title | type | required | description |
|---|---|---|---|---|
| transactionToken | 交易Token | string | true | 在物品结算完成时,通知应用软件的 JWT 形式交易Token 。 |
请求示例
请求示例如下。
POST /1.0.0/payment/introspection HTTP/1.1
Host: sb-api.andapp.jp:443
Content-Type: application/json
Authorization: Bearer {access_token}
{
"transactionToken": "eyj..."
}
响应状态
成功时的响应状态如下。
| status | description |
|---|---|
| 200 OK | Transaction Token 适当时,反馈此项。 |
响应头
响应头如下。
| name | value | required | description |
|---|---|---|---|
| Content-Type | application/json | true |
响应正文
带有下述参数的 JSON 字符串。详见下述示例。
| property | title | type | required | description |
|---|---|---|---|---|
| iss | Issuer 要求 | string | true | 表示发行者的 URI。 根据执行环境,其值如下。 sandbox https://sb-api.andapp.jp/1.0.0/payment
正式环境 https://api.andapp.jp/1.0.0/payment
|
| sub | Subject 要求 | string | true | 表示已支付玩家的URI 。 根据执行环境, URI 格式 (URI Template 格式) 如下。 sandbox https://sb-api.andapp.jp/1.0.0/users{/playerId}
正式环境 https://api.andapp.jp/1.0.0/users{/playerId}
|
| aud | Audience 要求 | string | true | 表示已请求支付的游戏 Client ID 的 URI。 根据执行环境, URI 格式 (URI Template 格式) 如下。 sandbox https://sb-api.andapp.jp/1.0.0/clients{/clientId}
正式环境 https://api.andapp.jp/1.0.0/clients{/clientId}
|
| typ | Token类别 | string | true | transaction_token 的固定值 |
| iat | 发行时间的UNIX 时间戳 | integer | true | 表示transaction_token 发行时间的 UNIX 时间戳值 |
| exp | 失效时间的UNIX 时间戳 | integer | true | 表示transaction_token 失效时间的 UNIX 时间戳值 超过失效时间的 Transaction Token 会失效 |
| transaction | 交易 对象 | object | true |
|
| transaction.id | 交易 ID | integer | true | 最大 16 位 |
| transaction.product | 已购买的产品对象 | object | true | |
| transaction.clientId | 已创建交易对象的 客户端 ID | integer | true | 最大 16 位 |
| transaction.userId | 已创建交易对象的 玩家 ID | integer | true | 最大 16 位 |
| transaction.product.id | 产品对象的 ID | string | true | |
| transaction.product.clientId | 已创建产品对象的客户端 ID | integer | true | 最大 16 位 |
| transaction.product.type | 产品类别 | string | true | CONSUMABLE 的固定值 |
| transaction.product.state | 产品状态 | string | true | AVAILABLE 的固定值 |
| transaction.product.prices | 不同货币的产品含税价格表 | array | true | |
| transaction.product.prices[] | 不同货币的产品含税价格对象 | object | true | |
| transaction.product.prices[].value | 价格 | number | true | |
| transaction.product.prices[].currency | 货币单位 | string | true | JPY 的固定值 |
| transaction.product.prices[].taxRate | 税率(%) | number | true | 0-100 之间的值 |
| transaction.product.language | 语言 | string | true | ja-JP 的固定值 |
| transaction.product.title | 产品名称 | string | true | |
| transaction.product.description | 产品说明语 | string | true | |
| transaction.product.createdAt | 产品创建时间的 UNIX 时间戳 | integer | true | |
| transcation.product.updatedAt | 产品更新时间的 UNIX 时间戳 | integer | true | |
| transaction.quantity | 购买数量 | integer | true | |
| transaction.totalPrice | 含税合计购买价格对象 | object | true | |
| transaction.totalPrice.value | 合计价格 | number | true | |
| transaction.totalPrice.currency | 货币单位 | string | true | JPY 的固定值 |
| transaction.totalPrice.taxRate | 税率(%) | number | true | 0-100 之间的值 |
| transaction.state | 交易状态 | string | true | PURCHASED 的固定值 |
| transaction.developerPayload | 请求支付时由开发者指定的任意有效载荷 | string | true | |
| transaction.refundTo | 退款接收方的交易 ID | integer | true | null的固定值 |
| transaction.refundedBy | 退款方的交易 ID | integer | true | null的固定值 |
| transaction.consumedAt | 产品消费时间的UNIX 时间戳 | integer | true | null的固定值 |
| transaction.purchasedAt | 支付确定时间的UNIX 时间戳 | integer | true | |
| transaction.createdAt | 交易创建时间的UNIX 时间戳 | integer | true | |
| transaction.updatedAt | 交易更新时间的UNIX 时间戳 | integer | true | |
| developerPayload | 开发者可任意输入的搜索框 | string | true | 0-4096 字, 默认带有 "" 。 |
响应示例
HTTP/1.1 200 OK
Content-Type: application/json
{
"iss": "https://sb-api.andapp.jp/1.0.0/payment",
"sub": "https://sb-api.andapp.jp/1.0.0/users/6104524",
"aud": "https://sb-api.andapp.jp/1.0.0/clients/189268204754",
"typ": "transaction_token",
"iat": 1464095267,
"exp": 1464096167,
"transaction": {
"id": 1234567890123456,
"clientId": 189268204754,
"userId": 1234567890123456,
"product": {
"id": "xxx.yyy.zzz.3000",
"clientId": 189268204754,
"type": "CONSUMABLE",
"state": "AVAILABLE",
"prices": [
{ "value": 3240, "currency": "JPY", "taxRate": 8 }
],
"language": "ja-JP",
"title": "物品名",
"description": "物品说明",
"createdAt": 1463468400,
"updatedAt": 1463468400
},
"quantity": 2,
"totalPrice": { "value": 6480, "currency": "JPY", "taxRate": 8 },
"state": "PURCHASED",
"developerPayload": "",
"refundTo": null,
"refundedBy": null,
"consumedAt": null,
"purchasedAt": 1463468400,
"createdAt": 1463468400,
"updatedAt": 1463468400
}
}
错误响应
错误响应以 application/problem+json 的形式发出。状态代码和 Problem Type 的 type 属性值如下。
| status | title | type | description |
|---|---|---|---|
| 400 | Invalid JWT Format | about:blank | 交易Token 的形式非 JWT 形式时 |
| 400 | Invalid JOSE Header | about:blank | 交易Token 的 JOSE Header 形式为非法值时 |
| 400 | Invalid JWT Claims | about:blank | 交易Token 的 JWT Claims 形式为非法值时 |
| 403 | Signature is not verified | about:blank | 交易Token 的签名不适当时 |
| 403 | Unexpected audience | about:blank | 调用该 API 的 Client 与交易Token 的 aud 要求所示的 Client 不一致时 |
| 403 | Expired token | about:blank | 交易Token 已失效时,反馈此项 |
| 403 | Withdrawal user | about:blank | 对用户有限制时,反馈此项。 |
| 500 | Server Error | about:blank | API 服务器端发生错误时,反馈此项 |
| 503 | Service Unavailable | about:blank | API 服务器暂时不能响应时,反馈此项 |
错误响应示例
错误响应示例如下。
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Bad Request",
"code": 400,
"instance": "https://sb-api.andapp.jp/1.0.0/payment/introspection"
}
更新履历
- 2017/02/07
- 添加以下最大位数
-
transaction.id
transaction.clientId
transaction.userId
transaction.product.clientId
-
- 添加以下最大位数
- 2016/10/05
- 响应正文中遗漏了 transaction.clientId 和 transaction.userId 的说明,故增补。
- 2016/10/03
- 增补了对用户有限制时的错误代码。
- 2016/07/28
- 新建