diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php new file mode 100644 index 00000000..8a5c0fe2 --- /dev/null +++ b/app/controller/api/Demo.php @@ -0,0 +1,15 @@ +$name]; + $a=WechatService::create()->micropay()->scanCode($order); + halt($a); + } +} \ No newline at end of file diff --git a/crmeb/services/WechatService.php b/crmeb/services/WechatService.php index 70f648cf..34f0dccf 100644 --- a/crmeb/services/WechatService.php +++ b/crmeb/services/WechatService.php @@ -78,6 +78,7 @@ class WechatService $this->application->register(new \crmeb\services\easywechat\merchant\ServiceProvider); $this->application->register(new \crmeb\services\easywechat\combinePay\ServiceProvider); $this->application->register(new \crmeb\services\easywechat\pay\ServiceProvider); + $this->application->register(new \crmeb\services\easywechat\micropay\ServiceProvider); $this->application->register(new \crmeb\services\easywechat\batches\ServiceProvider); $this->application->register(new \crmeb\services\easywechat\wechatTemplate\ServiceProvider); } @@ -993,7 +994,13 @@ class WechatService return $this->application->combinePay; } - + /** + * @return easywechat\micropay\Client + */ + public function micropay() + { + return $this->application->micropay; + } /** * 获取模板列表 diff --git a/crmeb/services/easywechat/micropay/Client.php b/crmeb/services/easywechat/micropay/Client.php new file mode 100644 index 00000000..114f2fd7 --- /dev/null +++ b/crmeb/services/easywechat/micropay/Client.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- + + +namespace crmeb\services\easywechat\micropay; + + +use crmeb\services\easywechat\BaseClient; + +class Client extends BaseClient +{ + + + public function scanCode($order) + { + $content=[ + 'appid'=>$this->app['config']['app_id'], + 'mch_id'=>2, + 'device_info'=>3, + 'body'=>'线下支付', + 'attach'=>'测试数据', + 'out_trade_no'=>time(), + 'total_fee'=>1, + 'spbill_create_ip'=>request()->ip(), + 'auth_code'=>$order['auth_code'], + ]; + $content = json_encode($content); + $res= $this->request('/pay/micropay', 'POST', ['sign_body' => $content]); + return $res; + } + + +} diff --git a/crmeb/services/easywechat/micropay/ServiceProvider.php b/crmeb/services/easywechat/micropay/ServiceProvider.php new file mode 100644 index 00000000..137a72b4 --- /dev/null +++ b/crmeb/services/easywechat/micropay/ServiceProvider.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + + namespace crmeb\services\easywechat\micropay; + +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Class ServiceProvider. + * + * @author ClouderSky + */ +class ServiceProvider implements ServiceProviderInterface +{ + /** + * {@inheritdoc}. + */ + public function register(Container $pimple) + { + $pimple['micropay'] = function ($pimple) { + return new Client($pimple['access_token'], $pimple); + }; + } +} diff --git a/route/api.php b/route/api.php index 9d7d66b4..9b23097d 100644 --- a/route/api.php +++ b/route/api.php @@ -21,6 +21,7 @@ use think\facade\Route; Route::group('api/', function () { Route::any('test', 'api.Auth/test'); + Route::any('ceshi', 'api.Demo/ceshi'); Route::any('promote_writing', 'api.Common/promote_writing'); Route::any('applet', 'api.Common/applet'); Route::any('promote_writing', 'api.Common/promoteWriting');