Skip to content

Commit fb6f375

Browse files
authored
created Miscellaneous APIs (#34)
1 parent fa40442 commit fb6f375

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

readme.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,18 @@ Verification::validateAccount($params);
391391
Verification::resolveCardBIN($bin, $params);
392392
```
393393

394-
### Miscellaneous **TODO**
394+
### Miscellaneous
395+
```php
396+
use Myckhel\Paystack\Support\Miscellaneous;
397+
398+
Miscellaneous::listBanks($params);
399+
400+
Miscellaneous::listProviders($params);
401+
402+
Miscellaneous::listCountries($params);
403+
404+
Miscellaneous::listStates($params);
405+
```
395406

396407
### Using WebHook route
397408
Laravel paystack provides you a predefined endpoint that listens to and validates incoming paystack's webhook events.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Myckhel\Paystack\Http\Controllers;
4+
5+
use Myckhel\Paystack\Support\Miscellaneous;
6+
7+
class MiscellaneousController extends Controller
8+
{
9+
function __call($method, $args)
10+
{
11+
return $args
12+
? Miscellaneous::$method($args[0], request()->all())
13+
: Miscellaneous::$method(request()->all());
14+
}
15+
}

src/Support/Miscellaneous.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Myckhel\Paystack\Support;
4+
5+
use Myckhel\Paystack\Traits\Request;
6+
7+
/**
8+
* The Miscellaneous API are supporting APIs that
9+
* can be used to provide more details to other APIs
10+
*
11+
*/
12+
class Miscellaneous
13+
{
14+
use Request;
15+
16+
/**
17+
* Get a list of all supported banks and their properties
18+
*
19+
* @return \Illuminate\Http\Response
20+
*/
21+
static function listBanks($params = [])
22+
{
23+
return self::get("/bank", $params);
24+
}
25+
26+
/**
27+
* Get a list of all providers for Dedicated Virtual Account
28+
*
29+
* @return \Illuminate\Http\Response
30+
*/
31+
static function listProviders($params = [])
32+
{
33+
return self::get("/banks", $params);
34+
}
35+
36+
/**
37+
* Gets a list of Countries that Paystack currently supports
38+
*
39+
* @return \Illuminate\Http\Response
40+
*/
41+
static function listCountries($params = [])
42+
{
43+
return self::get("/country", $params);
44+
}
45+
46+
/**
47+
* Get a list of states for a country for address verification.
48+
*
49+
* @return \Illuminate\Http\Response
50+
*/
51+
static function listStates($params = [])
52+
{
53+
return self::get("/address_verification/states", $params);
54+
}
55+
}

src/routes.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Myckhel\Paystack\Traits\PaystackConfig;
1313
use Myckhel\Paystack\Http\Controllers\HookController;
1414
use Myckhel\Paystack\Http\Controllers\InvoiceController;
15+
use Myckhel\Paystack\Http\Controllers\MiscellaneousController;
1516
use Myckhel\Paystack\Http\Controllers\PageController;
1617
use Myckhel\Paystack\Http\Controllers\PlanController;
1718
use Myckhel\Paystack\Http\Controllers\ProductController;
@@ -169,6 +170,11 @@
169170
'get,bank/resolve' => 'verification,resolve',
170171
'post,bank/validate' => 'verification,validateAccount',
171172
'get,decision/bin/{bin}' => 'verification,resolveCardBIN',
173+
// miscellaneous
174+
'get,bank' => 'miscellaneous,listBanks',
175+
'get,banks' => 'miscellaneous,listProviders',
176+
'get,country' => 'miscellaneous,listCountries',
177+
'get,address_verification/states' => 'miscellaneous,listStates',
172178
];
173179

174180
$controls = [
@@ -194,6 +200,7 @@
194200
'dispute' => DisputeController::class,
195201
'refund' => RefundController::class,
196202
'verification' => VerificationController::class,
203+
'miscellaneous' => MiscellaneousController::class,
197204
];
198205

199206
collect($routes)->map(function ($route, $index) use ($controls) {

0 commit comments

Comments
 (0)