0

解决方案

服务器日志告诉我我收到了 301 重定向。这是一个 .htaccess 问题,而不是 GWallet。重定向正在剥离我的 POST 数据,导致一个空白请求。谢谢大家的帮助。


我正在尝试处理来自 Google Wallet 的回发,但我没有从 Google Wallet 获得正确的数据来开始。

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>

我使用我提供给 Google Wallet 的 buy() 函数的 JWT 字符串自己发布到我的回发页面,它解码为我所期望的:

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
(
)

据我所知,Google Wallet 应该向我发送一个带有“jwt”变量的 POST,以解码与我发送的相同,但有响应,但我什么也没得到。

有任何想法吗?

4

0 回答 0