@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var $private_key |
31 | - */ |
|
31 | + */ |
|
32 | 32 | protected $private_key; |
33 | 33 | |
34 | 34 | |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @var $base_uri |
38 | 38 | * |
39 | - */ |
|
39 | + */ |
|
40 | 40 | protected $base_uri = 'https://api.demo.payant.ng'; |
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var $client |
45 | 45 | * |
46 | - */ |
|
46 | + */ |
|
47 | 47 | protected $client; |
48 | 48 | |
49 | 49 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * Get Base Url from Payant config file |
|
62 | - */ |
|
61 | + * Get Base Url from Payant config file |
|
62 | + */ |
|
63 | 63 | public function setBaseUrl() |
64 | 64 | { |
65 | 65 | if(Config::get('payant.mode') == 'LIVE') |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function setRequestOptions() |
84 | 84 | { |
85 | - $authorization_string = 'Bearer '. $this->private_key; |
|
85 | + $authorization_string = 'Bearer '. $this->private_key; |
|
86 | 86 | |
87 | 87 | //Set up Guzzle |
88 | 88 | $this->client = new Client( [ |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * [getStates Get States in a country (Nigeria)] |
102 | 102 | * @return object [list of banks and their respective bank_ids] |
103 | - */ |
|
103 | + */ |
|
104 | 104 | public function getBanks(){ |
105 | 105 | return $this->sendRequest('get', '/banks'); |
106 | 106 | } |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * [resolveAccount description] |
112 | 112 | * @param array $client_data [description] |
113 | 113 | * Required fields - 'settlement_bank', 'account_number' |
114 | - */ |
|
114 | + */ |
|
115 | 115 | public function resolveAccount( array $client_data){ |
116 | 116 | // Mandatory fields |
117 | 117 | $required_values = ['settlement_bank', 'account_number']; |
118 | 118 | |
119 | 119 | if(!array_keys_exist($client_data, $required_values)){ |
120 | - throw new RequiredValuesMissing("Missing required values :("); |
|
120 | + throw new RequiredValuesMissing("Missing required values :("); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $url = '/resolve-account'; |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @param array $client_data [description] |
134 | 134 | * Required fields - 'first_name', 'last_name', 'email', 'phone' |
135 | 135 | * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
136 | - */ |
|
136 | + */ |
|
137 | 137 | public function addClient( array $client_data){ |
138 | 138 | // Mandatory fields |
139 | 139 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
140 | 140 | |
141 | 141 | if(!array_keys_exist($client_data, $required_values)){ |
142 | - throw new RequiredValuesMissing("Missing required values :("); |
|
142 | + throw new RequiredValuesMissing("Missing required values :("); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $url = '/clients'; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * [getClient Get client Details] |
155 | 155 | * @param string $client_id |
156 | 156 | * @return object |
157 | - */ |
|
157 | + */ |
|
158 | 158 | public function getClient($client_id = null){ |
159 | 159 | if(!$client_id){ |
160 | 160 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | /** |
173 | - * [editClient - Edit Existing Client] |
|
174 | - * @param string $client_id |
|
175 | - * @param array $client_data |
|
176 | - * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
177 | - * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
178 | - */ |
|
173 | + * [editClient - Edit Existing Client] |
|
174 | + * @param string $client_id |
|
175 | + * @param array $client_data |
|
176 | + * Required fields - 'first_name', 'last_name', 'email', 'phone' |
|
177 | + * Optional - 'address', 'company_name', 'type', 'settlement_bank', 'account_number' |
|
178 | + */ |
|
179 | 179 | public function editClient( $client_id, array $client_data){ |
180 | 180 | if(!$client_id){ |
181 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
181 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Client Id"); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $url = "/clients/{$client_id}"; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $required_values = ['first_name', 'last_name', 'email', 'phone']; |
188 | 188 | |
189 | 189 | if(!array_keys_exist($client_data, $required_values)){ |
190 | - throw new RequiredValuesMissing("Missing required values :("); |
|
190 | + throw new RequiredValuesMissing("Missing required values :("); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return $this->sendRequest('put', $url, ['form_params' => $client_data]); |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | |
272 | 272 | |
273 | 273 | /** |
274 | - * [getInvoice ] |
|
275 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
276 | - * @return object |
|
277 | - */ |
|
274 | + * [getInvoice ] |
|
275 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
276 | + * @return object |
|
277 | + */ |
|
278 | 278 | public function getInvoice($reference_code){ |
279 | 279 | if(!$reference_code){ |
280 | 280 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | - * [sendInvoice] |
|
290 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
291 | - * @return object |
|
292 | - */ |
|
289 | + * [sendInvoice] |
|
290 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
291 | + * @return object |
|
292 | + */ |
|
293 | 293 | public function sendInvoice($reference_code = null){ |
294 | 294 | if(!$reference_code){ |
295 | 295 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
308 | - * [getInvoiceHistory] |
|
309 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
310 | - * @param string $start [Format - DD/MM/YYYY] |
|
311 | - * @param string $end [Format - DD/MM/YYYY] |
|
312 | - * @return object |
|
313 | - */ |
|
308 | + * [getInvoiceHistory] |
|
309 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
310 | + * @param string $start [Format - DD/MM/YYYY] |
|
311 | + * @param string $end [Format - DD/MM/YYYY] |
|
312 | + * @return object |
|
313 | + */ |
|
314 | 314 | public function getInvoiceHistory($period, $start = null, $end = null){ |
315 | 315 | if(!$period){ |
316 | 316 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -328,10 +328,10 @@ discard block |
||
328 | 328 | |
329 | 329 | |
330 | 330 | /** |
331 | - * [deleteInvoice] |
|
332 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
333 | - * @return object |
|
334 | - */ |
|
331 | + * [deleteInvoice] |
|
332 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
333 | + * @return object |
|
334 | + */ |
|
335 | 335 | public function deleteInvoice($reference_code){ |
336 | 336 | if(!$reference_code){ |
337 | 337 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | |
381 | 381 | |
382 | 382 | /** |
383 | - * [getTransfer ] |
|
384 | - * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
385 | - * @return object |
|
386 | - */ |
|
383 | + * [getTransfer ] |
|
384 | + * @param string $reference_code [Mandatory - Transfer Reference Code] |
|
385 | + * @return object |
|
386 | + */ |
|
387 | 387 | public function getTransfer($reference_code){ |
388 | 388 | if(!$reference_code){ |
389 | 389 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | |
401 | 401 | |
402 | 402 | /** |
403 | - * [getTransferHistory] |
|
404 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
405 | - * @param string $start [Format - DD/MM/YYYY] |
|
406 | - * @param string $end [Format - DD/MM/YYYY] |
|
407 | - * @return object |
|
408 | - */ |
|
403 | + * [getTransferHistory] |
|
404 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
405 | + * @param string $start [Format - DD/MM/YYYY] |
|
406 | + * @param string $end [Format - DD/MM/YYYY] |
|
407 | + * @return object |
|
408 | + */ |
|
409 | 409 | public function getTransferHistory($period, $start = null, $end = null){ |
410 | 410 | if(!$period){ |
411 | 411 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | |
425 | 425 | |
426 | 426 | /** |
427 | - * [deleteTransfer] |
|
428 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
429 | - * @return object |
|
430 | - */ |
|
427 | + * [deleteTransfer] |
|
428 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
429 | + * @return object |
|
430 | + */ |
|
431 | 431 | public function deleteTransfer($reference_code){ |
432 | 432 | if(!$reference_code){ |
433 | 433 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -444,12 +444,12 @@ discard block |
||
444 | 444 | |
445 | 445 | |
446 | 446 | /** |
447 | - * [addPayment] |
|
448 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
449 | - * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
450 | - * @param string $amount [Mandatory] |
|
451 | - * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
452 | - */ |
|
447 | + * [addPayment] |
|
448 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
449 | + * @param string $due_date [Mandatory - [Format - DD/MM/YYYY]] |
|
450 | + * @param string $amount [Mandatory] |
|
451 | + * @param string $channel [Mandatory - valid ["Cash", "BankTransfer", "POS", "Cheque"]] |
|
452 | + */ |
|
453 | 453 | public function addPayment(string $reference_code, string $due_date, string $amount, string $channel){ |
454 | 454 | if(!$reference_code){ |
455 | 455 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | |
489 | 489 | |
490 | 490 | /** |
491 | - * [getPayment] |
|
492 | - * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
493 | - */ |
|
491 | + * [getPayment] |
|
492 | + * @param string $reference_code [Mandatory - Invoice Reference Code] |
|
493 | + */ |
|
494 | 494 | public function getPayment($reference_code){ |
495 | 495 | if(!$reference_code){ |
496 | 496 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid reference_code"); |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | |
507 | 507 | |
508 | 508 | /** |
509 | - * [getPaymentHistory] |
|
510 | - * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
511 | - * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
512 | - * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
513 | - * @return object |
|
514 | - */ |
|
509 | + * [getPaymentHistory] |
|
510 | + * @param string $period [Mandatory || Valid Options ["today", "week", "month", "30", "90", "year", "custom"]] |
|
511 | + * @param string $start [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
512 | + * @param string $end [Format - DD/MM/YYYY || Optional if $period !== 'custom'] |
|
513 | + * @return object |
|
514 | + */ |
|
515 | 515 | public function getPaymentHistory(string $period, string $start, string $end){ |
516 | 516 | if(!$period){ |
517 | 517 | throw new RequiredValueMissing("Error Processing Request - period Missing"); |
@@ -530,12 +530,12 @@ discard block |
||
530 | 530 | |
531 | 531 | |
532 | 532 | /** |
533 | - * [addProduct] |
|
534 | - * @param string $name [Mandatory - Product's name] |
|
535 | - * @param string $description [Mandatory - Product's description] |
|
536 | - * @param string $unit_cost [Mandatory - Product's unit cost] |
|
537 | - * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
538 | - */ |
|
533 | + * [addProduct] |
|
534 | + * @param string $name [Mandatory - Product's name] |
|
535 | + * @param string $description [Mandatory - Product's description] |
|
536 | + * @param string $unit_cost [Mandatory - Product's unit cost] |
|
537 | + * @param string $type [Mandatory - Product type 'product' or 'service'] |
|
538 | + */ |
|
539 | 539 | public function addProduct(string $name, string $description, string $unit_cost, string $type){ |
540 | 540 | if(!$name){ |
541 | 541 | throw new IsNull("Error Processing Request - Null/Invalid name"); |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | |
576 | 576 | |
577 | 577 | /** |
578 | - * [getProduct] |
|
579 | - * @param int $product_id [Mandatory - Product ID] |
|
580 | - * @return object |
|
581 | - */ |
|
578 | + * [getProduct] |
|
579 | + * @param int $product_id [Mandatory - Product ID] |
|
580 | + * @return object |
|
581 | + */ |
|
582 | 582 | public function getProduct($product_id){ |
583 | 583 | if(!$product_id){ |
584 | 584 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid product_id"); |
@@ -594,14 +594,14 @@ discard block |
||
594 | 594 | |
595 | 595 | |
596 | 596 | /** |
597 | - * [editProduct] |
|
598 | - * @param string $product_id [Mandatory - Product ID] |
|
599 | - * @param array $product_data [description] |
|
600 | - * @return object |
|
601 | - */ |
|
597 | + * [editProduct] |
|
598 | + * @param string $product_id [Mandatory - Product ID] |
|
599 | + * @param array $product_data [description] |
|
600 | + * @return object |
|
601 | + */ |
|
602 | 602 | public function editProduct($product_id, array $product_data){ |
603 | 603 | if(!$product_id){ |
604 | - throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
604 | + throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | //Validate Type |
@@ -615,13 +615,13 @@ discard block |
||
615 | 615 | throw new IsInvalid("Invalid Type - Available options: 'product' or 'service'"); |
616 | 616 | } |
617 | 617 | |
618 | - $url = "/products/{$product_id}"; |
|
618 | + $url = "/products/{$product_id}"; |
|
619 | 619 | |
620 | - // Mandatory fields |
|
621 | - $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
620 | + // Mandatory fields |
|
621 | + $required_values = ['name', 'description', 'unit_cost', 'type']; |
|
622 | 622 | |
623 | 623 | if(!array_keys_exist($product_data, $required_values)){ |
624 | - throw new RequiredValuesMissing("Missing required values :("); |
|
624 | + throw new RequiredValuesMissing("Missing required values :("); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | return $this->sendRequest('put', $url, ['form_params' => $product_data]); |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | |
632 | 632 | |
633 | 633 | /** |
634 | - * [getProducts] |
|
635 | - * @return object |
|
636 | - */ |
|
634 | + * [getProducts] |
|
635 | + * @return object |
|
636 | + */ |
|
637 | 637 | public function getProducts(){ |
638 | 638 | $url = "/products"; |
639 | 639 | |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | |
645 | 645 | |
646 | 646 | /** |
647 | - * [deleteProduct] |
|
648 | - * @param $product_id [Mandatory - Product ID] |
|
649 | - * @return object |
|
650 | - */ |
|
647 | + * [deleteProduct] |
|
648 | + * @param $product_id [Mandatory - Product ID] |
|
649 | + * @return object |
|
650 | + */ |
|
651 | 651 | public function deleteProduct($product_id){ |
652 | 652 | if(!$product_id){ |
653 | 653 | throw new IsNullOrInvalid("Error Processing Request - Null/Invalid Product Id"); |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | |
662 | 662 | |
663 | 663 | /** |
664 | - * [addPayment] |
|
665 | - * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
666 | - * @param string $url [Mandatory - url to send request to] |
|
667 | - * @param array $params [data to post to request url] |
|
668 | - */ |
|
664 | + * [addPayment] |
|
665 | + * @param string $method [Mandatory - request method <get | post | put | delete> ] |
|
666 | + * @param string $url [Mandatory - url to send request to] |
|
667 | + * @param array $params [data to post to request url] |
|
668 | + */ |
|
669 | 669 | public function sendRequest($method, $url, $params=[]) |
670 | 670 | { |
671 | 671 | try{ |