-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcommerce_stripe.install
executable file
·59 lines (55 loc) · 1.88 KB
/
commerce_stripe.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
53
54
55
56
57
58
59
<?php
/**
* @file
* Contains requirements function for Commerce Stripe.
*/
/**
* Implements hook_requirements().
*/
function commerce_stripe_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$t = get_t();
// Check for the Stripe PHP library.
if (file_exists(libraries_get_path('stripe-php') . '/lib/Stripe.php')) {
$requirements['commerce_stripe_php'] = array(
'value' => $t('Installed'),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['commerce_stripe_php'] = array(
'value' => $t('Missing!'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Stripe library missing. Download the Stripe library from <a href="@url">https://github.com/stripe/stripe-php</a> and place it in to sites/all/libraries/stripe-php', array('@url' => 'https://github.com/stripe/stripe-php')),
);
}
$requirements['commerce_stripe_php']['title'] = $t('Stripe PHP library');
// Check for Commerce currency.
if (in_array(commerce_default_currency(), array('USD', 'CAD', 'EUR', 'GBP', 'AUD', 'CHF'))) {
$requirements['commerce_stripe_currency'] = array(
'value' => $t('Valid currency'),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['commerce_stripe_currency'] = array(
'value' => $t('Invalid default currency!'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Stripe currently supports only USD, CAD, EUR, GBP, AUD and CHF as a currency.'),
);
}
$requirements['commerce_stripe_currency']['title'] = $t('Stripe currency check');
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function commerce_stripe_uninstall() {
// Uninstall rules configuration.
$config = rules_config_load('commerce_payment_commerce_stripe');
if ($config) {
rules_config_delete(array($config->id));
}
}