PHP code example of jakubzapletal / payment-webpay-bundle

1. Go to this page and download the library: Download jakubzapletal/payment-webpay-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/ */

    

jakubzapletal / payment-webpay-bundle example snippets




// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new JakubZapletal\Payment\WebpayBundle\JakubZapletalPaymentWebpayBundle(),
    // ...
);

// class PaymentController

    // ...

    /**
     * @Route("/{orderNumber}/details", name = "payment_details")
     * @Template
     */
    public function detailsAction(Order $order)
    {
        $form = $this->getFormFactory()->create('jms_choose_payment_method', null, array(
            'amount'   => $order->getAmount(),
            'currency' => 'EUR',
            'default_method' => 'payment_webpay', // Optional
            'predefined_data' => array(
                'webpay' => array(
                    'return_url' => $this->router->generate('payment_complete', array(
                        'orderNumber' => $order->getOrderNumber(),
                    ), true),
                    'merchantOrderNumber' => $order->getId(), // Optional
                    'description' => (string)$order->getProduct() // Optional
                )
            ),
        ));

        if ('POST' === $this->request->getMethod()) {
            $form->bindRequest($this->request);

            if ($form->isValid()) {
                $this->ppc->createPaymentInstruction($instruction = $form->getData());

                $order->setPaymentInstruction($instruction);
                $this->em->persist($order);
                $this->em->flush($order);

                return new RedirectResponse($this->router->generate('payment_complete', array(
                    'orderNumber' => $order->getOrderNumber(),
                )));
            }
        }

        return array(
            'form' => $form->createView()
        );
    }

    // ...

$plugin = $container->get('jakub_zapletal.payment.webpay.plugin.webpay');