@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @var $private_key |
32 | - */ |
|
32 | + */ |
|
33 | 33 | protected $private_key; |
34 | 34 | |
35 | 35 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @var $base_uri |
39 | 39 | * |
40 | - */ |
|
40 | + */ |
|
41 | 41 | protected $base_uri = 'https://api.demo.payant.ng'; |
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @var $client |
46 | 46 | * |
47 | - */ |
|
47 | + */ |
|
48 | 48 | protected $client; |
49 | 49 | |
50 | 50 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * Get Base Url from Payant config file |
|
63 | - */ |
|
62 | + * Get Base Url from Payant config file |
|
63 | + */ |
|
64 | 64 | public function setBaseUrl() |
65 | 65 | { |
66 | 66 | if(Config::get('payant.mode') == 'LIVE') |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | private function setRequestOptions() |
85 | 85 | { |
86 | - $authorization_string = 'Bearer '. $this->private_key; |
|
86 | + $authorization_string = 'Bearer '. $this->private_key; |
|
87 | 87 | |
88 | 88 | //Set up Guzzle |
89 | 89 | $this->client = new Client( [ |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * [getStates Get States in a country (Nigeria)] |
103 | 103 | * @return [object] [list of banks and their respective bank_ids] |
104 | - */ |
|
104 | + */ |
|
105 | 105 | public function getBanks(){ |
106 | 106 | return $this->sendRequest('get', '/banks'); |
107 | 107 | } |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | * [resolveAccount description] |
113 | 113 | * @param array $client_data [description] |
114 | 114 | * Required fields - 'settlement_bank', 'account_number' |
115 | - */ |
|
115 | + */ |
|
116 | 116 | public function resolveAccount( array $client_data){ |
117 | 117 | // Mandatory fields |
118 | 118 | $required_values = ['settlement_bank', 'account_number']; |
119 | 119 | |
120 | 120 | if(!array_keys_exist($client_data, $required_values)){ |
121 | - throw new RequiredValuesMissing("Missing required values :("); |
|
121 | + throw new RequiredValuesMissing("Missing required values :("); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $url = '/resolve-account'; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @param array $client_data [description] |
135 | 135 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
136 | 136 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
137 | - */ |
|
137 | + */ |
|
138 | 138 | public function addClient( array $client_data){ |
139 | 139 | // Mandatory fields |
140 | 140 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
141 | 141 | |
142 | 142 | if(!array_keys_exist($client_data, $required_values)){ |
143 | - throw new RequiredValuesMissing("Missing required values :("); |
|
143 | + throw new RequiredValuesMissing("Missing required values :("); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $url = '/clients'; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * [getClient Get client Details] |
156 | 156 | * @param [string] $client_id |
157 | 157 | * @return [object] |
158 | - */ |
|
158 | + */ |
|
159 | 159 | public function getClient($client_id = null){ |
160 | 160 | if(!$client_id){ |
161 | 161 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | |
172 | 172 | |
173 | 173 | /** |
174 | - * [editClient - Edit Existing Client] |
|
175 | - * @param [string] $client_id |
|
176 | - * @param [array] $client_data |
|
177 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
178 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
179 | - */ |
|
174 | + * [editClient - Edit Existing Client] |
|
175 | + * @param [string] $client_id |
|
176 | + * @param [array] $client_data |
|
177 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
178 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
179 | + */ |
|
180 | 180 | public function editClient( $client_id, array $client_data){ |
181 | 181 | if(!$client_id){ |
182 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
182 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $url = "/clients/{$client_id}"; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
189 | 189 | |
190 | 190 | if(!array_keys_exist($client_data, $required_values)){ |
191 | - throw new RequiredValuesMissing("Missing required values :("); |
|
191 | + throw new RequiredValuesMissing("Missing required values :("); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return $this->sendRequest('put', $url, ['form_params' => $client_data]); |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | |
273 | 273 | |
274 | 274 | /** |
275 | - * [getInvoice ] |
|
276 | - * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
277 | - * @return [object] |
|
278 | - */ |
|
275 | + * [getInvoice ] |
|
276 | + * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
277 | + * @return [object] |
|
278 | + */ |
|
279 | 279 | public function getInvoice($reference_code){ |
280 | 280 | if(!$reference_code){ |
281 | 281 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
290 | - * [sendInvoice] |
|
291 | - * @param [type] $reference_code [Mandatory - Invoice Reference Code] |
|
292 | - * @return [object] |
|
293 | - */ |
|
290 | + * [sendInvoice] |
|
291 | + * @param [type] $reference_code [Mandatory - Invoice Reference Code] |
|
292 | + * @return [object] |
|
293 | + */ |
|
294 | 294 | public function sendInvoice($reference_code = null){ |
295 | 295 | if(!$reference_code){ |
296 | 296 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | |
307 | 307 | |
308 | 308 | /** |
309 | - * [getInvoiceHistory] |
|
310 | - * @param [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
311 | - * @param [string] $start [Format - DD/MM/YYYY] |
|
312 | - * @param [string] $end [Format - DD/MM/YYYY] |
|
313 | - * @return [object] |
|
314 | - */ |
|
309 | + * [getInvoiceHistory] |
|
310 | + * @param [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
311 | + * @param [string] $start [Format - DD/MM/YYYY] |
|
312 | + * @param [string] $end [Format - DD/MM/YYYY] |
|
313 | + * @return [object] |
|
314 | + */ |
|
315 | 315 | public function getInvoiceHistory($period, $start = null, $end = null){ |
316 | 316 | if(!$period){ |
317 | 317 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -346,10 +346,10 @@ discard block |
||
346 | 346 | |
347 | 347 | |
348 | 348 | /** |
349 | - * [deleteInvoice] |
|
350 | - * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
351 | - * @return [object] |
|
352 | - */ |
|
349 | + * [deleteInvoice] |
|
350 | + * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
351 | + * @return [object] |
|
352 | + */ |
|
353 | 353 | public function deleteInvoice($reference_code){ |
354 | 354 | if(!$reference_code){ |
355 | 355 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | |
366 | 366 | |
367 | 367 | /** |
368 | - * [addPayment] |
|
369 | - * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
370 | - * @param [string] $date [Mandatory - [Format - DD/MM/YYYY]] |
|
371 | - * @param [string] $amount [Mandatory] |
|
372 | - * @param [string] $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
373 | - */ |
|
368 | + * [addPayment] |
|
369 | + * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
370 | + * @param [string] $date [Mandatory - [Format - DD/MM/YYYY]] |
|
371 | + * @param [string] $amount [Mandatory] |
|
372 | + * @param [string] $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
373 | + */ |
|
374 | 374 | public function addPayment(string $reference_code, string $date, string $amount, string $channel){ |
375 | 375 | if(!$reference_code){ |
376 | 376 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | |
410 | 410 | |
411 | 411 | /** |
412 | - * [getPayment] |
|
413 | - * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
414 | - */ |
|
412 | + * [getPayment] |
|
413 | + * @param [string] $reference_code [Mandatory - Invoice Reference Code] |
|
414 | + */ |
|
415 | 415 | public function getPayment($reference_code){ |
416 | 416 | if(!$reference_code){ |
417 | 417 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | |
428 | 428 | |
429 | 429 | /** |
430 | - * [getPaymentHistory] |
|
431 | - * @param [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
432 | - * @param [string] $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
433 | - * @param [string] $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
434 | - * @return [object] |
|
435 | - */ |
|
430 | + * [getPaymentHistory] |
|
431 | + * @param [string] $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
432 | + * @param [string] $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
433 | + * @param [string] $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
434 | + * @return [object] |
|
435 | + */ |
|
436 | 436 | public function getPaymentHistory(string $period, string $start, string $end){ |
437 | 437 | if(!$period){ |
438 | 438 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | |
468 | 468 | |
469 | 469 | /** |
470 | - * [addProduct] |
|
471 | - * @param string $name [Mandatory - Product's name] |
|
472 | - * @param string $description [Mandatory - Product's description] |
|
473 | - * @param string $unit_cost [Mandatory - Product's unit cost] |
|
474 | - * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
475 | - */ |
|
470 | + * [addProduct] |
|
471 | + * @param string $name [Mandatory - Product's name] |
|
472 | + * @param string $description [Mandatory - Product's description] |
|
473 | + * @param string $unit_cost [Mandatory - Product's unit cost] |
|
474 | + * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
475 | + */ |
|
476 | 476 | public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
477 | 477 | if(!$name){ |
478 | 478 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | |
513 | 513 | |
514 | 514 | /** |
515 | - * [getProduct] |
|
516 | - * @param [int] $product_id [Mandatory - Product ID] |
|
517 | - * @return [object] |
|
518 | - */ |
|
515 | + * [getProduct] |
|
516 | + * @param [int] $product_id [Mandatory - Product ID] |
|
517 | + * @return [object] |
|
518 | + */ |
|
519 | 519 | public function getProduct($product_id){ |
520 | 520 | if(!$product_id){ |
521 | 521 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | |
532 | 532 | |
533 | 533 | /** |
534 | - * [editProduct] |
|
535 | - * @param string $product_id [Mandatory - Product ID] |
|
536 | - * @param array $product_data [description] |
|
537 | - * @return object |
|
538 | - */ |
|
534 | + * [editProduct] |
|
535 | + * @param string $product_id [Mandatory - Product ID] |
|
536 | + * @param array $product_data [description] |
|
537 | + * @return object |
|
538 | + */ |
|
539 | 539 | public function editProduct($product_id, array $product_data){ |
540 | 540 | if(!$product_id){ |
541 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
541 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | //Validate Type |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
553 | 553 | } |
554 | 554 | |
555 | - $url = "/products/{$product_id}"; |
|
555 | + $url = "/products/{$product_id}"; |
|
556 | 556 | |
557 | - // Mandatory fields |
|
558 | - $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
557 | + // Mandatory fields |
|
558 | + $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
559 | 559 | |
560 | 560 | if(!array_keys_exist($client_data, $required_values)){ |
561 | - throw new RequiredValuesMissing("Missing required values :("); |
|
561 | + throw new RequiredValuesMissing("Missing required values :("); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | return $this->sendRequest('put', $url, ['form_params' => $post_data]); |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | |
569 | 569 | |
570 | 570 | /** |
571 | - * [getProducts] |
|
572 | - * @return object |
|
573 | - */ |
|
571 | + * [getProducts] |
|
572 | + * @return object |
|
573 | + */ |
|
574 | 574 | public function getProducts(){ |
575 | 575 | $url = "/products"; |
576 | 576 | |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | |
582 | 582 | |
583 | 583 | /** |
584 | - * [deleteProduct] |
|
585 | - * @param $product_id [Mandatory - Product ID] |
|
586 | - * @return object |
|
587 | - */ |
|
584 | + * [deleteProduct] |
|
585 | + * @param $product_id [Mandatory - Product ID] |
|
586 | + * @return object |
|
587 | + */ |
|
588 | 588 | public function deleteProduct($product_id){ |
589 | 589 | if(!$product_id){ |
590 | 590 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | |
599 | 599 | |
600 | 600 | /** |
601 | - * [addPayment] |
|
602 | - * @param [string] $method [Mandatory - request method <get | post | put | delete> ] |
|
603 | - * @param [string] $url [Mandatory - url to send request to] |
|
604 | - * @param [array] $params [data to post to request url] |
|
605 | - */ |
|
601 | + * [addPayment] |
|
602 | + * @param [string] $method [Mandatory - request method <get | post | put | delete> ] |
|
603 | + * @param [string] $url [Mandatory - url to send request to] |
|
604 | + * @param [array] $params [data to post to request url] |
|
605 | + */ |
|
606 | 606 | public function sendRequest($method, $url, $params=[]) |
607 | 607 | { |
608 | 608 | try{ |