オファー検証 API
概要
プレイヤーがオファーメッセージを閲覧し、購入ボタンをクリックするなど、オファーを受諾すれば、次のステップに進む前にREST APIを利用してオファーを検証しなければなりません。 この検証APIを使えば、該当オファーがTentuPlayサーバーから来たもので、信頼性、完全性、そしてセキュリティ上に問題がないということを確認することができます。 オファーの検証は、パーソナライズされたおすすめとAI In-Game Shopの両方から適用可能であり、応答メッセージだけが異なります。
検証APIを使う前に、TentuPlayに以下のキー情報をリクエストしてもらってください。
|
APIキーセキュリティ フロントエンドアプリにAPIキーが露出しないように、リクエスト結果をもたらす時にバックエンドサーバーを通じて結果がフロントエンドに伝わるようにしてください。 |
APIメソッド
オファー検証
プレイヤーが受けたオファーidに対する検証リクエスト
Request Body
-
Content type: application/json
Name | Description | Type | Required | Default |
---|---|---|---|---|
|
プレイヤー固有のid |
string |
required |
null |
|
オファーid |
integer |
required |
null |
{
"player_uuid": "string",
"offer_id": 10
}
Responses
検証成功
HTTP/1.1 200 OK
Content-Type:application/json
{
"success": true, //boolean
"result": "(string encoded in base64)"
}
レスポンスデータはAES-256-CTR アルゴリズムで暗号化されています。レスポンスデータは仮の値(nonce)と暗号化されたデータが結合され、Hexにエンコードされています。 デコードされたデータの前の12バイトが仮の値です。
デコード後、データパートはペイロードキーで復号化してください。 たとえば、次の例コードは、Pythonで書かれた復号化コードです。
result = response.data['result']
byte_data = binascii.unhexlify(result.encode('utf-8'))
nonce = byte_data[:8]
encrypted_bytes = byte_data[8:]
cipher = AES.new(payload_key.encode('utf-8'), AES.MODE_CTR, nonce=nonce)
decrypted_bytes = cipher.decrypt(encrypted_bytes)
raw_data = decrypted_bytes.decode('utf-8')
復号化に成功すると、レスポンスメッセージのJSON bodyを次の例のように見ることができます。 レスポンスメッセージは、オファーの種類によって異なります。
- 手動オファー(パーソナライズされたおすすめ)
-
{ "player_uuid": "", "offer": { "price": 99.99, "message": { "en": { "url": "https://", "image": "https://", "title": "" } }, "product_id": "", "product_name": "", "discount_rate": 10, "discount_price": 89.99, "message_layout": "h" }, "is_opened": true, "expire_at": "YYYY-MM-DD hh:mm:ss" // 値がなければ期間に制限がないことを意味 }
- AIオファー(AI In-Game Shop)
-
{ "player_uuid": "", "offer": { "offer_type": "ai", "recommendations": [ { "store": "google", "product_list": [ { "purchasable_slug": "diamond_500", "product_index": "", "purchase_link": "", "start_datetime": "YYYY-MM-DD hh:mm:ss", "end_datetime": "YYYY-MM-DD hh:mm:ss" } ] } ], "display_parameters": { "en": { "title": "", "message": "", "background_url": "https://", "toggle_message": "don't see me again today" } }, { "player_uuid": "", "offer": { "offer_type": "ai", "recommendations": [ { "store": "google", "product_list": [ { "purchasable_slug": "diamond_500", "product_index": "", "purchase_link": "", "start_datetime": "YYYY-MM-DD hh:mm:ss", "end_datetime": "YYYY-MM-DD hh:mm:ss" } ] } ], "display_parameters": { "en": { "title": "", "message": "", "background_url": "https://", "toggle_message": "don't see me again today" } }, "message_parameters": { "<parameter_in_message>": { "entity": "<purchasable|characterarchetype|item|...>", "slug": "" } } }, "is_opened": true, "expire_at": "YYYY-MM-DD hh:mm:ss" // 値がなければ期間に制限がないことを意味 }