PaymentProecssor - Add frontend_title & make title required
authorColeman Watts <coleman@civicrm.org>
Sun, 19 Mar 2023 23:55:54 +0000 (19:55 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 28 Mar 2023 18:26:33 +0000 (14:26 -0400)
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

26 files changed:
CRM/Admin/Form/PaymentProcessor.php
CRM/Core/DAO.php
CRM/Core/I18n/SchemaStructure.php
CRM/Core/I18n/SchemaStructure_5_61_alpha1.php [new file with mode: 0644]
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/DAO/PaymentProcessor.php
CRM/Upgrade/Incremental/php/FiveSixtyOne.php
CRM/Upgrade/Incremental/sql/5.61.alpha1.mysql.tpl
CRM/Utils/Hook.php
Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php
Civi/Core/Event/PostEvent.php
api/v3/examples/PaymentProcessor/Create.ex.php
ext/contributioncancelactions/tests/phpunit/CancelTest.php
ext/elavon/tests/phpunit/CRM/Core/Payment/ElavonTest.php
ext/ewaysingle/tests/phpunit/CRM/Core/Payment/EwayTest.php
ext/payflowpro/tests/phpunit/CRM/Core/Payment/PayflowProTest.php
sql/civicrm_demo_processor.mysql
sql/civicrm_devel_config.mysql
sql/civicrm_dummy_processor.mysql
sql/civicrm_generated.mysql
tests/phpunit/CRM/Core/PseudoConstantTest.php
tests/phpunit/CRM/Extension/Manager/PaymentTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/PaymentProcessorTest.php
xml/schema/Financial/PaymentProcessor.xml

index f35eda6afa4e1a85439cf2dbea37f0490bc0b9d4..046fb6dec218b887f2a44a2a6a020942aacc81cd 100644 (file)
@@ -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 => "<em>{$values['name']}</em>"]), ts('Saved'), 'success');
+      CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', [1 => "<em>{$values['title']}</em>"]), 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'];
   }
 
   /**
index e8738fc68abae07e41a28c88b5e2de0b5a51fe7a..f1adb67e43939eca2d542dab5ecffd8645b11577 100644 (file)
@@ -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;
   }
index 1303857cc07bbdf23562c1e189e22f70e7adf541..f8bd1e27dd07f5bf49fc671a9309f1e110c09ead 100644 (file)
@@ -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 (file)
index 0000000..1ed39b5
--- /dev/null
@@ -0,0 +1,740 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ *
+ * Generated from schema_structure.tpl
+ * DO NOT EDIT.  Generated by CRM_Core_CodeGen
+ */
+class CRM_Core_I18n_SchemaStructure_5_61_alpha1 {
+
+  /**
+   * Get translatable columns.
+   *
+   * @return array
+   *   A table-indexed array of translatable columns.
+   */
+  public static function &columns() {
+    static $result = NULL;
+    if (!$result) {
+      $result = [
+        'civicrm_location_type' => [
+          '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 <div> 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;
+  }
+
+}
index d15066d9ceacc2098acf9ab3b5172074df1460f3..b81495ec073629fe3ef8ae51ec57c080edd9d0e8 100644 (file)
@@ -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();
   }
 
   /**
index 9e1bb694fa28704eb7000d05c98bb061aec182ad..f2ccc2ff791074fc2baa8b547d0842b5ccee849b 100644 (file)
@@ -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',
         ],
index 6b0233144ae3cc38bf5603cae0460e2e7c809c1e..6769e552ea0cf49f906ce4e63dab60507b86c58f 100644 (file)
@@ -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');
index 0bdc349b8c67adf32aaced5a302fa26cd9488b1d..20001eae561c91b021e8d485bef2b733c7ae2e8b 100644 (file)
@@ -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};
index f6ad4278cfe94855784c969cf62136e99aec6bb2..b15ff620c7efd39c861c8cbb016e495bb3c5d464 100644 (file)
@@ -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();
   }
index 9e11858ce02a890cfb1e10e86b9a855d59303612..5a592e5f7a90a14d646528e47cbff4733699dc15 100644 (file)
@@ -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);
 
index f3885af444ca36255806099d6d89b56b2fed53dd..d620ded7dc9fed6d4df2ed49c83248201a161029 100644 (file)
@@ -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];
   }
 
 }
index c06083e0cfea6f868eedfd84f6e1d3a37865230d..84862dfc114857a8cb259d5702dd5de8b42e6037 100644 (file)
@@ -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,
index 6ae6113080c593c3ffef1390718d67f8c3ed6985..39b199c8984ab518d8dcda2c3459c2bad75c623f 100644 (file)
@@ -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,
index 76ca53526e9bcf0543d72f8fc5440989d5de5880..cdaf061aeb6bd3a46679f5c75918844d59d949d1 100644 (file)
@@ -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,
index f22c9bcda26e64d9239f7061b1d09278dfa6b4ff..c2a0b8860a00223970a66e1f0e980e3d8d8f1a40 100644 (file)
@@ -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,
index dd5a889138c038f160b314891b172ce899ae863a..6326cbd98f3f204c10a8e5a571f8b80ef79ab390 100644 (file)
@@ -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,
index 5d29499e27148a125c767f84c18e3778d50264e4..5661f27d719c3e19fc9314e917d253e85601763a 100644 (file)
@@ -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();
 
index 1ef35a516fb4f1a8724a1748a2173f73ea42ef00..4b038ac4ff9cda1f5a099751ccadea5a88b77c0f 100644 (file)
@@ -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\";}';
index fed3c452bcf044b355f8c52040fc1181749f41bc..5a69f6a6dc4c5dd035933a657b036ddaa6b3615c 100644 (file)
@@ -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;
index d20812ebab4448c97b4f2aa096f21232d68b2686..18db6bccedbb34548c1120e1521940a222ad7e07 100644 (file)
@@ -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;
index 967c1340fd06eecfaac207fe0d730c2c7cb91c47..f2e0f5260767cda51446213a71da1af4f8f0c60a 100644 (file)
@@ -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/',
index d965f225d9a2b3ac99be7be457add92758883cd9..c33d56926953114ecbd6806a33c5b2c34e9f1101 100644 (file)
@@ -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(),
     ]);
index e90decf50dd379f1510b770678d68c0f847b18fd..690fee8ba6965a5a5be6e71ecbf902577ea82ced 100644 (file)
@@ -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,
index 72ad346b42056df18e1ba7db9195bd1ed9ef7913..456c6e686d84d6cc7633257be3cbbf1de47f247e 100644 (file)
@@ -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,
index 1d8859a867ecbf759e6aa9e828caaff9ad9eb002..3caf5fdd9bd1921a04a5f90b8558491b12a5db72 100644 (file)
@@ -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,
index 40bd71868a5c637c7977a0cc0f4d558b7b1ecf14..244995fab2392b1731fc1302778eed08ac4f22ce 100644 (file)
   </foreignKey>
   <field>
     <name>name</name>
-    <title>Payment Processor</title>
+    <title>Payment Processor Name</title>
+    <required>true</required>
     <type>varchar</type>
     <length>64</length>
     <comment>Payment Processor Name.</comment>
     <add>1.8</add>
     <html>
+      <label>Machine Name</label>
       <type>Text</type>
     </html>
   </field>
   <field>
     <name>title</name>
     <title>Payment Processor Title</title>
+    <required>true</required>
     <type>varchar</type>
-    <length>127</length>
+    <length>255</length>
     <localizable>true</localizable>
     <html>
+      <label>Backend Title</label>
       <type>Text</type>
     </html>
-    <comment>Payment Processor Descriptive Name.</comment>
+    <comment>Name of processor when shown to CiviCRM administrators.</comment>
     <add>5.13</add>
   </field>
+  <field>
+    <name>frontend_title</name>
+    <title>Payment Processor Frontend Title</title>
+    <required>true</required>
+    <type>varchar</type>
+    <length>255</length>
+    <localizable>true</localizable>
+    <html>
+      <label>Frontend Title</label>
+      <type>Text</type>
+    </html>
+    <comment>Name of processor when shown to users making a payment.</comment>
+    <add>5.61</add>
+  </field>
   <field>
     <name>description</name>
     <title>Processor Description</title>
     <type>varchar</type>
     <length>255</length>
     <html>
+      <label>Description</label>
       <type>Text</type>
     </html>
-    <comment>Payment Processor Description.</comment>
+    <comment>Additional processor information shown to administrators.</comment>
     <add>1.8</add>
   </field>
   <field>