Seamless Payments in Laravel: Introducing PayHere Integration
In the dynamic world of web development, simplifying payment processing is a game‑changer. That’s why the newly released Laravel PayHere plugin is generating buzz. Announced on June 23, 2025, it brings Sri Lanka’s popular PayHere payment gateway directly into Laravel apps—offering developers a reliable, feature‑rich integration.
What Is PayHere and Why It Matters
PayHere is a leading payment gateway in Sri Lanka, trusted by businesses for smooth online transactions (github.com). The official Laravel PayHere package wraps the gateway's full API suite—including checkout flows, subscriptions, recurring payments, refunds, and more—into a seamless Laravel‑friendly interface .
Core Features Developers Will Love
Onsite & Offsite Checkout: Choose user‑friendly flow options via JavaScript SDK or redirect forms .
Billing Events: Automatically dispatches Laravel events (e.g., CheckoutCallbackEvent, RecurringCallbackEvent) so you can hook into payment workflows.
Billable User Integration: Implements a PayHereCustomer interface or a Billable trait for authenticating user scenarios.
Mobile‑Friendly REST API: Provides intermediary REST endpoints ideal for hybrid or mobile apps.
Filament Admin Panel: Out-of-the-box functionality for managing payments and subscriptions via Filament.
Installing and Getting Started
Start with a simple Composer command:
composer require laravel-payhere/laravel-payhere php artisan payhere:install php artisan filament:assets # if using the Filament UIConfigure your .env with your PayHere credentials:
PAYHERE_MERCHANT_ID=... PAYHERE_MERCHANT_SECRET=... PAYHERE_APP_ID=... PAYHERE_APP_SECRET=...With environment setup complete, you’re ready to craft checkout logic:
use PayHere\PayHere; return PayHere::builder() ->guest() ->title("Retro Trucker Hat") ->amount(25) ->checkout();This code redirects users to PayHere’s checkout and returns them to your defined return URL.
Advanced Workflows: Onsite, Recurring, Preapproval & More
Want to keep users on your site? Use @payhereJS and the <x-payhere::button> Blade component to embed payment buttons and integrate the JS SDK for onsite checkout.
For subscription-style payments, PayHere’s recurring() method lets you set intervals (weekly, monthly, yearly) and durations, with callbacks automatically managed via Laravel events (github.com).
Additionally, the package supports:
Preapproval APIs for pre-authorizing charges,
Charging API to deduct payments programmatically,
Retrieval API to fetch payment details,
Subscription Manager to list, retry, or cancel subscriptions,
Refund API for handling refunds, and
Authorize & Capture APIs for hold-on-card use cases (github.com).
What This Means for Laravel Teams
All‑in‑one Integration: No need to stitch together disparate endpoints—everything is available from a single standardized package.
Laravel‑native: Out-of-the-box support for blade directives, traits, event handlers, and Filament UI makes integration feel natural.
Scalable: Whether it’s a one-off purchase, recurring subscription, or admin‑driven transaction, the package supports it.
Mobile‑ready: The REST API bridge makes it a breeze to support mobile or headless frontends.
In Summary: The Laravel PayHere plugin delivers a robust, full-stack solution for payment processing—tailored for Sri Lankan businesses—but built with globally-applicable patterns. Its rich feature set and natural alignment with Laravel’s conventions make it a valuable addition to any payment-driven app looking for reliability, flexibility, and local compliance.
🚀 Call to Action
If you're building with Laravel and catering to Sri Lankan customers—or want a structured, event‑driven payment system—PayHere for Laravel is worth exploring now. Visit the documentation, install via Composer, and plan your payment flows accordingly