PHP code example of zloter / przelewy24-php

1. Go to this page and download the library: Download zloter/przelewy24-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zloter / przelewy24-php example snippets


use Przelewy24\Przelewy24;

$przelewy24 = new Przelewy24([
    'merchant_id' => '12345',
    'crc' => 'aef0...',
    'mode' => 'sandbox', // live for production
]);

$transaction = $przelewy24->transaction([
    'session_id' => 'unique order identifier from your application',
    'url_return' => 'url to return to post transaction',
    'url_status' => 'url to which the transaction status webhook will be sent',
    'amount' => 'transaction amount as an integer (1.25 PLN = 125)',
    'description' => 'transaction description',
    'email' => 'buyer email address',
]);

$transaction->token();

$transaction->redirectUrl();

$webhook = $przelewy24->handleWebhook();

$przelewy24->verify([
    'session_id' => 'unique order identifier from your application',
    'order_id' => $webhook->orderId(),   // przelewy24 order id
    'amount' => 'transaction amount as an integer (1.25 PLN = 125)',
]);