PHP postback url google wallet IAP

后端 未结 4 1741
情深已故
情深已故 2021-01-16 05:12

My postback php for google wallet in-app payments looks like this:

 $sellerIdentifier,
  \"aud\" => \"Google\",
         


        
相关标签:
4条回答
  • 2021-01-16 05:42

    You're supposed to decode the raw encoded jwt data sent to your postback.php. In bare minimum your postback.php should look something like below (assuming your postback.php is hosted on apache server). Hope this helps

    <?php
    require_once(dirname(__FILE__) . "JWT.php");
    
    $response = isset($HTTP_RAW_POST_DATA) ?
        $HTTP_RAW_POST_DATA : file_get_contents("php://input");
    $response = substr_replace($response, "", 0, 4);   //remove "jwt=" from raw http data
    $response = JWT::decode($response, "your secret key here");
    print_r($response->response);
    ?>
    
    0 讨论(0)
  • 2021-01-16 05:51

    is your postback.php accessible without a .htaccess password and username? I had that for a while - drove me nuts... until i figured realized that my postback.php was password protected -.-

    0 讨论(0)
  • 2021-01-16 05:55

    to make a hotdog additionally do this:

    <?php
    $cake_payload = array(
      "iss" => $sellerIdentifier,
      "aud" => "Google",
      "typ" => "google/payments/inapp/item/v1",
      "exp" => time() + 3600,
      "iat" => time(),
      "request" => array (
        "name" => "cake",
        "description" => "yum yum",
        "price" => "10.50",
        "currencyCode" => "USD",
        "sellerData" => "",
      )
    );
    $hotdog_payload = array(
      "iss" => $sellerIdentifier,
      "aud" => "Google",
      "typ" => "google/payments/inapp/item/v1",
      "exp" => time() + 3600,
      "iat" => time(),
      "request" => array (
        "name" => "hotdog",
        "description" => "yum yum",
        "price" => "5.99",
        "currencyCode" => "USD",
        "sellerData" => "",
      )
    );
    
    $cake_token = JWT::encode($cake_payload, $sellerSecret);
    $hotdog_token = JWT::encode($hotdog_payload, $sellerSecret);
    ?>
    

    pass both to a separate purchase() function in javascript (so purchase_hotdog() and purchase_cake()

    0 讨论(0)
  • 2021-01-16 06:08

    Your example worked perfectly @Pawan. Thanks. The only change I needed was on the path to JWT.php.

    I now use

    require_once(dirname(FILE) . "/lib/JWT.php");

    Paul

    0 讨论(0)
提交回复
热议问题