PHP postback url google wallet IAP [英] PHP postback url google wallet IAP

查看:191
本文介绍了PHP postback url google wallet IAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对谷歌钱包应用内付款的回发php如下所示:

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);
?>

我有两个问题:

1 。
为什么我会看到这个错误?...呃哦。有一个问题。由于技术问题,我们无法完成您的购买。以下问题的详细信息:很遗憾,我们无法通过商家的服务器确认您的购买。您的订单已被取消。如果此问题仍然存在,请与商家联系。

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。
如果我有多件待售物品,这怎么办?上面的示例php让你买一个'10.50美元的比萨'我怎么能添加另一个像'热狗只需2.99美元'的项目?

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:我研究过以下文档:

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

感谢您的时间。

// update!

//update!

postback.php:
require_once'JWT.php';

postback.php: require_once 'JWT.php';

JWT.php:
$ json = json_encode($ input,JSON_UNESCAPED_SLASHES);

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.

推荐答案

你应该解码发送的原始编码jwt数据到你的postback.php。
至少你的postback.php应该如下所示(假设你的postback.php托管在apache服务器上)。希望这有帮助

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 google wallet IAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