You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.3 KiB
53 lines
1.3 KiB
12 months ago
|
<?php
|
||
|
|
||
|
/*
|
||
|
* This file is part of the overtrue/wechat.
|
||
|
*
|
||
|
* (c) overtrue <i@overtrue.me>
|
||
|
*
|
||
|
* This source file is subject to the MIT license that is bundled
|
||
|
* with this source code in the file LICENSE.
|
||
|
*/
|
||
|
|
||
|
namespace crmeb\services\easywechat\miniPayment;
|
||
|
|
||
|
use EasyWeChat\Payment\Merchant;
|
||
|
use Pimple\Container;
|
||
|
use Pimple\ServiceProviderInterface;
|
||
|
use EasyWeChat\MiniProgram\AccessToken;
|
||
|
|
||
|
/**
|
||
|
* Class ServiceProvider.
|
||
|
*
|
||
|
* @author mingyoung <mingyoungcheung@gmail.com>
|
||
|
*/
|
||
|
class ServiceProvider implements ServiceProviderInterface
|
||
|
{
|
||
|
/**
|
||
|
* {@inheritdoc}.
|
||
|
*/
|
||
|
public function register(Container $pimple)
|
||
|
{
|
||
|
$pimple['merchant'] = function ($pimple) {
|
||
|
$config = array_merge(
|
||
|
['app_id' => $pimple['config']['app_id']],
|
||
|
$pimple['config']->get('payment', [])
|
||
|
);
|
||
|
|
||
|
return new Merchant($config);
|
||
|
};
|
||
|
|
||
|
$pimple['mini_program.access_token'] = function ($pimple) {
|
||
|
return new AccessToken(
|
||
|
$pimple['config']['mini_program']['app_id'],
|
||
|
$pimple['config']['mini_program']['secret'],
|
||
|
$pimple['cache']
|
||
|
);
|
||
|
};
|
||
|
|
||
|
$pimple['minipay'] = function ($pimple) {
|
||
|
return new Client($pimple['mini_program.access_token'],$pimple['merchant']);
|
||
|
};
|
||
|
}
|
||
|
}
|