PHP postback url google wallet IAP(PHP postback url 谷歌钱包 IAP)
问题描述
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP postback url 谷歌钱包 IAP
基础教程推荐
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01