1 | <?php |
||
7 | class Paystack { |
||
8 | |||
9 | /** |
||
10 | * Transaction Verification Successful |
||
11 | */ |
||
12 | const VS = 'Verification successful'; |
||
13 | |||
14 | /** |
||
15 | * Invalid Transaction reference |
||
16 | */ |
||
17 | const ITF = "Invalid transaction reference"; |
||
18 | |||
19 | /** |
||
20 | * Issue Secret Key from your Paystack Dashboard |
||
21 | * @var mixed |
||
22 | */ |
||
23 | protected $secretKey; |
||
24 | |||
25 | /** |
||
26 | * Instance of Client |
||
27 | * @var object |
||
28 | */ |
||
29 | protected $client; |
||
30 | |||
31 | /** |
||
32 | * Response from requests made to Paystack |
||
33 | * @var mixed |
||
34 | */ |
||
35 | protected $response; |
||
36 | |||
37 | /** |
||
38 | * Paystack API base Url |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $baseUrl; |
||
42 | |||
43 | /** |
||
44 | * Authorization Url - Paystack payment page |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $authorizationUrl; |
||
48 | |||
49 | public function __construct() |
||
55 | |||
56 | /** |
||
57 | * Get Base Url from Paystack config file |
||
58 | */ |
||
59 | public function setBaseUrl() |
||
63 | |||
64 | /** |
||
65 | * Get secret key from Paystack config file |
||
66 | * @return void |
||
67 | */ |
||
68 | public function setKey() |
||
72 | |||
73 | /** |
||
74 | * Set options for making the Client request |
||
75 | * @return void |
||
76 | */ |
||
77 | private function setRequestOptions() |
||
89 | |||
90 | /** |
||
91 | * Initiate a payment request to Paystack |
||
92 | * @return Unicodeveloper\Paystack\Paystack |
||
93 | */ |
||
94 | public function makePaymentRequest() |
||
100 | |||
101 | /** |
||
102 | * Make the client request and get the response |
||
103 | * @param string $relativeUrl |
||
104 | * @return Unicodeveloper\Paystack\Paystack |
||
105 | */ |
||
106 | public function setResponse($relativeUrl) |
||
120 | |||
121 | /** |
||
122 | * Get the authorization url from the callback response |
||
123 | * @return Unicodeveloper\Paystack\Paystack |
||
124 | */ |
||
125 | public function getAuthorizationUrl() |
||
133 | |||
134 | /** |
||
135 | * Hit Paystack Gateway to Verify that the transaction is valid |
||
136 | * @return void |
||
137 | */ |
||
138 | private function verifyTransactionAtGateway() |
||
146 | |||
147 | /** |
||
148 | * True or false condition whether the transaction is verified |
||
149 | * @return boolean |
||
150 | */ |
||
151 | public function isTransactionVerificationValid() |
||
172 | |||
173 | /** |
||
174 | * Get Payment details if the transaction was verified successfully |
||
175 | * @throws Unicodeveloper\Paystack\Exceptions\PaymentVerificationFailedException |
||
176 | * @return json |
||
177 | */ |
||
178 | public function getPaymentData() |
||
186 | |||
187 | /** |
||
188 | * Fluent method to redirect to Paystack Payment Page |
||
189 | * @return Illuminate\Support\Redirect |
||
190 | */ |
||
191 | public function redirectNow() |
||
195 | |||
196 | /** |
||
197 | * Get Access code from transaction callback respose |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getAccessCode() |
||
204 | |||
205 | /** |
||
206 | * Generate a Unique Transaction Reference |
||
207 | * @return string |
||
208 | */ |
||
209 | public function genTranxRef() |
||
213 | |||
214 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: