第一个页面 :
window.location.href="./zhifuapi/demo/js_api_call.php?money=999";
微信支付页面:
if (!isset($_GET['code']))
{
//触发微信返回code码
$url = $jsApi->createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
$money = $_GET['money'];
$state = json_encode(array(
"body" => "body888",
"out_trade_no" => "dingdan888",
"total_fee" => "$money",
));
$url = str_replace("STATE", $state, $url);
Header("Location: $url");
}else
{
//获取code码,以获取openid
$code = $_GET['code'];
$jsApi->setCode($code);
$openid = $jsApi->getOpenId();
$state = $_GET['state'];
echo $state;
$param=json_decode($state,true);
$body=$param["body"];
$out_trade_no=$param["out_trade_no"];
$total_fee=$param["total_fee"]; //这个就是金额 。
}