PHP postback url 谷歌钱包 IAP

PHP postback url google wallet IAP(PHP postback url 谷歌钱包 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)