PHP code example of nexylan / paybox-direct

1. Go to this page and download the library: Download nexylan/paybox-direct 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/ */

    

nexylan / paybox-direct example snippets


use Nexy\PayboxDirect\Enum\Version;
use Nexy\PayboxDirect\Paybox;

$paybox = new Paybox([
    // Optional parameters:
    'timeout' => 30,        // Change the request timeout.
    'production' => true,   // Set to true to use the production API URL.
    // Required parameters:
    'paybox_version' => Version::DIRECT_PLUS,
    'paybox_site' => '1999888',
    'paybox_rank' => '32',
    'paybox_identifier' => '107904482',
    'paybox_key' => '1999888I',
]);

/** @var \Nexy\PayboxDirect\Paybox $paybox */
$paybox = $this->container->get('nexy_paybox_direct.sdk');

use Nexy\PayboxDirect\Exception\PayboxException;
use Nexy\PayboxDirect\Request\AuthorizeAndCaptureRequest;

$request = new AuthorizeAndCaptureRequest('CMD-42', 1000, '1111222233334444', '1224');
$request->setCardVerificationValue('123');
try {
    /** @var \Nexy\PayboxDirect\Response\DirectResponse $response */
    $response = $paybox->sendDirectRequest($request);
} catch (PayboxException $e) {
    echo $e->getMessage(); // Prints the Paybox error message.
    /** @var \Nexy\PayboxDirect\Response\DirectResponse $response */
    $response = $e->getResponse(); // Returns the response object if you want to manipulate it.
}
// Do stuff with the response!

$request = new AuthorizeAndCaptureRequest('CMD-42', 1000, 'subscriberCardRef', '1224', 'subscriberRef');
try {
    /** @var \Nexy\PayboxDirect\Response\DirectPlusResponse $response */
    $response = $paybox->sendDirectPlusRequest($request);
} catch (PayboxException $e) {
    echo $e->getMessage(); // Prints the Paybox error message.
    /** @var \Nexy\PayboxDirect\Response\DirectPlusResponse $response */
    $response = $e->getResponse(); // Returns the response object if you want to manipulate it.
}
// Do stuff with the response!
 php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Nexy\PayboxDirect\Bridge\Symfony\Bundle\NexyPayboxDirectBundle(),
    );

    // ...

    return $bundles;
}