Search

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a new plugin class
    Jgo\Bundle\PaymentTestBundle\Plugin\TelecashConnectPlugin
  2. Create a new form type class
    Jgo\Bundle\PaymentTestBundle\Form\Type\TelecashConnectType
  3. Create a new configuration class and define plugin specific data
    Jgo\Bundle\PaymentTestBundle\Plugin\Configuration
  4. Register services

...

Code Block
languagephp
<?php

namespace Jgo\Bundle\PaymentTestBundle\Plugin;

use JMS\Payment\CoreBundle\Plugin\AbstractPlugin;

/**
 * JMS Plugin class for the payment
 */
class TeleCashConnectPlugin extends AbstractPlugin
{
    /**
     * Implementation which determines, that this plugin will be able to handle
     * the 'telecash_connect' payment system.
     *
     * @param string $paymentSystemName
     * @return boolean
     */
    public function processes($paymentSystemName)
    {
        return $paymentSystemName === 'telecash_connect';
    }
}

...

Code Block
languagephp
<?php

namespace Jgo\Bundle\PaymentTestBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class TeleCashConnectType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
    }

    public function getBlockPrefix()
    {
        return 'telecash_connect';
    }
}

...

Code Block
languagephp
collapsetrue
namespace Jgo\Bundle\PaymentTestBundle\Plugin;

use Siso\Bundle\PaymentBundle\Api\PluginConfigurationInterface;
use Symfony\Component\Routing\RouterInterface;

/**
 * Configuration class for the Telecash payment plugin.
 */
class Configuration implements PluginConfigurationInterface
{
    /**
     * @var RouterInterface
     */
    private $router;

    /**
     * @var array
     */
    private $parameters;

    /**
     * @param RouterInterface $router
     * @param array $parameters
     */
    public function __construct(RouterInterface $router, array $parameters = array())
    {
        $this->router = $router;
        $this->parameters = $parameters + array(
            'timezone' => '',
            'storename' => '',
            'secret' => '',
            'mode' => '',
        );
    }

    /**
     * @param string $orderReference
     * @return array
     */
    public function createExtendedDataForOrder($orderReference)
    {
        return array(
            'success_url' => $this->router->generate(
                'siso_telecash_success',
                array(
                    'orderReference' => $orderReference,
                ),
                RouterInterface::ABSOLUTE_URL
            ),
            'error_url' => $this->router->generate(
                'siso_telecash_error',
                array(
                    'orderReference' => $orderReference,
                ),
                RouterInterface::ABSOLUTE_URL
            ),
            'notify_url' => $this->router->generate(
                'siso_telecash_notify',
                array(
                    'orderReference' => $orderReference,
                ),
                RouterInterface::ABSOLUTE_URL
            ),
            'timezone' => $this->parameters['timezone'],
            'storename' => $this->parameters['storename'],
            'secret' => $this->parameters['secret'],
            'mode' => $this->parameters['mode'],
        );
    }

    /**
     * Returns PluginConfigurationInterface::PO_SALE as no other payment
     * operation is currently supported.
     *
     * @return string
     */
    public function determinePaymentOperation()
    {
        // Only sale (approveAndDeposit) is currently supported by this plugin.
        return PluginConfigurationInterface::PO_SALE;
    }
} 

...

Code Block
languagehtml/xml
collapsetrue
    <parameters>
        <parameter key="payment.form.telecash_connect_type.class">Jgo>Bundle\Bundle\PaymentTestBundle\Form\Type\TelecashConnectType</parameter>
        <parameter key="payment.plugin.telecash_connect.class">Jgo>Bundle\Bundle\PaymentTestBundle\Plugin\TelecashConnectPlugin</parameter>
        <parameter key="payment.plugin.telecash_connect.config.class">Jgo>Bundle\Bundle\PaymentTestBundle\Plugin\Configuration</parameter>
    </parameters>

    <services>
        <service id="payment.plugin.telecash_connect.config"
                 class="%payment.plugin.telecash_connect.config.class%">
            <argument type="service" id="router" />
            <argument type="collection">
                <argument key="mode" type="string">%siso_telecash_payment.parameter.mode%</argument>
                <argument key="storename" type="string">%siso_telecash_payment.parameter.storename%</argument>
                <argument key="secret" type="string">%siso_telecash_payment.parameter.secret%</argument>
                <argument key="timezone" type="string">%siso_telecash_payment.parameter.timezone%</argument>
            </argument>
            <tag name="payment.plugin.config" paymentMethod="telecash_connect" />
        </service>

        <service id="payment.plugin.telecash_connect"
                 class="%payment.plugin.telecash_connect.class%">
            <call method="setParameters">
                <argument type="collection">
                    <argument key="currency_mapping">%siso_payment.currency_mapping%</argument>
                    <argument key="test_code">%siso_payment.telecash.test_code.success%</argument>
                    <argument key="application_mode">%siso_telecash_payment.application_mode%</argument>
                </argument>
            </call>
            <tag name="payment.plugin" />
        </service>

        <service id="payment.form.telecash_connect_type"
                 class="%payment.form.telecash_connect_type.class%">
            <tag name="payment.method_form_type" />
            <tag name="form.type" alias="telecash_connect" />
        </service>
    </services>

Services & Tags

Payment plugin

Jgo\Bundle\PaymentTestBundle\Plugin\TelecashConnectPlugin

Every payment plugin service is injected into the JMS PluginManager by the tag payment.plugin.

Form values

Jgo\Bundle\PaymentTestBundle\Form\Type\TelecashConnectType

...

Extended data configuration

Jgo\Bundle\PaymentTestBundle\Plugin\Configuration

...