-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathviksslcommerz.php
290 lines (251 loc) · 7.64 KB
/
viksslcommerz.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?php
/*
Plugin Name: VikSslCommerz
Description: SslCommerz integration to collect payments through the Vik plugins
Version: 1.0.0
Author: SslCommerz Integration Department.
Author URI: https://sslcommerz.io
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: viksslcommerz
Domain Path: /languages
*/
// No direct access
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
// require utils functions
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'utils.php';
define( 'VIKSSLCOMMERZ_LANG', basename( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'languages' );
define( 'VIKSSLCOMMERZ_LIB', basename( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lib' );
define( 'VIKSSLCOMMERZVERSION', '1.0.0' );
add_action( 'init', function () {
JFactory::getLanguage()->load( 'viksslcommerz', VIKSSLCOMMERZ_LANG );
} );
/**
* Returns the current plugin version for being used by
* VikUpdater, in order to check for new updates.
*
* @return string The plugin version.
*/
add_filter( 'vikwp_vikupdater_sslcommerz_version', function () {
return VIKSSLCOMMERZVERSION;
} );
/**
* Returns the base path of this plugin for being used by
* VikUpdater, in order to move the files of a newer version.
*
* @return string The plugin base path.
*/
add_filter( 'vikwp_vikupdater_sslcommerz_path', function () {
return plugin_dir_path( __FILE__ ) . "..";
} );
/**
* VIKRESTAURANTS HOOKS
*/
/**
* Pushes the sslcommerz gateway within the supported payments of VikRentCar plugin.
*
* @param array $drivers The current list of supported drivers.
*
* @return array The updated drivers list.
*/
add_filter( 'get_supported_payments_vikrestaurants', function ( $drivers ) {
$driver = viksslcommerz_get_payment_path( 'vikrestaurants' );
// make sure the driver exists
if ( $driver ) {
$drivers[] = $driver;
}
return $drivers;
} );
/**
* Loads sslcommerz payment handler when dispatched by Vikrestaurants.
*
* @param array &$drivers A list of payment classnames.
* @param string $payment The name of the invoked payment.
*
* @return void
*
* @see JPayment
*/
add_action( 'load_payment_gateway_vikrestaurants', function ( &$drivers, $payment ) {
// make sure the classname hasn't been generated yet by a different hook
// and the request payment matches 'kashier' string
if ( $payment == 'sslcommerz' ) {
$classname = viksslcommerz_load_payment( 'vikrestaurants' );
if ( $classname ) {
$drivers[] = $classname;
}
}
}, 10, 2 );
/**
* VIKRENTITEMS HOOKS
*/
/**
* Pushes the sslcommerz gateway within the supported payments of VikRentCar plugin.
*
* @param array $drivers The current list of supported drivers.
*
* @return array The updated drivers list.
*/
add_filter( 'get_supported_payments_vikrentitems', function ( $drivers ) {
$driver = viksslcommerz_get_payment_path( 'vikrentitems' );
// make sure the driver exists
if ( $driver ) {
$drivers[] = $driver;
}
return $drivers;
} );
/**
* Loads sslcommerz payment handler when dispatched by vikrentitems.
*
* @param array &$drivers A list of payment classnames.
* @param string $payment The name of the invoked payment.
*
* @return void
*
* @see JPayment
*/
add_action( 'load_payment_gateway_vikrentitems', function ( &$drivers, $payment ) {
// make sure the classname hasn't been generated yet by a different hook
// and the request payment matches 'sslcommerz' string
if ( $payment == 'sslcommerz' ) {
$classname = viksslcommerz_load_payment( 'vikrentitems' );
if ( $classname ) {
$drivers[] = $classname;
}
}
}, 10, 2 );
/**
* VIKRENTCAR HOOKS
*/
/**
* Pushes the sslcommerz gateway within the supported payments of VikRentCar plugin.
*
* @param array $drivers The current list of supported drivers.
*
* @return array The updated drivers list.
*/
add_filter( 'get_supported_payments_vikrentcar', function ( $drivers ) {
$driver = viksslcommerz_get_payment_path( 'vikrentcar' );
// make sure the driver exists
if ( $driver ) {
$drivers[] = $driver;
}
return $drivers;
} );
/**
* Loads sslcommerz payment handler when dispatched by Vikrentcar.
*
* @param array &$drivers A list of payment classnames.
* @param string $payment The name of the invoked payment.
*
* @return void
*
* @see JPayment
*/
add_action( 'load_payment_gateway_vikrentcar', function ( &$drivers, $payment ) {
// make sure the classname hasn't been generated yet by a different hook
// and the request payment matches 'sslcommerz' string
if ( $payment == 'sslcommerz' ) {
$classname = viksslcommerz_load_payment( 'vikrentcar' );
if ( $classname ) {
$drivers[] = $classname;
}
}
}, 10, 2 );
/**
* VIKAPPOINTMENTS HOOKS
*/
/**
* Pushes the sslcommerz gateway within the supported payments of VikAppointments plugin.
*
* @param array $drivers The current list of supported drivers.
*
* @return array The updated drivers list.
*/
add_filter( 'get_supported_payments_vikappointments', function ( $drivers ) {
$driver = viksslcommerz_get_payment_path( 'vikappointments' );
// make sure the driver exists
if ( $driver ) {
$drivers[] = $driver;
}
return $drivers;
} );
/**
* Loads sslcommerz payment handler when dispatched by VikAppointments.
*
* @param array &$drivers A list of payment classnames.
* @param string $payment The name of the invoked payment.
*
* @return void
*
* @see JPayment
*/
add_action( 'load_payment_gateway_vikappointments', function ( &$drivers, $payment ) {
// make sure the classname hasn't been generated yet by a different hook
// and the request payment matches 'sslcommerz' string
if ( $payment == 'sslcommerz' ) {
$classname = viksslcommerz_load_payment( 'vikappointments' );
if ( $classname ) {
$drivers[] = $classname;
}
}
}, 10, 2 );
/**
* VIKBOOKING HOOKS
*/
/**
* Pushes the sslcommerz gateway within the supported payments of VikBooking plugin.
*
* @param array $drivers The current list of supported drivers.
*
* @return array The updated drivers list.
*/
add_filter( 'get_supported_payments_vikbooking', function ( $drivers ) {
$driver = viksslcommerz_get_payment_path( 'vikbooking' );
// make sure the driver exists
if ( $driver ) {
$drivers[] = $driver;
}
return $drivers;
} );
/**
* Loads sslcommerz payment handler when dispatched by VikBooking.
*
* @param array &$drivers A list of payment instances.
* @param string $payment The name of the invoked payment.
*
* @return void
*
* @see JPayment
*/
add_action( 'load_payment_gateway_vikbooking', function ( &$drivers, $payment ) {
// make sure the classname hasn't been generated yet by a different hook
// and the request payment matches 'sslcommerz' string
if ( $payment == 'sslcommerz' ) {
$classname = viksslcommerz_load_payment( 'vikbooking' );
if ( $classname ) {
$drivers[] = $classname;
}
}
}, 10, 2 );
/**
* Filters the array containing the logo details to let VikBooking
* retrieves the correct image.
*
* In order to change the image logo, it is needed to inject the
* image path and URI within the $logo argument.
*
* @param array $logo An array containing the following information:
* - name The payment name;
* - path The payment logo base path;
* - uri The payment logo base URI.
*
* @return array The updated logo information.
*/
add_filter( 'vikbooking_oconfirm_payment_logo', function ( $logo ) {
if ( $logo['name'] == 'sslcommerz' ) {
$logo['path'] = VIKKASHIER_DIR . DIRECTORY_SEPARATOR . 'vikbooking' . DIRECTORY_SEPARATOR . 'sslcommerz.png';
$logo['uri'] = VIKKASHIER_URI . 'vikbooking/sslcommerz.png';
}
return $logo;
} );