You are here

protected function Stripe::init in Commerce Stripe 8

Initializes the SDK.

2 calls to Stripe::init()
Stripe::__construct in src/Plugin/Commerce/PaymentGateway/Stripe.php
Constructs a new PaymentGatewayBase object.
Stripe::__wakeup in src/Plugin/Commerce/PaymentGateway/Stripe.php
Re-initializes the SDK after the plugin is unserialized.

File

src/Plugin/Commerce/PaymentGateway/Stripe.php, line 114

Class

Stripe
Provides the Stripe payment gateway.

Namespace

Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway

Code

protected function init() {
  $extension_info = $this->moduleExtensionList
    ->getExtensionInfo('commerce_stripe');
  $version = !empty($extension_info['version']) ? $extension_info['version'] : '8.x-1.0-dev';
  StripeLibrary::setAppInfo('Centarro Commerce for Drupal', $version, 'https://www.drupal.org/project/commerce_stripe', 'pp_partner_Fa3jTqCJqTDtHD');

  // If Drupal is configured to use a proxy for outgoing requests, make sure
  // that the proxy CURLOPT_PROXY setting is passed to the Stripe SDK client.
  $http_client_config = Settings::get('http_client_config');
  if (!empty($http_client_config['proxy']['https'])) {
    $curl = new CurlClient([
      CURLOPT_PROXY => $http_client_config['proxy']['https'],
    ]);
    ApiRequestor::setHttpClient($curl);
  }
  StripeLibrary::setApiKey($this->configuration['secret_key']);
  StripeLibrary::setApiVersion('2019-12-03');
}