在 Sylius 中启用条纹

Enable Stripe in Sylius

我安装了 Sylius,我正试图连接到 Stripe 进行付款。我做了一些阅读,发现 Stripe 包含在 Payum 中。好的,开始安装 Payum。

所以我按照此处说明的第一部分进行操作:https://github.com/Payum/Stripe/blob/master/Resources/docs/checkout.md

php composer.phar require payum/stripe php-http/guzzle6-adapter

在那之后,Sylius 和 Symfony 似乎在配置方面分道扬镳,因为我在 sylius 上阅读的有关 Payum 的所有内容都引用了标准 config.yml 文件,而不是 config.php 文件Payum 文档中引用了它。所以我在网上找到了其他地方的基本配置,并将其添加到我的 config.yml:

payum:
    security:
        token_storage:
            myBundle\CoreBundle\Entity\PayumSecurityToken:
                doctrine:
                    driver: orm
    contexts:
        stripe:
            omnipay:
                type: Stripe
                options:
                    apiKey:  my_key_is_here
                    testMode: true
                actions:
                      - sylius.payum.stripe.action.capture_order_using_credit_card
                      - sylius.payum.action.obtain_credit_card
                      - sylius.payum.action.order_status
                      - sylius.payum.action.execute_same_request_with_payment_details
            storages:
                myBundle\CoreBundle\Entity\Order:
                      doctrine:
                          driver: orm
                Sylius\Bundle\PaymentsBundle\Model\Payment:
                      doctrine:
                          driver: orm

sylius_payments:
     driver: doctrine/orm
     gateways:
            stripe: Stripe

进行这些更改后,我现在收到错误消息:

There is no extension able to load the configuration for "sylius_payments" (in /Users/Me/Code/mysite/app/config/config.yml). Looked for namespace "sylius_payments", found "sylius_installer", "sylius_order", "sylius_money", "sylius_currency", "sylius_contact", "sylius_locale", "sylius_settings", "sylius_cart", "sylius_product", "sylius_archetype", "sylius_channel", "sylius_variation", "sylius_attribute", "sylius_taxation", "sylius_shipping", "sylius_payment", "sylius_mailer", "sylius_report", "sylius_promotion", "sylius_addressing", "sylius_inventory", "sylius_taxonomy", "sylius_flow", "sylius_pricing", "sylius_sequence", "sylius_content", "sylius_search", "sylius_rbac", "sylius_user", "sylius_ui", "sylius_admin", "sylius_shop", "sylius_metadata", "sylius_association", "sylius_review", "sylius_core", "sylius_web", "sylius_resource", "sylius_grid", "winzou_state_machine", "sylius_api", "sonata_block", "cmf_core", "cmf_block", "cmf_content", "cmf_routing", "cmf_menu", "cmf_create", "cmf_media", "doctrine", "doctrine_cache", "doctrine_phpcr", "assetic", "framework", "monolog", "security", "swiftmailer", "twig", "sonata_intl", "bazinga_hateoas", "fos_oauth_server", "fos_rest", "fos_elastica", "knp_gaufrette", "knp_menu", "knp_snappy", "liip_imagine", "payum", "jms_serializer", "jms_translation", "stof_doctrine_extensions", "white_october_pagerfanta", "doctrine_migrations", "sylius_fixtures", "sylius_payum", "sylius_theme", "debug", "web_profiler" in /Users/Me/Code/mysite/app/config/config.yml (which is being imported from "/Users/Me/Code/mysite/app/config/config_dev.yml").

我不确定从这里该何去何从,因为关于该主题的文档很少。

我想提出一个可能的答案。基于我从评论和外部资源中获得的帮助,我制定了我的 config.yml 可能只需要以下内容(当然是通过 composer 安装后:php composer.phar 需要 payum/stripe php-http/guzzle6-adapter)

payum:
    gateways:
        stripe:
            factory: stripe_checkout
            publishable_key: my_pusblishable_key
            secret_key: my_secret_key

这似乎是启动时不抛出错误所需的全部内容,就像我最初问题中的代码那样。我已经清除了缓存,并重新启动了服务器。但是,我在 Sylius 管理员的 'payment methods' 面板中没有看到任何新选项。这现在不应该显示为一个可行的选择吗?在我们弄清楚真正让 Stripe 工作需要什么之前,我不会接受我的回答。

编辑

看起来我的其他一点点,激活我刚刚定义的网关,是正确的。添加之后,现在一切正常,网关正确显示在管理面板中。万岁!

sylius_payments:
     driver: doctrine/orm
     gateways:
            stripe: Stripe

让 Stripe 在 Sylius 中工作的完整解决方案是:

通过作曲家安装:

将此添加到您的 config.yml:

payum:
    gateways:
        stripe:
            factory: stripe_checkout
            publishable_key: my_publishable_key
            secret_key: my_secret_key

sylius_payment:
     driver: doctrine/orm
     gateways:
            stripe: Stripe

清除缓存:

php app/console cache:clear

重新启动网络服务器,以备不时之需。就是这样!