function mollie_payment_get_client in Mollie Payment 7.2
Same name and namespace in other branches
- 7 mollie_payment.module \mollie_payment_get_client()
Initialize Mollie API client.
7 calls to mollie_payment_get_client()
- MolliePaymentMethodController::execute in includes/
mollie_payment.class.inc - Implements PaymentMethodController::execute().
- mollie_payment_configuration in ./
mollie_payment.module - Payment method configuration form elements callback.
- mollie_payment_listener in ./
mollie_payment.module - Listener callback.
- mollie_payment_payment_recurring_can_stop in ./
mollie_payment.module - Implements hook_payment_recurring_can_OPERATION() for stop.
- mollie_payment_payment_recurring_stop in ./
mollie_payment.module - Implements hook_payment_recurring_OPERATION() for stop.
File
- ./
mollie_payment.module, line 769 - Provides Mollie integration for the Payment platform.
Code
function mollie_payment_get_client(Payment $payment = NULL) {
$api_key = mollie_payment_get_api_key($payment);
try {
if (!libraries_load('mollie-api-php')) {
throw new Exception('Could not load Mollie API Library.');
}
$client = new \Mollie\Api\MollieApiClient();
$client
->setApiKey($api_key);
// Set organization access token if applicable.
if (is_null($payment)) {
$token = variable_get('mollie_payment_default_access_token', '');
if (!empty($token)) {
$client
->setAccessToken($token);
}
}
// Register major version of Drupal.
$client
->addVersionString('Drupal/7.x');
// Register minor version of Drupal.
$client
->addVersionString('Drupal/' . VERSION);
return $client;
} catch (Exception $e) {
watchdog('mollie_payment', $e
->getMessage(), array(), WATCHDOG_ERROR);
return FALSE;
}
}