My postback php for google wallet in-app payments looks like this:
$sellerIdentifier,
\"aud\" => \"Google\",
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);
?>
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 -.-
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()
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