This plugin allows you to integrate Payplug payment with Sylius platform app including payment features and refunding orders.
In the channel settings, the base currency must be set to EUR because the payment gateway only works in this currency.
In local environment, the plugin will not work properly because you will not be notified of the status of payments from the payment gateway.
You need to make some adjustments in order to make our plugin worked normally due to a dependency to refund-plugin. Please follow those requirements:
To generate "Credit memos" when refunding, your server need to have the WKHTMLTOPDF binary as explain in refund-pluging documentation # Pre-requirements
| Version | |
|---|---|
| PHP | ^8.2 |
| Sylius | ^2.0 |
composer config extra.symfony.allow-contrib true
composer require payplug/sylius-payplug-pluginThe plugin's extension does not prepend its resources.yaml, so the Sylius resource services for the Card and RefundHistory entities are never created. Add them manually in config/packages/sylius_resource.yaml:
sylius_resource:
resources:
payplug.payplug_card:
driver: doctrine/orm
classes:
model: PayPlug\SyliusPayPlugPlugin\Entity\Card
payplug.payplug_refund_history:
driver: doctrine/orm
classes:
model: PayPlug\SyliusPayPlugPlugin\Entity\RefundHistory
repository: PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepositoryThe plugin uses #[Autoconfigure] on some actions and relies on named constructor arguments that Symfony cannot resolve automatically. Add the following to config/services.yaml:
services:
PayPlug\SyliusPayPlugPlugin\Action\CaptureAction:
arguments:
$payplugCardRepository: '@payplug.repository.payplug_card'
PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepositoryInterface:
alias: payplug.repository.payplug_refund_historybin/console doctrine:migrations:migrateparameters:
locale: fr_FR
sylius_refund.supported_gateways:
- payplug
- payplug_oney
- payplug_bancontact
- payplug_apple_pay
- payplug_american_express- App\Entity\Customer\Customer
<?php
declare(strict_types=1);
namespace App\Entity\Customer;
use Doctrine\ORM\Mapping as ORM;
use PayPlug\SyliusPayPlugPlugin\Entity\CardsOwnerInterface;
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait;
use Sylius\Component\Core\Model\Customer as BaseCustomer;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_customer")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_customer')]
class Customer extends BaseCustomer implements CardsOwnerInterface
{
use CustomerTrait;
}- App\Entity\Payment\PaymentMethod
<?php
declare(strict_types=1);
namespace App\Entity\Payment;
use Doctrine\ORM\Mapping as ORM;
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentMethodTrait;
use Sylius\Component\Core\Model\PaymentMethod as BasePaymentMethod;
use Sylius\Component\Payment\Model\PaymentMethodTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_payment_method")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_payment_method')]
class PaymentMethod extends BasePaymentMethod
{
use PaymentMethodTrait;
protected function createTranslation(): PaymentMethodTranslationInterface
{
return new PaymentMethodTranslation();
}
}- App\Entity\Payment\Payment
<?php
declare(strict_types=1);
namespace App\Entity\Payment;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use PayPlug\SyliusPayPlugPlugin\Entity\Traits\PaymentTrait;
use Sylius\Component\Core\Model\Payment as BasePayment;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_payment")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_payment')]
class Payment extends BasePayment
{
use PaymentTrait;
}php bin/console translation:extract en PayPlugSyliusPayPlugPlugin --dump-messages
php bin/console translation:extract fr PayPlugSyliusPayPlugPlugin --dump-messagesbin/console cache:clear🎉 You are now ready to add Payplug Payment method.
In your back-office, go to Configuration > Payment methods, then click on Create and choose "Payplug".
On sylius 2.0.x, there is no automatic load of assets.
You need to add the following lines in assets/shop/controllers.json to allow Sylius to use our assets:
{
"controllers": {
"@payplug/sylius-payplug-plugin": {
"oney-popin": {
"enabled": true,
"fetch": "lazy",
"autoimport": {
"@payplug/sylius-payplug-plugin/shop/dist/oney_common/index.css": true,
"@payplug/sylius-payplug-plugin/shop/dist/oney_popin/index.css": true
}
},
"integrated-payment": {
"enabled": true,
"fetch": "lazy",
"autoimport": {
"@payplug/sylius-payplug-plugin/shop/dist/payment/integrated.css": true
}
},
"oney-payment": {
"enabled": true,
"fetch": "lazy"
},
"payment-logo": {
"enabled": true,
"fetch": "lazy"
},
"checkout-select-payment": {
"enabled": true,
"fetch": "lazy",
"autoimport": {
"@payplug/sylius-payplug-plugin/shop/dist/payment/index.css": true
}
},
"apple-pay": {
"enabled": true,
"fetch": "lazy"
}
}
},
"entrypoints": []
}Note
On Sylius Standard >= 2.1, assets are automatically loaded when you install the plugin with flex. If you are upgrading from a 2.0.x version, read the upgrade guide
If you want to follow the logs in the production environment, you need to add the configuration in config/packages/prod/monolog.yaml, logs should be in var/log/prod.log which can be searched after the phrase [Payum] or [Payplug]:
monolog:
handlers:
...
payum:
level: debug
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"Run the below command to see what Symfony services are shared with this plugin:
$ bin/console debug:container payplug_sylius_payplug_pluginSee How to contribute.
This library is under the MIT license.
For better Oney integration, you can check the Oney enhancement documentation.
Since 1.11.0, the plugin supports the authorized payment feature. You can check the Authorized Payment documentation.