如何使用Sylius实现Klarna支付网关?

时间:2017-12-24 13:53:42

标签: symfony sylius payum klarna

我一直试图添加klarna checkout网关而没有任何运气...... 我没有在Admin UI中看到Klarna Checkout!

不知道我在这里缺少什么,但我理解它的方式我所要做的就是通过composer安装网关付款,然后在config.yml文件中添加字段

我是否需要制作KlarnaGatewayConfigurationType.php文件?如果是,那么我应该在哪里添加它以及我还应该做什么?

这些是我遵循的步骤: 安装Klarna:composer require klarna/checkout

然后我在app\config\config.yml添加了此代码:

payum:
    gateways:
        klarna_checkout:
            factory: klarna_checkout
            secret:  'required'
            merchant_id: 'required'
            terms_uri: ''
            checkout_uri: ''
            sandbox: true

sylius_payment:
     gateways:
            klarna_checkout: klarna_checkout

php bin/console payum:gateway:debug给了我这个:

Order of actions, apis, extensions matters 
Found 3 gateways 

offline (Payum\Core\Gateway): 
        ........................................................................

klarna_checkout (Payum\Core\Gateway): 
        Actions: 
        Payum\Core\Bridge\Symfony\Action\GetHttpRequestAction 
        Payum\Core\Bridge\Symfony\Action\ObtainCreditCardAction 
        Sylius\Bundle\PayumBundle\Action\CapturePaymentAction 
        Sylius\Bundle\PayumBundle\Action\ExecuteSameRequestWithPaymentDetailsAction 
        Sylius\Bundle\PayumBundle\Action\ResolveNextRouteAction 
        Payum\Core\Action\CapturePaymentAction 
        Payum\Core\Action\AuthorizePaymentAction 
        Payum\Core\Action\PayoutPayoutAction 
        Payum\Core\Action\ExecuteSameRequestWithModelDetailsAction 
        Payum\Core\Bridge\Twig\Action\RenderTemplateAction 
        Payum\Core\Action\GetCurrencyAction 
        Payum\Core\Action\GetTokenAction 
        Payum\Klarna\Checkout\Action\AuthorizeRecurringAction 
        Payum\Klarna\Checkout\Action\AuthorizeAction 
        Payum\Klarna\Checkout\Action\NotifyAction 
        Payum\Klarna\Checkout\Action\StatusAction 
        Payum\Klarna\Checkout\Action\SyncAction 
        Payum\Klarna\Checkout\Action\ConvertPaymentAction 
        Payum\Klarna\Checkout\Action\Api\CreateOrderAction 
        Payum\Klarna\Checkout\Action\Api\UpdateOrderAction 
        Payum\Klarna\Checkout\Action\Api\FetchOrderAction 

        Extensions: 
        Sylius\Bundle\PayumBundle\Extension\UpdatePaymentStateExtension 
        Payum\Bundle\PayumBundle\Profiler\PayumCollector 
        Payum\Core\Extension\GenericTokenFactoryExtension 
        Payum\Core\Bridge\Psr\Log\LoggerExtension 
        Payum\Core\Bridge\Psr\Log\LogExecutedActionsExtension 
        Payum\Core\Extension\StorageExtension 
                Storage: Payum\Core\Bridge\Doctrine\Storage\DoctrineStorage 
                Model: Sylius\Component\Core\Model\Order 
        Payum\Core\Extension\StorageExtension 
                Storage: Payum\Core\Bridge\Doctrine\Storage\DoctrineStorage 
                Model: Sylius\Component\Core\Model\Payment 
        Payum\Core\Extension\EndlessCycleDetectorExtension 

        Apis: 
        Payum\Core\Bridge\Httplug\HttplugClient 
        Payum\Klarna\Checkout\Config 

Offline (Payum\Core\Gateway): 
        ........................................................................

最后一步:php bin/console cache:clear

我在这里做错了什么?

2 个答案:

答案 0 :(得分:2)

是的,您还应该添加网关配置类型表单,它在app/config/services.yml中显示如下:

sylius.form.type.gateway_configuration.swipe:
    class: Payum\Swipe\Type\SwipeGatewayConfigurationType
    tags:
        - { name: sylius.gateway_configuration_type, type: swipe, label: Swipe }
        - { name: form.type }

包含的类应包含Sylius Admin中的配置表单。您可以在Sylius\Bundle\PayumBundle\Form\Type命名空间中找到它的另一个示例。

答案 1 :(得分:-1)

最近 Klarna API 版本已经从旧的 V2 升级到最新的 V3。因此,我为 Klarna Checkout 和 Klarna Payment 实现了相同的功能。