解决方案
服务器日志告诉我我正在获得301重定向。这是一个.htaccess问题,而不是GWallet。重定向正在剥离我的POST数据,导致空白请求。谢谢大家的帮助。
我正在尝试处理Google电子钱包的回发,但我没有从Google电子钱包中获取正确的数据。
Apache的error_log没有我的回发条目。对于回发请求的每次尝试,access_log都会显示以下内容:
[source-ip-1] - - [16/Sep/2013:15:18:05 +0000] "POST /google-postback.php HTTP/1.1" 301 293 "-" "Google-In-App-Payments; (+http://www.google.com/payments)"
[source-ip-2] - - [16/Sep/2013:15:18:06 +0000] "GET /google-postback.php HTTP/1.1" 200 20 "-" "Google-In-App-Payments; (+http://www.google.com/payments)"
[source-ip-1] - - [16/Sep/2013:15:18:36 +0000] "POST /google-postback.php HTTP/1.1" 301 293 "-" "Google-In-App-Payments; (+http://www.google.com/payments)"
[source-ip-2] - - [16/Sep/2013:15:18:36 +0000] "GET /google-postback.php HTTP/1.1" 200 20 "-" "Google-In-App-Payments; (+http://www.google.com/payments)"
反向DNS显示两个IP都是谷歌代理。
执行请求的JavaScript如下:
<script src="https://sandbox.google.com/checkout/inapp/lib/buy.js"></script>
<script type="text/javascript">
//Success handler
var successHandler = function(purchaseAction){
if (window.console != undefined) {
console.log("Purchase completed successfully.");
}
}
//Failure handler
var failureHandler = function(purchaseActionError){
if (window.console != undefined) {
console.log("Purchase did not complete.");
}
}
function purchase()
{
console.log("Attempting to buy stuff");
google.payments.inapp.buy({
'jwt' : '<?=$jwt?>',
'success' : successHandler,
'failure' : failureHandler
});
}
</script>
我自己使用JWT字符串发布到我的回发页面,我给了Google Wallet的buy()函数,并将其解码为我的预期:
stdClass Object
(
[iss] => [my seller id]
[aud] => Google
[typ] => google/payments/inapp/item/v1
[exp] => 1379106326
[iat] => 1379102726
[request] => stdClass Object
(
[name] => Piece of Cake
[decription] => Virtual whazzit
[price] => 10.50
[currencyCode] => USD
[sellerData] => id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j
)
)
最初,我的回发看起来像这样:
<?php
require_once "google/googlefunctions.php";
$encoded_jwt = $_POST["jwt"];
$decodedJWT = JWT::decode($encoded_jwt, [seller_secret]);
$orderId = $decodedJWT->response->orderId;
header("HTTP/1.0 200 OK");
echo $orderId;
?>
但谷歌的弹出窗口仍然无法验证购买的错误(我忘记确切的消息)。在解决问题之后,我决定给自己发电子邮件以确认我实际上是在点击回发,而不是被卖家ID /秘密凭证问题阻止:
// google-postback.php
<?php
mail("my@email.com", "Purchase post", print_r($_POST, true));
?>
我的回复电子邮件如下:
Array
(
)
据我所知,谷歌钱包应该给我发送一个带有'jwt'变量的POST,以解码与我发送的相同,但有回复,但我什么也没得到。
有什么想法吗?