* Array of financial transactions which are payments, if error an array with an error id and error message
*/
function civicrm_api3_payment_get($params) {
- if (!CRM_Core_Permission::check('access CiviContribute')) {
- throw new API_Exception('You do not have permission to access this api');
- }
$financialTrxn = array();
$limit = '';
if (isset($params['options']) && CRM_Utils_Array::value('limit', $params['options'])) {
* Api result array
*/
function civicrm_api3_payment_delete(&$params) {
- if (!(CRM_Core_Permission::check('access CiviContribute') && CRM_Core_Permission::check('delete in CiviContribute'))) {
- throw new API_Exception('You do not have permission to access this api');
- }
return civicrm_api3('FinancialTrxn', 'delete', $params);
}
* Api result array
*/
function civicrm_api3_payment_cancel(&$params) {
- if (!(CRM_Core_Permission::check('access CiviContribute') && CRM_Core_Permission::check('edit contributions'))) {
- throw new API_Exception('You do not have permission to access this api');
- }
$eftParams = array(
'entity_table' => 'civicrm_contribution',
'financial_trxn_id' => $params['id'],
* Api result array
*/
function civicrm_api3_payment_create(&$params) {
- if (!(CRM_Core_Permission::check('access CiviContribute') && CRM_Core_Permission::check('edit contributions'))) {
- throw new API_Exception('You do not have permission to access this api');
- }
// Check if it is an update
if (CRM_Utils_Array::value('id', $params)) {
$amount = $params['total_amount'];
$this->_apiversion = 3;
$this->_individualId = $this->individualCreate();
- $config = CRM_Core_Config::singleton();
- $config->userPermissionClass->permissions = array();
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array();
}
/**
public function tearDown() {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(array('civicrm_uf_match'));
- $config = CRM_Core_Config::singleton();
- unset($config->userPermissionClass->permissions);
+ unset(CRM_Core_Config::singleton()->userPermissionClass->permissions);
}
/**
'contribution_id' => $contribution['id'],
'check_permissions' => TRUE,
);
- CRM_Core_Config::singleton()->userPermissionClass->permissions = array('administer CiviCRM');
- $payment = $this->callAPIFailure('payment', 'get', $params);
- $this->assertEquals('You do not have permission to access this api', $payment['error_message']);
+ CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'administer CiviCRM');
+ $payment = $this->callAPIFailure('payment', 'get', $params, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and access CiviContribute');
array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviContribute');
'id' => $payment['id'],
'check_permissions' => TRUE,
);
- $payment = $this->callAPIFailure('payment', 'cancel', $cancelParams);
- $this->assertEquals('You do not have permission to access this api', $payment['error_message']);
+ $payment = $this->callAPIFailure('payment', 'cancel', $cancelParams, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and edit contributions');
- array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'edit contributions');
+ array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviCRM', 'edit contributions');
$this->callAPIAndDocument('payment', 'cancel', $cancelParams, __FUNCTION__, __FILE__);
'id' => $payment['id'],
'check_permissions' => TRUE,
);
- $payment = $this->callAPIFailure('payment', 'delete', $deleteParams);
- $this->assertEquals('You do not have permission to access this api', $payment['error_message']);
+ $payment = $this->callAPIFailure('payment', 'delete', $deleteParams, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and delete in CiviContribute');
- array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'delete in CiviContribute');
+ array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviCRM', 'delete in CiviContribute');
$this->callAPIAndDocument('payment', 'delete', $deleteParams, __FUNCTION__, __FILE__);
$payment = $this->callAPIAndDocument('payment', 'get', $params, __FUNCTION__, __FILE__);
'id' => $payment['id'],
'check_permissions' => TRUE,
);
- $payment = $this->callAPIFailure('payment', 'create', $params);
- $this->assertEquals('You do not have permission to access this api', $payment['error_message']);
+ $payment = $this->callAPIFailure('payment', 'create', $params, 'API permission check failed for Payment/get call; insufficient permission: require access CiviCRM and edit contributions');
- array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'edit contributions');
+ array_push(CRM_Core_Config::singleton()->userPermissionClass->permissions, 'access CiviCRM', 'edit contributions');
$payment = $this->callAPIAndDocument('payment', 'create', $params, __FUNCTION__, __FILE__);
$params = array(