Skip to content
Snippets Groups Projects
Select Git revision
  • 4.0.0-beta2
  • 3.x default
  • 4.x
  • paywall_support
  • 3373359
  • 8.x-2.x
  • 8.x-1.x
  • 7.x-1.x
  • 4.0.0-beta3
  • 3.1.2
  • 3.1.1
  • 4.0.0-beta1
  • 4.0.0-alpha1
  • 3.1.0
  • 3.0.0
  • 3.0.0-beta2
  • 3.0.0-beta1
  • 3.0.0-alpha6
  • 3.0.0-alpha5
  • 3.0.0-alpha4
  • 3.0.0-alpha3
  • 3.0.0-alpha2
  • 3.0.0-alpha1
  • 8.x-2.4
  • 8.x-2.3
  • 8.x-2.2
  • 8.x-2.1
27 results

commerce_paytrail

  • Clone with SSH
  • Clone with HTTPS
  • Commerce paytrail

    CI coverage

    This module integrates Paytrail payment method with Drupal Commerce.

    Installation

    Install the Commerce paytrail module as you would normally install a contributed Drupal module. Visit https://www.drupal.org/node/1897420 for further information.

    Configuration

    1. Configure the Commerce Paytrail gateway from the Administration > Commerce > Configuration > Payment Gateways (/admin/commerce/config/payment-gateways), by editing an existing or adding a new payment gateway.
    2. Select Paytrail or Paytrail (Credit card) for the payment gateway plugin.
      • Mode: enables the Paytrail payment gateway in test or live mode.
      • Account: provide your Paytrail account.
      • Secret: provide your Paytrail secret.
      • Order discount strategy: Choose the order discount strategy.
    3. Click Save to save your configuration.

    Documentation

    Alter Paytrail API requests/responses

    Create an event subscriber that responds to \Drupal\commerce_paytrail\Event\ModelEvent::class events:

    
    class YourEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface {
    
      /**
       * Event callback.
       *
       * @param \Drupal\commerce_paytrail\Event\ModelEvent $event
       *   The event.
       */
      public function processEvent(ModelEvent $event): void {
        // See below for all available events.
        if ($event->event === \Drupal\commerce_paytrail\RequestBuilder\PaymentRequestBuilderInterface::PAYMENT_CREATE_EVENT) {
          // Do something based on event name.
        }
      }
    
      /**
       * {@inheritdoc}
       */
      public static function getSubscribedEvents() : array {
        return [
          ModelEvent::class => ['processEvent'],
        ];
      }
    }

    See https://www.drupal.org/docs/develop/creating-modules/subscribe-to-and-dispatch-events for more information about events.

    Available events

    Prevent saved payment method from being deleted

    /**
     * Implements hook_entity_predelete().
     */
    function hook_entity_predelete(\Drupal\Core\Entity\EntityInterface $entity) : void {
      if (condition) {
        throw new \Drupal\commerce_payment\Exception\PaymentGatewayException('Card cannot be deleted').
      }
    }

    Maintainers