1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace YEntWeChat\Foundation\ServiceProviders; |
4
|
|
|
|
5
|
|
|
use YEntWeChat\Payment\CashCoupon\CashCoupon; |
6
|
|
|
use YEntWeChat\Payment\LuckyMoney\LuckyMoney; |
7
|
|
|
use YEntWeChat\Payment\Merchant; |
8
|
|
|
use YEntWeChat\Payment\MerchantPay\MerchantPay; |
9
|
|
|
use YEntWeChat\Payment\Payment; |
10
|
|
|
use Pimple\Container; |
11
|
|
|
use Pimple\ServiceProviderInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class PaymentServiceProvider. |
15
|
|
|
*/ |
16
|
|
|
class PaymentServiceProvider implements ServiceProviderInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Registers services on the given container. |
20
|
|
|
* |
21
|
|
|
* This method should only be used to configure services and parameters. |
22
|
|
|
* It should not get services. |
23
|
|
|
* |
24
|
|
|
* @param Container $pimple A container instance |
25
|
|
|
*/ |
26
|
|
|
public function register(Container $pimple) |
27
|
|
|
{ |
28
|
|
|
$pimple['merchant'] = function ($pimple) { |
29
|
|
|
$config = array_merge( |
30
|
|
|
['app_id' => $pimple['config']['app_id']], |
31
|
|
|
$pimple['config']->get('payment', []) |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
return new Merchant($config); |
35
|
|
|
}; |
36
|
|
|
|
37
|
|
|
$pimple['payment'] = function ($pimple) { |
38
|
|
|
return new Payment($pimple['merchant']); |
39
|
|
|
}; |
40
|
|
|
|
41
|
|
|
$pimple['lucky_money'] = function ($pimple) { |
42
|
|
|
return new LuckyMoney($pimple['merchant']); |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
$pimple['merchant_pay'] = function ($pimple) { |
46
|
|
|
return new MerchantPay($pimple['merchant']); |
47
|
|
|
}; |
48
|
|
|
|
49
|
|
|
$pimple['cash_coupon'] = function ($pimple) { |
50
|
|
|
return new CashCoupon($pimple['merchant']); |
51
|
|
|
}; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|