1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yabacon\Paystack\Routes; |
4
|
|
|
|
5
|
|
|
use Yabacon\Paystack\Contracts\RouteInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Transaction |
9
|
|
|
* Insert description here |
10
|
|
|
* |
11
|
|
|
* @category |
12
|
|
|
* @package |
13
|
|
|
* @author |
14
|
|
|
* @copyright |
15
|
|
|
* @license |
16
|
|
|
* @version |
17
|
|
|
* @link |
18
|
|
|
* @see |
19
|
|
|
* @since |
20
|
|
|
*/ |
21
|
|
|
class Transaction implements RouteInterface |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
Root |
26
|
|
|
*/ |
27
|
3 |
|
public static function root() |
28
|
|
|
{ |
29
|
3 |
|
return '/transaction'; |
30
|
|
|
} |
31
|
|
|
/** |
32
|
|
|
* Initialize transaction |
33
|
|
|
* |
34
|
|
|
* @return array - definition for this route |
35
|
|
|
* |
36
|
|
|
* @static |
37
|
|
|
*/ |
38
|
2 |
|
public static function initialize() |
|
|
|
|
39
|
|
|
{ |
40
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
41
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/initialize', |
42
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
43
|
2 |
|
'callback_url', |
44
|
2 |
|
'amount', |
45
|
2 |
|
'email', |
46
|
2 |
|
'plan' ] |
47
|
2 |
|
]; |
48
|
|
|
} |
49
|
|
|
/** |
50
|
|
|
* Charge authorization |
51
|
|
|
* |
52
|
|
|
* @static |
53
|
|
|
*/ |
54
|
2 |
|
public static function charge() |
|
|
|
|
55
|
|
|
{ |
56
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
57
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/charge_authorization', |
58
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
59
|
2 |
|
'authorization_code', |
60
|
2 |
|
'email', |
61
|
2 |
|
'amount' ] ]; |
62
|
|
|
} |
63
|
|
|
/** |
64
|
|
|
* Charge token |
65
|
|
|
* |
66
|
|
|
* @static |
67
|
|
|
*/ |
68
|
2 |
|
public static function chargeToken() |
|
|
|
|
69
|
|
|
{ |
70
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::POST_METHOD, |
71
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/charge_token', |
72
|
2 |
|
RouteInterface::PARAMS_KEY => ['reference', |
73
|
2 |
|
'token', |
74
|
2 |
|
'email', |
75
|
2 |
|
'amount' ] ]; |
76
|
|
|
} |
77
|
|
|
/** |
78
|
|
|
* Get transaction by ID |
79
|
|
|
* |
80
|
|
|
* @static |
81
|
|
|
*/ |
82
|
2 |
|
public static function fetch() |
83
|
|
|
{ |
84
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
85
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/{id}', |
86
|
2 |
|
RouteInterface::ARGS_KEY => ['id' ] ]; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* List transactions |
91
|
|
|
* |
92
|
|
|
* @static |
93
|
|
|
* @see |
94
|
|
|
* @since |
95
|
|
|
*/ |
96
|
2 |
|
public static function getList() |
97
|
|
|
{ |
98
|
2 |
|
return [ RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
99
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() ]; |
100
|
|
|
} |
101
|
|
|
/** |
102
|
|
|
* Export transactions |
103
|
|
|
* |
104
|
|
|
* @static |
105
|
|
|
* @see |
106
|
|
|
* @since |
107
|
|
|
*/ |
108
|
2 |
|
public static function export() |
109
|
|
|
{ |
110
|
2 |
|
return [ RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
111
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/export', |
112
|
2 |
|
RouteInterface::PARAMS_KEY => ['from', |
113
|
2 |
|
'to', |
114
|
2 |
|
'settled', |
115
|
2 |
|
'payment_page' ] ]; |
116
|
|
|
} |
117
|
|
|
/* |
118
|
|
|
Get totals |
119
|
|
|
*/ |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* totals |
123
|
|
|
* Insert description here |
124
|
|
|
* |
125
|
|
|
* @return |
126
|
|
|
* |
127
|
|
|
* @access |
128
|
|
|
* @static |
129
|
|
|
* @see |
130
|
|
|
* @since |
131
|
|
|
*/ |
132
|
2 |
|
public static function totals() |
133
|
|
|
{ |
134
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
135
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/totals' ]; |
136
|
|
|
} |
137
|
|
|
/* |
138
|
|
|
Verify transaction |
139
|
|
|
*/ |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* verify |
143
|
|
|
* Insert description here |
144
|
|
|
* |
145
|
|
|
* @return |
146
|
|
|
* |
147
|
|
|
* @access |
148
|
|
|
* @static |
149
|
|
|
* @see |
150
|
|
|
* @since |
151
|
|
|
*/ |
152
|
2 |
|
public static function verify() |
153
|
|
|
{ |
154
|
2 |
|
return [RouteInterface::METHOD_KEY => RouteInterface::GET_METHOD, |
155
|
2 |
|
RouteInterface::ENDPOINT_KEY => Transaction::root() . '/verify/{reference}', |
156
|
2 |
|
RouteInterface::ARGS_KEY => ['reference' ] ]; |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
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.