123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\api\controller\pay;
- use Yansongda\Pay\Pay;
- class WxpayController
- {
- protected $config = [
- 'appid' => 'wx089c26eaf96c3d51',
- 'mch_id' => '1680393367',
- 'key' => 'c451cedbab8058e3502a35c6dacf0919',
- 'notify_url' => 'http://yanda.net.cn/notify.php',
- 'cert_client' => './cert/apiclient_cert.pem',
- 'cert_key' => './cert/apiclient_key.pem',
- 'log' => [
- 'file' => './logs/wechat.log',
- 'level' => 'info',
- 'type' => 'single',
- 'max_file' => 30,
- ],
- 'http' => [
- 'timeout' => 5.0,
- 'connect_timeout' => 5.0,
-
- ],
- 'mode' => 'dev',
- ];
- 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->config);
- 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' => 'info',
- 'type' => 'single',
- 'max_file' => 30,
- ],
- 'http' => [
- 'timeout' => 5.0,
- 'connect_timeout' => 5.0,
-
- ],
- 'mode' => 'dev',
- ];
- }
- }
|