Payolution - Installation and Configuration
  • Updated on 23 Jan 2020
  • 2 minutes to read
  • Print
  • Share
  • Dark
    Light

Payolution - Installation and Configuration

  • Print
  • Share
  • Dark
    Light

To integrate Payolution into your project, first you need to install and configure the CrefoPay module. This topic describes how to do that.

Installation

To install the Payolution module, run:

composer require spryker-eco/payolution

Configuration

Please refer to config/config.dist.php for example of module configuration.

To set up the initial Payolution configuration, use the credentials you received after registering your Payolution merchant account:

$config[PayolutionConstants::TRANSACTION_GATEWAY_URL] = '';
$config[PayolutionConstants::CALCULATION_GATEWAY_URL] = '';
$config[PayolutionConstants::TRANSACTION_SECURITY_SENDER] = '';
$config[PayolutionConstants::TRANSACTION_USER_LOGIN] = '';
$config[PayolutionConstants::TRANSACTION_USER_PASSWORD] = '';
$config[PayolutionConstants::CALCULATION_SENDER] = '';
$config[PayolutionConstants::CALCULATION_USER_LOGIN] = '';
$config[PayolutionConstants::CALCULATION_USER_PASSWORD] = '';
$config[PayolutionConstants::TRANSACTION_CHANNEL_PRE_CHECK] = '';
$config[PayolutionConstants::TRANSACTION_CHANNEL_INVOICE] = '';
$config[PayolutionConstants::TRANSACTION_CHANNEL_INSTALLMENT] = '';
$config[PayolutionConstants::CALCULATION_CHANNEL] = '';

Next, specify modes and order limits:

$config[PayolutionConstants::TRANSACTION_MODE] = 'CONNECTOR_TEST';
$config[PayolutionConstants::CALCULATION_MODE] = 'TEST';
$config[PayolutionConstants::MIN_ORDER_GRAND_TOTAL_INVOICE] = '500';
$config[PayolutionConstants::MAX_ORDER_GRAND_TOTAL_INVOICE] = '500000';
$config[PayolutionConstants::MIN_ORDER_GRAND_TOTAL_INSTALLMENT] = '500';
$config[PayolutionConstants::MAX_ORDER_GRAND_TOTAL_INSTALLMENT] = '500000';

Checkout Configuration

To use Payolution in frontend, add Payolution payment method handlers and subform to Pyz/Yves/Checkout/CheckoutDependencyProvider.php

 $container[static::PAYMENT_METHOD_HANDLER] = function () {
 $paymentHandlerPlugins = new StepHandlerPluginCollection();

 $paymentHandlerPlugins->add(new PayolutionHandlerPlugin(), PaymentTransfer::PAYOLUTION_INVOICE);
 $paymentHandlerPlugins->add(new PayolutionHandlerPlugin(), PaymentTransfer::PAYOLUTION_INSTALLMENT);

 return $paymentHandlerPlugins;
 };

 $container[static::PAYMENT_SUB_FORMS] = function () {
 $paymentSubFormPlugins = new SubFormPluginCollection();

 $paymentSubFormPlugins->add(new PayolutionInstallmentSubFormPlugin());
 $paymentSubFormPlugins->add(new PayolutionInvoiceSubFormPlugin());

 return $paymentSubFormPlugins;
 };

All subform and handler plugins are located in SprykerEco\Yves\Payolution\Plugin\ namespace.

OMS Configuration

Activate the following Payolution process:

$config[OmsConstants::ACTIVE_PROCESSES][] ='PayolutionInstalmentPayment01',
$config[OmsConstants::ACTIVE_PROCESSES][] ='PayolutionInvoicePayment01',

Default implementation for commands and options should be added to Pyz/Zed/Oms/OmsDependencyProvider.php

Commands:

$container->extend(OmsDependencyProvider::COMMAND_PLUGINS, function (CommandCollectionInterface $commandCollection) {
    $commandCollection
        ->add(new PreAuthorizePlugin(), 'Payolution/PreAuthorize')
        ->add(new ReAuthorizePlugin(), 'Payolution/ReAuthorize')
        ->add(new RevertPlugin(), 'Payolution/Revert')
        ->add(new CapturePlugin(), 'Payolution/Capture')
        ->add(new RefundPlugin(), 'Payolution/Refund');

    return $commandCollection;
});

Conditions:

