PHPackages                             onepay/laravel-checkout - 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. onepay/laravel-checkout

ActiveLibrary[Payment Processing](/categories/payments)

onepay/laravel-checkout
=======================

Laravel integration for the OnePay Checkout Link API

v2.0.2(2mo ago)064↓66.7%MITPHPPHP ^8.1

Since Apr 8Pushed 2mo agoCompare

[ Source](https://github.com/onepay-srilanka/onepay-laravel)[ Packagist](https://packagist.org/packages/onepay/laravel-checkout)[ RSS](/packages/onepay-laravel-checkout/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

 **Laravel · OnePay · Checkout Link API**

OnePay Checkout for Laravel
===========================

[](#onepay-checkout-for-laravel)

**Server-side Laravel integration for the OnePay Checkout Link API** (`api.onepay.lk`) — create payment links with correct SHA-256 hashing, validation, and structured error handling.

 [![Latest Stable Version](https://camo.githubusercontent.com/efb580719ec7fb2127fd1a2bda2b50be371de546a7b9d38a222a8c99db33a57b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e657061792f6c61726176656c2d636865636b6f75743f6c6162656c3d737461626c65267374796c653d666c61742d737175617265)](https://packagist.org/packages/onepay/laravel-checkout) [![Total Downloads](https://camo.githubusercontent.com/8c41e0f1ea1b53b8d1be5ef85b67b929704f56e5144efa3c6b7c3c21a89f321e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e657061792f6c61726176656c2d636865636b6f75743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onepay/laravel-checkout) [![Monthly Downloads](https://camo.githubusercontent.com/e8cf178b46027e79397a15ef401614bb83b6ad7e24a23531943df2177ad3f930/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6f6e657061792f6c61726176656c2d636865636b6f75743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/onepay/laravel-checkout) [![License](https://camo.githubusercontent.com/fd701049cb74513d9bbfda43a36e45d918d5146d625f3e88329003920d3df108/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6e657061792f6c61726176656c2d636865636b6f75743f7374796c653d666c61742d737175617265)](LICENSE)

---

Getting started
---------------

[](#getting-started)

The steps below work with **Laravel 10.x, 11.x, and 12.x** (PHP **8.1+**).

Laravel **auto-discovers** the package: you do not need to register the service provider manually unless you disabled discovery.

---

Install
-------

[](#install)

Install the package with Composer:

```
composer require onepay/laravel-checkout
```

---

Configure
---------

[](#configure)

Publish the configuration file:

```
php artisan vendor:publish --tag=onepay-config
```

This creates `config/onepay.php`. Set your **server-side only** secrets in `.env` (never expose these in frontend or mobile apps):

```
ONEPAY_APP_ID=your-app-id-here
ONEPAY_APP_TOKEN=your-app-token-here
ONEPAY_HASH_SALT=your-hash-salt-here
```

The **API base URL** is fixed in `config/onepay.php` (`https://api.onepay.lk/v3`) and is not read from `.env`, so it cannot be overridden from client input.

---

Usage
-----

[](#usage)

### Dependency injection (recommended)

[](#dependency-injection-recommended)

Inject `OnePay\Checkout\Services\OnePayService` into your controller or action:

```
use OnePay\Checkout\Services\OnePayService;
use OnePay\Checkout\Exceptions\OnePayException;

public function pay(OnePayService $onePay)
{
    try {
        $response = $onePay->createCheckoutLink([
            'reference' => 'ORD-' . $order->id, // required — your unique transaction reference
            'currency' => 'LKR', // required — 3-letter ISO code (e.g. from config('onepay.currency'))
            'amount' => 200.00,
            'customer_first_name' => 'John',
            'customer_last_name' => 'Doe',
            'customer_phone_number' => '+94771234567',
            'customer_email' => 'john@example.com',
            'transaction_redirect_url' => 'https://yoursite.test/payment/return',
            // optional:
            // 'additionalData' => 'extra context for the transaction',
            // 'items' => ['item_id_1', 'item_id_2'],
        ]);

        if (! $response->succeeded()) {
            // Handle logical failure using $response->rawResponse
        }

        return redirect()->away($response->redirectUrl);
    } catch (OnePayException $e) {
        if ($e->hasRemoteErrorPayload()) {
            // OnePay JSON: message + error — see $e->getRemoteMessage(), getRemoteError()
        }
        throw $e;
    }
}
```

### Facade

[](#facade)

```
use OnePay\Checkout\Facades\OnePay;

$response = OnePay::createCheckoutLink([
    'reference' => OnePay::generateReference('INV'),
    'currency' => 'LKR',
    'amount' => 1500,
    'customer_first_name' => 'Jane',
    'customer_last_name' => 'Doe',
    'customer_phone_number' => '+94770000000',
    'customer_email' => 'jane@example.com',
    'transaction_redirect_url' => 'https://yoursite.test/done',
]);
```

### Request fields

[](#request-fields)

FieldRequiredDescription`reference`**Yes**Unique transaction reference (**10–64** characters). Use your order id or `generateReference()`.`amount`YesAmount; normalised to 2 decimals for hashing and the API.`customer_first_name`Yes`customer_last_name`Yes`customer_phone_number`Yes`customer_email`Yes`transaction_redirect_url`YesReturn URL after payment.`currency`**Yes**Exactly **3** characters (e.g. `LKR`). Often `config('onepay.currency')`.`additionalData`NoAny extra string metadata for the transaction (API key: `additionalData`).`items`NoArray of created item ids (numeric ids are sent as strings in JSON).### Response object

[](#response-object)

`createCheckoutLink()` returns `OnePay\Checkout\DTOs\CheckoutResponse`:

Property / methodDescription`reference`Same reference you passed in (echo from your payload)`hash`SHA-256 sent to the API`redirectUrl`Gateway URL to send the customer to`rawResponse`Decoded JSON from OnePay`succeeded()`Helper for success-style payloads`toArray()`Array for JSON APIs### Hash rules (OnePay requirement)

[](#hash-rules-onepay-requirement)

The package normalises **amount to two decimal places** and builds:

`sha256(app_id + currency + amount + hash_salt)` → **lowercase** hex.

---

Laravel version compatibility
-----------------------------

[](#laravel-version-compatibility)

LaravelPHPPackage status12.x≥ 8.1Supported11.x≥ 8.1Supported10.x≥ 8.1Supported9.x—Not supported---

Security
--------

[](#security)

- Keep `ONEPAY_APP_TOKEN` and `ONEPAY_HASH_SALT` **only** on the server.
- Validate and **allowlist** `transaction_redirect_url` if it can be influenced by end users (open-redirect risk).
- Confirm paid orders using **OnePay’s official** callback / status flows — this package covers **checkout link creation** only.

---

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

Links
-----

[](#links)

- [Packagist — `onepay/laravel-checkout`](https://packagist.org/packages/onepay/laravel-checkout)
- OnePay API base: `https://api.onepay.lk/v3/checkout/link/`

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance87

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

5

Last Release

62d ago

Major Versions

v1.1.0 → v2.0.02026-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd54a472d63572925b32e2f5a6d3202c538ab2efaf3976d9c884fa3c504400dc?d=identicon)[onepay-srilanka](/maintainers/onepay-srilanka)

---

Top Contributors

[![SpemaiDev](https://avatars.githubusercontent.com/u/151663384?v=4)](https://github.com/SpemaiDev "SpemaiDev (8 commits)")

---

Tags

laravelpaymentcheckoutonepaysri-lanka

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/onepay-laravel-checkout/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)

PHPackages © 2026

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