Sylius Paygreen Plugin
Sylius plugin for Paygreen.io payment provider
Installation
Requirements
Package | Version |
---|---|
PHP | ^7.4 |
sylius/sylius | ^1.8 || ^1.9 |
Instructions
-
Install plugin using
composer
:$ composer require hraph/sylius-paygreen-plugin
-
Import config:
# config/packages/_sylius.yaml imports: # ... - { resource: "@SyliusPaygreenPlugin/Resources/config/app/config.yaml" }
-
Import routing:
# config/routes.yaml hraph_sylius_paygreen_plugin_admin: resource: "@SyliusPaygreenPlugin/Resources/config/admin_routing.yaml" prefix: /admin
-
Update your schema (for existing project):
# Generate and edit migration bin/console doctrine:migrations:diff # Then apply migration bin/console doctrine:migrations:migrate
Plugin configuration
# config/packages/sylius_paygreen.yaml
sylius_paygreen:
api:
username: PaygreenUsername
api_key: API_KEY
sandbox: true
force_use_authorize: true # All payments will be executed using authorize (fingerprint)
use_insite_mode: true # Use iframe mode
Views customization
You can customize the payment view by creating a custom file in templates/bundles/SyliusPaygreenPlugin/Checkout/payment.html.twig
:
{% block content %}
<iframe src="{{ execute_url ~ "?display=insite" }}" style="border: 0;width: 100%; height: 600px"></iframe>
{% endblock %}
Plugin extension
The following plugin entities can be extended using Sylius documentation guidelines:
paygreen_shop
paygreen_transfer
Example:
sylius_paygreen:
resources:
paygreen_shop:
classes:
interface: App\Entity\PaymentProvider\CustomPaymentProviderShopInterface
model: App\Entity\PaymentProvider\CustomPaymentProviderShop
factory: App\Entity\PaymentProvider\CustomPaymentProviderShopFactory
Contribution
Installation:
$ (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)
To be able to setup a plugin's database, remember to configure you database credentials in tests/Application/.env
and tests/Application/.env.test
.
Running plugin tests
-
PHPSpec
$ composer phpspec
-
Behat
$ composer behat
-
All tests (phpspec & behat)
$ composer test