1. Go to this page and download the library: Download mahefa/paybox-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mahefa / paybox-bundle example snippets
...
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' => '[email protected]',
'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,
)
);
}
...
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);
}
}
php
public function registerBundles()
{
return array(
// ...
new Lexik\Bundle\PayboxBundle\LexikPayboxBundle(),
// ...
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.