Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the configuration for Payum Bundle work?

I'm new to Payum and I am trying to create a new payment gateway. However I can't figure out how the config values relate to the files I've created (Actions/Factory etc).

Here's what I have so far;

payum:
    security:
        token_storage:
            Path\To\PaymentSecurityToken:
                doctrine:
                    driver: orm
    contexts:
        xxx:
            yyyy:
                api:
                    options:
                        sandbox: true
        storages:
            Path\To\Payment:
                doctrine:
                    driver: orm

I don't get what I am supposed to put into xxx and yyy. No matter what values I try I still don't get it. I keep getting the following error.

InvalidConfigurationException: Unrecognized options "yyy" under "payum.contexts.xxx"

Can anyone tell me what those values are supposed to be and how the values I set are related to the gateway and where there are needed so the config actually matches up to something in the gateway code?

Thanks in advance :)

like image 366
jonupton Avatar asked Oct 31 '22 22:10

jonupton


1 Answers

yyyy - is the payment (or storage) factory name. Under this section you put payment specific options. They are defined in addConfiguration method. These options later passed to method that creates a payment service

There are some factories shipped with Payum bundle. You can use they or add your own. For that you have to implement PaymentFactoryInterface and register it like others to Payum extension.

xxx - it is context name (you name it). The idea behind it is pretty simple. You can have two paypal payments but configured differently. One for US and one for EU (different paypal accounts). Something like:

payum:
   contexts:
       paypal_eu:
           paypal_express_checkout_nvp:
               username: ~
               password: ~
               signature: ~
       paypal_us:
           paypal_express_checkout_nvp:
               username: ~
               password: ~
               signature: ~

Later when you want to get the payment instance you have to use context name:

$payment = $container->get('payum')->getPayment('paypal_eu');

P.S. Some real config examples you can find in docs.

like image 146
Maksim Kotlyar Avatar answered Nov 15 '22 09:11

Maksim Kotlyar