Skip to content

Commit

Permalink
created Recipient APIs (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
myckhel authored May 21, 2022
1 parent 37dcdc1 commit 7d029e5
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
18 changes: 17 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,23 @@ Settlement::list($params);
Settlement::transactions($settlement, $params);
```

### Transfer Recipients **TODO**
### Transfer Recipients
```php
use Myckhel\Paystack\Support\Recipient;

Recipient::create($params);

Recipient::bulkCreate($params);

Recipient::list($params);

Recipient::fetch($recipient, $params);

Recipient::update($recipient, $params);

Recipient::remove($recipient, $params);
```

### Transfers **TODO**
### Transfers Control **TODO**
### Bulk Charges **TODO**
Expand Down
15 changes: 15 additions & 0 deletions src/Http/Controllers/RecipientController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Myckhel\Paystack\Http\Controllers;

use Myckhel\Paystack\Support\Recipient;

class RecipientController extends Controller
{
function __call($method, $args)
{
return $args
? Recipient::$method($args[0], request()->all())
: Recipient::$method(request()->all());
}
}
77 changes: 77 additions & 0 deletions src/Support/Recipient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Myckhel\Paystack\Support;

use Myckhel\Paystack\Traits\Request;

/**
* The Transfer Recipients API allows you create
* and manage beneficiaries that you send money to
*
*/
class Recipient
{
use Request;

/**
* Creates a new recipient. A duplicate account number
* will lead to the retrieval of the existing record.
*
* @return \Illuminate\Http\Response
*/
static function create($params = [])
{
return self::post("/transferrecipient", $params);
}

/**
* Create multiple transfer recipients in batches.
* A duplicate account number will lead to the retrieval of the existing record.
*
* @return \Illuminate\Http\Response
*/
static function bulkCreate($params = [])
{
return self::post("/transferrecipient", $params);
}

/**
* List transfer recipients available on your integration.
*
* @return \Illuminate\Http\Response
*/
static function list($params = [])
{
return self::get("/transferrecipient", $params);
}

/**
* Get details of a transfer recipients on your integration.
*
* @return \Illuminate\Http\Response
*/
static function fetch($recipient, $params = [])
{
return self::get("/transferrecipient/$recipient", $params);
}

/**
* Update a transfer recipients details on your integration
*
* @return \Illuminate\Http\Response
*/
static function update($recipient, $params = [])
{
return self::put("/transferrecipient/$recipient", $params);
}

/**
* Deletes a transfer recipient (sets the transfer recipient to inactive)
*
* @return \Illuminate\Http\Response
*/
static function remove($recipient, $params = [])
{
return self::delete("/transferrecipient/$recipient", $params);
}
}
9 changes: 9 additions & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Myckhel\Paystack\Http\Controllers\PageController;
use Myckhel\Paystack\Http\Controllers\PlanController;
use Myckhel\Paystack\Http\Controllers\ProductController;
use Myckhel\Paystack\Http\Controllers\RecipientController;
use Myckhel\Paystack\Http\Controllers\SettlementController;
use Myckhel\Paystack\Http\Controllers\SubAccountController;
use Myckhel\Paystack\Http\Controllers\SplitController;
Expand Down Expand Up @@ -104,6 +105,13 @@
// settlements
'get,settlement' => 'settlement,list',
'get,settlement/{settlement}/transactions' => 'settlement,transactions',
// transferrecipients
'post,transferrecipient' => 'transferrecipt,create',
'post,transferrecipient/bulk' => 'transferrecipt,bulkCreate',
'get,transferrecipient' => 'transferrecipt,list',
'get,transferrecipient/{transferrecipient}' => 'transferrecipt,fetch',
'put,transferrecipient/{transferrecipient}' => 'transferrecipt,update',
'delete,transferrecipient/{transferrecipient}' => 'transferrecipt,remove',
];

$controls = [
Expand All @@ -120,6 +128,7 @@
'page' => PageController::class,
'invoice' => InvoiceController::class,
'settlement' => SettlementController::class,
'transferrecipt' => RecipientController::class,
];

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

0 comments on commit 7d029e5

Please sign in to comment.