From 1afa57b5fe4db164b77fb35e198f4b7601a55d00 Mon Sep 17 00:00:00 2001 From: myckhel Date: Fri, 20 May 2022 21:29:19 +0100 Subject: [PATCH] added `Invoice` APIs --- readme.md | 24 ++++- src/Http/Controllers/InvoiceController.php | 15 +++ src/Support/Invoice.php | 105 +++++++++++++++++++++ src/routes.php | 12 +++ 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 src/Http/Controllers/InvoiceController.php create mode 100644 src/Support/Invoice.php diff --git a/readme.md b/readme.md index 1c5398d..1f6b432 100644 --- a/readme.md +++ b/readme.md @@ -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** diff --git a/src/Http/Controllers/InvoiceController.php b/src/Http/Controllers/InvoiceController.php new file mode 100644 index 0000000..7715f7f --- /dev/null +++ b/src/Http/Controllers/InvoiceController.php @@ -0,0 +1,15 @@ +all()) + : Invoice::$method(request()->all()); + } +} diff --git a/src/Support/Invoice.php b/src/Support/Invoice.php new file mode 100644 index 0000000..007adb4 --- /dev/null +++ b/src/Support/Invoice.php @@ -0,0 +1,105 @@ + '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 = [ @@ -103,6 +114,7 @@ 'subscription' => SubscriptionController::class, 'product' => ProductController::class, 'page' => PageController::class, + 'invoice' => InvoiceController::class, ]; collect($routes)->map(function ($route, $index) use ($controls) {