PHPackages                             bpotmalnik/lunar-tpay - 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. bpotmalnik/lunar-tpay

ActiveLibrary[Payment Processing](/categories/payments)

bpotmalnik/lunar-tpay
=====================

Tpay payment driver for LunarPHP

v1.0.0(yesterday)013↑2900%MITPHPPHP ^8.3

Since Jun 22Pushed yesterdayCompare

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

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

lunar-tpay
==========

[](#lunar-tpay)

Tpay Open API payment driver for [LunarPHP](https://lunarphp.io).

The package provides:

- `Payments::driver('tpay')` registration
- Tpay OAuth token handling
- transaction creation and redirect authorization
- JWS-signed notification handling
- Lunar capture transaction creation after successful payment
- full and partial refunds through Tpay
- English and Polish error translations
- a `FakeTpayClient` for application tests

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

[](#requirements)

- PHP 8.3+
- ext-openssl
- Laravel 12 or 13
- LunarPHP 1.x

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

[](#installation)

```
composer require bpotmalnik/lunar-tpay
php artisan vendor:publish --tag=lunar-tpay-config
php artisan vendor:publish --tag=lunar-tpay-migrations
php artisan migrate
```

Optionally publish translations:

```
php artisan vendor:publish --tag=lunar-tpay-lang
```

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

[](#configuration)

```
TPAY_CLIENT_ID=
TPAY_CLIENT_SECRET=
TPAY_SANDBOX=true
TPAY_NOTIFICATION_PATH=tpay/notification
TPAY_PAYMENT_DESCRIPTION="Order payment"
TPAY_LANG=pl
TPAY_NOTIFICATION_EMAIL=

TPAY_STATUS_CORRECT=payment-received
TPAY_STATUS_REFUND=payment-refunded
TPAY_STATUS_CANCELED=payment-failed
```

The package registers this notification route automatically:

```
POST /tpay/notification

```

When creating transactions, the adapter sends this URL in Tpay's `callbacks.notification.url` field. Tpay signs notification bodies using JWS in the `X-JWS-Signature` header.

Usage
-----

[](#usage)

```
use Lunar\Facades\Payments;

$result = Payments::driver('tpay')
    ->cart($cart)
    ->withData([
        'continue_url' => route('checkout.pending', $order),
        'error_url' => route('checkout.failed', $order),
    ])
    ->authorize();

if (! $result->success) {
    return back()->withErrors(['payment' => $result->message]);
}

return redirect($result->redirectUrl);
```

Supported `withData()` keys:

KeyDescription`continue_url`Tpay success redirect URL.`error_url`Tpay error redirect URL. Defaults to `continue_url`.`notification_url`Override the webhook URL sent to Tpay.`description`Transaction description.`lang`Payment page language. Defaults to `TPAY_LANG`.`method`Optional Tpay payment method. Leave unset for the default Tpay payment page.`group_id`Optional Tpay payment group ID, e.g. `150` for BLIK or `103` for card.`channel_id`Optional Tpay channel ID.Notifications
-------------

[](#notifications)

Tpay sends successful payment notifications with `data.transactionStatus` set to `correct`. The package:

- verifies `X-JWS-Signature` using Tpay's signing certificate and root CA,
- looks up the local payment by `data.transactionId` or `data.transactionHiddenDescription`,
- locks the payment row during processing,
- marks the Lunar intent transaction successful,
- creates a Lunar `capture` transaction,
- sets `placed_at` on the order,
- updates the Lunar order status using `lunar.tpay.status_mapping`,
- dispatches `PaymentConfirmed`.

The controller responds to accepted signed notifications with the literal body expected by Tpay:

```
TRUE

```

Refunds
-------

[](#refunds)

Refund amounts are passed in the smallest currency unit:

```
$result = Payments::driver('tpay')->refund($captureTransaction, 5000);
```

That creates a 50.00 PLN refund request against the original Tpay transaction. Tpay's refund API does not expose refund cancellation in the same transaction endpoint used here, so `cancelRefund()` returns a failed `PaymentRefund` response with an admin-facing message.

Events
------

[](#events)

```
use Bpotmalnik\LunarTpay\Events\PaymentConfirmed;
use Bpotmalnik\LunarTpay\Events\PaymentFailed;

Event::listen(PaymentConfirmed::class, function (PaymentConfirmed $event) {
    $event->order;
    $event->tpayPayment;
});
```

Testing
-------

[](#testing)

```
use Bpotmalnik\LunarTpay\Contracts\TpayClientContract;
use Bpotmalnik\LunarTpay\Testing\FakeTpayClient;

$fake = new FakeTpayClient;
$this->app->instance(TpayClientContract::class, $fake);
```

The fake returns:

- `transactionId`: `01J9XH0PDXH1Q8C9MMEB3VJ0G6`
- `transactionPaymentUrl`: `https://secure.tpay.com/fake-redirect`
- `status`: `pending`

Its notification signature verifier always returns `true`, which makes webhook feature tests straightforward.

Development
-----------

[](#development)

```
composer test
```

In local environments without `ext-intl`, install dependencies with:

```
composer update --ignore-platform-req=ext-intl
```

Lunar itself requires `ext-intl`; some cart-calculation paths will still need it at runtime.

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20015942?v=4)[Bart Potmalnik](/maintainers/bpotmalnik)[@bpotmalnik](https://github.com/bpotmalnik)

---

Top Contributors

[![bpotmalnik](https://avatars.githubusercontent.com/u/20015942?v=4)](https://github.com/bpotmalnik "bpotmalnik (2 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/bpotmalnik-lunar-tpay/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M118](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)

PHPackages © 2026

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