|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bmatovu\AirtelMoney; |
|
4
|
|
|
|
|
5
|
|
|
use Bmatovu\AirtelMoney\Commands\AuthCommand; |
|
6
|
|
|
use Bmatovu\AirtelMoney\Commands\PinCommand; |
|
7
|
|
|
use Bmatovu\AirtelMoney\Products\Account; |
|
8
|
|
|
use Bmatovu\AirtelMoney\Products\Authorization; |
|
9
|
|
|
use Bmatovu\AirtelMoney\Products\Collection; |
|
10
|
|
|
use Bmatovu\AirtelMoney\Products\Disbursement; |
|
11
|
|
|
use Bmatovu\AirtelMoney\Products\Kyc; |
|
12
|
|
|
use Bmatovu\AirtelMoney\Support\Util; |
|
13
|
|
|
use GuzzleHttp\Client; |
|
14
|
|
|
use GuzzleHttp\ClientInterface; |
|
15
|
|
|
use Illuminate\Support\ServiceProvider; |
|
16
|
|
|
|
|
17
|
|
|
class AirtelMoneyServiceProvider extends ServiceProvider |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
29 |
|
public function boot() |
|
23
|
|
|
{ |
|
24
|
29 |
|
if (! $this->app->runningInConsole()) { |
|
25
|
|
|
return; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
29 |
|
$this->publishes([ |
|
29
|
29 |
|
__DIR__.'/../config/airtel-money.php' => base_path('config/airtel-money.php'), |
|
30
|
29 |
|
], 'config'); |
|
31
|
|
|
|
|
32
|
29 |
|
$this->publishes([ |
|
33
|
29 |
|
__DIR__.'/../storage/airtel.pub' => storage_path('airtel.pub'), |
|
34
|
29 |
|
], 'public-key'); |
|
35
|
|
|
|
|
36
|
29 |
|
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
37
|
|
|
|
|
38
|
29 |
|
$this->commands([ |
|
39
|
29 |
|
PinCommand::class, |
|
40
|
29 |
|
AuthCommand::class, |
|
41
|
29 |
|
]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
29 |
|
public function register() |
|
45
|
|
|
{ |
|
46
|
29 |
|
$this->mergeConfigFrom(__DIR__.'/../config/airtel-money.php', 'airtel-money'); |
|
47
|
|
|
|
|
48
|
29 |
|
$this->app->when(Authorization::class) |
|
49
|
29 |
|
->needs(ClientInterface::class) |
|
50
|
29 |
|
->give(function () { |
|
51
|
|
|
return new Client([ |
|
52
|
|
|
'handler' => Util::logMiddleware(), |
|
53
|
|
|
'base_uri' => $this->app['config']->get('airtel-money.base_uri'), |
|
54
|
|
|
'headers' => [ |
|
55
|
|
|
'Content-Type' => 'application/json', |
|
56
|
|
|
], |
|
57
|
|
|
]); |
|
58
|
29 |
|
}); |
|
59
|
|
|
|
|
60
|
29 |
|
$this->app->when([Kyc::class, Account::class, Collection::class, Disbursement::class]) |
|
61
|
29 |
|
->needs(ClientInterface::class) |
|
62
|
29 |
|
->give(function () { |
|
63
|
|
|
return Util::http(); |
|
64
|
29 |
|
}); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|