You are here

public function CheckoutSdkFactory::get in Commerce PayPal 8

Retrieves the PayPal Checkout SDK for the given config.

Parameters

array $configuration: An associative array, containing at least these three keys:

  • mode: The API mode (e.g "test" or "live").
  • client_id: The client ID.
  • secret: The client secret.

Return value

\Drupal\commerce_paypal\CheckoutSdk The PayPal Checkout SDK.

Overrides CheckoutSdkFactoryInterface::get

File

src/CheckoutSdkFactory.php, line 106

Class

CheckoutSdkFactory
Defines a factory for our custom PayPal checkout SDK.

Namespace

Drupal\commerce_paypal

Code

public function get(array $configuration) {
  $client_id = $configuration['client_id'];
  if (!isset($this->instances[$client_id])) {
    $client = $this
      ->getClient($configuration);
    $this->instances[$client_id] = new CheckoutSdk($client, $this->adjustmentTransformer, $this->eventDispatcher, $this->moduleHandler, $this->time, $configuration);
  }
  return $this->instances[$client_id];
}