Payplug integration to symfony2

Installs: 315

Dependents: 0

Stars: 6

Watchers: 4

Forks: 3

Language: PHP

v1.2.4 2015-05-15 13:26 UTC


Payplug integration to symfony2.

Latest Stable Version Scrutinizer Code Quality SensioLabsInsight Build Status License


Step 1: Download using composer

    "require": {
        "alcalyn/payplug-bundle": "1.x"

Update your composer.

php composer.phar update

Step 2: Register the Bundle

// app/AppKernel.php

    public function registerBundles()
        $bundles = array(
            // ...
            new Alcalyn\PayplugBundle\AlcalynPayplugBundle(),

Step 3: Import Payplug IPN route

To create payments and process IPNs, the bundle need to have its routes enabled.

Add this to app/config/routing.yml:

# Payplug routing
    resource: "@AlcalynPayplugBundle/Resources/config/routing.yml"
    prefix:   /

Step 4: Configure the bundle and your account settings

Add these lines to your config.yml:

# Payplug configuration
        url:                %payplug_account_url%
        amount_min:         %payplug_account_amount_min%
        amount_max:         %payplug_account_amount_max%
        currencies:         %payplug_account_currencies%
        payplugPublicKey:   %payplug_account_payplugPublicKey%
        yourPrivateKey:     %payplug_account_yourPrivateKey%

And these lines into parameters.yml, and optionally into parameters.yml.dist:

    payplug_account_url:                ~
    payplug_account_amount_min:         ~
    payplug_account_amount_max:         ~
    payplug_account_currencies:         ~
    payplug_account_payplugPublicKey:   ~
    payplug_account_yourPrivateKey:     ~

Then run this command to load your Payplug account settings:

php app/console payplug:account:update

(Your Payplug email and password will be prompted)


Be sure to never commit your account settings by commiting your parameters.yml

See Payplug documentation for more informations about account configuration.


This command uses curl to load your account parameters from

If the command fails, go to and copy/paste your parameters manually.

Your parameters.yml should looks like this: parameters.yml.example

You can also configure your TEST mode.

Basic usage:

Generating payment url:

use Alcalyn\PayplugBundle\Model\Payment;

// ...

    public function wtfAction()
        // Create a payment of 16 €
        $payment = new Payment(1600, Payment::EUROS);

        // Get Payplug payment service
        $payplugPayment = $this->get('payplug.payment');

        // Generate url
        $payplugPayment->generateUrl($payment); // returns ""

Treat IPNs

AlcalynPayplugBundle dispatches PayplugIPNEvent when an IPN is received.

This event contains an instance of IPN that you can access by calling PayplugIPNEvent::getIPN().

So listen it like that:

  • Create the listener class:
// src/Acme/AcmeBundle/EventListener/PaymentListener.php

namespace Acme\AcmeBundle\EventListener;

use Alcalyn\PayplugBundle\Event\PayplugIPNEvent;

class PaymentListener
     * @param PayplugIPNEvent $event
    public function onPayment(PayplugIPNEvent $event)
        $ipn = $event->getIPN();

        // treat $ipn
  • Register your listener:
# src/Acme/AcmeBundle/Resources/services.yml
        class: Acme\AcmeBundle\EventListener\PaymentListener
            - { name: kernel.event_listener, event: event.payplug.ipn, method: onPayment }

Advanced usage:


This bundle is under the MIT license. See the complete license: