commerce_braintree.install in Commerce Braintree 8
Same filename and directory in other branches
Contains install and update functions for Commerce Braintree.
File
commerce_braintree.installView source
<?php
/**
* @file
* Contains install and update functions for Commerce Braintree.
*/
/**
* Implements hook_requirements().
*/
function commerce_braintree_requirements($phase) {
$requirements = [];
if ($phase == 'install') {
if (!class_exists('\\Braintree\\Gateway')) {
$requirements['commerce_braintree_library'] = [
'description' => t('Commerce Braintree requires the braintree/braintree_php library.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
}
/**
* Add 3d_secure setting to gateway configuration.
*/
function commerce_braintree_update_8001() {
$gateway_storage = \Drupal::entityTypeManager()
->getStorage('commerce_payment_gateway');
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface[] $gateways */
$gateways = $gateway_storage
->loadByProperties([
'plugin' => 'braintree_hostedfields',
]);
foreach ($gateways as $gateway) {
$configuration = $gateway
->getPlugin()
->getConfiguration();
$configuration['3d_secure'] = '';
$gateway
->getPlugin()
->setConfiguration($configuration);
$gateway
->save();
}
}
Functions
Name | Description |
---|---|
commerce_braintree_requirements | Implements hook_requirements(). |
commerce_braintree_update_8001 | Add 3d_secure setting to gateway configuration. |