This bundle provides an integration with Adyen for Symfony2.
Installation is a 3 step process:
- Download BSPAdyenBundle using composer
- Enable the Bundle
- Configure the bundle
{
"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.
Enable the bundle in the kernel:
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new BSP\AdyenBundle\BSPAdyenBundle(),
);
}
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
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!
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');
$adyen->setup( 'account-unique-name', 'account-email@mailinator.com', '100', 'EUR', 'http://localhost/myReturnUrl' );
# 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
}
}
$adyen->charge( 'account-unique-name', 'account-email@mailinator.com', '2500', 'EUR' ); // returns true or false
# 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
}
}
You can also do it by a console command
php app/console bsp:adyen:charge account-unique-name account-email@mailinator.com 2500 EUR