PHPackages                             prahsys/laravel-cashier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. prahsys/laravel-cashier

ActiveLibrary[Payment Processing](/categories/payments)

prahsys/laravel-cashier
=======================

Laravel integration package for Prahsys payments with session management and webhooks

00PHP

Since Sep 9Pushed 8mo agoCompare

[ Source](https://github.com/Prahsys/laravel-cashier)[ Packagist](https://packagist.org/packages/prahsys/laravel-cashier)[ RSS](/packages/prahsys-laravel-cashier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Clerk - Prahsys Payments Integration
============================================

[](#laravel-clerk---prahsys-payments-integration)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5320e625e449f4d6026c4dc7f09e021cf23b40eb9d5ac6932e0a406c37ab3930/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f707261687379732f6c61726176656c2d636c65726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prahsys/laravel-clerk)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7fe1662aaf016a45f462f54677bdf10520641461771d6991dc62af4cd1b71ce9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f507261687379732f6c61726176656c2d636c65726b2f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/Prahsys/laravel-clerk/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/86277e5a31b45980d07c374a4c3126cf04e1f4b933a54eeadfe2b497f16bce6a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f507261687379732f6c61726176656c2d636c65726b2f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/Prahsys/laravel-clerk/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4f207f802d4b9a475d39e6528de5e47d8ccad9ef379304518e50ab6e0aae542c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f707261687379732f6c61726176656c2d636c65726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prahsys/laravel-clerk)

The Laravel-native way to integrate Prahsys payments. Built for developers who value simplicity, security, and comprehensive features.

**Trusted by Laravel developers for processing millions in transactions.**

Why Laravel Clerk?
------------------

[](#why-laravel-clerk)

- **🚀 Laravel-First**: Built specifically for Laravel with Eloquent models, database migrations, and artisan commands
- **💳 Multiple Payment Methods**: Cards, digital wallets, and card-present transactions
- **🔒 Enterprise Security**: PCI compliant with comprehensive audit logging and webhook verification
- **⚡ Developer Experience**: Type-safe DTOs, comprehensive test coverage, and excellent documentation
- **🔄 Robust Webhooks**: Automatic retry logic, signature verification, and event handling
- **📊 Complete Tracking**: Every transaction, status change, and event is logged and auditable

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require prahsys/laravel-clerk
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="clerk-migrations"
php artisan migrate
```

Publish the configuration file:

```
php artisan vendor:publish --tag="clerk-config"
```

Configuration
-------------

[](#configuration)

Add your Prahsys API credentials to your `.env` file:

```
PRAHSYS_API_KEY=your_api_key_here
PRAHSYS_ENTITY_ID=your_entity_id_here
PRAHSYS_ENVIRONMENT=sandbox # or 'production'
PRAHSYS_WEBHOOK_SECRET=your_webhook_secret_here
```

Quick Start
-----------

[](#quick-start)

### 1. Create a Payment Session

[](#1-create-a-payment-session)

```
use Prahsys\LaravelClerk\Services\PaymentSessionManager;

$paymentManager = app(PaymentSessionManager::class);

// Create a simple payment session
$session = $paymentManager->createPaymentSession(
    paymentId: 'payment-123',
    amount: 99.99,
    description: 'Order #1234',
    customerEmail: 'customer@example.com',
    customerName: 'John Doe'
);

// Redirect user to the payment URL
return redirect($session->checkout_url);
```

### 2. Create a Payment Portal Session

[](#2-create-a-payment-portal-session)

```
// Create a hosted payment portal
$session = $paymentManager->createPortalSession(
    paymentId: 'payment-123',
    amount: 99.99,
    description: 'Premium Subscription',
    returnUrl: route('payment.success'),
    cancelUrl: route('payment.cancel'),
    merchantName: 'My Store',
    merchantLogo: 'https://mystore.com/logo.png'
);

return redirect($session->portal_url);
```

### 3. Handle Webhooks

[](#3-handle-webhooks)

Create a webhook controller to handle payment events:

```
use Prahsys\LaravelClerk\Services\WebhookEventHandler;
use Illuminate\Http\Request;

class PaymentWebhookController extends Controller
{
    public function handle(Request $request, WebhookEventHandler $handler)
    {
        $event = $handler->handleWebhook(
            payload: $request->getContent(),
            signature: $request->header('X-Prahsys-Signature')
        );

        // The event is automatically stored and processed
        // You can add custom logic here based on event type

        match($event->event_type) {
            'payment.captured' => $this->handlePaymentSuccess($event),
            'payment.failed' => $this->handlePaymentFailure($event),
            default => null,
        };

        return response('OK');
    }

    private function handlePaymentSuccess($event)
    {
        // Send confirmation email, update order status, etc.
        $session = $event->paymentSession;

        // Access payment details
        logger("Payment successful: {$session->payment_id} for {$session->amount}");
    }
}
```

Core Features
-------------

[](#core-features)

### Payment Session Management

[](#payment-session-management)

```
use Prahsys\LaravelClerk\Models\PaymentSession;

// Query payment sessions
$pendingSessions = PaymentSession::where('status', 'pending')->get();
$completedToday = PaymentSession::whereDate('completed_at', today())->get();

// Check session status
if ($session->isCompleted()) {
    // Payment was successful
}

if ($session->isExpired()) {
    // Session has expired, create a new one
}

// Access related data
foreach ($session->transactions as $transaction) {
    echo "Transaction: {$transaction->transaction_id} - {$transaction->status}";
}
```

### Transaction Processing

[](#transaction-processing)

```
use Prahsys\LaravelClerk\Models\PaymentTransaction;

// Query transactions
$successfulTransactions = PaymentTransaction::where('status', 'captured')->get();
$failedTransactions = PaymentTransaction::where('status', 'failed')
    ->whereDate('created_at', today())
    ->get();

// Check transaction types
if ($transaction->isPayment()) {
    // This is a payment transaction
}

if ($transaction->isRefund()) {
    // This is a refund transaction
}

// Access gateway response data
$gatewayResponse = $transaction->gateway_response;
$responseCode = $gatewayResponse['response_code'];
```

### Audit Logging

[](#audit-logging)

Every action is automatically logged for compliance and debugging:

```
use Prahsys\LaravelClerk\Models\AuditLog;

// View all audit logs for a payment session
$logs = $session->auditLogs()->recent()->get();

// Query specific events
$paymentEvents = AuditLog::forEventType('payment_processed')->get();
$recentActivity = AuditLog::recent(50)->get();

foreach ($logs as $log) {
    echo "Event: {$log->event_type} at {$log->created_at}";
    echo "Changes: " . json_encode($log->new_values);
}
```

### Card Present Transactions

[](#card-present-transactions)

```
// Create a card present payment session
$session = $paymentManager->createPaymentSession(
    paymentId: 'terminal-payment-123',
    amount: 49.99,
    description: 'In-store purchase',
    customerEmail: 'customer@example.com',
    paymentMethod: 'card_present',
    metadata: [
        'terminal_id' => 'TERM_001',
        'location' => 'Store Front Desk'
    ]
);
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Payment Flows

[](#custom-payment-flows)

```
use Prahsys\LaravelClerk\Http\Requests\CreatePortalSessionRequest;
use Prahsys\LaravelClerk\Services\PaymentService;

class CustomPaymentController extends Controller
{
    public function createCustomPayment(PaymentService $paymentService)
    {
        // Direct API integration for custom flows
        $response = $paymentService->createPortalSession([
            'amount' => 150.00,
            'currency' => 'USD',
            'paymentId' => 'custom-' . uniqid(),
            'operation' => 'PAY',
            'customer' => [
                'email' => 'customer@example.com',
                'name' => 'Jane Smith'
            ],
            'returnUrl' => route('payment.success'),
            'cancelUrl' => route('payment.cancel'),
            'merchant' => [
                'name' => 'Premium Services',
                'logo' => asset('images/logo.png')
            ]
        ]);

        if ($response->successful()) {
            $data = $response->data();
            return redirect($data->redirectUrl);
        }

        return back()->withErrors('Payment session creation failed');
    }
}
```

### Error Handling

[](#error-handling)

```
try {
    $session = $paymentManager->createPaymentSession(/* ... */);
} catch (\Prahsys\LaravelClerk\Exceptions\PrahsysException $e) {
    logger()->error('Payment session creation failed', [
        'error' => $e->getMessage(),
        'code' => $e->getErrorCode(),
        'details' => $e->getDetails()
    ]);

    return response()->json(['error' => 'Payment unavailable'], 503);
}
```

### Testing

[](#testing)

Laravel Clerk provides comprehensive factories for testing:

```
use Prahsys\LaravelClerk\Models\PaymentSession;

public function test_successful_payment_flow()
{
    // Create test data
    $session = PaymentSession::factory()
        ->completed()
        ->create(['amount' => 99.99]);

    $transaction = PaymentTransaction::factory()
        ->successful()
        ->create(['payment_session_id' => $session->id]);

    $this->assertTrue($session->isCompleted());
    $this->assertTrue($transaction->isSuccessful());
}

public function test_webhook_processing()
{
    // Test webhook events
    $webhookEvent = WebhookEvent::factory()
        ->paymentCaptured()
        ->create();

    $this->assertEquals('payment.captured', $webhookEvent->event_type);
    $this->assertTrue($webhookEvent->isProcessed());
}
```

Configuration Options
---------------------

[](#configuration-options)

The configuration file provides extensive customization options:

```
// config/clerk.php
return [
    'api' => [
        'base_url' => env('PRAHSYS_BASE_URL', 'https://api.prahsys.com'),
        'timeout' => 30,
        'max_retries' => 3,
        'retry_delay' => 1000, // milliseconds
    ],

    'webhooks' => [
        'secret' => env('PRAHSYS_WEBHOOK_SECRET'),
        'max_retry_attempts' => 5,
        'verify_signatures' => true,
    ],

    'audit' => [
        'enabled' => true,
        'log_user_data' => true,
        'retention_days' => 365,
    ],
];
```

Testing
-------

[](#testing-1)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Prahsys Team](https://github.com/Prahsys)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance43

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/976179?v=4)[Stephen Rushing](/maintainers/stephenr85)[@stephenr85](https://github.com/stephenr85)

---

Top Contributors

[![stephenrprahsys](https://avatars.githubusercontent.com/u/194008910?v=4)](https://github.com/stephenrprahsys "stephenrprahsys (5 commits)")[![stephenr85](https://avatars.githubusercontent.com/u/976179?v=4)](https://github.com/stephenr85 "stephenr85 (1 commits)")

### Embed Badge

![Health badge](/badges/prahsys-laravel-cashier/health.svg)

```
[![Health](https://phpackages.com/badges/prahsys-laravel-cashier/health.svg)](https://phpackages.com/packages/prahsys-laravel-cashier)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
