-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpayment_datatrans.install
52 lines (42 loc) · 1.75 KB
/
payment_datatrans.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @file
* Install, update and uninstall functions for the node module.
*/
use Drupal\Component\Utility\SafeMarkup;
/**
* Implements hook_requirements().
*/
function payment_datatrans_requirements($phase) {
$requirements = array();
// Check the server's ability to indicate upload progress.
if ($phase == 'runtime') {
$datatrans_payment_method_configuration = entity_load('payment_method_configuration', 'payment_datatrans');
if (!$datatrans_payment_method_configuration) {
return $requirements;
}
$plugin_configuration = $datatrans_payment_method_configuration->getPluginConfiguration();
if (empty($plugin_configuration['security']) || $plugin_configuration['security']['security_level'] != 2 || empty($plugin_configuration['security']['hmac_key'])) {
if (empty($plugin_configuration['security']['hmac_key'])) {
$value = t('No HMAC key defined');
}
if (empty($plugin_configuration['security']) || $plugin_configuration['security']['security_level'] != 2) {
$value = t('Insecure security level');
}
$severity = REQUIREMENT_ERROR;
}
else {
$value = t('Secure Configuration');
$severity = REQUIREMENT_OK;
}
$edit_link = $datatrans_payment_method_configuration->link(t('Edit Configuration'));
$description = t('You should not work with anything else than security level 2 on a productive system. Without the HMAC key there is no way to check whether the data really comes from Datatrans. @edit_link', array('@edit_link' => $edit_link));
$requirements['payment_datatrans'] = array(
'title' => t('Datatrans Security'),
'value' => $value,
'severity' => $severity,
'description' => $description,
);
}
return $requirements;
}