-
Notifications
You must be signed in to change notification settings - Fork 45
/
Plugin.php
195 lines (181 loc) · 5.69 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php namespace Responsiv\Pay;
use Backend;
use System\Classes\PluginBase;
use System\Classes\SettingsManager;
/**
* Pay Plugin Information File
*/
class Plugin extends PluginBase
{
/**
* @var array require plugins
*/
public $require = [
'RainLab.User',
'RainLab.UserPlus',
'RainLab.Location',
'Responsiv.Currency'
];
/**
* pluginDetails returns information about this plugin.
*/
public function pluginDetails()
{
return [
'name' => "Pay",
'description' => "Invoicing and Accounting",
'author' => 'Responsiv Software',
'icon' => 'icon-credit-card',
'homepage' => 'https://github.com/responsiv/pay-plugin'
];
}
/**
* register the service provider.
*/
public function register()
{
$this->registerSingletons();
$this->registerConsoleCommand('pay.migratev1', \Responsiv\Pay\Console\MigrateV1Command::class);
}
/**
* boot the module events.
*/
public function boot()
{
}
/**
* registerSingletons
*/
protected function registerSingletons()
{
$this->app->singleton('pay.gateways', \Responsiv\Pay\Classes\GatewayManager::class);
}
/**
* registerComponents
*/
public function registerComponents()
{
return [
\Responsiv\Pay\Components\Payment::class => 'payment',
\Responsiv\Pay\Components\Invoice::class => 'invoice',
\Responsiv\Pay\Components\Invoices::class => 'invoices',
\Responsiv\Pay\Components\PayProfile::class => 'payProfile',
\Responsiv\Pay\Components\PayProfiles::class => 'payProfiles',
];
}
/**
* Registers any back-end permissions used by this plugin.
*
* @return array
*/
public function registerPermissions()
{
return [
'responsiv.pay.access_invoices' => [
'tab' => 'Pay',
'label' => 'Access invoices'
],
'responsiv.pay.manage_taxes' => [
'tab' => 'Pay',
'label' => 'Manage taxes'
],
'responsiv.pay.manage_gateways' => [
'tab' => 'Pay',
'label' => 'Manage gateways'
],
'responsiv.pay.access_settings' => [
'tab' => 'Pay',
'label' => 'Access settings'
],
];
}
/**
* registerPaymentGateways registers any payment gateways implemented in this plugin.
*
* The gateways must be returned in the following format:
*
* [DriverName1::class => 'alias'],
* [DriverName2::class => 'anotherAlias']
*/
public function registerPaymentGateways()
{
return [
\Responsiv\Pay\PaymentTypes\PayPalPayment::class => 'paypal',
\Responsiv\Pay\PaymentTypes\StripePayment::class => 'stripe',
\Responsiv\Pay\PaymentTypes\CustomPayment::class => 'custom',
];
}
/**
* registerNavigation
*/
public function registerNavigation()
{
return [
'pay' => [
'label' => "Payments",
'url' => Backend::url('responsiv/pay/invoices'),
'icon' => 'icon-credit-card',
'iconSvg' => 'plugins/responsiv/pay/assets/images/pay-icon.svg',
'permissions' => ['responsiv.pay.*'],
'order' => 420,
'sideMenu' => [
'invoices' => [
'label' => "Invoices",
'icon' => 'icon-file-text-o',
'url' => Backend::url('responsiv/pay/invoices'),
'permissions' => ['responsiv.pay.access_invoices'],
],
'taxes' => [
'label' => "Tax Classes",
'icon' => 'icon-table',
'url' => Backend::url('responsiv/pay/taxes'),
'permissions' => ['responsiv.pay.manage_taxes'],
'order' => 500,
],
'types' => [
'label' => "Payment Methods",
'icon' => 'icon-money',
'url' => Backend::url('responsiv/pay/paymentmethods'),
'permissions' => ['responsiv.pay.manage_gateways'],
'order' => 510,
],
]
]
];
}
/**
* registerSettings
*/
public function registerSettings()
{
return [
'settings' => [
'label' => "Payment Settings",
'description' => "Manage payment configuration",
'icon' => 'icon-credit-card',
'class' => \Responsiv\Pay\Models\Setting::class,
'category' => SettingsManager::CATEGORY_SHOP,
'permissions' => ['responsiv.pay.access_settings'],
'order' => 800,
],
'invoice_settings' => [
'label' => "Invoice Settings",
'description' => "Customize invoice templates and settings.",
'icon' => 'icon-file-excel-o',
'url' => Backend::url('responsiv/pay/invoicetemplates'),
'category' => SettingsManager::CATEGORY_SHOP,
'permissions' => ['responsiv.pay.access_settings'],
'order' => 900,
]
];
}
/**
* registerFormWidgets
*/
public function registerFormWidgets()
{
return [
\Responsiv\Pay\FormWidgets\Discount::class => 'discount'
];
}
}