2017 © Pedro Peláez
 

library client-bundle

Cardinity Credit Card payments bundle for Symfony 3

image

cardinity/client-bundle

Cardinity Credit Card payments bundle for Symfony 3

  • Tuesday, June 12, 2018
  • by wSuFF
  • Repository
  • 3 Watchers
  • 1 Stars
  • 4,748 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 6 Versions
  • 10 % Grown

The README.md

CardinityClientBundle

Build Status Scrutinizer Code Quality SensioLabsInsight, (*1)

Deprecation notice

This repository is deprecated., (*2)

Installation

Installing via Composer

$ php composer.phar require cardinity/client-bundle

Configuration

To use the bundle you have to define two parameters in your app/config/config.yml file under cardinity_client section, (*3)

# app/config/config.yml
cardinity_client:
    consumer_key: key
    consumer_secret: secret

Where: - consumer_key: You can find your Consumer Key and Consumer Secret in Cardinity member’s area. - consumer_secret: You can find your Consumer Key and Consumer Secret in Cardinity member’s area., (*4)

Registering the Bundle

You have to add CardinityClientBundle to your AppKernel.php:, (*5)

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

        return $bundles;
    }
}

Enable credit card processing with 3-D secure DEMO

Include following lines to app/config/routing.yml:, (*6)

cardinity_client:
    resource: "@CardinityClientBundle/Resources/config/routing.yml"
    prefix: /cardinity

And if you are using PHP built-in web server:, (*7)

    app/console server:run

Try to open browser with address http://localhost:8000/cardinity., (*8)

Usage

Services

This bundle comes with following service which simplifies the Cardinity implementation in your project:, (*9)

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

Available Methods

Validates and executes Cardinity query, (*10)

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

Available Queries

Payment

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

Settlement

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

Void

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

Refund

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

Usage

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
}

More usage examples available at Cardinity PHP client repository.

Official API documentation can be found here.

The Versions