duangangmo0583 2014-06-02 13:08
浏览 66
已采纳

Sylius:添加一个新的Payum Gateway(Rabobank Omnikassa)

I've been looking at a lot of posts but nowhere have I found a solution to my question. There doesn't same to be a single place on the internet that explains how to properly add a new payment gateway to the Sylius Payum Bundle.

I'm using the latest sylius 0.10.* version and I'd like to add a new payment gateway (Rabobank Omnikassa, a Dutch payment endpoint).

There's some info on how to add a PaymentFactory for the PayumPayumBundle, however the folder structure of this bundle is nothing like SyliusPayumBundle. I've created my own Acme\Bundle\PayumBundle which overrides from the SyliusPayumBundle.

I would like to set it up in a similar fashion to the PaypalExpressCheckoutPaymentFactory.

config/payum.yml

Here I'm just testing a few things to get Sylius to find my stuff.

payum:
    contexts:
        rabobank:
            storages:
                Sylius\Component\Core\Model\Order:
                    doctrine:
                        driver: orm
                Sylius\Component\Core\Model\Payment:
                    doctrine:
                        driver: orm

            custom:
                actions:
                    - Shopfish\Bundle\PayumBundle\Payum\Rabobank\Action\CapturePaymentAction
                    - Shopfish\Bundle\PayumBundle\Payum\Rabobank\Action\NotifyOrderAction

config/services.xml

I'm not sure what service tags to use where..

<parameters>
    <parameter key="shopfish.payum.rabobank.action.capture_payment.class">Shopfish\Bundle\PayumBundle\Payum\Rabobank\Action\CapturePaymentAction</parameter>
    <parameter key="shopfish.payum.rabobank.action.notify_order.class">Shopfish\Bundle\PayumBundle\Payum\Rabobank\Action\NotifyOrderAction</parameter>
    <parameter key="shopfish.payum.rabobank.action.payment_status.class">Shopfish\Bundle\PayumBundle\Payum\Rabobank\Action\PaymentStatusAction</parameter>
</parameters>

<services>
    <!-- Rabobank Omnikassa -->
    <service id="shopfish.payum.rabobank.action.capture_payment" class="%shopfish.payum.rabobank.action.capture_payment.class%" public="false">
        <tag name="payum.action" factory="omnipay" />
    </service>

    <service id="shopfish.payum.rabobank.action.notify_order" class="%shopfish.payum.rabobank.action.notify_order.class%" public="false">
        <argument type="service" id="event_dispatcher" />
        <argument type="service" id="sylius.manager.payment" />
        <argument type="service" id="finite.factory" />

        <tag name="payum.action" factory="paypal_express_checkout_nvp" />
    </service>
</services>

config/config.yml

And ofcourse I'm registering the gateway in the config.yml file

sylius_payment:
    gateways:
        rabobank: Rabobank Omnikassa

Exception: Invalid configuration for path

It doesn't seem to recognize Rabobank as a valid type. Where does one register a new type?

InvalidConfigurationException: Invalid configuration for path "payum.contexts.rabobank.omnipay": Given type Rabobank is not supported. These types AuthorizeNet_AIM, AuthorizeNet_SIM, Buckaroo, CardSave, Dummy, Eway_Rapid, GoCardless, Manual, Migs_ThreeParty, Migs_TwoParty, Mollie, MultiSafepay, Netaxept, NetBanx, PayFast, Payflow_Pro, PaymentExpress_PxPay, PaymentExpress_PxPost, PayPal_Express, PayPal_Pro, Pin, SagePay_Direct, SagePay_Server, SecurePay_DirectPost, Stripe, TargetPay_Directebanking, TargetPay_Ideal, TargetPay_Mrcash, TwoCheckout, WorldPay are supported.

Registering the Payment Factory

In this file you can see how they're registering the factories in Payum. I'd like to do the same in Sylius from within my own Bundle.

What are good steps to take from here?

  • 写回答

2条回答 默认 最新

  • dongshen5115 2014-06-02 14:12
    关注

    There are two ways to add custom payment solution to Payum\Sylius.

    • The quickest is using custom factory. That what you did, but you have to add a services to actions section not classes. The tag payum.action could be used with this approach like <tag name="payum.action" context="rabobank" />. I didnot use factory custom in the tag because in this case actions will be added to all contexts created by custom factory. It is not what we want.

    • Second way is to create a payment factory. For that you have to implement PaymentFactoryInterface and register it to Payum extension. You have to choose this if you need some options to be configured before you able to create a payment. The tag payum.action could be used with this approach like <tag name="payum.action" context="rabobank" /> or <tag name="payum.action" factory="rabobank" />. The difference is: first tag adds an action only to one context where second one adds action to all contexts that were created by a factory.

    Some general suggestions:

    There's some info on how to add a PaymentFactory for the PayumBundle, however the folder structure of this bundle is nothing like SyliusPayumBundle.

    It should not be. SyliusPayumBundle is a thin integration layer between Sylius and PayumBundle.

    I've created my own Acme\Bundle\PayumBundle which overrides from the SyliusPayumBundle.

    You dont have to do that, everything should work fine without this.

    I'm not sure what service tags to use where..

    If you chose a custom factory you dont need tags, configure actions section correctly.

    InvalidConfigurationException: Invalid configuration for path "payum.contexts.rabobank.omnipay":

    Are you sure you posted right configs? I believe you cannot get this exception with what you posted. I expect different exception with different message.

    And ofcourse I'm registering the gateway in the config.yml file

    You also have to put some data in your payment_gateway table (If I recall the table name correctly).

    In this file you can see how they're registering the factories in Payum. I'd like to do the same in Sylius from within my own Bundle.

    Just do same in your bundle's build method.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus
  • ¥15 解决编写PyDracula时遇到的问题