PHPackages                             mnastalski/przelewy24-php - 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. mnastalski/przelewy24-php

ActiveLibrary[Payment Processing](/categories/payments)

mnastalski/przelewy24-php
=========================

Przelewy24 PHP library

v1.6.0(1y ago)52101.2k↓22.1%24[2 PRs](https://github.com/mnastalski/przelewy24-php/pulls)2MITPHPPHP ^8.1CI passing

Since Sep 28Pushed 5mo ago4 watchersCompare

[ Source](https://github.com/mnastalski/przelewy24-php)[ Packagist](https://packagist.org/packages/mnastalski/przelewy24-php)[ Docs](https://github.com/mnastalski/przelewy24-php)[ RSS](/packages/mnastalski-przelewy24-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (16)Used By (2)

Przelewy24 PHP library
======================

[](#przelewy24-php-library)

PHP wrapper for [Przelewy24](https://www.przelewy24.pl/).

If you are using Laravel, check out [mnastalski/przelewy24-laravel](https://github.com/mnastalski/przelewy24-laravel/).

Przelewy24's API documentation is available at .

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

[](#requirements)

- PHP &gt;=8.1

For lower PHP versions, check the [0.x](https://github.com/mnastalski/przelewy24-php/tree/0.x) versions.

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

[](#installation)

```
composer require mnastalski/przelewy24-php
```

Usage
-----

[](#usage)

### Creating an instance

[](#creating-an-instance)

```
use Przelewy24\Przelewy24;

$przelewy24 = new Przelewy24(
    merchantId: 12345,
    reportsKey: 'f0ae...',
    crc: 'aef0...',
    isLive: false,
);
```

Setting `isLive` to `false` will use the [sandbox environment](https://sandbox.przelewy24.pl/panel/). Set it to `true` to use production/live mode.

### Testing the connection

[](#testing-the-connection)

You may use the following method to test if the connection to Przelewy24's API using provided credentials is working:

```
$test = $przelewy24->tests()->testAccess();

var_dump($test->data());
```

```
bool(true)

```

### Creating a transaction

[](#creating-a-transaction)

```
$transaction = $przelewy24->transactions()->register(
    // Required parameters:
    sessionId: 'unique order identifier from your application',
    amount: 125,
    description: 'transaction description',
    email: 'buyer email address',
    urlReturn: 'url to return to after transaction',

    // Optional parameters:
    urlStatus: 'url to which the transaction status webhook will be sent',

    // client: 'Mateusz Nastalski',
    // currency: \Przelewy24\Enums\Currency::EUR,
    // language: Language::ENGLISH,
    // ...
);
```

Note that `amount` is passed as an integer, so if the actual amount is `1.25 PLN` you will need to pass `125` as value.

For the complete list of available parameters check the signature of [TransactionRequests::register()](src/Api/Requests/TransactionRequests.php#L22).

#### Return the transaction's token:

[](#return-the-transactions-token)

```
$transaction->token();
```

#### Return the URL to the payment gateway:

[](#return-the-url-to-the-payment-gateway)

```
$transaction->gatewayUrl();
```

### Listening for transaction registration status webhook

[](#listening-for-transaction-registration-status-webhook)

To parse the webhook's payload, pass the whole request's POST data as an array to `handleWebhook()`:

```
// $requestData = $request->request->all();
// $requestData = $request->post();
// $requestData = json_decode(file_get_contents('php://input'), true);

$webhook = $przelewy24->handleWebhook($requestData);
```

`handleWebhook()` returns `TransactionStatusNotification::class`, which has a bunch of useful methods you can use to check the transaction's data, as well as verify the webhook's signature:

```
$webhook->amount();
$webhook->currency();
$webhook->orderId();
...
$webhook->isSignValid(...);
```

If you would like to make sure the incoming request's IP address belongs to Przelewy24 then a list of valid IPs is available in the `\Przelewy24\Constants\IpAddresses::V4` constant. A helper method that accepts a string with an IP address and returns a boolean is also available: `\Przelewy24\Constants\IpAddresses::isValid($ip)`.

### Verifying a transaction

[](#verifying-a-transaction)

```
$przelewy24->transactions()->verify(
    sessionId: 'unique order identifier from your application',
    orderId: $webhook->orderId(),
    amount: 125,
);
```

Similarly to registering a transaction, the `amount` is passed as an integer.

### Refunding transactions

[](#refunding-transactions)

```
$refund = $przelewy24->transactions()->refund(
    requestId: 'unique request identifier from your application',
    refundsId: 'unique refunds identifier from your application',
    refunds: [
        new RefundItem(
            orderId: $webhook->orderId(),
            sessionId: 'unique order identifier from your application',
            amount: 2100,
            description: 'item #1',
        ),
        new RefundItem(
            orderId: $webhook->orderId(),
            sessionId: 'unique order identifier from your application',
            amount: 125,
            description: 'item #2',
        ),
    ],
    urlStatus: 'url to which the refund status webhook will be sent',
);
```

#### Return the refunds' item list:

[](#return-the-refunds-item-list)

```
$refund->refunds();
```

### Listening for transaction refund status webhook

[](#listening-for-transaction-refund-status-webhook)

To parse the webhook's payload, pass the whole request's POST data as an array to `handleRefundWebhook()`:

```
// $requestData = $request->request->all();
// $requestData = $request->post();
// $requestData = json_decode(file_get_contents('php://input'), true);

$webhook = $przelewy24->handleRefundWebhook($requestData);
```

### Error handling

[](#error-handling)

Should Przelewy24's API return an erroneous response, an `ApiResponseException::class` (which extends `Przelewy24Exception::class`) will be thrown. You can therefore use a `try/catch` block to handle any errors:

```
use Przelewy24\Exceptions\Przelewy24Exception;

try {
    $przelewy24->transactions()->verify([
        // ...
    ]);
} catch (Przelewy24Exception $e) {
    // Handle the error...
}
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance61

Regular maintenance activity

Popularity47

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% 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 ~129 days

Recently: every ~120 days

Total

14

Last Release

375d ago

Major Versions

0.x-dev → v1.0.02023-06-24

PHP version history (2 changes)v0.0.1PHP &gt;=7.1.3

v1.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e44eb54b1f8c3db37673ce225a3fb933a6716c3976d410a5c675c6a4f478e9b4?d=identicon)[mnastalski](/maintainers/mnastalski)

---

Top Contributors

[![mnastalski](https://avatars.githubusercontent.com/u/10223434?v=4)](https://github.com/mnastalski "mnastalski (53 commits)")[![dbojdo](https://avatars.githubusercontent.com/u/1272416?v=4)](https://github.com/dbojdo "dbojdo (1 commits)")[![KamilWojtalak](https://avatars.githubusercontent.com/u/48104288?v=4)](https://github.com/KamilWojtalak "KamilWojtalak (1 commits)")

---

Tags

phpprzelewy24paymentsPrzelewy24

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mnastalski-przelewy24-php/health.svg)

```
[![Health](https://phpackages.com/badges/mnastalski-przelewy24-php/health.svg)](https://phpackages.com/packages/mnastalski-przelewy24-php)
```

###  Alternatives

[unicodeveloper/laravel-paystack

A Laravel Package for Paystack

650975.6k11](/packages/unicodeveloper-laravel-paystack)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[prevailexcel/laravel-nowpayments

A Laravel Package for NOWPayments

1414.2k](/packages/prevailexcel-laravel-nowpayments)[itsmurumba/laravel-mpesa

Laravel Package for Mpesa Daraja API

191.6k](/packages/itsmurumba-laravel-mpesa)

PHPackages © 2026

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