Giter VIP home page Giter VIP logo

syliuspayplugplugin's Introduction

License CI Version Total Downloads

PayPlug payment plugin for Sylius

This plugin allows you to integrate PayPlug payment with Sylius platform app including payment features and refunding orders.

Requirements

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.

⚠️ Refunds requirements

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

Compatibility

Version
PHP 7.4, 8.0
Sylius 1.9, 1.10

Installation

  1. Require the payplug/sylius-payplug-plugin :

    composer config extra.symfony.allow-contrib true
    composer require payplug/sylius-payplug-plugin
  2. Apply migrations to your database:

    bin/console doctrine:migrations:migrate
  3. Copy templates that are overridden by Sylius into templates/bundles/SyliusAdminBundle

    mkdir -p templates/bundles/SyliusAdminBundle/
    cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
  4. Add PayPlug to refundable payment method for Sylius Refund Plugin in config/services.yaml

    parameters:
        sylius_refund.supported_gateways:
            - payplug
            - payplug_oney
  5. Add PayPlug routes in config/routes.yaml

    sylius_payplug:
       resource: "@PayPlugSyliusPayPlugPlugin/Resources/config/routing.yaml"
  6. Add Traits for Customer and PaymentMethod entities

  • App\Entity\Customer\Customer

    <?php
    
    declare(strict_types=1);
    
    namespace App\Entity\Customer;
    
    use Doctrine\ORM\Mapping as ORM;
    use PayPlug\SyliusPayPlugPlugin\Entity\Traits\CustomerTrait;
    use Sylius\Component\Core\Model\Customer as BaseCustomer;
    
    /**
    * @ORM\Entity
    * @ORM\Table(name="sylius_customer")
    */
    class Customer extends BaseCustomer
    {
       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")
     */
    class PaymentMethod extends BasePaymentMethod
    {
        use PaymentMethodTrait;
    
        protected function createTranslation(): PaymentMethodTranslationInterface
        {
            return new PaymentMethodTranslation();
        }
    }
  1. Process translations

    php bin/console translation:update en PayPlugSyliusPayPlugPlugin --dump-messages
    php bin/console translation:update fr PayPlugSyliusPayPlugPlugin --dump-messages
  2. Clear cache:

    php bin/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".

Logs

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"

Customization

Available services you can decorate and forms you can extend

Run the below command to see what Symfony services are shared with this plugin:

$ bin/console debug:container payplug_sylius_payplug_plugin

Template overriding

This plugin override some sylius templates. If you plan override them also, you should retrieve them in your application.

Copy Sylius templates overridden in plugin to your templates directory (e.g templates/bundles/)

mkdir -p templates/bundles/SyliusAdminBundle/
mkdir -p templates/bundles/SyliusShopBundle/
mkdir -p templates/bundles/SyliusUiBundle/
cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusShopBundle/* templates/bundles/SyliusShopBundle/
cp -R vendor/payplug/sylius-payplug-plugin/src/Resources/views/SyliusUiBundle/* templates/bundles/SyliusUiBundle/

You also need to edit your twig config to add your path to avoid our configuration to be prepended :

twig:
  paths:
    '%kernel.project_dir%/templates/bundles/SyliusAdminBundle': SyliusAdmin
    '%kernel.project_dir%/templates/bundles/SyliusShopBundle': SyliusShop
    '%kernel.project_dir%/templates/bundles/SyliusUiBundle': SyliusUi

Development

See How to contribute.

License

This library is under the MIT license.

Oney Integration

For better Oney integration, you can check the Oney enhancement documentation.

Doc

syliuspayplugplugin's People

Watchers

 avatar

Forkers

tuyetrinhvo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.