webgriffe / sylius-klarna-payments-plugin
Sylius电子商务框架的Klarna支付插件
Requires
- php: ^8.2
- sylius/sylius: ^1.12
- symfony/webpack-encore-bundle: ^1.17
Requires (Dev)
- behat/behat: ^3.14
- behat/mink-selenium2-driver: ^1.6
- dbrekelmans/bdi: ^1.1
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.10
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.5
- friends-of-behat/variadic-extension: ^1.5
- phpspec/phpspec: ^7.5
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-doctrine: 1.3.69
- phpstan/phpstan-strict-rules: ^1.5
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.3
- sylius-labs/suite-tags-extension: ^0.2
- symfony/browser-kit: ^6.4
- symfony/debug-bundle: ^6.4
- symfony/dotenv: ^6.4
- symfony/flex: ^2.4
- symfony/intl: ^6.4
- symfony/web-profiler-bundle: ^6.4
- vimeo/psalm: ^5.9
This package is auto-updated.
Last update: 2024-09-22 08:03:25 UTC
README
Sylius Klarna 插件
Sylius插件,用于Klarna支付支付方式。
安装
-
运行
composer require webgriffe/sylius-klarna-payments-plugin
-
将以下代码添加到您的
config/bundles.php
文件中:通常,通过
composer require
命令自动将插件添加到config/bundles.php
文件。如果没有,您需要手动添加。 -
创建一个新文件
config/packages/webgriffe_sylius_klarna_payments_plugin.yaml
imports: - { resource: "@WebgriffeSyliusKlarnaPaymentsPlugin/config/config.php" } webgriffe_sylius_klarna_payments: product_images: type: 'main' # Type of the product image to send to Klarna. If none is specified or the type does not exists on current product then the first image will be used. filter: 'sylius_medium' # Liip filter to apply to the image. If none is specified then the original image will be used.
-
导入取消支付的所需路由。将以下内容添加到您的
config/routes.yaml
文件中:webgriffe_sylius_klarna_payments_plugin: resource: "@WebgriffeSyliusKlarnaPaymentsPlugin/config/shop_routing.php" prefix: /{_locale} requirements: _locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$ webgriffe_sylius_klarna_payments_plugin_ajax: resource: "@WebgriffeSyliusKlarnaPaymentsPlugin/config/shop_ajax_routing.php" sylius_shop_payum_cancel: resource: "@PayumBundle/Resources/config/routing/cancel.xml"
注意:文件 shop_routing 需要在 _locale 前缀之后,以便可以在正确的语言中显示消息。如果您还没有,还应包括 Payum bundle 中的取消路由!
-
运行
php bin/console sylius:install:assets
或者,您可以将其添加到您的
webpack.config.js
文件中.addEntry( 'webgriffe-sylius-klarna-payments-entry', './vendor/webgriffe/sylius-klarna-payments-plugin/public/poll_payment.js' )
然后覆盖模板
WebgriffeSyliusKlarnaPaymentsPlugin/Process/index.html.twig
以包含条目{% block javascripts %} {{ parent() }} <script> window.afterUrl = "{{ afterUrl }}"; window.paymentStatusUrl = "{{ paymentStatusUrl }}"; </script> {{ encore_entry_script_tags('webgriffe-sylius-klarna-payments-entry', null, 'sylius.shop') }} {% endblock %}
用法
访问管理面板并转到 支付方式
部分。创建一个新的支付方式并选择 Klarna支付
作为网关。然后,使用所需参数配置支付方式。
贡献
有关Sylius插件开发的全面指南,请访问Sylius文档,在那里您可以找到插件开发指南,其中包含大量示例。
快速安装
传统方式
-
运行
composer create-project sylius/plugin-skeleton ProjectName
。 -
从插件骨架根目录,运行以下命令
$ (cd tests/Application && yarn install) $ (cd tests/Application && yarn build) $ (cd tests/Application && APP_ENV=test bin/console assets:install public) $ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create) $ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
为了能够设置插件数据库,请记住在 tests/Application/.env
和 tests/Application/.env.test
中配置您的数据库凭据。
Docker
-
执行
docker compose up -d
-
初始化插件
docker compose exec app make init
-
在浏览器中打开
open localhost
用法
运行插件测试
-
PHPUnit
vendor/bin/phpunit
-
PHPSpec
vendor/bin/phpspec run
-
Behat(非JS场景)
vendor/bin/behat --strict --tags="~@javascript"
-
Behat(JS场景)
-
启动Headless Chrome
google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1
- 安装SSL证书(仅需要一次)并在
127.0.0.1:8080
上运行测试应用程序的web服务器
symfony server:ca:install APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
- 运行Behat
vendor/bin/behat --strict --tags="@javascript"
-
静态分析
-
Psalm
vendor/bin/psalm
-
PHPStan
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
-
-
编码标准
vendor/bin/ecs check
使用您的插件打开Sylius
-
使用
test
环境(cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load) (cd tests/Application && APP_ENV=test bin/console server:run -d public)
-
使用
dev
环境(cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load) (cd tests/Application && APP_ENV=dev bin/console server:run -d public)