我现在真的搞砸了理解需求的概念和原因,甚至不知道如何通过编码来实现.
所以,我用团结制作手机游戏,c#.使用php,mysql进行高分,并在应用程序购买项目信息中存储用户.
我一周前在google play上发布了我的游戏,我的谷歌钱包显示没有人,直到现在购买该游戏中的任何项目.
但是,当我检查我的游戏服务器(mysql数据库)时,一些用户有大量应该购买的项目.
这意味着一些用户使用黑客工具并绕过谷歌游戏检查过程并欺骗我的游戏并进行假购买.
所以我没有实现developerPayload,也没有验证google play购买收据.
所以现在我删除了我的数据库中的整个恶意用户的项目(这将设置0到该用户的客户端项目),并且想要实现google play购买收据的服务器端验证.
我通过谷歌搜索搜索了许多帖子,但从头到尾没有完美的解决方案.
无论如何,我到目前为止实现了这样的.
首先,在用户结束谷歌结账过程(无论这是真的还是假的)之后,我的Unity客户端的OnPurchaseSucceded函数被调用,在那里我实现了开始在我的服务器上传递我的PHP脚本.
private void OnPurchaseSucceded(Purchase purchase)
{
/*
// Optional verification of the payload. Can be moved to a custom server
if (!VerifyDeveloperPayload(purchase.DeveloperPayload)) {
return;
}*/
StartCoroutine(VerifyReceiptCo(purchase));
}
IEnumerator VerifyReceiptCo(Purchase purchase)
{
WWWForm hsFm = new WWWForm();
hsFm.AddField("data", purchase.OriginalJson);
hsFm.AddField("signature", purchase.Signature);
WWW hs = new WWW(verifyURL, hsFm);
yield return hs;
Debug.Log("verify result is " + hs.text);
// if result is true(validated), give item to user.
}
Run Code Online (Sandbox Code Playgroud)
在这里问题,
1. [我在代码上方做得对吗?对于"数据"字段,我使用了buy.OriginalJson,但这是对的吗?如果没有,我该怎么用?] …
我从这个页面发送用户名和密码:https://www.paypal.com/us/cgi-bin/webscr?cmd = _profile-api-signature
AppId是我在Android应用中用来创建付款的ID:https://apps.paypal.com/user/my-account/applications
我正在使用以下功能:
function verify_paypal($payKey, $appID)
{
global $payPalUser_Id, $payPalPassword, $payPalSig;
$headerArray = array(
'X-PAYPAL-SECURITY-USERID:'.$payPalUser_Id,
'X-PAYPAL-SECURITY-PASSWORD:'.$payPalPassword,
'X-PAYPAL-SECURITY-SIGNATURE:'.$payPalSig,
'X-PAYPAL-REQUEST-DATA-FORMAT:JSON',
'X-PAYPAL-RESPONSE-DATA-FORMAT:XML',
'X-PAYPAL-APPLICATION-ID:'.$appID
);
$url="https://svcs.paypal.com/AdaptivePayments/PaymentDetails?payKey={$payKey}&requestEnvelope.errorLanguage=en_US";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
$adaptiveResponse = curl_exec($ch);
curl_close($ch);
return $adaptiveResponse;
}
Run Code Online (Sandbox Code Playgroud)
但它给出了这个错误:
<?xml version='1.0' encoding='UTF-8'?>
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap">
<responseEnvelope>
<timestamp>2013-11-27T14:58:07.463-08:00</timestamp>
<ack>Failure</ack>
<correlationId>d97c635f935b3</correlationId>
<build>7935900</build>
</responseEnvelope>
<error>
<errorId>580001</errorId>
<domain>PLATFORM</domain>
<subdomain>Application</subdomain>
<severity>Error</severity>
<category>Application</category>
<message>Invalid request: {0}</message>
</error>
</ns3:FaultMessage>
Run Code Online (Sandbox Code Playgroud)