2017 © Pedro Peláez
 

symfony-bundle paybox-bundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

image

lexik/paybox-bundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  • Wednesday, September 27, 2017
  • by sdieunidou
  • Repository
  • 15 Watchers
  • 41 Stars
  • 83,103 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 29 Forks
  • 13 Open issues
  • 11 Versions
  • 5 % Grown

The README.md

LexikPayboxBundle

Build Status Latest Stable Version SensioLabsInsight, (*1)

Important!

This bundle is partially maintained. No new features will be added but some PR will be merged for compatibility or security., (*2)

LexikPayboxBundle makes the use of Paybox payment system easier by doing all the boring things for you., (*3)

LexikPayboxBundle silently does : * hmac hash calculation of parameters during request. * server testing before request to be sure it is up. * signature verification with openssl on ipn response. * triggers an event on response., (*4)

You only need to provide parameters of your transaction, customize the response page and wait for the event triggered on ipn response., (*5)

Requirements

  • PECL hash >= 1.1
  • openssl enabled

Installation

Installation with composer :, (*6)

composer require lexik/paybox-bundle

Add this bundle to your app/AppKernel.php :, (*7)

``` php public function registerBundles() { return array( // ... new Lexik\Bundle\PayboxBundle\LexikPayboxBundle(), // ... ); }, (*8)


Configuration ------------- Your personnal account informations must be set in your config.yml ```yml # Lexik Paybox Bundle lexik_paybox: parameters: production: false # Switches between Paybox test and production servers (preprod-tpe <> tpe) site: '9999999' # Site number provided by the bank rank: '99' # Rank number provided by the bank login: '999999999' # Customer's login provided by Paybox hmac: key: '01234...BCDEF' # Key used to compute the hmac hash, provided by Paybox

Additional configuration:, (*9)

lexik_paybox:
    parameters:
        currencies:  # Optionnal parameters, this is the default value
            - '036'  # AUD
            - '124'  # CAD
            - '756'  # CHF
            - '826'  # GBP
            - '840'  # USD
            - '978'  # EUR
        hmac:
            algorithm:      sha512 # signature algorithm
            signature_name: Sign   # customize the signature parameter name

The routing collection must be set in your routing.yml, (*10)

# Lexik Paybox Bundle
lexik_paybox:
    resource: '@LexikPayboxBundle/Resources/config/routing.yml'

Usage of Paybox System

The bundle includes a sample controller SampleController.php with two actions., (*11)

...
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

/**
 * Sample action to call a payment.
 * It create the form to submit with all parameters.
 */
public function callAction()
{
    $paybox = $this->get('lexik_paybox.request_handler');
    $paybox->setParameters(array(
        'PBX_CMD'          => 'CMD'.time(),
        'PBX_DEVISE'       => '978',
        'PBX_PORTEUR'      => 'test@paybox.com',
        'PBX_RETOUR'       => 'Mt:M;Ref:R;Auto:A;Erreur:E',
        'PBX_TOTAL'        => '1000',
        'PBX_TYPEPAIEMENT' => 'CARTE',
        'PBX_TYPECARTE'    => 'CB',
        'PBX_EFFECTUE'     => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'success'), UrlGeneratorInterface::ABSOLUTE_URL),
        'PBX_REFUSE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'denied'), UrlGeneratorInterface::ABSOLUTE_URL),
        'PBX_ANNULE'       => $this->generateUrl('lexik_paybox_sample_return', array('status' => 'canceled'), UrlGeneratorInterface::ABSOLUTE_URL),
        'PBX_RUF1'         => 'POST',
        'PBX_REPONDRE_A'   => $this->generateUrl('lexik_paybox_ipn', array('time' => time()), UrlGeneratorInterface::ABSOLUTE_URL),
    ));

    return $this->render(
        'LexikPayboxBundle:Sample:index.html.twig',
        array(
            'url'  => $paybox->getUrl(),
            'form' => $paybox->getForm()->createView(),
        )
    );
}
...
/**
 * Sample action of a confirmation payment page on witch the user is sent
 * after he seizes his payment informations on the Paybox's platform.
 * This action must only containts presentation logic.
 */
