我如何验证谷歌玩在应用程序购买在PHP? [英] How can i verify google play in-app purchase in php?

查看:280
本文介绍了我如何验证谷歌玩在应用程序购买在PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过使用php页面的谷歌播放验证应用程序内购买的收据。
我应该怎么做?

I wish to verify a receipt of in-app purchase in an app through google play using a php page. How should i do it?

推荐答案

我不是PHP专家,所以我不会发布任何信息代码,但整个过程非常直接,它应该很容易移植到PHP。您需要三件事来验证购买:

I'm no PHP expert so I'm not going to post any code, but the overall process is very straight forward and it should be dead easy to port to PHP. You need three things to verify a purchase:


  1. 您应用的公钥(来自Google Play Developer中的Services& APIs
    console )

  2. 购买的原始JSON

  3. 购买签名

如果您使用 IabHelper类在Android上实施应用内结算,您将获得成功购买或查询库存时购买对象。 Purchase对象包含两种您需要的方法: Purchase.getOriginalJson() Purchase.getSignature()

If you implement in-app billing on Android using the IabHelper classes you'll get a Purchase object when you make a successful purchase or when you query the inventory. The Purchase object contains two methods that you need: Purchase.getOriginalJson() and Purchase.getSignature().

将您应用程序的公钥保存在您的服务器上,并将POST签名和原始JSON (在你发送之前用base64编码)给你的服务器。从$ _POST中检索签名和json,并参考Google的如何验证购买的Java实现好像您可以使用在openssl_verify函数中构建的PHP

Securely store your app's public key on your server and POST the signature and the original JSON (base64 encode it before you send it) to you server. Retrieve the signature and json from $_POST and refer to Google's Java implementation of how to verify a purchase. It seems as though you can use PHPs built in openssl_verify function.

这篇关于我如何验证谷歌玩在应用程序购买在PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