pledg / sylius-payment-plugin
Payment Gateway Plugin using Pledg
Installs: 11 264
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 14
Forks: 2
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^7.4 | ^8.0
- php-http/message-factory: ^1.1
- psr/http-factory: ^1.1
- sylius/sylius: ~1.9.0|~1.10.0|~1.11.0|~1.12.0|~1.13.0|~1.14.0
Requires (Dev)
- behat/behat: ^3.6.1
- behat/mink-selenium2-driver: ^1.4
- dbrekelmans/bdi: ^1.1
- dmore/behat-chrome-extension: ^1.3
- dmore/chrome-mink-driver: ^2.7
- friends-of-behat/mink: ^1.8
- friends-of-behat/mink-browserkit-driver: ^1.4
- friends-of-behat/mink-debug-extension: ^2.0.0
- friends-of-behat/mink-extension: ^2.4
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.1
- friends-of-behat/variadic-extension: ^1.3
- phpspec/phpspec: ^7.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.8.1
- phpstan/phpstan-doctrine: 1.3.69
- phpstan/phpstan-strict-rules: ^1.3.0
- phpstan/phpstan-webmozart-assert: ^1.2.0
- phpunit/phpunit: ^10.5
- polishsymfonycommunity/symfony-mocker-container: ^1.0
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.2
- sylius-labs/suite-tags-extension: ^0.2
- symfony/browser-kit: ^5.4 || ^6.4
- symfony/debug-bundle: ^5.4 || ^6.4
- symfony/dotenv: ^5.4 || ^6.4
- symfony/flex: ^2.4
- symfony/intl: ^5.4 || ^6.4
- symfony/mailer: ^5.0 | ^6.0 | ^7.0
- symfony/web-profiler-bundle: ^5.4 || ^6.4
- symfony/webpack-encore-bundle: ^1.15
Conflicts
- symfony/framework-bundle: 6.2.8
README
Installation
- Install the package (beware of which version of our plugin supports your version of Sylius)
composer require pledg/sylius-payment-plugin
- Import routes in one of your routing file or create a new one (like
config/routes/pledg_sylius_payment.yaml
)
pledg_sylius_payment: resource: "@PledgSyliusPaymentPlugin/Resources/config/routing.yml" prefix: /pledg
- Clear your cache in order to see translations
bin/console c:c
Sandbox and production environment
By default, plugin uses sandbox mode. You can configure it by specify the mode in your configuration files.
For example if you only want to disable the sandbox mode for the production environment you just have to create a config/packages/prod/pledg_sylius_payment_plugin.yaml
file with :
pledg_sylius_payment: sandbox: false
Create your payment method
Now you can use the plugin and create your first Pledg Payment method :
- Select the Pledg Type
- Fill all required fields (specially with your merchant id, secret and restricted countries). Don't forget to activate the method on your channel.
Pledg allow to use a payment method without a signature but the plugin does not allow it. So even in sandbox mode, the secret is required and exchanges will be signed.
Add assets
mkdir -p templates/bundles/SyliusAdminBundle/ mkdir -p templates/bundles/SyliusShopBundle/ cp -R vendor/pledg/sylius-payment-plugin/tests/Application/templates/bundles/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/ cp -R vendor/pledg/sylius-payment-plugin/tests/Application/templates/bundles/SyliusShopBundle/* templates/bundles/SyliusShopBundle/
Add state machine configuration
Import the configuration in _sylius.yaml
or your pledg_sylius_payment_plugin.yaml
file :
imports: - { resource: "@PledgSyliusPaymentPlugin/Resources/config/state_machine.yaml" }
How the plugin works ?
We use Payum and the Sylius payment workflow in order to redirect on the Pledg payment page. Pledg uses all the parameters already filled in order to avoid you to refill them again. If all mandatory parameters are filled, you just need to fill your banking information. Otherwise, you could potentially fill in your address and your phone number.
All parameters in this url are in a signature parameter corresponding to a JSON Web Token encoding with the HS256 algorithm.
The plugin reuses Payum in order to retrieve the result of the payment process.
We also have a webhook route for 2 types of Pledg notifications (Standard and Transfer mode). This 2 types are also signed : the first with a custom signature and the second with a JWT.
All the details (parameters, redirection url, pledg result, pledg errors, pledg notifications) are stored in the payment entity.
How to contribute ?
You just have to :
- Retrieve the package
- Launch
make install
to install the database - Launch
make up-d
in order to install the plugin in a dockerized environment with a test application - Launch
make ci
if you want to check if everything works fine - Make a PR and check if the CI is green. Do not forget to upgrade the version number in the CHANGELOG.md and in the Pledg\SyliusPaymentPlugin\RedirectUrl\ParamBuilder.php file.
The plugin does not (yet) use behat. To compensate this, we wrote unit tests with PHPUnit in a classical way.