1 | <?php |
||
15 | class MazzumaPayment |
||
16 | { |
||
17 | /** @var string The API access token */ |
||
18 | private $key; |
||
19 | /** @var string The Network directional flow of payment */ |
||
20 | private $flow; |
||
21 | /** @var string The network of the Sender */ |
||
22 | private $payeeNetwork; |
||
23 | /** @var string The Sender Telephone Number */ |
||
24 | private $from; |
||
25 | /** @var string The Reciever Telephone Number */ |
||
26 | private $to; |
||
27 | /** @var integer The amount being Transfered */ |
||
28 | private $amount; |
||
29 | /** @var integer The response from the API */ |
||
30 | private $apiResponse; |
||
31 | |||
32 | /** @var string The API URL */ |
||
33 | private $api = 'https://client.teamcyst.com/api_call.php'; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * Creates a new MazzumaPayment Instance |
||
38 | * |
||
39 | */ |
||
40 | public function __construct($key) |
||
44 | |||
45 | /** |
||
46 | * Calls the API to process the transaction |
||
47 | * |
||
48 | * @return object The Response from the API Call |
||
49 | */ |
||
50 | public function send() |
||
81 | |||
82 | /** |
||
83 | * Parses the Payment Details into Json for API call |
||
84 | * @param string $paymentDirectionalFlow The Network directional flow of payment |
||
85 | * @param string $payeeNetwork The Network Operator of the Sender |
||
86 | * @param string $APIKey The API access key, as obtained on https://dashboard.mazzuma.com/ |
||
87 | * @param string $payee The Sender Telephone Number |
||
88 | * @param string $reciever The Recievers Telephone Number |
||
89 | * @param integer $amount The amount been transacted |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | private function parsePaymentDetails( |
||
125 | |||
126 | /** |
||
127 | * Sets the Sender |
||
128 | * @param $payee string The telephone Number of the Sender |
||
129 | * |
||
130 | * @return MazzumaPayment |
||
131 | */ |
||
132 | public function from($payee) |
||
139 | |||
140 | /** |
||
141 | * returns the Sender |
||
142 | * |
||
143 | * @return string |
||
144 | */ |
||
145 | public function getFrom() |
||
149 | |||
150 | /** |
||
151 | * Sets the Reciever |
||
152 | * @param $reciever string The telephone Number of the Reciever |
||
153 | * |
||
154 | * @return MazzumaPayment |
||
155 | */ |
||
156 | public function to($reciever) |
||
163 | |||
164 | /** |
||
165 | * returns the Reciever |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getTo() |
||
173 | |||
174 | /** |
||
175 | * Sets the Amount |
||
176 | * @param $totalAmount string The amount to be sent |
||
177 | * |
||
178 | * @return MazzumaPayment |
||
179 | */ |
||
180 | public function amount($totalAmount) |
||
187 | |||
188 | /** |
||
189 | * returns the Amount |
||
190 | * @param $totalAmount string The amount to be sent |
||
191 | * |
||
192 | * @return integer |
||
193 | */ |
||
194 | public function getAmount() |
||
198 | |||
199 | /** |
||
200 | * Sets the Sender Network |
||
201 | * @param $paymentFlow string The flow of the Payment |
||
202 | * |
||
203 | * @return MazzumaPayment |
||
204 | */ |
||
205 | public function transfer($paymentFlow) |
||
213 | |||
214 | /** |
||
215 | * Checks if payment was successful |
||
216 | * |
||
217 | * @return boolean |
||
218 | */ |
||
219 | public function isSuccessful() |
||
227 | |||
228 | /** |
||
229 | * Gets the Sender Network from the payment Flow |
||
230 | * |
||
231 | * @return string |
||
232 | */ |
||
233 | private function getSenderNetwork($paymentFlow) |
||
239 | |||
240 | /** |
||
241 | * returns the Reciever |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | public function getPayeeNetwork() |
||
249 | |||
250 | /** |
||
251 | * Sets the Option Parameter in the Data Payload |
||
252 | *` |
||
253 | * @param string $paymentDirection The flow of the Payment |
||
254 | * |
||
255 | * @return string Returns the ioption value for the payload |
||
256 | */ |
||
257 | private function setPaymentRoute($paymentDirection) |
||
291 | |||
292 | /** |
||
293 | * returns the Flow of the Transaction |
||
294 | * |
||
295 | * @return string |
||
296 | */ |
||
297 | public function getFlow() |
||
301 | |||
302 | /** |
||
303 | * Validates The telephone Numbers |
||
304 | * |
||
305 | * @param string $telephone The telephone number of a reciever or sender |
||
306 | * |
||
307 | * @return boolean |
||
308 | */ |
||
309 | private function validateTelephone($telephone) |
||
317 | |||
318 | /** |
||
319 | * Validates The Amount |
||
320 | * |
||
321 | * @param string $amount The amount been transacted |
||
322 | * |
||
323 | * @return boolean |
||
324 | */ |
||
325 | private function validateAmount($amount) |
||
333 | } |
||
334 |