smile / hipay-sylius-plugin
A Symfony plugin for Sylius to add payment method Hipay.
Installs: 118
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 12
Forks: 3
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.4
- ext-json: *
- hipay/hipay-fullservice-sdk-php: ^2.8
- sylius/sylius: ~1.9
- symfony/console: ~4.0||~5.0
- symfony/framework-bundle: ~4.0||~5.0
This package is auto-updated.
Last update: 2022-02-25 10:16:09 UTC
README
➡️ Due to a lack of time that can be given to this project, it is now abandoned but the "beta" code will stay online to help you integrate an Hipay payment method to your project. Please note that the project is still unstable and may have undiscovered vulnerabilities.
This plugin is designed to add a new gateway on Sylius with Payum to support Hipay payment.
Installation
$ composer require smile/hipay-sylius-plugin
Enable it in your application Kernel.
<?php // config/bundles.php return [ //... Smile\HipaySyliusPlugin\SmileHipaySyliusPlugin::class => ['dev' => true, 'test' => true], ];
Import routing
# config/routes.yaml sylius_hipay_routing: resource: "@SmileHipaySyliusPlugin/config/routing.yaml"
Configure your credentials.
In the first node called api
, you must fill in the main account credentials.
In the second node called api_moto
, you must fill in the Mo/To account credentials.
# config/packages/sylius_hipay.yaml sylius_hipay: # The "api" key works for credit cards (as hosted field) but also for paiement 3x/4x api: api_private_username: 'Username for api' api_private_password: 'Password for api' api_secret_passphrase: 'Secret Passphrase for api' stage: 'stage or prod' locale: 'fr' # notify_url: '' # Optional; for development purpose, e.g a link to a requestbin listener. do_refunds: true # The "api_moto" key is a dedicated creddential for Mo/To paiements api_moto: api_private_username: 'Username for api Mo/TO' api_private_password: 'Password for api Mo/TO' api_secret_passphrase: 'Secret Passphrase for api Mo/TO' stage: 'stage or prod' locale: 'fr' # notify_url: '' # Optional; for development purpose, e.g a link to a requestbin listener. do_refunds: true
Configuration
Override twig file
Add block javascripts at the end of file after your others overrides blocks
# templates/bundles/SyliusShopBundle/Order/show.html.twig {% block javascripts %} {{ parent() }} {% include '@SmileHipaySyliusPlugin/Scripts/hipay_scripts.html.twig' %} {% endblock %}
# templates/bundles/SyliusShopBundle/Checkout/selectPayment.html.twig {% block javascripts %} {{ parent() }} {% include '@SmileHipaySyliusPlugin/Scripts/hipay_scripts.html.twig' %} {% endblock %}
And you can override this file to activate the Hipay fields and add restrictions for cartAmount (configured in backoffice)
# templates/bundles/SyliusShopBundle/Checkout/SelectPayment/_choice.html.twig {% set cartAmount = order.total / 100 %} {% set cartAmountMin = method.gatewayConfig.config.cartAmountMin ?? null %} {% set cartAmountMax = method.gatewayConfig.config.cartAmountMax ?? null %} {% if (cartAmountMin is null or cartAmountMin <= cartAmount) and (cartAmountMax is null or cartAmountMax >= cartAmount) %} <div class="item" {{ sylius_test_html_attribute('payment-item') }}> <div class="field"> <div class="ui radio checkbox" {{ sylius_test_html_attribute('payment-method-checkbox') }}> {{ form_widget(form, sylius_test_form_attribute('payment-method-select')) }} </div> </div> <div class="content"> <a class="header">{{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }}</a> {% if method.description is not null %} <div class="description"> <p>{{ method.description }}</p> </div> {% endif %} {{ include('@SmileHipaySyliusPlugin/Payment/hipay_gateways.html.twig') }} {% if method.gatewayConfig.factoryName == 'sylius.pay_pal' %} {{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderPaymentPageButtonsAction', {'orderId': order.id})) }} {% endif %} </div> </div> {% endif %}