1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\api\controller\pay;
- use Yansongda\Pay\Pay;
- class WxpayController
- {
- public function index()
- {
- $order = [
- 'out_trade_no' => time(),
- 'body' => 'subject-测试',
- 'total_fee' => '1',
- ];
- $pay = Pay::wechat($this->getConfig())->app($order)->send();
-
-
-
-
-
- }
- 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' => 'http://yanda.net.cn/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' => 'debug',
- 'type' => 'single',
- 'max_file' => 30,
- ],
- 'http' => [
- 'timeout' => 5.0,
- 'connect_timeout' => 5.0,
-
- ],
- ];
- }
- }
|