public function responseAction($status)
{
    return $this->render(
        'LexikPayboxBundle:Sample:return.html.twig',
        array(
            'status'     => $status,
            'parameters' => $this->getRequest()->query,
        )
    );
}
...

The getUrl() method silently does a server check and throws an exception if the destination server does not respond., (*12)

The payment confirmation in your business logic must be done when the instant payment notification (IPN) occurs. The plugin contains a controller with an action that manages this IPN and triggers an event. The event contains all data transmetted during the request and a boolean that tells if signature verification was successful., (*13)

The bundle contains a listener example that simply create a file on each ipn call., (*14)

namespace Lexik\Bundle\PayboxBundle\Listener;

use Symfony\Component\Filesystem\Filesystem;

use Lexik\Bundle\PayboxBundle\Event\PayboxResponseEvent;

/**
 * Simple listener that create a file for each ipn call.
 */
class PayboxResponseListener
{
    private $rootDir;

    private $filesystem;

    /**
     * Constructor.
     *
     * @param string     $rootDir
     * @param Filesystem $filesystem
     */
    public function __construct($rootDir, Filesystem $filesystem)
    {
        $this->rootDir = $rootDir;
        $this->filesystem = $filesystem;
    }

    /**
     * Creates a txt file containing all parameters for each IPN.
     *
     * @param  PayboxResponseEvent $event
     */
    public function onPayboxIpnResponse(PayboxResponseEvent $event)
    {
        $path = $this->rootDir . '/../data/' . date('Y\/m\/d\/');
        $this->filesystem->mkdir($path);

        $content = sprintf("Signature verification : %s\n", $event->isVerified() ? 'OK' : 'KO');
        foreach ($event->getData() as $key => $value) {
            $content .= sprintf("%s:%s\n", $key, $value);
        }

        file_put_contents($path . time() . '.txt', $content);
    }
}

To create your own listener, you just have to make it wait for the "paybox.ipn_response" event. For example the listener of the bundle:, (*15)

parameters:
    lexik_paybox.sample_response_listener.class: 'Lexik\Bundle\PayboxBundle\Listener\SampleIpnListener'

services:
    ...
    lexik_paybox.sample_response_listener:
        class: %lexik_paybox.sample_response_listener.class%
        arguments: [ %kernel.root_dir%, @filesystem ]
        tags:
            - { name: kernel.event_listener, event: paybox.ipn_response, method: onPayboxIpnResponse }

Resources

All transactions parameters are available in the official documentation., (*16)

The Versions

27/09 2017

dev-master

9999999-dev https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

12/10 2016

v2.1.1

2.1.1.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

19/04 2016

v2.1.0

2.1.0.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

02/10 2015

v2.0.1

2.0.1.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

11/08 2015

v2.0.0

2.0.0.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

12/01 2015

v1.1.0

1.1.0.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve
by Lexik

payment symfony2 bundle paybox

19/12 2014

v1.0.4

1.0.4.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Olivier Maisonneuve

payment symfony2 bundle paybox

06/03 2013

v1.0.3

1.0.3.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

by Olivier Maisonneuve

payment symfony2 bundle paybox

27/02 2013

v1.0.2

1.0.2.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

by Olivier Maisonneuve

payment symfony2 bundle paybox

16/01 2013

v1.0.1

1.0.1.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

by Olivier Maisonneuve

payment symfony2 bundle paybox

08/01 2013

v1.0.0

1.0.0.0 https://github.com/lexik/LexikPayboxBundle

LexikPayboxBundle eases the implementation of the Paybox payment system.

  Sources   Download

MIT

The Requires

 

by Olivier Maisonneuve

payment symfony2 bundle paybox