From df3b3799337a18ef22e059681ca36784d66f0f1b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 19 Mar 2023 19:55:54 -0400 Subject: [PATCH] PaymentProecssor - Add frontend_title & make title required Clarifies the role of 'title' as "for admins" and adds a new "frontend_title" for end-users. Updates the PaymentProcessor form/dao to use hooks instead of an overloaded "create" function, and only allows the title and frontend_title instead of the name to be entered on the form. The name will be autogenerated from the title in the DAO::writeRecord function. The frontend_title is required in the database but will be filled from `title` if not supplied during `create` Updates tests, sql and sample data with required field --- CRM/Admin/Form/PaymentProcessor.php | 24 +- CRM/Core/DAO.php | 4 +- CRM/Core/I18n/SchemaStructure.php | 10 +- CRM/Core/I18n/SchemaStructure_5_61_alpha1.php | 740 ++++++++++++++++++ CRM/Financial/BAO/PaymentProcessor.php | 120 +-- CRM/Financial/DAO/PaymentProcessor.php | 59 +- CRM/Upgrade/Incremental/php/FiveSixtyOne.php | 9 + .../Incremental/sql/5.61.alpha1.mysql.tpl | 7 + CRM/Utils/Hook.php | 6 +- .../PaymentProcessorCreationSpecProvider.php | 7 + Civi/Core/Event/PostEvent.php | 13 +- .../examples/PaymentProcessor/Create.ex.php | 1 + .../tests/phpunit/CancelTest.php | 2 +- .../phpunit/CRM/Core/Payment/ElavonTest.php | 1 + .../phpunit/CRM/Core/Payment/EwayTest.php | 1 + .../CRM/Core/Payment/PayflowProTest.php | 1 + sql/civicrm_demo_processor.mysql | 4 +- sql/civicrm_devel_config.mysql | 6 +- sql/civicrm_dummy_processor.mysql | 4 +- sql/civicrm_generated.mysql | 8 +- tests/phpunit/CRM/Core/PseudoConstantTest.php | 1 + .../CRM/Extension/Manager/PaymentTest.php | 3 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/api/v3/ContributionTest.php | 1 + tests/phpunit/api/v3/PaymentProcessorTest.php | 3 + xml/schema/Financial/PaymentProcessor.xml | 27 +- 26 files changed, 958 insertions(+), 106 deletions(-) create mode 100644 CRM/Core/I18n/SchemaStructure_5_61_alpha1.php diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index f35eda6afa..046fb6dec2 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -48,12 +48,13 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 'name' => 'payment_processor_type_id', 'required' => TRUE, ], - 'name' => [ - 'name' => 'name', - 'required' => TRUE, - ], 'title' => [ 'name' => 'title', + 'required' => TRUE, + ], + 'frontend_title' => [ + 'name' => 'frontend_title', + 'required' => TRUE, ], 'description' => [ 'name' => 'description', @@ -186,13 +187,6 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_PaymentProcessor'); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Financial_DAO_PaymentProcessor', - $this->_id, - 'name', - CRM_Core_Config::domainID(), - ]); - // @todo - remove this & let the entityForm do it - need to make sure we are handling the js though. $this->add('select', 'payment_processor_type_id', @@ -419,7 +413,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { CRM_Core_Session::singleton()->pushUserContext($this->refreshURL); } else { - CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', [1 => "{$values['name']}"]), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', [1 => "{$values['title']}"]), ts('Saved'), 'success'); } } @@ -467,7 +461,11 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 'accepted_credit_cards' => $creditCards, ], $values); - civicrm_api3('PaymentProcessor', 'create', $params); + $result = civicrm_api4('PaymentProcessor', 'save', [ + 'records' => [$params], + ]); + // Pass autogenerated name back + $values['name'] = $result->single()['name']; } /** diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index e8738fc68a..f1adb67e43 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -974,7 +974,7 @@ class CRM_Core_DAO extends DB_DataObject { CRM_Core_BAO_CustomValueTable::store($record['custom'], static::$_tableName, $instance->$idField, $op); } - \CRM_Utils_Hook::post($op, $entityName, $instance->$idField, $instance); + \CRM_Utils_Hook::post($op, $entityName, $instance->$idField, $instance, $record); return $instance; } @@ -1026,7 +1026,7 @@ class CRM_Core_DAO extends DB_DataObject { // For other operations this hook is passed an incomplete object and hook listeners can load if needed. // But that's not possible with delete because it's gone from the database by the time this hook is called. // So in this case the object has been pre-loaded so hook listeners have access to the complete record. - CRM_Utils_Hook::post('delete', $entityName, $record[$idField], $instance); + CRM_Utils_Hook::post('delete', $entityName, $record[$idField], $instance, $record); return $instance; } diff --git a/CRM/Core/I18n/SchemaStructure.php b/CRM/Core/I18n/SchemaStructure.php index 1303857cc0..f8bd1e27dd 100644 --- a/CRM/Core/I18n/SchemaStructure.php +++ b/CRM/Core/I18n/SchemaStructure.php @@ -117,7 +117,8 @@ class CRM_Core_I18n_SchemaStructure { 'options' => "text COMMENT 'Store comma-delimited list of color, size, etc. options for the product.'", ], 'civicrm_payment_processor' => [ - 'title' => "varchar(127) COMMENT 'Payment Processor Descriptive Name.'", + 'title' => "varchar(255) NOT NULL COMMENT 'Name of processor when shown to CiviCRM administrators.'", + 'frontend_title' => "varchar(255) NOT NULL COMMENT 'Name of processor when shown to users making a payment.'", ], 'civicrm_membership_type' => [ 'name' => "varchar(128) NOT NULL COMMENT 'Name of Membership Type'", @@ -490,7 +491,14 @@ class CRM_Core_I18n_SchemaStructure { ], 'civicrm_payment_processor' => [ 'title' => [ + 'label' => "Backend Title", 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'label' => "Frontend Title", + 'type' => "Text", + 'required' => "true", ], ], 'civicrm_membership_type' => [ diff --git a/CRM/Core/I18n/SchemaStructure_5_61_alpha1.php b/CRM/Core/I18n/SchemaStructure_5_61_alpha1.php new file mode 100644 index 0000000000..1ed39b5169 --- /dev/null +++ b/CRM/Core/I18n/SchemaStructure_5_61_alpha1.php @@ -0,0 +1,740 @@ + [ + 'display_name' => "varchar(64) COMMENT 'Location Type Display Name.'", + ], + 'civicrm_option_group' => [ + 'title' => "varchar(255) COMMENT 'Option Group title.'", + 'description' => "text COMMENT 'Option group description.'", + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => "varchar(64) COMMENT 'label for relationship of contact_a to contact_b.'", + 'label_b_a' => "varchar(64) COMMENT 'Optional label for relationship of contact_b to contact_a.'", + 'description' => "varchar(255) COMMENT 'Optional verbose description of the relationship type.'", + ], + 'civicrm_contact_type' => [ + 'label' => "varchar(64) COMMENT 'localized Name of Contact Type.'", + 'description' => "text COMMENT 'localized Optional verbose description of the type.'", + ], + 'civicrm_batch' => [ + 'title' => "varchar(255) COMMENT 'Friendly Name.'", + 'description' => "text COMMENT 'Description of this batch set.'", + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => "varchar(255) COMMENT 'Title for Premiums section.'", + 'premiums_intro_text' => "text COMMENT 'Displayed in
at top of Premiums section of page. Text and HTML allowed.'", + 'premiums_nothankyou_label' => "varchar(255) COMMENT 'Label displayed for No Thank-you option in premiums block (e.g. No thank you)'", + ], + 'civicrm_membership_status' => [ + 'label' => "varchar(128) COMMENT 'Label for Membership Status'", + ], + 'civicrm_survey' => [ + 'title' => "varchar(255) NOT NULL COMMENT 'Title of the Survey.'", + 'instructions' => "text COMMENT 'Script instructions for volunteers to use for the survey.'", + 'thankyou_title' => "varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).'", + 'thankyou_text' => "text COMMENT 'text and html allowed. displayed above result on success page'", + ], + 'civicrm_participant_status_type' => [ + 'label' => "varchar(255) COMMENT 'localized label for display of this status type'", + ], + 'civicrm_case_type' => [ + 'title' => "varchar(64) NOT NULL COMMENT 'Natural language name for Case Type'", + 'description' => "varchar(255) COMMENT 'Description of the Case Type'", + ], + 'civicrm_tell_friend' => [ + 'title' => "varchar(255)", + 'intro' => "text COMMENT 'Introductory message to contributor or participant displayed on the Tell a Friend form.'", + 'suggested_message' => "text COMMENT 'Suggested message to friends, provided as default on the Tell A Friend form.'", + 'thankyou_title' => "varchar(255) COMMENT 'Text for Tell a Friend thank you page header and HTML title.'", + 'thankyou_text' => "text COMMENT 'Thank you message displayed on success page.'", + ], + 'civicrm_custom_group' => [ + 'title' => "varchar(64) NOT NULL COMMENT 'Friendly Name.'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'", + 'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'", + ], + 'civicrm_custom_field' => [ + 'label' => "varchar(255) NOT NULL COMMENT 'Text for form field label (also friendly name for administering this custom property).'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'", + 'help_post' => "text COMMENT 'Description and/or help text to display after this field.'", + ], + 'civicrm_option_value' => [ + 'label' => "varchar(512) NOT NULL COMMENT 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.'", + 'description' => "text COMMENT 'Optional description.'", + ], + 'civicrm_group' => [ + 'title' => "varchar(255) COMMENT 'Name of Group.'", + 'frontend_title' => "varchar(255) DEFAULT NULL COMMENT 'Alternative public title for this Group.'", + 'frontend_description' => "text DEFAULT NULL COMMENT 'Alternative public description of the group.'", + ], + 'civicrm_contribution_page' => [ + 'title' => "varchar(255) COMMENT 'Contribution Page title. For top of page display'", + 'intro_text' => "text COMMENT 'Text and html allowed. Displayed below title.'", + 'pay_later_text' => "text COMMENT 'The text displayed to the user in the main form'", + 'pay_later_receipt' => "text COMMENT 'The receipt sent to the user instead of the normal receipt text'", + 'initial_amount_label' => "varchar(255) COMMENT 'Initial amount label for partial payment'", + 'initial_amount_help_text' => "text COMMENT 'Initial amount help text for partial payment'", + 'thankyou_title' => "varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).'", + 'thankyou_text' => "text COMMENT 'text and html allowed. displayed above result on success page'", + 'thankyou_footer' => "text COMMENT 'Text and html allowed. displayed at the bottom of the success page. Common usage is to include link(s) to other pages such as tell-a-friend, etc.'", + 'receipt_from_name' => "varchar(255) COMMENT 'FROM email name used for receipts generated by contributions to this contribution page.'", + 'receipt_text' => "text COMMENT 'text to include above standard receipt info on receipt email. emails are text-only, so do not allow html for now'", + 'footer_text' => "text COMMENT 'Text and html allowed. Displayed at the bottom of the first page of the contribution wizard.'", + 'frontend_title' => "varchar(255) DEFAULT NULL COMMENT 'Contribution Page Public title'", + ], + 'civicrm_product' => [ + 'name' => "varchar(255) NOT NULL COMMENT 'Required product/premium name'", + 'description' => "text COMMENT 'Optional description of the product/premium.'", + 'options' => "text COMMENT 'Store comma-delimited list of color, size, etc. options for the product.'", + ], + 'civicrm_payment_processor' => [ + 'title' => "varchar(255) NOT NULL COMMENT 'Name of processor when shown to CiviCRM administrators.'", + 'frontend_title' => "varchar(255) NOT NULL COMMENT 'Name of processor when shown to users making a payment.'", + ], + 'civicrm_membership_type' => [ + 'name' => "varchar(128) NOT NULL COMMENT 'Name of Membership Type'", + 'description' => "varchar(255) COMMENT 'Description of Membership Type'", + ], + 'civicrm_membership_block' => [ + 'new_title' => "varchar(255) COMMENT 'Title to display at top of block'", + 'new_text' => "text COMMENT 'Text to display below title'", + 'renewal_title' => "varchar(255) COMMENT 'Title for renewal'", + 'renewal_text' => "text COMMENT 'Text to display for member renewal'", + ], + 'civicrm_price_set' => [ + 'title' => "varchar(255) NOT NULL COMMENT 'Displayed title for the Price Set.'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'", + 'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'", + ], + 'civicrm_dashboard' => [ + 'label' => "varchar(255) COMMENT 'dashlet title'", + ], + 'civicrm_uf_group' => [ + 'title' => "varchar(64) NOT NULL COMMENT 'Form title.'", + 'frontend_title' => "varchar(64) COMMENT 'Profile Form Public title'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'", + 'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'", + 'cancel_button_text' => "varchar(64) DEFAULT NULL COMMENT 'Custom Text to display on the Cancel button when used in create or edit mode'", + 'submit_button_text' => "varchar(64) DEFAULT NULL COMMENT 'Custom Text to display on the submit button on profile edit/create screens'", + ], + 'civicrm_uf_field' => [ + 'help_post' => "text COMMENT 'Description and/or help text to display after this field.'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'", + 'label' => "varchar(255) NOT NULL COMMENT 'To save label for fields.'", + ], + 'civicrm_price_field' => [ + 'label' => "varchar(255) NOT NULL COMMENT 'Text for form field label (also friendly name for administering this field).'", + 'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'", + 'help_post' => "text COMMENT 'Description and/or help text to display after this field.'", + ], + 'civicrm_price_field_value' => [ + 'label' => "varchar(255) DEFAULT NULL COMMENT 'Price field option label'", + 'description' => "text DEFAULT NULL COMMENT 'Price field option description.'", + 'help_pre' => "text DEFAULT NULL COMMENT 'Price field option pre help text.'", + 'help_post' => "text DEFAULT NULL COMMENT 'Price field option post field help.'", + ], + 'civicrm_pcp_block' => [ + 'link_text' => "varchar(255) DEFAULT NULL COMMENT 'Link text for PCP.'", + ], + 'civicrm_event' => [ + 'title' => "varchar(255) COMMENT 'Event Title (e.g. Fall Fundraiser Dinner)'", + 'summary' => "text COMMENT 'Brief summary of event. Text and html allowed. Displayed on Event Registration form and can be used on other CMS pages which need an event summary.'", + 'description' => "text COMMENT 'Full description of event. Text and html allowed. Displayed on built-in Event Information screens.'", + 'registration_link_text' => "varchar(255) COMMENT 'Text for link to Event Registration form which is displayed on Event Information screen when is_online_registration is true.'", + 'event_full_text' => "text COMMENT 'Message to display on Event Information page and INSTEAD OF Event Registration form if maximum participants are signed up. Can include email address/info about getting on a waiting list, etc. Text and html allowed.'", + 'fee_label' => "varchar(255)", + 'intro_text' => "text COMMENT 'Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'", + 'footer_text' => "text COMMENT 'Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'", + 'confirm_title' => "varchar(255) DEFAULT NULL COMMENT 'Title for Confirmation page.'", + 'confirm_text' => "text COMMENT 'Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'", + 'confirm_footer_text' => "text COMMENT 'Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'", + 'confirm_email_text' => "text COMMENT 'text to include above standard event info on confirmation email. emails are text-only, so do not allow html for now'", + 'confirm_from_name' => "varchar(255) COMMENT 'FROM email name used for confirmation emails.'", + 'thankyou_title' => "varchar(255) DEFAULT NULL COMMENT 'Title for ThankYou page.'", + 'thankyou_text' => "text COMMENT 'ThankYou Text.'", + 'thankyou_footer_text' => "text COMMENT 'Footer message.'", + 'pay_later_text' => "text COMMENT 'The text displayed to the user in the main form'", + 'pay_later_receipt' => "text COMMENT 'The receipt sent to the user instead of the normal receipt text'", + 'initial_amount_label' => "varchar(255) COMMENT 'Initial amount label for partial payment'", + 'initial_amount_help_text' => "text COMMENT 'Initial amount help text for partial payment'", + 'waitlist_text' => "text COMMENT 'Text to display when the event is full, but participants can signup for a waitlist.'", + 'approval_req_text' => "text COMMENT 'Text to display when the approval is required to complete registration for an event.'", + 'template_title' => "varchar(255) COMMENT 'Event Template Title'", + ], + ]; + } + return $result; + } + + /** + * Get a table indexed array of the indices for translatable fields. + * + * @return array + * Indices for translatable fields. + */ + public static function &indices() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ + 'name' => 'UI_title_extends', + 'field' => [ + 'title', + 'extends', + ], + 'unique' => 1, + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ + 'name' => 'UI_label_custom_group_id', + 'field' => [ + 'label', + 'custom_group_id', + ], + 'unique' => 1, + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ + 'name' => 'UI_title', + 'field' => [ + 'title', + ], + 'unique' => 1, + ], + ], + ]; + } + return $result; + } + + /** + * Get tables with translatable fields. + * + * @return array + * Array of names of tables with fields that can be translated. + */ + public static function &tables() { + static $result = NULL; + if (!$result) { + $result = array_keys(self::columns()); + } + return $result; + } + + /** + * Get a list of widgets for editing translatable fields. + * + * @return array + * Array of the widgets for editing translatable fields. + */ + public static function &widgets() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_location_type' => [ + 'display_name' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_group' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => [ + 'type' => "Text", + ], + 'label_b_a' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_contact_type' => [ + 'label' => [ + 'label' => "Label", + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_batch' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => [ + 'type' => "Text", + ], + 'premiums_intro_text' => [ + 'type' => "Text", + ], + 'premiums_nothankyou_label' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_status' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_survey' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'instructions' => [ + 'type' => "TextArea", + 'rows' => "20", + 'cols' => "80", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_participant_status_type' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_case_type' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_tell_friend' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro' => [ + 'type' => "Text", + ], + 'suggested_message' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_custom_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_custom_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'help_post' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_value' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_group' => [ + 'title' => [ + 'type' => "Text", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + 'frontend_description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_contribution_page' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'label' => "Initial Amount Label", + ], + 'initial_amount_help_text' => [ + 'label' => "Initial Amount Help Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'thankyou_footer' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'receipt_from_name' => [ + 'type' => "Text", + ], + 'receipt_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + ], + 'civicrm_product' => [ + 'name' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + 'options' => [ + 'type' => "Text", + ], + ], + 'civicrm_payment_processor' => [ + 'title' => [ + 'label' => "Backend Title", + 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'label' => "Frontend Title", + 'type' => "Text", + 'required' => "true", + ], + ], + 'civicrm_membership_type' => [ + 'name' => [ + 'type' => "Text", + 'label' => "Name", + 'required' => "true", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + 'label' => "Description", + ], + ], + 'civicrm_membership_block' => [ + 'new_title' => [ + 'type' => "Text", + ], + 'new_text' => [ + 'type' => "Text", + ], + 'renewal_title' => [ + 'type' => "Text", + ], + 'renewal_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_price_set' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_dashboard' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + 'label' => "Pre Help", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'cancel_button_text' => [ + 'type' => "Text", + ], + 'submit_button_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_field' => [ + 'help_post' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + ], + 'civicrm_price_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_price_field_value' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + 'label' => "Description", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + 'label' => "Pre Help", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + 'label' => "Post Help", + ], + ], + 'civicrm_pcp_block' => [ + 'link_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_event' => [ + 'title' => [ + 'label' => "Title", + 'type' => "Text", + ], + 'summary' => [ + 'label' => "Summary", + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'description' => [ + 'label' => "Description", + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'registration_link_text' => [ + 'type' => "Text", + ], + 'event_full_text' => [ + 'label' => "Event Full Message", + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'fee_label' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_title' => [ + 'type' => "Text", + ], + 'confirm_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_email_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "50", + ], + 'confirm_from_name' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'thankyou_footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "RichTextEditor", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'waitlist_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + 'label' => "Waitlist Text", + ], + 'approval_req_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + 'label' => "Approval Required Text", + ], + 'template_title' => [ + 'type' => "Text", + ], + ], + ]; + } + return $result; + } + +} diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index d15066d9ce..b81495ec07 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -26,67 +26,14 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces public static $_defaultPaymentProcessor = NULL; /** - * Create Payment Processor. + * @deprecated * * @param array $params - * Parameters for Processor entity. * * @return CRM_Financial_DAO_PaymentProcessor - * - * @throws \CRM_Core_Exception */ public static function create(array $params): CRM_Financial_DAO_PaymentProcessor { - // If we are creating a new PaymentProcessor and have not specified the payment instrument to use, get the default from the Payment Processor Type. - if (empty($params['id']) && empty($params['payment_instrument_id'])) { - $params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', [ - 'id' => $params['payment_processor_type_id'], - 'return' => 'payment_instrument_id', - ]); - } - $processor = new CRM_Financial_DAO_PaymentProcessor(); - $processor->copyValues($params); - - if (empty($params['id'])) { - $ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType(); - $ppTypeDAO->id = $params['payment_processor_type_id']; - if (!$ppTypeDAO->find(TRUE)) { - throw new CRM_Core_Exception(ts('Could not find payment processor meta information')); - } - - // also copy meta fields from the info DAO - $processor->is_recur = $ppTypeDAO->is_recur; - $processor->billing_mode = $ppTypeDAO->billing_mode; - $processor->class_name = $ppTypeDAO->class_name; - $processor->payment_type = $ppTypeDAO->payment_type; - } - - $processor->save(); - // CRM-11826, add entry in civicrm_entity_financial_account - // if financial_account_id is not NULL - if (!empty($params['financial_account_id'])) { - $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); - $values = [ - 'entity_table' => 'civicrm_payment_processor', - 'entity_id' => $processor->id, - 'account_relationship' => $relationTypeId, - 'financial_account_id' => $params['financial_account_id'], - ]; - CRM_Financial_BAO_EntityFinancialAccount::add($values); - } - - if (isset($params['id']) && isset($params['is_active']) && !isset($params['is_test'])) { - // check if is_active has changed & if so update test instance is_active too. - $test_id = self::getTestProcessorId($params['id']); - $testDAO = new CRM_Financial_DAO_PaymentProcessor(); - $testDAO->id = $test_id; - if ($testDAO->find(TRUE)) { - $testDAO->is_active = $params['is_active']; - $testDAO->save(); - } - } - - Civi\Payment\System::singleton()->flushProcessors(); - return $processor; + return self::writeRecord($params); } /** @@ -184,20 +131,79 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces static::deleteRecord(['id' => $paymentProcessorID]); } + /** + * Callback for hook_civicrm_pre(). + * @param \Civi\Core\Event\PreEvent $event + */ + public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) { + if ($event->action === 'create') { + // If we are creating a new PaymentProcessor and have not specified the payment instrument to use, get the default from the Payment Processor Type. + if (empty($event->params['payment_instrument_id'])) { + $event->params['payment_instrument_id'] = civicrm_api3('PaymentProcessorType', 'getvalue', [ + 'id' => $event->params['payment_processor_type_id'], + 'return' => 'payment_instrument_id', + ]); + } + // Supply defaults for `title` and `frontend_title` + if (!isset($event->params['title'])) { + $event->params['title'] = $event->params['name']; + } + if (!isset($event->params['frontend_title'])) { + $event->params['frontend_title'] = $event->params['title']; + } + + // also copy meta fields from the ppType DAO + $ppTypeDAO = new CRM_Financial_DAO_PaymentProcessorType(); + $ppTypeDAO->id = $event->params['payment_processor_type_id']; + if (!$ppTypeDAO->find(TRUE)) { + throw new CRM_Core_Exception(ts('Could not find payment processor meta information')); + } + $event->params['is_recur'] = $ppTypeDAO->is_recur; + $event->params['billing_mode'] = $ppTypeDAO->billing_mode; + $event->params['class_name'] = $ppTypeDAO->class_name; + $event->params['payment_type'] = $ppTypeDAO->payment_type; + } + } + /** * Callback for hook_civicrm_post(). * @param \Civi\Core\Event\PostEvent $event */ public static function self_hook_civicrm_post(\Civi\Core\Event\PostEvent $event) { + if ($event->action === 'create' || $event->action === 'edit') { + // CRM-11826, add entry in civicrm_entity_financial_account + // if financial_account_id is not NULL + if (!empty($event->params['financial_account_id'])) { + $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); + $values = [ + 'entity_table' => 'civicrm_payment_processor', + 'entity_id' => $event->id, + 'account_relationship' => $relationTypeId, + 'financial_account_id' => $event->params['financial_account_id'], + ]; + CRM_Financial_BAO_EntityFinancialAccount::add($values); + } + } + if ($event->action === 'edit') { + // check if is_active has changed & if so update test instance is_active too. + if (isset($event->object->is_active) && empty($event->object->is_test)) { + $test_id = self::getTestProcessorId($event->id); + $testDAO = new CRM_Financial_DAO_PaymentProcessor(); + $testDAO->id = $test_id; + if ($testDAO->find(TRUE)) { + $testDAO->is_active = $event->object->is_active; + $testDAO->save(); + } + } + } if ($event->action === 'delete') { // When a paymentProcessor is deleted, delete the associated test processor $testDAO = new CRM_Financial_DAO_PaymentProcessor(); $testDAO->name = $event->object->name; $testDAO->is_test = 1; $testDAO->delete(); - - Civi\Payment\System::singleton()->flushProcessors(); } + Civi\Payment\System::singleton()->flushProcessors(); } /** diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 9e1bb694fa..f2ccc2ff79 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Financial/PaymentProcessor.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:ab188763651019a650ed4e4a7d212efe) + * (GenCodeChecksum:beafb7d7c0f62e3e4ba0367d7b7f58af) */ /** @@ -70,23 +70,32 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { /** * Payment Processor Name. * - * @var string|null + * @var string * (SQL type: varchar(64)) * Note that values will be retrieved from the database as a string. */ public $name; /** - * Payment Processor Descriptive Name. + * Name of processor when shown to CiviCRM administrators. * - * @var string|null - * (SQL type: varchar(127)) + * @var string + * (SQL type: varchar(255)) * Note that values will be retrieved from the database as a string. */ public $title; /** - * Payment Processor Description. + * Name of processor when shown to users making a payment. + * + * @var string + * (SQL type: varchar(255)) + * Note that values will be retrieved from the database as a string. + */ + public $frontend_title; + + /** + * Additional processor information shown to administrators. * * @var string|null * (SQL type: varchar(255)) @@ -332,8 +341,9 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'name' => [ 'name' => 'name', 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Payment Processor'), + 'title' => ts('Payment Processor Name'), 'description' => ts('Payment Processor Name.'), + 'required' => TRUE, 'maxlength' => 64, 'size' => CRM_Utils_Type::BIG, 'usage' => [ @@ -349,6 +359,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Text', + 'label' => ts("Machine Name"), ], 'add' => '1.8', ], @@ -356,8 +367,9 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'name' => 'title', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Payment Processor Title'), - 'description' => ts('Payment Processor Descriptive Name.'), - 'maxlength' => 127, + 'description' => ts('Name of processor when shown to CiviCRM administrators.'), + 'required' => TRUE, + 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'usage' => [ 'import' => FALSE, @@ -372,14 +384,40 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'localizable' => 1, 'html' => [ 'type' => 'Text', + 'label' => ts("Backend Title"), ], 'add' => '5.13', ], + 'frontend_title' => [ + 'name' => 'frontend_title', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Payment Processor Frontend Title'), + 'description' => ts('Name of processor when shown to users making a payment.'), + 'required' => TRUE, + 'maxlength' => 255, + 'size' => CRM_Utils_Type::HUGE, + 'usage' => [ + 'import' => FALSE, + 'export' => FALSE, + 'duplicate_matching' => FALSE, + 'token' => FALSE, + ], + 'where' => 'civicrm_payment_processor.frontend_title', + 'table_name' => 'civicrm_payment_processor', + 'entity' => 'PaymentProcessor', + 'bao' => 'CRM_Financial_BAO_PaymentProcessor', + 'localizable' => 1, + 'html' => [ + 'type' => 'Text', + 'label' => ts("Frontend Title"), + ], + 'add' => '5.61', + ], 'description' => [ 'name' => 'description', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Processor Description'), - 'description' => ts('Payment Processor Description.'), + 'description' => ts('Additional processor information shown to administrators.'), 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'usage' => [ @@ -395,6 +433,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { 'localizable' => 0, 'html' => [ 'type' => 'Text', + 'label' => ts("Description"), ], 'add' => '1.8', ], diff --git a/CRM/Upgrade/Incremental/php/FiveSixtyOne.php b/CRM/Upgrade/Incremental/php/FiveSixtyOne.php index 6b0233144a..6769e552ea 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixtyOne.php +++ b/CRM/Upgrade/Incremental/php/FiveSixtyOne.php @@ -48,7 +48,16 @@ class CRM_Upgrade_Incremental_php_FiveSixtyOne extends CRM_Upgrade_Incremental_B * The version number matching this function name */ public function upgrade_5_61_alpha1($rev): void { + // First add `frontend_title` column *without* NOT NULL constraint + $this->addTask('Add frontend_title to civicrm_payment_processor', 'addColumn', + 'civicrm_payment_processor', 'frontend_title', "varchar(255) COMMENT 'Name of processor when shown to users making a payment.'", TRUE, '5.61.alpha1' + ); + // Sql contains updates to fill paymentProcessor title & frontend_title $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Make PaymentProcessor.name required', 'alterColumn', 'civicrm_payment_processor', 'name', "varchar(64) NOT NULL COMMENT 'Payment Processor Name.'"); + $this->addTask('Make PaymentProcessor.title required', 'alterColumn', 'civicrm_payment_processor', 'title', "varchar(255) NOT NULL COMMENT 'Name of processor when shown to CiviCRM administrators.'", TRUE); + $this->addTask('Make PaymentProcessor.frontend_title required', 'alterColumn', 'civicrm_payment_processor', 'frontend_title', "varchar(255) NOT NULL COMMENT 'Name of processor when shown to users making a payment.'", TRUE); + $this->addTask(ts('Dedupe cache table'), 'dedupeCache'); $this->addTask(ts('Drop index %1', [1 => 'civicrm_cache.UI_group_path_date']), 'dropIndex', 'civicrm_cache', 'UI_group_path_date'); $this->addTask(ts('Create index %1', [1 => 'civicrm_cache.UI_group_name_path']), 'addIndex', 'civicrm_cache', [['group_name', 'path']], 'UI'); diff --git a/CRM/Upgrade/Incremental/sql/5.61.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.61.alpha1.mysql.tpl index 0bdc349b8c..20001eae56 100644 --- a/CRM/Upgrade/Incremental/sql/5.61.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.61.alpha1.mysql.tpl @@ -1 +1,8 @@ {* file to handle db changes in 5.61.alpha1 during upgrade *} + +{* https://github.com/civicrm/civicrm-core/pull/25873 *} +UPDATE civicrm_payment_processor + SET {localize field="frontend_title,title"}frontend_title = COALESCE(title, name){/localize}; + +UPDATE civicrm_payment_processor + SET {localize field="title"}title = name{/localize}; diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index f6ad4278cf..b15ff620c7 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -359,13 +359,15 @@ abstract class CRM_Utils_Hook { * The unique identifier for the object. * @param object $objectRef * The reference to the object if available. + * @param array $params + * Original params used, if available * * @return mixed * based on op. pre-hooks return a boolean or * an error message which aborts the operation */ - public static function post($op, $objectName, $objectId, &$objectRef = NULL) { - $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef); + public static function post($op, $objectName, $objectId, &$objectRef = NULL, $params = NULL) { + $event = new \Civi\Core\Event\PostEvent($op, $objectName, $objectId, $objectRef, $params); Civi::dispatcher()->dispatch('hook_civicrm_post', $event); return $event->getReturnValues(); } diff --git a/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php b/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php index 9e11858ce0..5a592e5f7a 100644 --- a/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php +++ b/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php @@ -25,6 +25,13 @@ class PaymentProcessorCreationSpecProvider extends \Civi\Core\Service\AutoServic * @inheritDoc */ public function modifySpec(RequestSpec $spec) { + // Name is autogenerated from title if missing + $spec->getFieldByName('name')->setRequired(FALSE)->setRequiredIf('empty($values.title)'); + // Title is supplied from name if missing + $spec->getFieldByName('title')->setRequired(FALSE)->setRequiredIf('empty($values.name)'); + // Frontend_title is copied from title if missing + $spec->getFieldByName('frontend_title')->setRequired(FALSE); + // Billing mode is copied across from the payment processor type field in the BAO::create function. $spec->getFieldByName('billing_mode')->setRequired(FALSE); diff --git a/Civi/Core/Event/PostEvent.php b/Civi/Core/Event/PostEvent.php index f3885af444..d620ded7dc 100644 --- a/Civi/Core/Event/PostEvent.php +++ b/Civi/Core/Event/PostEvent.php @@ -35,10 +35,15 @@ class PostEvent extends GenericHookEvent { public $id; /** - * @var Object + * @var CRM_Core_DAO */ public $object; + /** + * @var array + */ + public $params; + /** * Class constructor * @@ -46,19 +51,21 @@ class PostEvent extends GenericHookEvent { * @param string $entity * @param int $id * @param object $object + * @param array $params */ - public function __construct($action, $entity, $id, &$object) { + public function __construct($action, $entity, $id, &$object, $params = NULL) { $this->action = $action; $this->entity = $entity; $this->id = $id; $this->object = &$object; + $this->params = $params; } /** * @inheritDoc */ public function getHookValues() { - return [$this->action, $this->entity, $this->id, &$this->object]; + return [$this->action, $this->entity, $this->id, &$this->object, $this->params]; } } diff --git a/api/v3/examples/PaymentProcessor/Create.ex.php b/api/v3/examples/PaymentProcessor/Create.ex.php index c06083e0cf..84862dfc11 100644 --- a/api/v3/examples/PaymentProcessor/Create.ex.php +++ b/api/v3/examples/PaymentProcessor/Create.ex.php @@ -13,6 +13,7 @@ function payment_processor_create_example() { $params = [ 'name' => 'API Test PP', + 'title' => 'API Test PP', 'payment_processor_type_id' => 1, 'class_name' => 'CRM_Core_Payment_APITest', 'is_recur' => 0, diff --git a/ext/contributioncancelactions/tests/phpunit/CancelTest.php b/ext/contributioncancelactions/tests/phpunit/CancelTest.php index 6ae6113080..39b199c898 100644 --- a/ext/contributioncancelactions/tests/phpunit/CancelTest.php +++ b/ext/contributioncancelactions/tests/phpunit/CancelTest.php @@ -182,7 +182,7 @@ class CancelTest extends TestCase implements HeadlessInterface, HookInterface, T */ public function createPaymentProcessor(array $params = []): int { $params = array_merge([ - 'name' => 'demo', + 'title' => $params['name'] ?? 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'PayPal', 'is_active' => 1, diff --git a/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php b/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php index 76ca53526e..cdaf061aeb 100644 --- a/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php +++ b/ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php @@ -114,6 +114,7 @@ class CRM_Core_Payment_ElavonTest extends \PHPUnit\Framework\TestCase implements public function setUpElavonProcessor(): void { $params = [ 'name' => 'demo', + 'title' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'Elavon', 'is_active' => 1, diff --git a/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php b/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php index f22c9bcda2..c2a0b8860a 100644 --- a/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php +++ b/ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php @@ -140,6 +140,7 @@ class CRM_Core_Payment_EwayTest extends \PHPUnit\Framework\TestCase implements H public function setUpEwayProcessor(): void { $params = [ 'name' => 'demo', + 'title' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'eWAY', 'is_active' => 1, diff --git a/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php b/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php index dd5a889138..6326cbd98f 100644 --- a/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php +++ b/ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php @@ -175,6 +175,7 @@ class CRM_Core_Payment_PayflowProTest extends \PHPUnit\Framework\TestCase implem $this->callAPISuccess('PaymentProcessorType', 'create', ['id' => $paymentProcessorType['id'], 'is_active' => 1]); $params = [ 'name' => 'demo', + 'title' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'PayflowPro', 'is_active' => 1, diff --git a/sql/civicrm_demo_processor.mysql b/sql/civicrm_demo_processor.mysql index 5d29499e27..5661f27d71 100644 --- a/sql/civicrm_demo_processor.mysql +++ b/sql/civicrm_demo_processor.mysql @@ -12,8 +12,8 @@ SELECT @ppTypeID := id FROM civicrm_payment_processor_type WHERE name = 'PayPal'; -INSERT INTO `civicrm_payment_processor` (`id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `domain_id`) VALUES (3, 'PP Pro', '', @ppTypeID, 1, 1, 0, 'xxx', 'yyy', 'zzz', 'https://www.paypal.com/', 'https://api-3t.paypal.com/', NULL, 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', NULL, 'Payment_PayPalImpl', 3, 1, 1); -INSERT INTO `civicrm_payment_processor` (`id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `domain_id`) VALUES (4, 'PP Pro', '', @ppTypeID, 1, 0, 1, 'dave_api1.northtower.com', 'S5YW42RS7WRWT9AD', 'AUsrQDMAfRs6zQSEYuw3M4QDuTBHAAvpXf7N0jYi8G1UCfKRI2NrvWVM', 'https://www.sandbox.paypal.com/', 'https://api-3t.sandbox.paypal.com/', NULL, 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', NULL, 'Payment_PayPalImpl', 3, 1, 1); +INSERT INTO `civicrm_payment_processor` (`id`, `name`, `frontend_title`, `title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `domain_id`) VALUES (3, 'PP Pro', 'PP Pro', 'PP Pro', '', @ppTypeID, 1, 1, 0, 'xxx', 'yyy', 'zzz', 'https://www.paypal.com/', 'https://api-3t.paypal.com/', NULL, 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', NULL, 'Payment_PayPalImpl', 3, 1, 1); +INSERT INTO `civicrm_payment_processor` (`id`, `name`, `frontend_title`, `title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `domain_id`) VALUES (4, 'PP Pro', 'PP Pro', 'PP Pro', '', @ppTypeID, 1, 0, 1, 'dave_api1.northtower.com', 'S5YW42RS7WRWT9AD', 'AUsrQDMAfRs6zQSEYuw3M4QDuTBHAAvpXf7N0jYi8G1UCfKRI2NrvWVM', 'https://www.sandbox.paypal.com/', 'https://api-3t.sandbox.paypal.com/', NULL, 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', NULL, 'Payment_PayPalImpl', 3, 1, 1); SET @pp := LAST_INSERT_ID(); diff --git a/sql/civicrm_devel_config.mysql b/sql/civicrm_devel_config.mysql index 1ef35a516f..4b038ac4ff 100644 --- a/sql/civicrm_devel_config.mysql +++ b/sql/civicrm_devel_config.mysql @@ -8,8 +8,8 @@ SELECT @domainId := MAX(id) FROM civicrm_domain; INSERT INTO civicrm_payment_processor - (domain_id, name, payment_processor_type, is_active, is_default, is_test, user_name, class_name, billing_mode) VALUES - (@domainId, 'dummy', 'Dummy', 1, 1, 0, 'dummy', 'Payment_Dummy', 1), - (@domainId, 'dummy', 'Dummy', 1, 0, 1, 'dummy', 'Payment_Dummy', 1); + (domain_id, name, title, frontend_title, payment_processor_type, is_active, is_default, is_test, user_name, class_name, billing_mode) VALUES + (@domainId, 'dummy', 'Dummy', 'Dummy', 'Dummy', 1, 1, 0, 'dummy', 'Payment_Dummy', 1), + (@domainId, 'dummy', 'Dummy', 'Dummy', 'Dummy', 1, 0, 1, 'dummy', 'Payment_Dummy', 1); UPDATE civicrm_preferences SET mailing_backend = 'a:4:{s:15:\"outBound_option\";s:1:\"0\";s:10:\"smtpServer\";s:9:\"localhost\";s:8:\"smtpPort\";s:2:\"25\";s:8:\"smtpAuth\";s:1:\"0\";}'; diff --git a/sql/civicrm_dummy_processor.mysql b/sql/civicrm_dummy_processor.mysql index fed3c452bc..5a69f6a6dc 100644 --- a/sql/civicrm_dummy_processor.mysql +++ b/sql/civicrm_dummy_processor.mysql @@ -1,7 +1,7 @@ SELECT @pptype := id FROM civicrm_payment_processor_type WHERE name='Dummy'; -INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES (1, 'Test Processor', '', @pptype, 1, 1, 0, 'dummy', NULL, NULL, 'http://dummy.com', NULL, 'http://dummyrecur.com', NULL, NULL, 'Payment_Dummy', 1, 1, 1); -INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES (1, 'Test Processor', '', @pptype, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Payment_Dummy', 1, 1, 1); +INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `title`, `frontend_title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES (1, 'Test Processor', 'Test Processor', 'Test Processor', '', @pptype, 1, 1, 0, 'dummy', NULL, NULL, 'http://dummy.com', NULL, 'http://dummyrecur.com', NULL, NULL, 'Payment_Dummy', 1, 1, 1); +INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `title`, `frontend_title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES (1, 'Test Processor', 'Test Processor', 'Test Processor', '', @pptype, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Payment_Dummy', 1, 1, 1); SELECT @dp := max(id) from civicrm_payment_processor where name = 'Test Processor' AND is_test = 0; SELECT @dpTest := max(id) from civicrm_payment_processor where name = 'Test Processor' AND is_test = 1; diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index d20812ebab..18db6bcced 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -12665,10 +12665,10 @@ DROP TABLE IF EXISTS `civicrm_value_donor_information_3`; CREATE TABLE IF NOT EXISTS `civicrm_value_donor_information_3` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Default MySQL primary key', `entity_id` int(10) unsigned NOT NULL COMMENT 'Table that this extends', `known_areas_of_interest_5` text COLLATE utf8mb4_unicode_ci, `how_long_have_you_been_a_donor_6` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_entity_id` (`entity_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; SELECT @pptype := id FROM civicrm_payment_processor_type WHERE name='Dummy'; -INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES - (1, 'Test Processor', '', @pptype, 1, 1, 0, 'dummy', NULL, NULL, 'http://dummy.com', NULL, 'http://dummyrecur.com', NULL, NULL, 'Payment_Dummy', 1, 1, 1); -INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES - (1, 'Test Processor', '', @pptype, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Payment_Dummy', 1, 1, 1); +INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `title`, `frontend_title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES + (1, 'Test Processor', 'Test Processor', 'Test Processor', '', @pptype, 1, 1, 0, 'dummy', NULL, NULL, 'http://dummy.com', NULL, 'http://dummyrecur.com', NULL, NULL, 'Payment_Dummy', 1, 1, 1); +INSERT INTO `civicrm_payment_processor` (`domain_id`, `name`, `title`, `frontend_title`, `description`, `payment_processor_type_id`, `is_active`, `is_default`, `is_test`, `user_name`, `password`, `signature`, `url_site`, `url_api`, `url_recur`, `url_button`, `subject`, `class_name`, `billing_mode`, `is_recur`, `payment_type`) VALUES + (1, 'Test Processor', 'Test Processor', 'Test Processor', '', @pptype, 1, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Payment_Dummy', 1, 1, 1); SELECT @dp := max(id) from civicrm_payment_processor where name = 'Test Processor' AND is_test = 0; SELECT @dpTest := max(id) from civicrm_payment_processor where name = 'Test Processor' AND is_test = 1; diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 967c1340fd..f2e0f52607 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -73,6 +73,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'domain_id' => 1, 'payment_processor_type_id' => 'Dummy', 'name' => $pp_name, + 'title' => $pp_name, 'user_name' => $pp_name, 'class_name' => 'Payment_Dummy', 'url_site' => 'https://test.com/', diff --git a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php index d965f225d9..c33d569269 100644 --- a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php +++ b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php @@ -94,7 +94,8 @@ class CRM_Extension_Manager_PaymentTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest" AND is_active = 1'); $payment_processor_type_id = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"'); - $ppDAO = CRM_Financial_BAO_PaymentProcessor::create([ + $ppDAO = CRM_Financial_BAO_PaymentProcessor::writeRecord([ + 'title' => __FUNCTION__, 'payment_processor_type_id' => $payment_processor_type_id, 'domain_id' => CRM_Core_Config::domainID(), ]); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index e90decf50d..690fee8ba6 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2288,7 +2288,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { */ public function paymentProcessorCreate($params = []) { $params = array_merge([ - 'name' => 'demo', + 'title' => $params['name'] ?? 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type_id' => 'PayPal', 'is_active' => 1, diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 72ad346b42..456c6e686d 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -88,6 +88,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->_processorParams = [ 'domain_id' => 1, 'name' => 'Dummy', + 'title' => 'Dummy', 'payment_processor_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', 'Dummy'), 'financial_account_id' => 12, 'is_active' => 1, diff --git a/tests/phpunit/api/v3/PaymentProcessorTest.php b/tests/phpunit/api/v3/PaymentProcessorTest.php index 1d8859a867..3caf5fdd9b 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTest.php @@ -39,6 +39,7 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { $this->_paymentProcessorType = $result['id']; $this->_params = [ 'name' => 'API Test PP', + 'title' => 'API Test PP', 'payment_processor_type_id' => $this->_paymentProcessorType, 'class_name' => 'CRM_Core_Payment_APITest', 'is_recur' => 0, @@ -104,6 +105,8 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase { 'id' => $result['id'], 'domain_id' => $params['domain_id'], 'name' => $updateParams['name'], + 'title' => $params['title'], + 'frontend_title' => $params['title'], 'payment_processor_type_id' => $params['payment_processor_type_id'], 'is_default' => 0, 'is_test' => 0, diff --git a/xml/schema/Financial/PaymentProcessor.xml b/xml/schema/Financial/PaymentProcessor.xml index 40bd71868a..244995fab2 100644 --- a/xml/schema/Financial/PaymentProcessor.xml +++ b/xml/schema/Financial/PaymentProcessor.xml @@ -50,36 +50,55 @@ name - Payment Processor + Payment Processor Name + true varchar 64 Payment Processor Name. 1.8 + Text title Payment Processor Title + true varchar - 127 + 255 true + Text - Payment Processor Descriptive Name. + Name of processor when shown to CiviCRM administrators. 5.13 + + frontend_title + Payment Processor Frontend Title + true + varchar + 255 + true + + + Text + + Name of processor when shown to users making a payment. + 5.61 + description Processor Description varchar 255 + Text - Payment Processor Description. + Additional processor information shown to administrators. 1.8 -- 2.25.1