Search code examples
phpsymfonypayum

Register custom gateway with PayumBundle


I am trying to register a custom Gateway Factory with the PayumBundle. If I register my Gateway Factory directly with the PayumBuilder it works fine. But if i add it via the PayumBundle all the extensions are missing.

# app/config/config.yml
payum:
    gateways_v2:
        superpay:
            factory: superpay
            service: ~

And my service configuration looks like this:

# app/config/services.yml
services:
    app.superpay.factory:
        class: App\Payum\Superpay\SuperpayGatewayFactory
        arguments:
            - { url: http://www.example.com } # change this
        tags:
            - { name: payum.gateway_factory, factory_name: superpay, human_name: Superpay }

Maybe it's related to https://github.com/Payum/Payum/issues/452

I use symfony 2.8, payum-core 1.2.2 and payum-bundle 1.2.3


Update: With payum-bundle 2.0 it works with this configuration

# app/config/config.yml
payum:
    gateways:
        superpay:
            factory: superpay
            url: http://www.example.com

and service configuration like

# app/config/services.yml

services:
    app.superpay.factory
        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [App\Payum\Superpay\SuperpayGatewayFactory]
        tags:
            - { name: payum.gateway_factory_builder, factory: girosim }

Solution

  • I'd suggest to jump to payum bundle 2.x, it should not be hard and allows to solve your problem easier than you can do it in 1.x. In 2.x you have to register a gateway factory builder service with a tag, like this: https://github.com/makasim/PayumBundleSandbox/blob/master/app/config/payum.yml#L194

    If you still want to stick to payum bundle 1.x you have to implement the factory from the bundle, like this one https://github.com/Payum/PayumBundle/blob/1.x/DependencyInjection/Factory/Gateway/PaypalExpressCheckoutNvpGatewayFactory.php

    and register it in the bundle's extension like this https://github.com/Payum/PayumBundle/blob/1.x/PayumBundle.php#L39