小程序端:小程序
xml:api
use think\Config;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Log;
public function miniGetPayMoney(){ if ($this->request->isPost()) { $validate = new \think\Validate(['order_list_id'=>'require']); $request_data = $this->request->param(); $check_result = $validate->check($request_data); if($check_result == true){ $order_list_model = new \app\api\model\order\Orderlist; $price = $order_list_model->calculatePrice($request_data['order_list_id']); $price *= 100; $user_info = $this->auth->getUserinfo(); $user_id = $user_info['id']; $out_trade_no = $user_id . '-' . time(); $order = [ 'out_trade_no' => $out_trade_no, 'body' => '商品支付', 'total_fee' => $price, 'openid' => $this->auth->getUser()->openid, ]; $result = Pay::wechat(Config::get('wechat.pay'))->miniapp($order); \app\api\model\pay\Order::create( [ 'package' => $out_trade_no, 'order_type' => 'order', 'order_mes' => $request_data['order_list_id'] ] ); $this->success('success', ['order_list_id'=>$request_data['order_list_id'],'money'=>$price,'result'=>$result]); }else{ $this->error('沒傳訂單編號'); } } $this->error('提交方式不是POST');}