PHP code example of obanach / zen-php-sdk

1. Go to this page and download the library: Download obanach/zen-php-sdk 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/ */

    

obanach / zen-php-sdk example snippets


use Zen\ZenClient;

$client = new ZenClient('PAYWALL_SECRET', 'IPN_SECRET', 'TERMINAL_UUID');

$checkout = $client->createCheckout([
    'merchantTransactionId' => 'myCustomTransactionId',
    'amount' => 10.00,
    'currency' => 'PLN',
    'customer' => [
        'firstName' => 'John',
        'lastName' => 'Doe',
        'email' => '[email protected]'
    ],
    'items' => [
        [
            'code' => 't-shirt',
            'name' => 'Blue t-shirt',
            'price' => 10.00,
            'quantity' => 1,
            'lineAmountTotal' => 10.00,
        ]
    ]
]);

if ($checkout->getStatus()) {
    $checkout->getCheckoutUrl();
} else {
    $checkout->getMessage();
}

use Zen\ZenClient;

$client = new ZenClient('PAYWALL_SECRET', 'IPN_SECRET', 'TERMINAL_UUID');

// raw json data received from IPN
$json = '{"merchantTransactionId":"myCustomTransactionId","amount":"10.00","currency":"EUR","status":"PAID","hash":"5CD4255C8BEE2A45ADF57DA13CADCA406FF4C5D2A1046E5EF719890A8FB09807"}'

$validate = $client->validateIpn($json);

if ($validate->getStatus()) {
    // validate on your own if currency and amount are correct
    $validate->getMerchantTransactionId();
    $validate->getCurrency();
    $validate->getAmount();
    $validate->getPaymentStatus();
} else {
    // handle error
    $validate->getMessage();
}
bash
composer