public function StripeGateway::prepareApi in Ubercart Stripe 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/Ubercart/PaymentMethod/StripeGateway.php \Drupal\uc_stripe\Plugin\Ubercart\PaymentMethod\StripeGateway::prepareApi()
Utility function: Load stripe API
Return value
bool
1 call to StripeGateway::prepareApi()
- StripeGateway::chargeCard in src/
Plugin/ Ubercart/ PaymentMethod/ StripeGateway.php - Called when a credit card should be processed.
File
- src/
Plugin/ Ubercart/ PaymentMethod/ StripeGateway.php, line 351
Class
- StripeGateway
- Stripe Ubercart gateway payment method.
Namespace
Drupal\uc_stripe\Plugin\Ubercart\PaymentMethodCode
public function prepareApi() {
// Not clear that this is useful since payment config form forces at least some config
if (!_uc_stripe_check_api_keys($this
->getConfiguration())) {
\Drupal::logger('uc_stripe')
->error('Stripe API keys are not configured. Payments cannot be made without them.', array());
return FALSE;
}
$secret_key = $this->configuration['testmode'] ? $this->configuration['test_secret_key'] : $this->configuration['live_secret_key'];
try {
\Stripe\Stripe::setApiKey($secret_key);
} catch (Exception $e) {
\Drupal::logger('uc_stripe')
->notice('Error setting the Stripe API Key. Payments will not be processed: %error', array(
'%error' => $e
->getMessage(),
));
}
return TRUE;
}