PHP code example of cardinity / client-bundle

1. Go to this page and download the library: Download cardinity/client-bundle 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/ */

    

cardinity / client-bundle example snippets


# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ... other bundles
            new Cardinity\ClientBundle\CardinityClientBundle()
        );

        return $bundles;
    }
}

/** @type Cardinity\Client */
$client = $this->container->get('cardinity_client.service.client');

/** @type Cardinity\Method\ResultObjectInterface
$result = $client->call($query);

Cardinity\Payment\Create($body)
Cardinity\Payment\Finalize($paymentId, $authorizeData)
Cardinity\Payment\Get($paymentId)
Cardinity\Payment\GetAll($limit)

Cardinity\Settlement\Create($paymentId, $amount, $description = null)
Cardinity\Settlement\Get($paymentId, $settlementId)
Cardinity\Settlement\GetAll($paymentId)

Cardinity\Void\Create($paymentId, $description = null)
Cardinity\Void\Get($paymentId, $voidId)
Cardinity\Void\GetAll($paymentId)

Cardinity\Refund\Create($paymentId, $amount, $description = null)
Cardinity\Refund\Get($paymentId, $refundId)
Cardinity\Refund\GetAll($paymentId)

use Cardinity\Method\Payment;

/** @type Cardinity\Client */
$client = $this->container->get('cardinity_client.service.client');
try {
    /** @type Payment\Payment */
    $payment = $client->call(new Payment\Create([
        'amount' => 50.00,
        'currency' => 'EUR',
        'settle' => false,
        'description' => 'some description',
        'order_id' => '12345678',
        'country' => 'LT',
        'payment_method' => Cardinity\Payment\Create::CARD,
        'payment_instrument' => [
            'pan' => '4111111111111111',
            'exp_year' => 2018,
            'exp_month' => 12,
            'cvc' => '456',
            'holder' => 'Mike Dough'
        ]
    ]));

    /** @type Payment\Payment */
    $finalizedPayment = $client->call(new Payment\Finalize(
        $payment->getId(),
        $payment->getAuthorizationInformation()->getData()
    ));
} catch (Cardinity\Exception\Declined $e) {
    // Payment has been declined
} catch (Cardinity\Exception\Runtime $e) {
    // Other type of error happened
}
bash
$ php composer.phar