2017 © Pedro Peláez
 

symfony-bundle robokassa-bundle

robokassa support for symfony2

image

cmdconfig/robokassa-bundle

robokassa support for symfony2

  • Monday, April 16, 2018
  • by cmdconfig
  • Repository
  • 1 Watchers
  • 0 Stars
  • 469 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

RobokassaBundle

Описание на русском, (*1)

current version supports only POST methods, (*2)

Installation

php composer.phar require jh9/robokassa-bundle
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new jh9\RobokassaBundle\jh9RobokassaBundle(),

    );
}
# app/config/config.yml
jh9_robokassa:
    login: %login%
    password1: %password1%
    password2: %password2%
    test: %test% # default to true

Usage

in your template (to generate the "pay" button):, (*3)

#pay_order.html.twig
    {{ jh9_robokassa_form(order.id, order.price {# (optional) , {
                "template": "jh9RobokassaBundle:Twig:payForm.html.twig", {# default #}
                "Desc": "my description", {# default null #}
                "IncCurrLabel": "WMZM", {# default null #}
                "Encoding": "utf-8" {# default #}
            }
        #}
    ) }}

in your result action:, (*4)

    /**
     * @Route("/ResultUrl")
     * @Methods({"POST"})
     */
    public function resultAction(Request $request)
    {
        $manager = $this->get('jh9.robokassa.manager');
        $result = $manager->handleResult($request);

        if ($result->isValid()) {
            // ...

            // your success logic, such as set your order as paid
            /*
                $em = $this->get('doctrine.orm.default_entity_manager');
                $order = $em->find('jh9ShopProductBundle:Order', $result->getInvId());
                if (! $order) {
                    return $this->createNotFoundException();
                }
                $order->setStatus(OrderTypes::STATUS_PAYED);
             */
            return new Response();
        } else {
            return new Response('Not valid', 500);
        }
    }

in your success action you can do:, (*5)

    /**
     * @Route("/SuccessUrl")
     * @Methods({"POST"})
     */
    public function robokassaSuccessAction(Request $request)
    {
        $manager = $this->get('jh9.robokassa.manager');
        $payResult = $manager->handleSuccess($request);
        if (! $payResult->isValid()) {
            return new Response('not valid', 400);
        }
        return new Response(
            "Your order with id = " . $payResult->getInvId() . " is paid" .
             " , amount = " $payResult->getOutSum() .
            " your language is" . $payResult->getCulture()
        );
    }

in your fail action:, (*6)

    /**
     * @Route("/payment/fail")
     * @Methods({"POST"})
     */
    public function robokassaFailAction(Request $request)
    {
        $payResult = $this->get('jh9.robokassa.manager')->handleFail($request);

        return new Response(
            " Your order with id " . $payResult->getInvId() . " is not paid" .
            " amount: " . $payResult->getOutSum()
        );
    }

Template

to rewrite default template put your own to app/Resources/jh9RobokassaBundle/views/Twig/payForm.html.twig, (*7)

# app/Resources/jh9RobokassaBundle/views/Twig/payForm.html.twig
{{ form_start(form) }}
    {{ form_widget(form) }}
    <div>
        <button type="submit" class="btn btn-primary"> ROBOKASSA </button>
    </div>
{{ form_end(form) }}

or set 'template' option in robokassa form call:, (*8)

    {{ jh9_robokassa_form(
        order.id,
        order.price,
        {
            'template': "AcmeBundle:RobokassaTemplate:myTemplate.html.twig
        }
    }}

The Versions

16/04 2018

dev-master

9999999-dev https://github.com/jh9aea/jh9RobokassaBundle

robokassa support for symfony2

  Sources   Download

MIT

The Requires

 

by John Alex

robokassa

08/11 2013

dev-copy-of-master

dev-copy-of-master https://github.com/jh9aea/jh9RobokassaBundle

robokassa support for symfony2

  Sources   Download

MIT

The Requires

 

by John Alex

robokassa