Skip to content

obanach/zen-php-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zen.com PHP SDK

PHP client library for creating and retrieving payments via ZEN.COM API

Installation

composer require obanach/zen-php-sdk

Usage

Create checkout

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();
}

Validate IPN

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();
}

API Documentation

See the official zen.com API documentation

License

MIT license.

About

PHP client library for creating and retrieving payments via ZEN.COM API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages