return civicrm_api3_create_success($contributions, $params, 'Order', 'get');
}
+/**
+ * Adjust Metadata for Get action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_order_get_spec(&$params) {
+ $params['id']['api.aliases'] = ['order_id'];
+ $params['id']['title'] = ts('Contribution / Order ID');
+}
+
/**
* Add or update a Order.
*
* Api result array
*/
function civicrm_api3_order_create(&$params) {
- $contribution = array();
+
$entity = NULL;
$entityIds = array();
if (CRM_Utils_Array::value('line_items', $params) && is_array($params['line_items'])) {
'title' => 'Total Amount',
'api.required' => TRUE,
);
- $params['financial_type_id'] = array(
+ $params['financial_type_id'] = [
'name' => 'financial_type_id',
'title' => 'Financial Type',
'type' => CRM_Utils_Type::T_INT,
'api.required' => TRUE,
- );
+ 'table_name' => 'civicrm_contribution',
+ 'entity' => 'Contribution',
+ 'bao' => 'CRM_Contribute_BAO_Contribution',
+ 'pseudoconstant' => [
+ 'table' => 'civicrm_financial_type',
+ 'keyColumn' => 'id',
+ 'labelColumn' => 'name',
+ ],
+ ];
}
/**
if ($name == 'PrintLabel') {
return 'CRM_Badge_BAO_Layout';
}
+ if ($name === 'Order') {
+ // Order basically maps to contribution at the top level but
+ // has enhanced access to other entities.
+ $name = 'Contribution';
+ }
$dao = _civicrm_api3_get_DAO($name);
if (!$dao) {
return NULL;
'contact_id' => $this->_individualId,
'receive_date' => '2010-01-20',
'total_amount' => 200,
- 'financial_type_id' => $this->_financialTypeId,
+ 'financial_type_id' => 'Event Fee',
'contribution_status_id' => 1,
);
$priceFields = $this->createPriceSet();