PHP code example of pavlaq / przelewy24-bundle-fork
1. Go to this page and download the library: Download pavlaq/przelewy24-bundle-fork 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/ */
pavlaq / przelewy24-bundle-fork example snippets
// ...
class AppKernel extends Kernel
// ...
public function registerBundles()
{
$bundles = [
// ...
new Allset\Przelewy24Bundle\AllsetPrzelewy24Bundle(),
// ...
];
}
// ...
use Allset\Przelewy24Bundle\Factory\ProcessFactory;
use Allset\Przelewy24Bundle\Model\Payment;
// ...
class AppController extends Controller
{
// ...
public function processAction(ProcessFactory $processFactory)
{
$order = // ... - You are creating your order here
$payment = new Payment();
$payment
->setCurrency('PLN')
->setSessionId($order->geToken()) //VERY IMPORTANT some unique id from your order in your db
->setAmount($order->getAmount())
->setDescription($order->getDesc())
->setEmail($order->getEmail())
->setReturnUrl($this->generateUrl('return', [], 0)); // use following syntax to genreate absolute url
$processFactory->setPayment($payment);
$url = $processFactory->createAndGetUrl();
return $this->redirect($url);
}
// ...
}
namespace AppBundle\EventListener\Przelewy24;
use Allset\Przelewy24Bundle\Event\PaymentEventInterfce;
class PaymentSuccessListener
{
// ..
public function onPrzelewy24EventPaymentSuccess(PaymentEventInterfce $event)
{
$token = $event->getPayment()->getSessionId();
// ..
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.