Search by

paymint / paymint-laravel

Netvirux

There is no license information available for the latest version (v1.1.1) of this package.

The official Laravel wrapper for PayMint Africa

Package info

github.com/Paymint-Africa/paymint-laravel

pkg:composer/paymint/paymint-laravel

Statistics

Installs: 240

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.1 2026-09-11 08:21 UTC

This package is auto-updated.

Last update: 2026-09-11 08:26:33 UTC


README

The official Laravel wrapper for PayMint Africa. Seamlessly integrate PayMint checkout, virtual accounts, and webhooks into your Laravel application with zero configuration and elegant syntax.

Installation

Install the package via Composer:

composer require paymint/paymint-laravel

Configuration

Add your PayMint API keys to your .env file:

PAYMINT_SECRET_KEY=sec_live_your_secret_key

# Optional: Set a custom base URL for local testing or staging
# PAYMINT_BASE_URL=https://api.paymint.africa/v1/

Usage

Use the elegant PayMint Facade anywhere in your application.

1. Hosted Checkout (Start Payment & Verify)

use PayMint\Laravel\Facades\PayMint;

class PaymentController extends Controller
{
    // Step 1: Initialize and redirect customer
    public function initiatePayment(Request $request)
    {
        $response = PayMint::checkout()->initialize([
            'amount'       => 5000,
            'email'        => $request->user()->email,
            'reference'    => 'ORDER_' . uniqid(),
            'redirect_url' => route('payment.callback'),
            'name'         => $request->user()->name,
        ]);

        return redirect($response['data']['authorization_url']);
    }

    // Step 2: Handle customer return & verify
    public function handleCallback(Request $request)
    {
        $reference = $request->query('reference');
        $payment = PayMint::checkout()->verify($reference);

        if (($payment['data']['status'] ?? '') === 'successful') {
            // Order is paid! Deliver value
            return view('payment.success');
        }

        return view('payment.failed');
    }
}

2. Dedicated Virtual Accounts

use PayMint\Laravel\Facades\PayMint;

$account = PayMint::virtualAccounts()->create([
    'name'  => 'Jane Doe',
    'email' => 'jane@example.com',
    'phone' => '08123456789'
]);

return response()->json($account);

3. Webhook Verification

use Illuminate\Http\Request;
use PayMint\Laravel\Facades\PayMint;
use Illuminate\Support\Facades\Route;

Route::post('/webhook/paymint', function (Request $request) {
    $payload = $request->getContent();
    $signature = $request->header('X-Paymint-Signature');

    if (!PayMint::webhooks()->verifySignature($payload, $signature)) {
        return response()->json(['error' => 'Invalid signature detected.'], 401);
    }

    $event = $request->input('event');
    if ($event === 'payment.success') {
        // Credit the customer's wallet or update order status
    }

    return response()->json(['status' => 'success']);
});

License

MIT License