PHPackages                             prahsys/laravel-lunar - 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-lunar

ActiveLibrary[Payment Processing](/categories/payments)

prahsys/laravel-lunar
=====================

Prahsys payment driver for Lunar ecommerce with seamless checkout integration

00PHP

Since Sep 1Pushed 10mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Prahsys Lunar Payment Driver
============================

[](#prahsys-lunar-payment-driver)

[![Latest Version on Packagist](https://camo.githubusercontent.com/19d9db2b52a436710455f1a0717892cdd1bdb7cfd3f1bd1f8f2b067c424688f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f707261687379732f6c61726176656c2d6c756e61722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prahsys/laravel-lunar)[![GitHub Tests Action Status](https://camo.githubusercontent.com/63d7704b5bee00bdc55e1bc572f79ebc7e73c289b573e8cd1909c8126230bf4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f507261687379732f6c61726176656c2d6c756e61722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/Prahsys/laravel-lunar/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2e608b4b75bebc178b46841499556a4b7e15f2c55739b1c382e7f09fa760a720/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f707261687379732f6c61726176656c2d6c756e61722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/prahsys/laravel-lunar)

A Laravel package that integrates Prahsys payment processing with the Lunar e-commerce framework.

Features
--------

[](#features)

- 🛒 **Seamless Cart Integration** - Direct integration with Lunar's cart system
- 💳 **Multiple Payment Methods** - Support for hosted (`pay_portal`) and embedded (`pay_session`) checkout
- 🎨 **Customizable UI Components** - Pre-built Blade components with Alpine.js integration
- 🔒 **Secure Webhooks** - Comprehensive webhook handling for payment events
- ⚡ **Real-time Status** - Live payment status updates and monitoring
- 🔄 **Refund Support** - Full and partial refund capabilities
- 📊 **Audit Logging** - Complete transaction and event audit trail
- 🧪 **Comprehensive Tests** - Full test suite with 80%+ coverage

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12+
- Lunar Framework
- `prahsys/laravel-clerk` package (core Prahsys integration)

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

[](#installation)

1. Install the core Clerk package first:

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

2. Install the Lunar driver package:

```
composer require prahsys/laravel-lunar
```

3. Publish the configuration file:

```
php artisan vendor:publish --tag=lunar-prahsys-config
```

4. Publish the views (optional):

```
php artisan vendor:publish --tag=lunar-prahsys-views
```

5. Configure your environment variables:

```
PRAHSYS_API_KEY=your_api_key_here
PRAHSYS_WEBHOOK_SECRET=your_webhook_secret_here
LUNAR_PRAHSYS_ENABLED=true
```

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

[](#quick-start)

### Basic Checkout Integration

[](#basic-checkout-integration)

Add the checkout button to your cart page:

```

```

For embedded checkout with customer information collection:

```

```

### Programmatic Usage

[](#programmatic-usage)

```
use Lunar\Facades\CartSession;
use Prahsys\Lunar\Drivers\PrahsysPaymentDriver;

$cart = CartSession::current();
$paymentDriver = app(PrahsysPaymentDriver::class);

$transaction = $paymentDriver->cart($cart, [
    'payment_method' => 'pay_portal',
]);

if ($transaction && $transaction->success) {
    $session = PrahsysPaymentSession::where('session_id', $transaction->reference)->first();
    return redirect($session->checkout_url);
}
```

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

[](#configuration)

The `config/lunar-prahsys.php` file provides extensive customization options:

```
return [
    'driver' => [
        'enabled' => env('LUNAR_PRAHSYS_ENABLED', true),
    ],

    'payment_methods' => [
        'default' => 'pay_portal',
        'available' => [
            'pay_portal' => [
                'name' => 'Hosted Checkout',
                'description' => 'Redirect to Prahsys hosted payment page',
            ],
            'pay_session' => [
                'name' => 'Embedded Checkout',
                'description' => 'Embedded payment form',
                'requires_customer_info' => true,
            ],
        ],
    ],

    'checkout' => [
        'success_url' => '/checkout/success',
        'cancel_url' => '/checkout/cancel',
        'session_expires_in' => 3600, // 1 hour
    ],

    'webhooks' => [
        'middleware' => ['api'],
        'events' => [
            'payment.completed',
            'payment.failed',
            'payment.cancelled',
            'payment.refunded',
            'payment.partially_refunded',
        ],
    ],
];
```

Payment Methods
---------------

[](#payment-methods)

### Hosted Checkout (`pay_portal`)

[](#hosted-checkout-pay_portal)

Redirects customers to a secure Prahsys-hosted payment page. Best for simple integration with minimal customization needs.

### Embedded Checkout (`pay_session`)

[](#embedded-checkout-pay_session)

Embeds the payment form directly in your application. Provides more control over the user experience and requires customer information collection.

Webhook Configuration
---------------------

[](#webhook-configuration)

Configure your Prahsys webhook endpoint to:

```
POST https://yoursite.com/prahsys/webhooks/lunar

```

The package handles these webhook events automatically:

- `payment.completed` - Payment successfully processed
- `payment.failed` - Payment failed or was declined
- `payment.cancelled` - Payment cancelled by customer
- `payment.refunded` - Full refund processed
- `payment.partially_refunded` - Partial refund processed

Refund Processing
-----------------

[](#refund-processing)

```
use Prahsys\Lunar\Drivers\PrahsysPaymentDriver;

$paymentDriver = app(PrahsysPaymentDriver::class);

// Full refund
$transaction = $paymentDriver->refund($order, [
    'notes' => 'Customer requested refund',
]);

// Partial refund
$transaction = $paymentDriver->refund($order, [
    'amount' => 1500, // $15.00 refund
    'notes' => 'Partial refund for damaged item',
]);
```

Testing with Docker Tinker
--------------------------

[](#testing-with-docker-tinker)

During development, you can test features using Docker Tinker as recommended in the development workflow:

```
# Test payment driver instantiation
docker exec fable_app php artisan tinker --execute="
use Prahsys\Lunar\Drivers\PrahsysPaymentDriver;
echo 'Driver loaded: ' . (class_exists(PrahsysPaymentDriver::class) ? 'YES' : 'NO');
"

# Test payment session creation
docker exec fable_app php artisan tinker --execute="
use Prahsys\LaravelClerk\Models\PrahsysPaymentSession;
\$session = PrahsysPaymentSession::factory()->create();
echo 'Test session created: ' . \$session->session_id;
"
```

Testing
-------

[](#testing)

Run the comprehensive test suite:

```
# Run all tests
vendor/bin/phpunit

# Run with coverage
vendor/bin/phpunit --coverage-html build/coverage

# Run specific test suites
vendor/bin/phpunit --testsuite Unit
vendor/bin/phpunit --testsuite Feature
```

The test suite covers:

- Payment driver functionality
- Checkout controller integration
- Webhook processing
- Error handling and validation
- Refund processing
- Security features

API Routes
----------

[](#api-routes)

The package automatically registers these routes:

```
// Checkout routes
POST /prahsys/checkout              // Create payment session
GET  /prahsys/checkout/success      // Payment success callback
GET  /prahsys/checkout/cancel       // Payment cancellation callback
GET  /prahsys/checkout/status/{id}  // Payment status check

// Webhook routes
POST /prahsys/webhooks/lunar        // Primary webhook handler
GET  /prahsys/webhooks/status       // Webhook status check
POST /prahsys/webhooks/lunar-legacy // Legacy webhook handler
```

Security
--------

[](#security)

- All webhook signatures are automatically verified
- CSRF tokens are included in checkout forms
- Payment data is validated before processing
- Sensitive information is never logged or exposed

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

**Cart is Empty Error**: Ensure cart has items before checkout

```
$cart = CartSession::current();
if (!$cart || $cart->lines->isEmpty()) {
    return redirect()->back()->with('error', 'Please add items to cart');
}
```

**Payment Session Not Found**: Check session ID is passed correctly in callbacks

```
'success_url' => route('checkout.success') . '?session_id={session_id}',
```

**Webhook Signature Failed**: Verify webhook secret is configured correctly

```
PRAHSYS_WEBHOOK_SECRET=your_actual_webhook_secret
```

### Debug Mode

[](#debug-mode)

Enable debug logging:

```
// In config/lunar-prahsys.php
'debug' => env('PRAHSYS_DEBUG', false),
```

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

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Write tests for your changes
4. Ensure tests pass (`vendor/bin/phpunit`)
5. Commit your changes (`git commit -m 'Add amazing feature'`)
6. Push to the branch (`git push origin feature/amazing-feature`)
7. Open a Pull Request

Changelog
---------

[](#changelog)

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

License
-------

[](#license)

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

Support
-------

[](#support)

- 📧 **Email:**
- 📖 **Documentation:**
- 🐛 **Issues:**
- 💬 **Discord:**

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 (3 commits)")

### Embed Badge

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

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

###  Alternatives

[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.2k](/packages/msilabs-bkash)

PHPackages © 2026

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