$container->extend(OmsDependencyProvider::CONDITION_PLUGINS, function (ConditionCollectionInterface $conditionCollection) {
    $conditionCollection
        ->add(new IsPreAuthorizationApprovedPlugin(), 'Payolution/IsPreAuthorizationApproved')
        ->add(new IsReAuthorizationApprovedPlugin(), 'Payolution/IsReAuthorizationApproved')
        ->add(new IsReversalApprovedPlugin(), 'Payolution/IsReversalApproved')
        ->add(new IsCaptureApprovedPlugin(), 'Payolution/IsCaptureApproved')
        ->add(new IsRefundApprovedPlugin(), 'Payolution/IsRefundApproved');

    return $conditionCollection;
});

All commands and conditions are located in SprykerEco\Zed\Payolution\Communication\Plugin\Oms\ namespace.

Payment Configuration

Default implementation for checkout payment plugins should be added to Pyz/Zed/Payment/PaymentDependencyProvider.php

 $container->extend(static::CHECKOUT_PLUGINS, function (CheckoutPluginCollection $pluginCollection) {
 $pluginCollection
 ->add(new PayolutionPreCheckPlugin(), PayolutionConfig::PROVIDER_NAME, static::CHECKOUT_PRE_CHECK_PLUGINS)
 ->add(new PayolutionSaveOrderPlugin(), PayolutionConfig::PROVIDER_NAME, static::CHECKOUT_ORDER_SAVER_PLUGINS)
 ->add(new PayolutionPostCheckPlugin(), PayolutionConfig::PROVIDER_NAME, static::CHECKOUT_POST_SAVE_PLUGINS);

 return $pluginCollection;
 });

All payment plugins are located in SprykerEco\Zed\Payolution\Communication\Plugin\Checkout\ namespace.

Frontend Integration

To show Payolution on Frontend, extend the payment view:

src/Pyz/Yves/CheckoutPage/Theme/default/views/payment/payment.twig
{% extends template('page-layout-checkout', 'CheckoutPage') %}

{% define data = {
   backUrl: _view.previousStepUrl,
   forms: {
       payment: _view.paymentForm
   },
   title: 'checkout.step.payment.title' | trans,
   customForms: {}
} %}

{% block content %}
   {% embed molecule('form') with {
       class: 'box',
       data: {
           form: data.forms.payment,
           options: {
               attr: {
                   id: 'payment-form'
               }
           },
           submit: {
               enable: true,
               text: 'checkout.step.summary' | trans
           },
           cancel: {
               enable: true,
               url: data.backUrl,
               text: 'general.back.button' | trans
           },
           customForms: data.customForms
       }
   } only %}
       {% block fieldset %}
           {% for name, choices in data.form.paymentSelection.vars.choices %}
               {% set paymentProviderIndex = loop.index0 %}
               <h5>{{ ('checkout.payment.provider.' ~ name) | trans }}</h5>
               <ul>
                   {% for key, choice in choices %}
                       <li class="list__item spacing-y clear">
                           {% embed molecule('form') with {
                               data: {
                                   form: data.form[data.form.paymentSelection[key].vars.value],
                                   enableStart: false,
                                   enableEnd: false,
                                   customForms: data.customForms
                               },
                               embed: {
                                   index: loop.index ~ '-' ~ paymentProviderIndex,
                                   toggler: data.form.paymentSelection[key]
                               }
                           } only %}
                               {% block fieldset %}
                                   {{ form_row(embed.toggler, {
                                       required: false,
                                       component: molecule('toggler-radio'),
                                       attributes: {
                                           'target-class-name': 'js-payment-method-' ~ embed.index,
                                       }
                                   }) }}
                                   {% set templateName = data.form.vars.template_path | replace('/', '-') %}
                                   {% set viewName = data.form.vars.template_path | split('/') %}

                                   <div class="col col--sm-12 is-hidden js-payment-method-{{embed.index}}">
                                       <div class="col col--sm-12 col--md-6">
                                           {% if 'Payolution' in data.form.vars.template_path %}
                                               {% include view(viewName[1], viewName[0]) with {
                                                   form: data.form.parent
                                               } only %}
                                           {% else %}
                                               {{ parent() }}
                                           {% endif %}
                                       </div>
                                   </div>
                               {% endblock %}
                           {% endembed %}
                       </li>
                   {% endfor %}
               </ul>
           {% endfor %}
       {% endblock %}
   {% endembed %}
{% endblock %}


Was this article helpful?