LoginSignup
0
0

More than 3 years have passed since last update.

UnityIAPでAndroidのReceipt情報などを持ってくるときの注意点

Posted at

tl; dr

public static void ProcessReceipt(Product item)
{
    var receipt = Jsonをデシリアライズする処理(item.receipt);

    var payload = Jsonをデシリアライズする処理(receipt.String("Payload"));

    // json    Google によって提供される文字列にエンコードされた JSON
    // signature    Google によって提供される JSON パラメーターの署名
    var json = payload.String("json");
    var sig = payload.String("signature");

言いたいこと

諸悪の根源: https://docs.unity3d.com/ja/current/Manual/UnityIAPPurchaseReceipts.html

Productreceipt には JSON 文字列が入ってくるが、それをJSONとして解釈したとき Payload をキーとして引っ張ってこれる文字列は JSON 文字列であり、これをさらに JSON として解釈したとき……

  1. json キーで取り出せる文字列が INAPP_PURCHASE_DATA に相当する JSON 文字列である(さらにこれをJSONとして解釈せねばならない)
  2. signature キーで取り出せる文字列は INAPP_DATA_SIGNATURE に相当する文字列である

インターネットのどこを見ても説明が分かりづらい(具体的にProduct.receiptにどのような文字列が入り込むのか、そこまで具体的に挙げて説明しているサイトが見当たらないので)。

JSON.stringify した文字列を JSON に文字列として入れ込むの、好き過ぎじゃないですか。どこまでも入れ子して運用してる現場、沢山あるんだろうか……恐ろしい……。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0