-
Notifications
You must be signed in to change notification settings - Fork 45
/
omnipaymultiprocessor.php
93 lines (81 loc) · 2.83 KB
/
omnipaymultiprocessor.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
require_once 'omnipaymultiprocessor.civix.php';
use CRM_Omnipaymultiprocessor_ExtensionUtil as E;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use \Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Implements hook_civicrm_container()
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_container/
*/
function omnipaymultiprocessor_civicrm_container(ContainerBuilder $container) {
$container->addCompilerPass(new Civi\OmnipayMultiProcessor\ActionProvider\CompilerPass(), PassConfig::TYPE_OPTIMIZE);
}
/**
* Implementation of hook_civicrm_config
*
* @param $config
*/
function omnipaymultiprocessor_civicrm_config($config) {
_omnipaymultiprocessor_civix_civicrm_config($config);
$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
$include_path = $extRoot . DIRECTORY_SEPARATOR . 'vendor' . PATH_SEPARATOR . get_include_path( );
set_include_path( $include_path );
require_once 'vendor/autoload.php';
}
/**
* Implementation of hook_civicrm_install
*/
function omnipaymultiprocessor_civicrm_install() {
_omnipaymultiprocessor_civix_civicrm_install();
}
/**
* Implementation of hook_civicrm_enable
*/
function omnipaymultiprocessor_civicrm_enable() {
_omnipaymultiprocessor_civix_civicrm_enable();
}
/**
* @param string $entity
* @param string $action
* @param array $params
* @param array $permissions
*/
function omnipaymultiprocessor_civicrm_alterAPIPermissions(string $entity, $action, $params, &$permissions) {
$permissions['payment_processor']['preapprove'] = ['make online contributions'];
}
/**
* Implements hook_alterMenu().
*
* @param array $items
*/
function omnipaymultiprocessor_civicrm_alterMenu(&$items) {
$items['civicrm/ajax/rest']['page_callback'] = ['CRM_Utils_RestPreapprove', 'ajax'];
$items['civicrm/ajax/rest']['access_arguments'][0][] = 'make online contributions';
}
function omnipaymultiprocessor_civicrm_navigationMenu(&$menu) {
_omnipaymultiprocessor_civix_insert_navigation_menu($menu, 'Administer/System Settings', [
'label' => E::ts('Omnipay Developer Settings'),
'name' => 'omnpay-dev',
'url' => 'civicrm/settings/omnipay-dev',
'permission' => 'administer payment processors',
]);
}
function omnipaymultiprocessor_civicrm_preProcess($formName, $form) {
if ($formName === 'CRM_Contribute_Form_Contribution_Main') {
$form->assign('isJsValidate', TRUE);
if (!empty($form->_values['is_recur'])) {
$recurOptions = [
'is_recur_interval' => $form->_values['is_recur_interval'],
'frequency_unit' => $form->_values['recur_frequency_unit'],
'is_recur_installments' => $form->_values['is_recur_installments'],
];
if (!$recurOptions['is_recur_interval']) {
$recurOptions['frequency_interval'] = 1;
}
CRM_Core_Resources::singleton()->addVars(
'omnipay', $recurOptions
);
}
}
}