How to register a new payment method and add actions?

I created a payment method. I created a payment form that stores payment data, and then I create a payment security token. All this looks fine so far, and payum generates a token in the store.

However, I cannot register it. I don’t know where I should add actions so that they are used when loading the payment method.

I have the following questions.

  • Where can I add a link to my PaymentFactory? . I am currently loading the payum extension in the package build method and adding the PaymentFactory instance to the extension. Is that all I need to do?
  • I created a Capture and Status action. Where to add these actions to the payment gateway? Do I write them in PaymentFactory? I added a dump and exits to both classes, and when I launch a payment in a browser, it seems to never get into action and does not exit in the place that I installed.

Any help would be appreciated

Thanks in advance:)

+4
source share
1 answer

There are several ways to add payment actions:

  • The fastest use of custom factory.

    payum:
        contexts:
            you_name_it:
                custom:
                    actions:
                        - your.action.service.from.container
                        - your.another.action.service.from.container
    
  • factory. , . PaymentFactoryInterface Payum. factory ( symfony):

    <?php
    
    function create(ContainerBuilder $container, $contextName, array $config)
    {
        $paymentDefinition = new Definition;
        $paymentId = 'paymentId';
    
        $container->setDefinition($paymentId, $paymentDefinition);
    
        $paymentDefinition->addMethodCall('addAction', array(
            new Reference('your.action.service.from.container')
        ));
    }
    

    xml . payum.action. factory. factory. : paypal_express_checkout_nvp.xml

    <service
        id="your.action.service.from.container"
        class="%your.action.service.from.container.class%"
        public="false"
    >
        <tag name="payum.action" factory="your_factory_name" />
    </service>
    
+2

Source: https://habr.com/ru/post/1542737/


All Articles