|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\PackageBase\BaseBootableServiceProvider; |
|
6
|
|
|
use ByTIC\Payments\Console\Commands\SessionsCleanup; |
|
7
|
|
|
use ByTIC\Payments\Console\Commands\SubscriptionsCharge; |
|
8
|
|
|
use ByTIC\Payments\Gateways\Manager; |
|
9
|
|
|
use ByTIC\Payments\Utility\PackageConfig; |
|
10
|
|
|
use ByTIC\Payments\Utility\PaymentsModels; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class PaymentsServiceProvider |
|
14
|
|
|
* @package ByTIC\Payments |
|
15
|
|
|
*/ |
|
16
|
|
|
class PaymentsServiceProvider extends BaseBootableServiceProvider |
|
17
|
|
|
{ |
|
18
|
|
|
public const NAME = 'payments'; |
|
19
|
|
|
|
|
20
|
|
|
public const PURCHASES = 'purchases'; |
|
21
|
1 |
|
public const SESSIONS = 'purchase-sessions'; |
|
22
|
|
|
public const GATEWAYS = 'payments.gateways'; |
|
23
|
1 |
|
|
|
24
|
1 |
|
/** |
|
25
|
1 |
|
* @inheritdoc |
|
26
|
1 |
|
*/ |
|
27
|
|
|
public function register() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->registerPurchases(); |
|
30
|
1 |
|
$this->registerGatewaysManager(); |
|
31
|
1 |
|
$this->registerPurchaseSessions(); |
|
32
|
1 |
|
} |
|
33
|
1 |
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @inheritdoc |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function provides() |
|
38
|
|
|
{ |
|
39
|
1 |
|
return [ |
|
40
|
1 |
|
self::PURCHASES, |
|
41
|
|
|
self::SESSIONS, |
|
42
|
|
|
self::GATEWAYS, |
|
43
|
|
|
]; |
|
44
|
1 |
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
public function migrations(): ?string |
|
47
|
1 |
|
{ |
|
48
|
|
|
if (PackageConfig::shouldRunMigrations()) { |
|
49
|
|
|
return dirname(__DIR__) . '/migrations/'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
return null; |
|
53
|
|
|
} |
|
54
|
1 |
|
|
|
55
|
1 |
|
protected function registerPurchases() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->getContainer()->share(self::PURCHASES, function () { |
|
58
|
|
|
return PaymentsModels::purchases(); |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function registerPurchaseSessions() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->getContainer()->share(self::SESSIONS, function () { |
|
65
|
|
|
return PaymentsModels::sessions(); |
|
66
|
|
|
}); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
protected function registerGatewaysManager() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->getContainer()->share(self::GATEWAYS, function () { |
|
72
|
|
|
return new Manager(); |
|
73
|
|
|
}); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
protected function registerCommands() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->commands( |
|
79
|
|
|
SessionsCleanup::class, |
|
80
|
|
|
SubscriptionsCharge::class |
|
81
|
|
|
); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|