2017 © Pedro Peláez
 

symfony-bundle przelewy24-bundle

This is Symfony 3.3+ P24 Bundle.

image

allset/przelewy24-bundle

This is Symfony 3.3+ P24 Bundle.

  • Wednesday, May 30, 2018
  • by AllsetPL
  • Repository
  • 1 Watchers
  • 2 Stars
  • 149 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1142 % Grown

The README.md

Allset Przelewy24 Bundle

This is superb easy to use Przelewy24 Bundle with bulit-in Symfony Events., (*1)

Instalation

composer require allset/przelewy24-bundle

and then update your AppKernel.php:, (*2)

// ...
class AppKernel extends Kernel
// ...
    public function registerBundles()
    {
        $bundles = [
        // ...
            new Allset\Przelewy24Bundle\AllsetPrzelewy24Bundle(),
        // ...
        ];
    }

Than add to your routing.yml file:, (*3)

#app/config/routing.yml
allset_przelewy24:
    resource: "@AllsetPrzelewy24Bundle/Resources/config/routing.xml"

If you want to have access to Test Tools add this to routing_dev.yml:, (*4)

#app/config/routing_dev.yml
allset_przelewy24:
    resource: "@AllsetPrzelewy24Bundle/Resources/config/routing_dev.xml"

Requirements

Symfony 3.3++ (becouse bundle is using Symfony Service Autowire)
Guzzle ^6.3 (already included in composer.json), (*5)

Config

Add to your config folowing lines:, (*6)

#app/config/config.yml
allset_przelewy24:
    sandbox: true #or false
    merchant_id: <your-merchant-id>
    crc_key: <your-crc>

Usage

1. Create your super-custom action

In your controller., (*7)

// ...

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);
    }

    // ...

}
2. Register Payment Success Event Listener
#app/config/services.yml
    AppBundle\EventListener\Przelewy24\PaymentSuccessListener:
        tags:
            - { name: kernel.event_listener, event: przelewy24.event.payment_success }
3. Do what only you want with your succesed payment
namespace AppBundle\EventListener\Przelewy24;

use Allset\Przelewy24Bundle\Event\PaymentEventInterfce;

class PaymentSuccessListener
{
    // ..

    public function onPrzelewy24EventPaymentSuccess(PaymentEventInterfce $event)
    {
        $token = $event->getPayment()->getSessionId();

    // ..

    }
}

Developer Tools

Testing connection

To access tests you have to add @AllsetPrzelewy24Bundle/Resources/config/routing_dev.xml to your rounting_dev.yml file. (check out Instaltion chapter)., (*8)

After that you have access to allset_przelewy24_test route or simpler go to /p24-test path and checkout the results., (*9)

Simulating Payment Success

Due to Przelewy24 native API you are unable to get success response on your localhost, but you can simulate it with Simulating Payment Success Tool., (*10)

To access simulating you have to add @AllsetPrzelewy24Bundle/Resources/config/routing_dev.xml to your rounting_dev.yml file. (check out Instaltion chapter)., (*11)

After that you can simply go to /p24-fake-success/{sessionId} path or redirect to route allset_przelewy24_fake_success to make bundle to trigger przelewy24.event.payment_success event., (*12)

The Versions

30/05 2018

dev-master

9999999-dev

This is Symfony 3.3+ P24 Bundle.

  Sources   Download

MIT

The Requires

 

20/05 2018

v1.1.0

1.1.0.0

This is Symfony 3.3+ P24 Bundle.

  Sources   Download

MIT

The Requires

 

10/03 2018

v0.0.1

0.0.1.0

More info soon...

  Sources   Download

MIT

The Requires