1. Go to this page and download the library: Download webtopay/webtopay-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/ */
webtopay / webtopay-bundle example snippets
namespace Vendor\Bundle\PaymentsBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\BrowserKit\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class PayseraPaymentsController extends Controller
{
/**
* @Route("/payments/paysera/pay", name="paysera.pay")
*/
public function redirectToPaymentAction()
{
$acceptUrl = $this->generateUrl('paysera.accept');
$cancelUrl = $this->generateUrl('paysera.cancel');
$callbackUrl = $this->generateUrl('paysera.callback');
$url = $this->container->get('evp_web_to_pay.request_builder')->buildRequestUrlFromData(array(
'orderid' => 0,
'amount' => 1000,
'currency' => 'EUR',
'country' => 'LT',
'accepturl' => $acceptUrl,
'cancelurl' => $cancelUrl,
'callbackurl' => $callbackUrl,
'test' => 0,
));
return new RedirectResponse($url);
}
/**
* @Route("/payments/paysera/accept", name="paysera.accept")
*/
public function acceptAction()
{
// payment was successful
}
/**
* @Route("/payments/paysera/cancel", name="paysera.cancel")
*/
public function cancelAction()
{
// payment was unsuccessful
}
/**
* @Route("/payments/paysera/callback", name="paysera.callback")
*/
public function callbackAction()
{
try {
$callbackValidator = $this->get('evp_web_to_pay.callback_validator');
$data = $callbackValidator->validateAndParseData($this->getRequest()->query->all());
if ($data['status'] == 1) {
// Provide your customer with the service
return new Response('OK');
}
} catch (\Exception $e) {
//handle the callback validation error here
return new Response($e->getTraceAsString(), 500);
}
}
}
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
//... your existing bundles here
new Evp\Bundle\WebToPayBundle\EvpWebToPayBundle(),
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.