開発ブログ

株式会社Nextatのスタッフがお送りする技術コラムメインのブログ。

電話でのお問合わせ 075-744-6842 ([月]-[金] 10:00〜17:00)

  1. top >
  2. 開発ブログ >
  3. Unity >
  4. [Unity IAP 1.19] Google Play StoreのdeveloperPayloadに関する変更
no-image

[Unity IAP 1.19] Google Play StoreのdeveloperPayloadに関する変更

こんにちは、ナカエです。最近の業務はゲーム開発が主で、フロント側ではJavaScriptではなくUnityを触ることが多いです。

現在関わっているプロジェクトでは、課金処理に公式のUnity IAPを利用しています。

組み込みのGoogle Play Store, App Storeに加えて独自のStoreを実装しているのですが、プラットフォームごとの課金フローの差異を吸収できる点、通信失敗時の復元処理があらかじめ実装されている点が非常に便利です。独自Storeの実装では結構ハマりましたが……。

今回は、Unity IAPのバージョンを上げた際に、Google Play Storeのレシートに関する挙動の変化があったので覚書です。

 

developerPayload

Google Play StoreのレシートにはdeveloperPayloadという項目があります。購入リクエスト時にアプリ側が自由に設定でき、レシートに埋め込まれる仕組みです。開発者がユーザIDや追跡トークンを埋め込み、不正を防ぐ手段の1つとして利用できます。
 

Unity IAP 1.19での変更点

Unity IAPをバージョンアップしたところ、サーバサイドのGoogle Play Storeのレシート検証処理が動かなくなりました。このdeveloperPayloadをUnity IAPが改変して項目を付け足すようになっていたためでした。 元のdeveloperPayloadをbase64エンコードしたものとUnity IAPが独自に付与する項目をまとめたJSON文字列を新たにdeveloperPayloadの値とするようです。
"developerPayload":"{\"developerPayload\":\"元のdeveloperPayloadをbase64エンコードしたもの\",\"is_free_trial\":false,\"has_introductory_price_trial\":false}

Unity IAPのリリースノートのスレッドにはこの変更について下記のような記載があります。

Other changes: 
For GooglePlay store, developerPayload is now encoded to base64 string and formatted to a JSON string with two other information of the product. When extracting developerPayload from the product receipt, firstly decode the JSON string and get the developerPayload field base64 string, secondly decode the base64 string to the original developerPayload

そのプロジェクトではUnity IAPプラグイン自体に手を入れる気にはならなかったので、サーバサイドで上記リリースノート記載の対応をすることにしました。Unity IAPはまだ新機能追加が活発なようなので、メジャーバージョンアップに対応する心構えでバージョンを上げた方が良さそうですね。

  • posted by Nextatスタッフ
  • Unity
TOPに戻る