1. Go to this page and download the library: Download gabrielextso/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/ */
gabrielextso / 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 indexAction($account)
{
$service = sprintf('lexik_paybox.request_handler.%s', $account);
if (!$this->has($service)) {
throw new NotFoundHttpException(sprintf('Service %s not found', $service));
}
$paybox = $this->get($service);
$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('account' => $account, 'status' => 'success'), UrlGenerator::ABSOLUTE_URL),
'PBX_REFUSE' => $this->generateUrl('lexik_paybox_sample_return', array('account' => $account, 'status' => 'denied'), UrlGenerator::ABSOLUTE_URL),
'PBX_ANNULE' => $this->generateUrl('lexik_paybox_sample_return', array('account' => $account, 'status' => 'canceled'), UrlGenerator::ABSOLUTE_URL),
'PBX_RUF1' => 'POST',
'PBX_REPONDRE_A' => $this->generateUrl('lexik_paybox_ipn', array('account' => $account, 'time' => time()), UrlGenerator::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 returnAction(Request $request, $status, $account)
{
return $this->render('LexikPayboxBundle:Sample:return.html.twig', array(
'status' => $status,
'account' => $account,
'parameters' => $request->query,
));
}
...
namespace Lexik\Bundle\PayboxBundle\Listener;
use Lexik\Bundle\PayboxBundle\Event\PayboxResponseEvent;
use Symfony\Component\Filesystem\Filesystem;
/**
* Sample listener that create a file for each ipn call.
*/
class SampleIpnListener
{
/**
* @var string
*/
private $rootDir;
/**
* @var Filesystem
*/
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 = sprintf('%s/../data/%s', $this->rootDir, date('Y\/m\/d\/'));
$this->filesystem->mkdir($path);
$content = sprintf('Account : %s%s', $event->getAccount(), PHP_EOL);
$content .= sprintf('Signature verification : %s%s', $event->isVerified() ? 'OK' : 'KO', PHP_EOL);
foreach ($event->getData() as $key => $value) {
$content .= sprintf("%s:%s%s", $key, $value, PHP_EOL);
}
file_put_contents(
sprintf('%s%s.txt', $path, time()),
$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.