「Unity/課金/リモートレシート検証/phpサーバ」の版間の差分
提供: 初心者エンジニアの簡易メモ
| 行1: | 行1: | ||
==phpで検証== | ==phpで検証== | ||
<pre> | <pre> | ||
| − | $receiptJson = '{"orderId":" | + | $receiptJson = '{"orderId":"GPA.xxxx-xxxx-xxxx-xxxxx","productId":"product1",...}'; |
| − | $signature = base64_decode(' | + | $signature = base64_decode('[signatureデータ]'); |
// 下記のURLなどを参考にpem形式に変換 | // 下記のURLなどを参考にpem形式に変換 | ||
2025年3月18日 (火) 13:10時点における版
phpで検証
$receiptJson = '{"orderId":"GPA.xxxx-xxxx-xxxx-xxxxx","productId":"product1",...}';
$signature = base64_decode('[signatureデータ]');
// 下記のURLなどを参考にpem形式に変換
// FYI: http://php.net/manual/ja/ref.openssl.php
$publicKey = der2pem(base64_decode('[googleplay収益化セットアップのrsa公開鍵]'));
if (openssl_verify($receiptJson, $signature, openssl_get_publickey($publicKey)) === 1) {
// 検証ok
}
