PHP code example of nzovopay / noderpay-laravel

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/ */

    

nzovopay / noderpay-laravel example snippets


use NoderPay\Laravel\Facades\NoderPay;

$invoice = NoderPay::invoices()->create([
    'amount' => 35.00,
    'currency' => 'USD',
    'order_id' => (string) $order->id,
    'redirect_url' => route('payment.success'),
]);

return redirect()->away($invoice->checkoutUrl);

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]);
    }
}
bash
php artisan vendor:publish --provider="NoderPay\Laravel\NoderPayServiceProvider" --tag="noderpay-config"
bash
php artisan noderpay:test