学习笔记

Study notes

googleplay 内购 In-app Billing php代码

云逐梦34802017-07-25 23:00:00返回列表

googleplay 内购 In-app Billing php代码

<?php

//如果参数receipt,signature需要urldecode则可用urldecode(str_replace('+','%2b',$_REQUEST['receipt'])); 需要注意的是+转义的问题(+号会转成空格。)
$receipt       = $_REQUEST['receipt'];    // receipt data from Corona (event.transaction.receipt)
$signature     = $_REQUEST['signature'];  // signature from Corona (event.transaction.signature)


$googlePlayKey   = "MIIBIjANB... Public key text from Google Play Developer Console ...";
$publicKey       = "-----BEGIN PUBLIC KEY-----\n" . chunk_split($googlePlayKey, 64, "\n") . '-----END PUBLIC KEY-----';

$result = openssl_verify($receipt, base64_decode($signature), $publicKey);
 if ( $result == 1 ) {
echo "google in app billing success";
 }elseif ($result == 0) {
     echo "google app billing verify failed";
 }else{
     echo "error checking signature";
 }
 
?>


返回
顶部