作者 郭鑫
1 个管道 的构建 通过 耗费 1 秒

付款修改

... ... @@ -28,20 +28,30 @@ 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);
... ... @@ -54,10 +64,12 @@ class SomepayController extends HomeBaseController
//微信回调
public function pay_notify()
{
$a['a'] ='7';
$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");
$base = new \WxPayResults();
... ... @@ -65,7 +77,7 @@ class SomepayController extends HomeBaseController
//验签
if ($base->CheckSign($config)) {
if ($data["return_code"] == "SUCCESS") {
$a['a'] ='9';
$a['a'] ='99';
$a['c'] = json_decode($data);
Db::name('Test')->insertGetId($a);
// 支付成功
... ...