1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yabacon\Paystack\Routes; |
4
|
|
|
|
5
|
|
|
use Yabacon\Paystack\Contracts\RouteInterface; |
6
|
|
|
|
7
|
|
|
class Transaction implements RouteInterface |
8
|
|
|
{ |
9
|
|
|
|
10
|
4 |
|
public static function root() |
11
|
|
|
{ |
12
|
4 |
|
return '/transaction'; |
13
|
|
|
} |
14
|
|
|
|
15
|
2 |
|
public static function initialize() |
16
|
|
|
{ |
17
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
18
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/initialize', |
19
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
20
|
2 |
|
'callback_url', |
21
|
2 |
|
'amount', |
22
|
2 |
|
'email', |
23
|
2 |
|
'plan' ] |
24
|
2 |
|
]; |
25
|
|
|
} |
26
|
|
|
|
27
|
2 |
|
public static function charge() |
|
|
|
|
28
|
|
|
{ |
29
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
30
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/charge_authorization', |
31
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
32
|
2 |
|
'authorization_code', |
33
|
2 |
|
'email', |
34
|
2 |
|
'amount' ] ]; |
35
|
|
|
} |
36
|
|
|
|
37
|
2 |
|
public static function checkAuthorization() |
38
|
|
|
{ |
39
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
40
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/check_authorization', |
41
|
2 |
|
RouteInterface::PARAMS_KEY => ['authorization_code', |
42
|
2 |
|
'email', |
43
|
2 |
|
'amount' ] ]; |
44
|
|
|
} |
45
|
|
|
|
46
|
2 |
|
public static function chargeAuthorization() |
47
|
|
|
{ |
48
|
2 |
|
return Transaction::charge(); |
49
|
|
|
} |
50
|
|
|
|
51
|
2 |
|
public static function chargeToken() |
|
|
|
|
52
|
|
|
{ |
53
|
2 |
|
trigger_error('This endpoint is deprecated!', E_USER_NOTICE); |
54
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
55
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/charge_token', |
56
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
57
|
2 |
|
'token', |
58
|
2 |
|
'email', |
59
|
2 |
|
'amount' ] ]; |
60
|
|
|
} |
61
|
|
|
|
62
|
2 |
|
public static function fetch() |
63
|
|
|
{ |
64
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
65
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/{id}', |
66
|
2 |
|
RouteInterface::ARGS_KEY => ['id' ] ]; |
67
|
|
|
} |
68
|
|
|
|
69
|
2 |
|
public static function getList() |
70
|
|
|
{ |
71
|
2 |
|
return [ RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
72
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() ]; |
73
|
|
|
} |
74
|
|
|
|
75
|
2 |
|
public static function export() |
76
|
|
|
{ |
77
|
2 |
|
return [ RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
78
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/export', |
79
|
2 |
|
RouteInterface::PARAMS_KEY => ['from', |
80
|
2 |
|
'to', |
81
|
2 |
|
'settled', |
82
|
2 |
|
'payment_page' ] ]; |
83
|
|
|
} |
84
|
|
|
|
85
|
2 |
|
public static function totals() |
86
|
|
|
{ |
87
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
88
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/totals' ]; |
89
|
|
|
} |
90
|
|
|
|
91
|
3 |
|
public static function verify() |
92
|
|
|
{ |
93
|
3 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
94
|
3 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/verify/{reference}', |
95
|
3 |
|
RouteInterface::ARGS_KEY => ['reference' ] ]; |
96
|
|
|
} |
97
|
|
|
|
98
|
2 |
|
public static function verifyAccessCode() |
99
|
|
|
{ |
100
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
101
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/verify_access_code/{access_code}', |
102
|
2 |
|
RouteInterface::ARGS_KEY => ['access_code' ] ]; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.