You are here

public function Mollie::__construct in Commerce Mollie 8

Constructs a new PaymentGatewayBase object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\commerce_payment\PaymentTypeManager $payment_type_manager: The payment type manager.

\Drupal\commerce_payment\PaymentMethodTypeManager $payment_method_type_manager: The payment method type manager.

\Drupal\Component\Datetime\TimeInterface $time: The time.

\Drupal\commerce_price\MinorUnitsConverterInterface $minor_units_converter: The minor units converter.

Overrides PaymentGatewayBase::__construct

File

src/Plugin/Commerce/PaymentGateway/Mollie.php, line 49

Class

Mollie
Provides the Mollie payment gateway.

Namespace

Drupal\commerce_mollie\Plugin\Commerce\PaymentGateway

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PaymentTypeManager $payment_type_manager, PaymentMethodTypeManager $payment_method_type_manager, TimeInterface $time) {
  parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $payment_type_manager, $payment_method_type_manager, $time);

  // MollieAPIClient should be setup in the payment_method?
  $this->api = Drupal::service('commerce_mollie.mollie.api');

  // Initialize api_key.
  try {
    if (!empty($configuration['api_key_live']) && $configuration['api_key_live'] !== $this
      ->defaultConfiguration()['api_key_live'] && $configuration['mode'] === 'live') {
      $this->api
        ->setApiKey($configuration['api_key_live']);
    }
    elseif (!empty($configuration['api_key_test']) && $configuration['api_key_test'] !== $this
      ->defaultConfiguration()['api_key_test'] && $configuration['mode'] === 'test') {
      $this->api
        ->setApiKey($configuration['api_key_test']);
    }
  } catch (MollieApiException $e) {
    ErrorHelper::handleException($e);
  }
}