PHP code example of fullpipe / payum-flexidengi

1. Go to this page and download the library: Download fullpipe/payum-flexidengi 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/ */

    

fullpipe / payum-flexidengi example snippets




// src/Acme/PaymentBundle/AcmePaymentBundle.php

namespace Acme\PaymentBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Fullpipe\Payum\Flexidengi\Bridge\Symfony\FlexidengiPaymentFactory;

class AcmePaymentBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $extension = $container->getExtension('payum');
        $extension->addPaymentFactory(new FlexidengiPaymentFactory());
    }
}


// /src/Acme/PaymentBundle/Controller/PaymentController.php

namespace Acme\PaymentBundle\Controller;

use Payum\Bundle\PayumBundle\Controller\PayumController;
use Symfony\Component\HttpFoundation\Request;
use Payum\Core\Request\Notify;
use Payum\Core\Request\GetHumanStatus;
use Fullpipe\Payum\Flexidengi\Api;

class PaymentController extends PayumController
{
    public function notifyAction(Request $request)
    {
        $gateway = $this->getPayum()->getPayment('flexidengi_gateway');
        $payment = $this->getPayum()
            ->getStorage('Acme\PaymentBundle\Entity\Payment')
            ->findBy(array(
                'number' => $request->query->get(Api::ORDER_ID_PARAM_NAME),
            ));

        if ($reply = $gateway->execute(new Notify($payment), true)) {
            if ($reply instanceof HttpResponse) {
                $gateway->execute($status = new GetHumanStatus($payment));

                if ($status->isCaptured()) {
                    // Payment is done
                    // Notify your app here
                }

                throw $reply;
            }

            throw new \LogicException('Unsupported reply', null, $reply);
        }
        return new Response('', 204);
    }
}



namespace Acme\PaymentBundle\Controller;

use Payum\Bundle\PayumBundle\Controller\PayumController;
use Symfony\Component\HttpFoundation\Request;
use Payum\Core\Request\Notify;
use Payum\Core\Request\GetHumanStatus;
use Fullpipe\Payum\Uniteller\Api;

class PaymentController extends PayumController
{
    public function prepareAction()
    {
        $order = ...;
        $user = ...;

        $paymentName = 'flexidengi_gateway';

        $storage = $this->get('payum')
            ->getStorage('Acme\PaymentBundle\Entity\Payment');

        $payment = $storage->create();
        $payment->setNumber($order->getId());
        $payment->setCurrencyCode('RUB');
        $payment->setTotalAmount(14025); // 140 руб, 25 коп.

        $storage->update($payment);

        $captureToken = $this->get('payum.security.token_factory')
            ->createCaptureToken(
                $paymentName,
                $payment,
                'acme_payment_done'
            );

        return $this->redirect($captureToken->getTargetUrl());
    }
}