X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FContribution.php;h=00aa5ccbdb78f79c026ee22f1c3adb8ad69a59ce;hb=11a1ad01c57740352bf558e9ac326ef341fde5bb;hp=1f393bbaae800ff3673e3b1374b8b5ec57f2d8d6;hpb=b8416fbb0b2292d8b1390b970816415251d6a256;p=civicrm-core.git diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 1f393bbaae..00aa5ccbdb 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -1,7 +1,7 @@ $params['id'], + 'return' => 'financial_type_id', + )); + } + $op = 'edit'; + } + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op); + if (!in_array($params['financial_type_id'], array_keys($types))) { + return civicrm_api3_create_error('You do not have permission to create this contribution'); + } + } if (!empty($params['id']) && !empty($params['contribution_status_id'])) { $error = array(); //throw error for invalid status change such as setting completed back to pending @@ -183,6 +201,15 @@ function _civicrm_api3_contribution_create_legacy_support_45(&$params) { function civicrm_api3_contribution_delete($params) { $contributionID = !empty($params['contribution_id']) ? $params['contribution_id'] : $params['id']; + // First check contribution financial type + $financialType = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionID, 'financial_type_id'); + // Now check permissioned lineitems & permissioned contribution + if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() + && !CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($financialType)) || + !CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributionID, 'delete', FALSE) + ) { + return civicrm_api3_create_error('You do not have permission to delete this contribution'); + } if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionID)) { return civicrm_api3_create_success(array($contributionID => 1)); } @@ -427,6 +454,9 @@ function civicrm_api3_contribution_completetransaction(&$params) { throw new API_Exception(ts('Contribution already completed'), 'contribution_completed'); } $input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id; + if (!empty($params['fee_amount'])) { + $input['fee_amount'] = $params['fee_amount']; + } $params = _ipn_process_transaction($params, $contribution, $input, $ids); } @@ -460,12 +490,21 @@ function _civicrm_api3_contribution_completetransaction_spec(&$params) { 'description' => '. If not provided this will default to domain mail or contribution page', 'type' => CRM_Utils_Type::T_STRING, ); - $params['payment_processor_id'] = array( 'title' => 'Payment processor ID', - 'description' => '. Providing this is strongly recommended, as not possible to calculate it accurately always', + 'description' => 'Providing this is strongly recommended, as not possible to calculate it accurately always', 'type' => CRM_Utils_Type::T_INT, ); + $params['fee_amount'] = array( + 'title' => 'Fee charged on transaction', + 'description' => 'If a fee has been charged then the amount', + 'type' => CRM_Utils_Type::T_FLOAT, + ); + $params['trxn_date'] = array( + 'title' => 'Transaction Date', + 'description' => 'Date this transaction occurred', + 'type' => CRM_Utils_Type::T_DATE, + ); } /** @@ -541,6 +580,9 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC if (isset($params['is_email_receipt'])) { $input['is_email_receipt'] = $params['is_email_receipt']; } + if (!empty($params['trxn_date'])) { + $input['trxn_date'] = $params['trxn_date']; + } if (empty($contribution->contribution_page_id)) { static $domainFromName; static $domainFromEmail;