Introspection API
概要
アイテム決済完了時、アプリケーションに通知される JWT 形式のトランザクショントークンの検証を行う API です。
認可方法
この API を利用する為には表に示す grant_type, scope で取得した access token を Authorization リクエストヘッダに指定する必要があります。
- 認可タイプ
- 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 | トランザクショントークン | string | true | アイテム決済完了時、アプリケーションに通知される JWT 形式のトランザクショントークンです。 |
リクエスト例
リクエスト例は以下のようになります。
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 | トークン種別 | 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 | |
| transaction.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 | トランザクショントークンの形式が JWT 形式でない場合 |
| 400 | Invalid JOSE Header | about:blank | トランザクショントークンの JOSE Header の形式が不正な値の場合 |
| 400 | Invalid JWT Claims | about:blank | トランザクショントークンの JWT Claims の形式が不正な値の場合 |
| 403 | Signature is not verified | about:blank | トランザクショントークンの署名が妥当ではない場合 |
| 403 | Unexpected audience | about:blank | この API を呼び出した Client とトランザクショントークンの aud クレームが表す Client が一致しない場合 |
| 403 | Expired token | about:blank | トランザクショントークンが失効している場合に返されます |
| 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
- 新規作成