android in app billing v3 with php -
i'm trying android in app billing v3 verifying on remote php server.
but, seems wrong @ codes.
i think openssl_verify function problem.
result failed!
i can't find first parameter verify openssl_verify. actually, 'm confuse what's reasonable format place @ first parameter :(
could me solve it?
$result = openssl_verify($data["purchasetoken"], base64_decode($signature), $key); // original // failed
belows full test codes.
<?php $responsecode = 0; $encoded='{ "orderid":"12999763169054705758.1111111111111", "packagename":"com.xxx.yyy", "productid":"test__100_c", "purchasetime":1368455064000, "purchasestate":0, "purchasetoken":"tcmggamllmgqiabymvcgtfsj.ao-j1owoozofd-g-....." }'; $data = json_decode($encoded,true); $signature = "tkdvc42ujbyfll+3sgdl7rauplnv....."; $publickey = "miibijanbgkqhkig9w0baqefaaocaq8amiibcgkcaqea2kmri6me5+....."; $key = "-----begin public key-----\n" . chunk_split($publickey, 64, "\n") . "-----end public key-----"; $key = openssl_get_publickey($key); if (false === $key) { exit("error openssl_get_publickey"); } var_dump($key); $result = openssl_verify($data["purchasetoken"], base64_decode($signature), $key); // original // failed //$result = openssl_verify($data, base64_decode($signature), $key); // failed //$result = openssl_verify($encoded, base64_decode($signature), $key); // failed //$result = openssl_verify(base64_decode($data["purchasetoken"]), base64_decode($signature), $key); // failed //$result = openssl_verify(base64_decode($signature),$data["purchasetoken"], $key,openssl_algo_sha512 ); // failed if ($result == 1) { echo "good"; } elseif ($result == 0) { echo "bad"; } else { echo "error"; } echo($result);
thanks :)
you passing wrong $data
value openssl_verify()
. value should full json string google play, not purchase token inside it. important json string untouched, if add space or newlines it, signature no longer work.
all need in code above change line:
$result = openssl_verify($data["purchasetoken"], base64_decode($signature), $key);
to
$result = openssl_verify($data, base64_decode($signature), $key);
and should success, assuming you're using correct public key , json purchase string valid. i'm pretty sure json string not original string google however, ones google not contain newlines. 1 long line of json text. make sure that's passing openssl_verify()
.
Comments
Post a Comment