...
|
...
|
@@ -28,30 +28,20 @@ class SomepayController extends HomeBaseController |
|
|
// 微信支付
|
|
|
public function pay($openId , $price , $order_sn , $url,$content)
|
|
|
{
|
|
|
$a['a'] ='11';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$price = intval($price * 100);
|
|
|
$tools = new \JsApiPay();
|
|
|
$input = new \WxPayUnifiedOrder();
|
|
|
$a['a'] ='22';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$input->SetBody($content);
|
|
|
$input->SetAttach($content);
|
|
|
$a['a'] ='33';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$input->SetOut_trade_no($order_sn);
|
|
|
$input->SetTotal_fee($price);
|
|
|
$input->SetTime_start(date("YmdHis"));
|
|
|
$input->SetTime_expire(date("YmdHis", time() + 600));
|
|
|
$input->SetGoods_tag($content);
|
|
|
$input->SetNotify_url($url);
|
|
|
$a['a'] ='44';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$input->SetTrade_type("JSAPI");
|
|
|
$input->SetOpenid($openId);
|
|
|
$config = new \WxPayConfig();
|
|
|
$a['a'] ='55';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$order = \WxPayApi::unifiedOrder($config, $input);
|
|
|
$jsApiParameters = $tools->GetJsApiParameters($order);
|
|
|
return json_decode($jsApiParameters);
|
...
|
...
|
@@ -64,16 +54,19 @@ class SomepayController extends HomeBaseController |
|
|
//微信回调
|
|
|
public function pay_notify()
|
|
|
{
|
|
|
$a['a'] ='333';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$config = new \WxPayConfig();
|
|
|
$notify = new \WxPayNotify();
|
|
|
$a['a'] ='888';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$notify->Handle($config, false);
|
|
|
$xml = file_get_contents("php://input");
|
|
|
$a['a'] ='333';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$base = new \WxPayResults();
|
|
|
$a['a'] ='888';
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
$data = $base->FromXml($xml);
|
|
|
$a['a'] ='234';
|
|
|
$a['c'] = json_decode($data);
|
|
|
Db::name('Test')->insertGetId($a);
|
|
|
//验签
|
|
|
if ($base->CheckSign($config)) {
|
|
|
if ($data["return_code"] == "SUCCESS") {
|
...
|
...
|
|