PHPackages                             necessarylion/opn-payments-laravel - 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. necessarylion/opn-payments-laravel

ActiveLibrary[Payment Processing](/categories/payments)

necessarylion/opn-payments-laravel
==================================

Laravel package for Opn Payments

1.0.3(3y ago)11MITPHPPHP &gt;=7.4CI passing

Since Oct 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/necessarylion/opn-payments-laravel)[ Packagist](https://packagist.org/packages/necessarylion/opn-payments-laravel)[ RSS](/packages/necessarylion-opn-payments-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Opn Payments Laravel Package (Unofficial)
=========================================

[](#opn-payments-laravel-package-unofficial)

[![php](https://camo.githubusercontent.com/96937b71dc1896bbab66351601dc3fbb0353e47cfc9d8ec4fd6cfad7757ab3e8/68747470733a2f2f62616467656e2e6e65742f62616467652f69636f6e2f7068703f69636f6e3d7061636b6167697374266c6162656c3d4c61726176656c2543322541305061636b616765)](https://packagist.org/packages/necessarylion/opn-payments-laravel) [![php](https://camo.githubusercontent.com/80f6ef5002279e9d2bb33c2db2adce4882324d5edb5299664c3964f6eae1a8d0/68747470733a2f2f62616467656e2e6e65742f62616467652f4f706e2543322541305061796d656e74732f4c61726176656c2f726564)](https://camo.githubusercontent.com/80f6ef5002279e9d2bb33c2db2adce4882324d5edb5299664c3964f6eae1a8d0/68747470733a2f2f62616467656e2e6e65742f62616467652f4f706e2543322541305061796d656e74732f4c61726176656c2f726564)

A Laravel package for integrating [Opn Payments (formerly Omise)](https://opn.ooo) using the omise-php SDK. This package provides a simple way to implement payments in your Laravel project with a ready-made payment form and automatic payment handling.

[View Full Documentation](https://necessarylion.github.io/opn-payments-laravel)

[![drawing](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/preview-desktop.png)](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/preview-desktop.png) [![drawing](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/preview-mobile.png)](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/preview-mobile.png)

[![flow diagram](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/flow-diagram.png)](https://raw.githubusercontent.com/necessarylion/opn-payments-laravel/master/flow-diagram.png)

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

[](#installation)

1. **Install Package**

```
composer require necessarylion/opn-payments-laravel
```

2. **Generate vendor**

```
php artisan vendor:publish --provider="OpnPayments\OpnPaymentsServiceProvider" --force
```

3. **Run Migration**

```
php artisan migrate
```

4. **Register Event Listener (optional)**

- Register `OpnPaymentCompleted` class in `app/Providers/EventServiceProvider.php`
    to handle your order, sending email etc...

```
public function boot()
{
    ...
    Event::listen(
        \OpnPayments\Events\OpnPaymentCompleted::class,
        [\App\Listeners\OpnPaymentHandler::class, 'handle']
    );
}
```

5. **Add credentials in .env file**

```
OPN_MODE=test  # test or live
OPN_TEST_PUBLIC_KEY=pkey_***
OPN_TEST_SECRET_KEY=skey_***
OPN_LIVE_PUBLIC_KEY=pkey_***
OPN_LIVE_SECRET_KEY=skey_***
```

- Make sure that `APP_URL` include port if you are running on port
- Example

```
APP_URL=http://localhost:8000
```

Create Charge
-------------

[](#create-charge)

Create charge using redirect url function

```
$payload = new OpnPaymentsRedirectPayload();
$payload->amount = 1000;
$payload->currency = OpnPaymentsCurrency::THAILAND_BAHT;
$payload->cancelUri = 'http://localhost:8000';
$payload->redirectUri = 'http://localhost:8000';
$payload->orderId = Str::uuid();
$payload->locale = OpnPaymentsLocale::ENGLISH;
$payload->paymentMethods = OpnPayments::paymentMethods();

return redirect(OpnPayments::getRedirectUrl($payload)->authorized_uri);
```

**Fields****Type****Description**`amount``int`Amount to charge`currency``string`Currency of the amount eg. THB, SGD, RGN. You can use `OpnPaymentsCurrency` helper class for this field`cancelUri``string`Url to redirect back if the user cancel payment`redirectUri``string`Url to redirect back if the payment completed`orderId``string`Unique order Id.`paymentMethods``array`Array of payment methods. You can see list of supported methods [here](https://www.omise.co/omise-js#supported-payment-methods-for-pre-built-form)`locale``string`Language, such ash , en, th, ja. You can use `OpnPaymentsLocale` helper class for this field`metaData``array`Extra meta data to append.Product List
------------

[](#product-list)

If you want to show list of products in payment page, you can do as below.

```
$payload->metaData = [
    'product' => [
        'image' => 'https://placehold.jp/75767a/ffffff/150x150.png'
        'name' => 'I Phone',
        'quantity' => '1',
        'price' => '320000',
    ]
];
```

OR

```
$payload->metaData = [
    'products' => [
        [
            'image' => 'https://placehold.jp/75767a/ffffff/150x150.png'
            'name' => 'I Phone',
            'quantity' => '1',
            'price' => '320000',
        ]
    ]
];
```

Event Listener
--------------

[](#event-listener)

**Handle Completed Payment using `OpnPaymentHandler` Listener**

*in `app/Listeners/OpnPaymentHandler.php`, you can check the `payment_successful` status of payment attempt.*
*to handle order, sending email etc..*

```
public function handle(OpnPaymentCompleted $event) {
    $attempt = $event->attempt;
    $charge = $event->charge;
    if ($attempt->payment_successful) {
        // handle payment success here
    } else {
        // handle payment failed here
    }
}
```

Scheduler
---------

[](#scheduler)

Register scheduler for pending charges.

*This scheduler will get all pending charge from records withing 24 hours. Then it will fetch status from Opn API and update if success or failed.*

In `app/Console/Kernel.php` inside `schedule()` function add below line.

```
$schedule->command('opn-payments-scheduler')->everyFiveMinutes();
```

Additional Functions
--------------------

[](#additional-functions)

**Name****Description**`OpnPayments::charge()`To create/retrieve charge`OpnPayments::account()`To retrieve account information`OpnPayments::capability()`To retrieve capability data`OpnPayments::card()`To create/retrieve card`OpnPayments::token()`To create/retrieve token`OpnPayments::refund()`To create/retrieve refund`OpnPayments::event()`To create/retrieve event`OpnPayments::source()`To create/retrieve source`OpnPayments::customer()`To create/retrieve customer`OpnPayments::receipt()`To create/retrieve receipt`OpnPayments::transfer()`To create/retrieve transfer`OpnPayments::balance()`To create/retrieve balanceContribute
----------

[](#contribute)

Want to contribute? Great! Fork the repo and create PR to us.

Development Process
-------------------

[](#development-process)

- In your Laravel project
- Create packages folder `mkdir packages`
- And clone our package `git clone git@github.com:necessarylion/opn-payments-laravel.git`

```
{
    ...
    "repositories": {
        "opn-payments-laravel" : {
            "type": "path",
            "url" : "packages/opn-payments-laravel",
            "options": {
                "symlink": true
            }
        }
    },
}
```

```
"require": {
    ...
    "necessarylion/opn-payments-laravel" : "@dev"
},
```

```
composer update
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1289d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/790f48f31f3770b92b73886358dfcd42b920f8f266a32f456e97fb54ee0f3f99?d=identicon)[necessarylion](/maintainers/necessarylion)

---

Top Contributors

[![necessarylion](https://avatars.githubusercontent.com/u/42437544?v=4)](https://github.com/necessarylion "necessarylion (33 commits)")

---

Tags

omiseomise-laravelomise-phpomise-php-sdkomise-sdkopnopn-laravelopn-paymentsomiseomise-phpopn paymentsopn sdkomise sdkomise paymentsopn-payment-phpomise laravel

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/necessarylion-opn-payments-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/necessarylion-opn-payments-laravel/health.svg)](https://phpackages.com/packages/necessarylion-opn-payments-laravel)
```

###  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)[omise/omise-php

A PHP library designed specifically to connect with Omise API.

71478.0k6](/packages/omise-omise-php)[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)[omise/omise-magento

Accept payments on your Magento 2 website with Omise

3418.8k](/packages/omise-omise-magento)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)

PHPackages © 2026

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