Skip to content

Commit

Permalink
[REF] Convert Elavon Payment Processor to be a core Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Aug 8, 2022
1 parent d5b2b3f commit d488da1
Show file tree
Hide file tree
Showing 18 changed files with 1,679 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
!/ext/eventcart
!/ext/ewaysingle
!/ext/greenwich
!/ext/elavon
/ext/greenwich/dist
/ext/greenwich/extern
!/ext/message_admin
Expand Down
72 changes: 72 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveFiftyFour.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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 |
+--------------------------------------------------------------------+
*/

/**
* Upgrade logic for the 5.54.x series.
*
* Each minor version in the series is handled by either a `5.54.x.mysql.tpl` file,
* or a function in this class named `upgrade_5_54_x`.
* If only a .tpl file exists for a version, it will be run automatically.
* If the function exists, it must explicitly add the 'runSql' task if there is a corresponding .mysql.tpl.
*
* This class may also implement `setPreUpgradeMessage()` and `setPostUpgradeMessage()` functions.
*/
class CRM_Upgrade_Incremental_php_FiveFiftyFour extends CRM_Upgrade_Incremental_Base {


/**
* Upgrade step; adds tasks including 'runSql'.
*
* @param string $rev
* The version number matching this function name
*/
public function upgrade_5_54_alpha1($rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Install Elavon Payment Processor Extension as needed', 'installElavonPaymentProcessorExtension');
}

/**
* @param CRM_Queue_TaskContext $ctx
* @return bool
*/
public static function installElavonPaymentProcessorExtension(CRM_Queue_TaskContext $ctx) {
$paymentProcessors = CRM_Core_DAO::singleValueQuery("SELECT count(cpp.id) FROM civicrm_payment_processor cpp
INNER JOIN civicrm_payment_processor_type cppt ON cppt.id = cpp.payment_processor_type_id
WEHERE cppt.name = 'Elavon'");
if (count($paymentProcessors) > 1) {
$paymentProcessorType = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_payment_processor_type WHERE name = 'Elavon'");
$insert = CRM_Utils_SQL_Insert::into('civicrm_extension')->row([
'type' => 'module',
'full_name' => 'elavon',
'name' => 'Elavon Payment Processor',
'label' => 'Elavon Payment Processor',
'file' => 'elavon',
'schema_version' => NULL,
'is_active' => 1,
]);
CRM_Core_DAO::executeQuery($insert->usingReplace()->toSQL());
$mgdInert = CRM_Utils_SQL_Insert::into('civicrm_managed')->row([
'module' => 'elavon',
'name' => 'Elavon',
'entity_type' => 'PaymentProcessorType',
'entity_id' => $paymentProcessorType,
'cleanup' => NULL,
'update' => NULL,
]);
CRM_Core_DAO::executeQuery($mgdInert->usingReplace()->toSQL());
}
else {
CRM_Core_DAO::exeucteQuery("DELETE FROM civicrm_payment_processor_type WHERE name = 'Elavon'");
}
return TRUE;
}

}
1 change: 1 addition & 0 deletions distmaker/core-ext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ recaptcha
search_kit
sequentialcreditnotes
legacycustomsearches
evalon
27 changes: 27 additions & 0 deletions ext/elavon/CRM/Core/Payment/Elavon.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
use CRM_Elavon_ExtensionUtil as E;
// This file declares a managed database record of type "ReportTemplate".
// The record will be automatically inserted, updated, or deleted from the
// database as appropriate. For more details, see "hook_civicrm_managed" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
return [
0 => [
'name' => 'Elavon',
'entity' => 'PaymentProcessorType',
'params' => [
'version' => 3,
'name' => 'Elavon',
'title' => E::ts('Elavon Payment Processor'),
'description' => E::ts('Elavon / Nova Virtual Merchant'),
'user_name_label' => E::ts('SSL Merchant ID'),
'password_label' => E::ts('SSL User ID'),
'signature_label' => E::ts('SSL PIN'),
'class_name' => 'Payment_Elavon',
'billing_mode' => 1,
'url_site_default' => 'https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do',
'payment_type' => 1,
'is_recur' => 0,
'url_site_test_default' => 'https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do',
],
],
];
File renamed without changes.
Loading

0 comments on commit d488da1

Please sign in to comment.