PHPackages                             xgrz/payu - 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. xgrz/payu

ActiveLibrary[Payment Processing](/categories/payments)

xgrz/payu
=========

PayU payments with Laravel

0.2.1(1y ago)010[2 issues](https://github.com/xGrz/payu/issues)MITPHPPHP ^8.1

Since Oct 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xGrz/payu)[ Packagist](https://packagist.org/packages/xgrz/payu)[ RSS](/packages/xgrz-payu/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (12)Used By (0)

Laravel PayU plugin by xGrz
===========================

[](#laravel-payu-plugin-by-xgrz)

This package handles: `Payments`, `Refunds` and `Payouts`.

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

[](#requirements)

This package requires queue, scheduler and cache configured in your Laravel project.

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

[](#installation)

Install package via composer, publish config and run migrations:

```
composer require xgrz/payu

php artisan payu:publish-config
php artisan migrate

```

Update your .env file with:

```
PAYU_SHOP_ID=
PAYU_MERCHANT_POS_ID=
PAYU_SIGNATURE_KEY=
PAYU_O_AUTH_CLIENT_ID=
PAYU_O_AUTH_CLIENT_SECRET=

```

Please fill all values with your PayU account settings. You can leave it without values when you want to use PayU public sandbox (same functions are limited). If you want to use all functions you can use personal sandbox account.

Using personal sandbox for testing is recommended. See what features are limited in the table below.

FeaturesPublic sandboxPersonal sandboxProductionPaymentsAvailableAvailableAvailableRefundsAvailableAvailableAvailablePayoutsNo\*AvailableAvailablePayment methodsNo\*AvailableAvailableAccount balanceNo\*AvailableAvailableSelect payment method while creating transactionNo\*AvailableAvailable(\*) All unavailable features are limited by PayU API, not by package.

If you are running in personal sandbox or production environment you should manually run:

```
php artisan payu:sync-methods

```

This method will run automatically in Laravel scheduler (every day) for payment methods synchronizing with local database (performance reason).

Create payment
--------------

[](#create-payment)

We provide a TransactionWizard facade for easier payment creation. There are some helpers too: `Products`, `Product`, `Buyer`, (`Address`|`PostalBox`). Wizard and helper object's can be created by `new CLASS_NAME($args)` or `CLASS_NAME::make($args)`;

For example lets create `Buyer`:

```
use xGrz\PayU\Facades\TransactionWizard\Buyer;

$buyer = Buyer::make($email, $phone, $firstName, $lastName, $language, $customerId);

```

Every transaction requires only `Products` and *description* to be sent to Api, however for better user experience we suggest to provide at least `Buyer` too.

Prepare transaction with TransactionWizard:

```
use xGrz\PayU\Facades\TransactionWizard;
use xGrz\PayU\Facades\TransactionWizard\Product;
use xGrz\PayU\Facades\TransactionWizard\Products;
xGrz\PayU\Facades\TransactionWizard\Delivery\Address;
xGrz\PayU\Facades\TransactionWizard\Delivery\PostalBox;

$transactionWizard = TransactionWizard(
    // Required - visible in PayU system (admin panel)
    $description,

    // Required
    Products::make([
        // Product is required.
        // Default value for quantity=1, isVirtual is set default to false.
        Product::make(name: 'First Product', unitPrice: 100, quantity: 2),
        Product::make(name: 'Second Product', unitPrice: 99.99, quantity: 1),
        Product::make(name: 'DHL Delivery', unitPrice: 19.99, quantity: 1, isVirtual: true);
    ]),
    // Optional, but recommended. If you do not provide Buyer PayU payment site will ask for data from Buyer object.
    // For better user experience you shoud send Buyer object in transaction.
    Buyer::make('example@example.com', '500 600 700', 'John', 'Kovalsky', 'pl', 120),

    // Delivery is optional. You can send Address delivery object of PostalBox delivery object depends on user choice.
    Address::make(
        postalCode: '02-020',
        city: 'Katowice',
        streetWithNumber: 'Wolska 201/21',
        countryCode: 'PL',
        recipientEmail: 're@example.com',
        recipientFullName: 'Karol Novak',
        recipientPhone: '999666444'
    ),

    // or when your delivery is to postal boxes:
    // PostalBox::make(postalBox: 'WA201',recipientEmail: 're@example.com', recipientFullName: 'Karol Novak', recipientPhone: '999666444'),

    // Optional, but strongly recommended is redirect url address after transaction
    // Redirect is individual for every transaction. When transaction fails payu will add ?error parameter to your url.
    redirectAfterTransaction: 'https://yoursite.com/order/summary'

    // Optional, only when you allow users to chose payment method on your site (not at PayU site)
    // You have to provide method code selected by customer. This is not working in public sandbox api.
    PayMethod::make(method: 'P'),

);

```

Optional you can add visible description (visible at PayU payment site):

```
$transaction->setVisibleDescription('You are paying for order XXXX/XX');

```

Once your transaction wizard is completed you can send it to PayU:

```
$transaction = PayU::createPayment($transactionWizard);

```

If payment method fail PayUGeneralException will be thrown, otherwise Transaction model will be returned.

From transaction model you can get payment link (`$transaction->link`) to PayU payment site. If you are not redirecting user automatically to PayU and you want to give link for user please notice to display it in blade as unescaped data `{!! $transaction->link !!}`. Displaying link as escaped will broke link parameters and transaction will not work.

Transaction model stores current status in `$transaction->status` enum. It is updated in background when notification webhook is received from PayU system. Notifications are signed with secure keys. Any data manipulations are not allowed by webhook controller. Incoming notifications has middleware that checks is request ip is on whitelist too.

Handling payment
----------------

[](#handling-payment)

Payment status is updated by notification webhook. PayU allows you to get manual or auto-accept payments for each payment method individually. You can set it in PayU panel (sandbox panel too).

When automatic accept is turned on you should get COMPLETED or CANCELED status depends on user transaction status. In case of manual accepting you will get WAITING\_FOR\_CONFIRMATION status. In that case you can ACCEPT or REJECT payment.

```
use xGrz\PayU\Facades\PayU;

// accept
PayU::accept($transaction);

// reject
PayU::reject($transaction);

```

`$transaction` is eloquent model returned from `PayU::createPayment($transactionWizard);` method.

Refunds
-------

[](#refunds)

When transaction is completed you can make a refund to this transaction.

To start new refund you can write:

```
use xGrz\PayU\Facades\PayU;

PayU::refund($transaction, $amount, $description, $bankDescription);

```

- `$transaction` is a payment with status COMPLETED - required
- `$amount` is amount to refund (for ex. 100.99) - required
- `$description` is a reason of refund (for ex. 'RMA') - required
- `$bankDescription` is part of bank account refund title given by PayU bank account transfer (optional)

If you accidentally refunded wrong amount you have some time to cancel refund (see Config section). While refund has status INITIALIZED or SCHEDULED you can delete it by calling:

```
use xGrz\PayU\Facades\PayU;

PayU::cancelRefund($refund);

```

Refund status is automatically updated by notification webhook. Important! If someone defines refund in PayU panel it will appear on list when is completed.

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

[](#configuration)

In installation section we have published config. You can find it in config directory (Laravel default path is /config) - please search payu.php.

Default configuration is given in this config file. In jobs section you can configure delays for sending/retrying refunds and payouts (values are in seconds). It is recommended to give at least 60 seconds delay on sending refunds/payouts. This time is given to admin in case of wrong amount given in form.

`transaction_method_check` is retrieving payment method of transaction (not available for public sandbox api).

As payouts are not notified by webhook our plugin will periodically check status od payouts. Fill free to set your on status check interval much longer then default.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance40

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

10

Last Release

571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c110497bed6b5684b40b8cfd88b60d24ffdc96664ce56d3e03854afae6a0562?d=identicon)[xgrz](/maintainers/xgrz)

---

Top Contributors

[![xGrz](https://avatars.githubusercontent.com/u/33755434?v=4)](https://github.com/xGrz "xGrz (208 commits)")

---

Tags

laravelpayu

### Embed Badge

![Health badge](/badges/xgrz-payu/health.svg)

```
[![Health](https://phpackages.com/badges/xgrz-payu/health.svg)](https://phpackages.com/packages/xgrz-payu)
```

###  Alternatives

[lemonsqueezy/laravel

A package to easily integrate your Laravel application with Lemon Squeezy.

58596.1k](/packages/lemonsqueezy-laravel)[tsaiyihua/laravel-ecpay

ecpay library for laravel

6416.3k](/packages/tsaiyihua-laravel-ecpay)[alexo/laravel-payu

Una interfaz fluida para Laravel usando el SDK oficial de PayU latam.

296.7k](/packages/alexo-laravel-payu)[infyomlabs/laravel-payumoney

Laravel Payumoney Integration Library

113.9k](/packages/infyomlabs-laravel-payumoney)[tsaiyihua/laravel-linepay

linepay library for laravel

102.9k](/packages/tsaiyihua-laravel-linepay)

PHPackages © 2026

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