我在谷歌钱包应用内付款的回发php看起来像这样:
<?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);
?>
我有两个问题:
1。 为什么我看到这个错误?...哦,哦。有一个问题。由于技术问题,我们无法完成您的购买。以下问题的详细信息:很遗憾,我们无法通过商家的服务器确认您的购买。您的订单已被取消。如果此问题仍然存在,请与商家联系。
2。 如果我有多件待售物品,这怎么办?上面的示例php允许您购买“10.50美元的比萨饼”,如何以2.99美元的价格添加“热狗”这样的项目?
ps:我研究过以下文档:
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
感谢您的时间。
//更新!
postback.php: require_once'JWT.php';
JWT.php: $ json = json_encode($ input,JSON_UNESCAPED_SLASHES);
哦,哦。有一个问题。 由于技术问题,我们无法完成您的购买。 问题详情如下: 很遗憾,我们无法确认您与商家的购买 服务器。您的订单已被取消。如果,请联系商家 这个问题还在继续。答案 0 :(得分:1)
您应该解码发送到postback.php的原始编码jwt数据。 至少你的postback.php应该如下所示(假设你的postback.php托管在apache服务器上)。希望这有帮助
<?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);
?>
答案 1 :(得分:0)
你的postback.php是否可以在没有.htaccess密码和用户名的情况下访问?我有一段时间了 - 让我疯了......直到我认为我的postback.php受密码保护 - .-
答案 2 :(得分:0)
另外做一个热狗:
<?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);
?>
将两者传递给javascript中的单独buy()函数(所以purchase_hotdog() and purchase_cake()
答案 3 :(得分:0)
你的例子非常适合@Pawan。谢谢。我需要的唯一改变是通往JWT.php的路径。
我现在用
require_once(dirname( FILE )。“/ lib / JWT.php”);
保