<?php
include 'WxPay.Api.php';
header("Access-Control-Allow-Origin: *");//跨域问题
header("Content-type: text/html; charset=utf-8");//编码
$openid= $_GET['openid'];
$total_fee = $_GET['total_fee'];
$order_no = $_GET['dingdanhao'];
$wxOrderData = new WxPayUnifiedOrder();
$wxOrderData->SetTrade_type('JSAPI');
$wxOrderData->SetOut_trade_no($order_no);
$wxOrderData->SetTotal_fee($total_fee*100);
$wxOrderData->SetBody('精品会');
$wxOrderData->SetOpenid($openid);
$wxOrderData->SetNotify_url('https://www.qdshengqian.com/fangxinshifu/notify.php');
$wxOrder = WxPayApi::unifiedOrder($wxOrderData);
$prepay_id = $wxOrder['prepay_id'];
$jsApiPayData = new WxPayJsApiPay();
$jsApiPayData->SetAppid('/* AppId */');
$jsApiPayData->SetTimeStamp((string)time());
$rand = md5(time().mt_rand(0,100));
$jsApiPayData->SetNonceStr($rand);
$jsApiPayData->SetPackage('prepay_id='.$prepay_id);
$jsApiPayData->SetSignType('md5');
$sign = $jsApiPayData->MakeSign();
$rawValues = $jsApiPayData->GetValues();
$rawValues['paySign']=$sign;
echo json_encode($rawValues);
?>
网友评论