12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace app\api\controller\pay;
- use app\model\Order;
- use support\Request;
- use Yansongda\Pay\Pay;
- class WxpayController
- {
- public function index(Request $request)
- {
- $orderId = $request->post('order_id','');
- if (!$orderId){
- return json_fail('参数异常');
- }
- $order = Order::where('order_id',$orderId)->where('order_status_payment','PENDING')->first();
- if (!$order){
- return json_fail('订单异常');
- }
- $payData = [
- 'out_trade_no' => $orderId,
- 'body' => '万悦悦享家订单',
- 'total_fee' => $order->order_amount_pay,
- ];
- return json_success('',Pay::wechat($this->getConfig())->app($payData));
-
-
-
-
-
- }
- public function notify()
- {
- $pay = Pay::wechat($this->getConfig());
- try {
- $data = $pay->verify();
- Log::debug('Wechat notify', $data->all());
- } catch (\Exception $e) {
-
- }
- return $pay->success()->send();
- }
- private function getConfig()
- {
- return [
- 'appid' => 'wx089c26eaf96c3d51',
- 'mch_id' => '1680393367',
- 'key' => 'c451cedbab8058e3502a35c6dacf0919',
- 'notify_url' => 'https://api.wanyuewellness.com.cn/api.pay.notify.php',
- 'cert_client' => config_path('cert/wxpay/apiclient_cert.pem'),
- 'cert_key' => config_path('cert/wxpay/apiclient_key.pem'),
- 'log' => [
- 'file' => runtime_path('logs/wechat.log'),
- 'level' => 'info',
- 'type' => 'single',
- 'max_file' => 30,
- ],
- 'http' => [
- 'timeout' => 5.0,
- 'connect_timeout' => 5.0,
-
- ],
- ];
- }
- }
|