Java-google play支付如何用php验证订单完成的合法性
在接google play的充值渠道,用户购买和支付都在客户端完成操作,用户支付完成后,客户端会下发支付信息给充值平台(php开发的),充值平台需要验证这些信息的合法性。请教有开发过的同学,如何使用php验证支付信息。
订单相关信息
"nonce" : 1836535032137741465,
"orders" :
[{ "notificationId" : "android.test.purchased",
"orderId" : "transactionId.android.test.purchased",
"packageName" : "com.example.dungeons",
"productId" : "android.test.purchased",
"developerPayload" : "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseTime" : 1290114783411,
"purchaseState" : 0,
"purchaseToken" : "rojeslcdyyiapnqcynkjyyjh" }]
}
这是文档http://developer.android.com/guide/google/play/billing/billing_overview.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
得到高人的指点。可以这么验证。
$signture_data = '{"nonce":2923936465474897294,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"com.kunlun.fysg.test","productId":"android.test.purchased","purchaseTime":1346916115611,"purchaseState":0}]}';
$signture = '';
//google app 提供的public key
$public_key = "";
$public_key = chunk_split($public_key, 64, "n") . "-----END PUBLIC KEY-----";
$public_key_handle = openssl_get_publickey($public_key);
$result = openssl_verify($signture_data, base64_decode($signture), $public_key_handle, OPENSSL_ALGO_SHA1);
if ($result == 1)
{
echo "good";
}
elseif ($ok == 0)
{
echo "bad";
}
else
{
echo "ugly, error checking signature";
}
刚刚做完V3版本的解密。
public_key 分隔应该是缺了前面一部分
$public_key = "-----BEGIN PUBLIC KEY-----n" . chunk_split($public_key, 64, "n") . "-----END PUBLIC KEY-----";
解密算法同V2一样
purchaseState The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), 2 (refunded), or 3 (expired, for subscription purchases only).
注意这个参数值
https://developer.android.com/guide/google/play/billing/billing_reference.html#billing-intents
你好,我最近也在做google play verifying purchase on server ,但是遇到的问题是客户端传过来的$signture_data 却不是上面那样的json。
客户端传过来的json是这样的:
'{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
"purchaseTime":1345678900000,
"purchaseState":0,
"developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
"purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
}'
这个是google play的文档:
http://developer.android.com/google/play/billing/billing_integrate.html
客户端用的是v3的api。
请问要怎么去验证支付的正确性?