我看了很多帖子,但没有找到解决我问题的方法。互联网上没有一个地方可以解释如何正确地将新的支付网关添加到 Sylius Payum Bundle。
我正在使用最新的 sylius
0.10.*
版本,并且我想添加新的支付网关(Rabobank Omnikassa,荷兰支付端点)。
有一些关于如何为 PayumPayumBundle
添加 PaymentFactory
的信息,但是该 bundle 的文件夹结构与 SyliusPayumBundle
完全不同。我创建了自己的 Acme\Bundle\PayumBundle
,它覆盖了 SyliusPayumBundle
。
我想以与 PaypalExpressCheckoutPaymentFactory 类似的方式进行设置.
配置/payum.yml
在这里,我只是测试一些东西,以便让 Sylius 找到我的东西。
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
我不确定在哪里使用什么服务标签..
<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.yml
当然,我正在 config.yml 文件中注册网关
sylius_payment:
gateways:
rabobank: Rabobank Omnikassa
异常:路径配置无效
它似乎无法将 Rabobank
识别为有效类型。在哪里注册新类型?
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.
注册支付工厂
在 this file你可以看到他们如何在 Payum 注册工厂。我想在我自己的 Bundle 中对 Sylius 做同样的事情。
从这里开始可以采取哪些好的步骤?
最佳答案
有两种方法可以将自定义支付解决方案添加到 Payum\Sylius。
最快的是使用自定义工厂。这就是你所做的,但是你必须将服务添加到
actions
节而不是类。标签payum.action
可以与这种方法一起使用,例如<tag name="payum.action" context="rabobank" />
。我没有使用工厂custom
在标签中,因为在这种情况下,操作将添加到自定义工厂创建的所有上下文中。这不是我们想要的。第二种方法是创建支付工厂。为此,您必须实现
PaymentFactoryInterface
并将其注册到 Payum 扩展。如果您需要在创建付款之前配置一些选项,则必须选择此选项。标签payum.action
可以与这种方法一起使用,例如<tag name="payum.action" context="rabobank" />
或<tag name="payum.action" factory="rabobank" />
。区别在于:第一个标签仅向一个上下文添加操作,而第二个标签向工厂创建的所有上下文添加操作。
一些一般性建议:
There's some info on how to add a PaymentFactory for the PayumBundle, however the folder structure of this bundle is nothing like SyliusPayumBundle.
不应该。 SyliusPayumBundle 是 Sylius 和 PayumBundle 之间的一个薄集成层。
I've created my own Acme\Bundle\PayumBundle which overrides from the SyliusPayumBundle.
你不必这样做,没有这个一切都应该正常工作。
I'm not sure what service tags to use where..
如果您选择了不需要标签的自定义工厂,请配置 actions
部分正确。
InvalidConfigurationException: Invalid configuration for path "payum.contexts.rabobank.omnipay":
您确定您发布了正确的配置吗?我相信您发布的内容无法获得此异常(exception)。我期望不同的异常有不同的消息。
And ofcourse I'm registering the gateway in the config.yml file
您还必须将一些数据放入 payment_gateway
中表(如果我没记错表名的话)。
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.
只需在 bundle 的构建方法中执行相同的操作即可。
关于php - Sylius:添加新的 Payum 网关(Rabobank Omnikassa),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23995316/