Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,29 @@ Page::checkSlug($slug, $params);
Page::addProduct($page, $params);
```

### Invoices **TODO**
### Invoices
```php
use Myckhel\Paystack\Support\Invoice;

Invoice::create($params);

Invoice::list($params);

Invoice::fetch($invoice, $params);

Invoice::update($invoice, $params);

Invoice::verify($code, $params);

Invoice::notify($code, $params);

Invoice::totals($params);

Invoice::finalize($code, $params);

Invoice::archive($code, $params);
```

### Settlements **TODO**
### Transfer Recipients **TODO**
### Transfers **TODO**
Expand Down
15 changes: 15 additions & 0 deletions src/Http/Controllers/InvoiceController.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\Invoice;

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

namespace Myckhel\Paystack\Support;

use Myckhel\Paystack\Traits\Request;

/**
* The Invoices API allows you issue out and manage payment requests
*
*/
class Invoice
{
use Request;

/**
* Create a invoice on your integration
*
* @return \Illuminate\Http\Response
*/
static function create($params = [])
{
return self::post("/paymentrequest", $params);
}

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

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

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

/**
* Verify details of an invoice on your integration.
*
* @return \Illuminate\Http\Response
*/
static function verify($code, $params = [])
{
return self::get("/paymentrequest/verify/$code", $params);
}

/**
* Send notification of an invoice to your customers
*
* @return \Illuminate\Http\Response
*/
static function notify($code, $params = [])
{
return self::post("/paymentrequest/notify/$code", $params);
}

/**
* Get invoice metrics for dashboard
*
* @return \Illuminate\Http\Response
*/
static function totals($params = [])
{
return self::get("/paymentrequest/totals", $params);
}

/**
* Get invoice metrics for dashboard
*
* @return \Illuminate\Http\Response
*/
static function finalize($code, $params = [])
{
return self::post("/paymentrequest/finalize/$code", $params);
}

/**
* Used to archive an invoice. Invoice will no longer
* be fetched on list or returned on verify.
*
* @return \Illuminate\Http\Response
*/
static function archive($code, $params = [])
{
return self::post("/paymentrequest/archive/$code", $params);
}
}
12 changes: 12 additions & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Myckhel\Paystack\Http\Controllers\TransactionController;
use Myckhel\Paystack\Traits\PaystackConfig;
use Myckhel\Paystack\Http\Controllers\HookController;
use Myckhel\Paystack\Http\Controllers\InvoiceController;
use Myckhel\Paystack\Http\Controllers\PageController;
use Myckhel\Paystack\Http\Controllers\PlanController;
use Myckhel\Paystack\Http\Controllers\ProductController;
Expand Down Expand Up @@ -89,6 +90,16 @@
'put,page/{page}' => 'page,update',
'get,page/check_slug_availability/{slug}' => 'page,checkSlug',
'post,page/{page}/product' => 'page,addProduct',
// invoices
'post,paymentrequest' => 'invoice,create',
'get,paymentrequest' => 'invoice,list',
'get,paymentrequest/{invoice}' => 'invoice,fetch',
'put,paymentrequest/{invoice}' => 'invoice,update',
'get,paymentrequest/verify/{invoice_code}' => 'invoice,verify',
'post,paymentrequest/notify/{invoice_code}' => 'invoice,notify',
'get,paymentrequest/totals' => 'invoice,totals',
'post,paymentrequest/finalize/{invoice_code}' => 'invoice,finalize',
'post,paymentrequest/archive/{invoice_code}' => 'invoice,archive',
];

$controls = [
Expand All @@ -103,6 +114,7 @@
'subscription' => SubscriptionController::class,
'product' => ProductController::class,
'page' => PageController::class,
'invoice' => InvoiceController::class,
];

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