Skip to content

alfonsfoubert/BSPAdyenBundle

Repository files navigation

BSPAdyenBundle

This bundle provides an integration with Adyen for Symfony2.

Installation

Installation is a 3 step process:

  1. Download BSPAdyenBundle using composer
  2. Enable the Bundle
  3. Configure the bundle

Step 1: Download BSPAdyenBundle using composer

{
	"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/D3r3ck/BSPAdyenBundle"
        }
    ],
    "require": {
        "d3r3ck/bsp-adyen-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update d3r3ck/bsp-adyen-bundle

Composer will install the bundle to your project's vendor/d3r3ck/bsp-adyen-bundle directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new BSP\AdyenBundle\BSPAdyenBundle(),
    );
}

Step 3: Configure the bundle

Add the following lines to your config.yml

# app/config/config.yml

bsp_adyen:
    platform: test # Options are 'live' or 'test'
    merchant_account: MyAppAccount
    skin: 6bci2GpJ
    shared_secret: testing-key
    currency: EUR # Default value is EUR
	payment_methods: [ 'visa', 'mastercard' ] # Look for available payment methods in the Adyen documentation
    webservice_username: username
    webservice_password: password

Warning

Username and Password for the webservice are not enabled by default. If you need recurring payments you'll have to ask for it to Adyen.

And you are done!

Basic Usage

This bundle integrates the Adyen functionalities into a Symfony2 project by triggering events into your system. All processes are called by the bsp.adyen.service

$adyen = $this->get('bsp.adyen.service');

Creating a recurring account

1. Setup the account

$adyen->setup( 'account-unique-name', 'account-email@mailinator.com', '100', 'EUR', 'http://localhost/myReturnUrl' );

2. Listen to notification

# Acme/DemoBundle/Resources/config/services.yml

acme_demo.adyen_listener:
    class: Acme\DemoBundle\EventListener\MyListener
    tags:
        - { name: kernel.event_listener, event: bsp.adyen.setup, method: onSetup }
// File: Acme/DemoBundle/EventListener/MyListener.php

class MyListener
{
    public function onSetup( BSP\AdyenBundle\Event\SetupEvent $event )
    {
        $parameters = $event->getParameters();
        $trackId    = $parameters['merchantReference'];
        $extraData  = array( 'store' => $parameters['shopperReference'] );
        // ... do your stuff
    }
}

Charging money to a recurring amount

1. Charge

$adyen->charge( 'account-unique-name', 'account-email@mailinator.com', '2500', 'EUR' ); // returns true or false

2. Listen to notification

# Acme/DemoBundle/Resources/config/services.yml

acme_demo.adyen_listener:
    class: Acme\DemoBundle\EventListener\MyListener
    tags:
        - { name: kernel.event_listener, event: adyen.notification.authorisation, method: onAuthorisation }
// File: Acme/DemoBundle/EventListener/MyListener.php

class MyListener
{
    public function onAuthorisation( BSP\AdyenBundle\Event\NotificationEvent $event )
    {
        // ... do your stuff
    }
}

Extra

You can also do it by a console command

php app/console bsp:adyen:charge account-unique-name account-email@mailinator.com 2500 EUR

About

Adyen integration in Symfony2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages