1. Go to this page and download the library: Download nzovopay/noderpay-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use NoderPay\NoderPay;
final class BillingService
{
public function __construct(private NoderPay $noderpay) {}
public function createInvoice(array $data)
{
return $this->noderpay->invoices()->create($data);
}
}
// routes/web.php or routes/api.php
Route::post('/webhooks/noderpay', NoderPayWebhookController::class);
use Illuminate\Http\Request;
use NoderPay\Laravel\Facades\NoderPay;
final class NoderPayWebhookController
{
public function __invoke(Request $request)
{
$raw = $request->getContent();
$signature = $request->header('Merchant-Sig');
if (!NoderPay::webhooks()->verify($raw, $signature, config('noderpay.webhook_secret'))) {
abort(401);
}
$event = NoderPay::webhooks()->parse($raw);
if ($event->type === 'InvoiceSettled' && $event->invoice !== null) {
// Look up the local order by $event->invoice->orderId, confirm it
// matches your records, then dispatch a job to mark it paid.
// Do this via a queued job, not inline here, so the webhook
// response returns quickly.
}
return response()->json(['ok' => true]);
}
}