Skip to content
Snippets Groups Projects
Commit e87adb97 authored by mattwire's avatar mattwire
Browse files

Add Payment_details custom group and allow custom fields to be saved via Mjwpayment.create

parent 1129c8ce
Branches
Tags
1 merge request!40Support for Stripe 6.9 release
......@@ -183,21 +183,28 @@ function civicrm_api3_mjwpayment_create_payment($params) {
}
}
}
if (!empty($params['payment_processor'])) {
// I can't find evidence this is passed in - I was gonna just remove it but decided to deprecate as I see getToFinancialAccount
// also anticipates it.
CRM_Core_Error::deprecatedFunctionWarning('passing payment_processor is deprecated - use payment_processor_id');
$params['payment_processor_id'] = $params['payment_processor'];
}
// Check if it is an update
if (!empty($params['id'])) {
$amount = $params['total_amount'];
civicrm_api3('Payment', 'cancel', $params);
$params['total_amount'] = $amount;
}
$trxn = CRM_Financial_BAO_Payment::create($params);
$customFields = \Civi\Api4\CustomField::get(FALSE)
->addWhere('custom_group_id:name', '=', 'Payment_details')
->execute()
->indexBy('name');
foreach ($customFields as $key => $value) {
if (isset($params[$key])) {
$customParams['custom_' . $value['id']] = $params[$key];
}
}
if (!empty($customParams)) {
$customParams['entity_id'] = $trxn->id;
civicrm_api3('CustomValue', 'create', $customParams);
}
$values = [];
_civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
return civicrm_api3_create_success($values, $params, 'Payment', 'create', $trxn);
......
<?php
use CRM_Mjwshared_ExtensionUtil as E;
// This enables custom fields for Grant entities
return [
[
'name' => 'cg_extend_objects:FinancialTrxn',
'entity' => 'OptionValue',
'cleanup' => 'always',
'update' => 'always',
'params' => [
'version' => 4,
'values' => [
'option_group_id.name' => 'cg_extend_objects',
'label' => E::ts('Financial Transaction (Payment)'),
'value' => 'FinancialTrxn',
'name' => 'civicrm_financial_trxn',
'is_reserved' => TRUE,
'is_active' => TRUE,
],
],
],
[
'name' => 'CustomGroup_Payment_details',
'entity' => 'CustomGroup',
'cleanup' => 'never',
'update' => 'always',
'params' => [
'version' => 4,
'values' => [
'name' => 'Payment_details',
'title' => E::ts('Payment details'),
'extends' => 'FinancialTrxn',
'extends_entity_column_id' => NULL,
'extends_entity_column_value' => NULL,
'style' => 'Inline',
'collapse_display' => FALSE,
'help_pre' => E::ts(''),
'help_post' => E::ts(''),
'weight' => 30,
'is_active' => TRUE,
'is_multiple' => FALSE,
'min_multiple' => NULL,
'max_multiple' => NULL,
'collapse_adv_display' => TRUE,
'is_reserved' => FALSE,
'is_public' => TRUE,
'icon' => '',
],
'match' => [
'name',
],
],
],
];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment