Download the PHP package escolalms/przelewy24-php without Composer
On this page you can find all versions of the php package escolalms/przelewy24-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download escolalms/przelewy24-php
More information about escolalms/przelewy24-php
Files in escolalms/przelewy24-php
Package przelewy24-php
Short Description Przelewy24 PHP library
License MIT
Homepage https://github.com/mnastalski/przelewy24-php
Informations about the package przelewy24-php
Przelewy24 PHP library
PHP wrapper for Przelewy24.
If you are using Laravel, check out mnastalski/przelewy24-laravel.
Przelewy24's API documentation is available at https://developers.przelewy24.pl/.
Requirements
- PHP >=8.1
For lower PHP versions, check the 0.x versions.
Installation
Usage
Creating an instance
Setting isLive
to false
will use the sandbox environment. Set it to true
to use production/live mode.
Creating a transaction
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().
Return the transaction's token:
Return the URL to the payment gateway:
Listening for transaction status webhook
To parse the webhook's payload, pass the whole request's POST data as an array to handleWebhook()
:
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:
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
Similarly to registering a transaction, the amount
is passed as an integer.
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: