Download the PHP package dominservice/przelewy24-php without Composer
On this page you can find all versions of the php package dominservice/przelewy24-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dominservice/przelewy24-php
More information about dominservice/przelewy24-php
Files in dominservice/przelewy24-php
Package przelewy24-php
Short Description Przelewy24 PHP library
License MIT
Homepage https://github.com/dominservice/przelewy24-php
Informations about the package przelewy24-php
Przelewy24 PHP library
PHP wrapper for Przelewy24.
If you are using Laravel, check out dominservice/przelewy24-laravel.
Przelewy24's API documentation is available at https://developers.przelewy24.pl/.
The library was copied to implement payment card support from dbojdo.
Requirements
- PHP >=8.1
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: