My postback php for google wallet in-app payments looks like this:
<?php
$payload = array(
"iss" => $sellerIdentifier,
"aud" => "Google",
"typ" => "google/payments/inapp/item/v1",
"exp" => time() + 3600,
"iat" => time(),
"request" => array (
"name" => "pizza ",
"description" => "yum yum",
"price" => "10.50",
"currencyCode" => "USD",
"sellerData" => "",
)
);
$testToken = JWT::encode($payload, $sellerSecret);
?>
I have two questions:
1. why do I see this error?... Uh oh. There was a problem. We couldn't complete your purchase because of a technical issue. Details of the problem below:Unfortunately, we could not confirm your purchase with the merchant's server. Your order has been canceled. Please contact the merchant if this problem continues.
2. How can this work if I have multiple items for sale? the example php above lets you buy a 'pizza for $10.50' how can I add another item like a 'hotdog for $2.99'?
ps: I have studied the following documentation:
https://developers.google.com/in-app-payments/docs/tutorial#4
https://developers.google.com/in-app-payments/docs/jsreference#jwt
https://developers.google.com/in-app-payments/docs/postback
Thank you for your time.
//update!
postback.php: require_once 'JWT.php';
JWT.php: $json = json_encode($input, JSON_UNESCAPED_SLASHES);
Uh oh. There was a problem. We couldn't complete your purchase because of a technical issue. Details of the problem below: Unfortunately, we could not confirm your purchase with the merchant's server. Your order has been canceled. Please contact the merchant if this problem continues.
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);
?>
这篇关于PHP postback url 谷歌钱包 IAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!