Skip to content

Commit

Permalink
Merge pull request #24183 from seamuslee001/elavon_extension_convert
Browse files Browse the repository at this point in the history
[REF] Convert Elavon Payment Processor to be a core Extension
  • Loading branch information
seamuslee001 authored Aug 19, 2022
2 parents e708fbb + 64b87c9 commit 77b49e8
Show file tree
Hide file tree
Showing 15 changed files with 1,469 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
37 changes: 37 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveFiftyFour.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
public function upgrade_5_54_alpha1($rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Add "created_id" column to "civicrm_participant"', 'addCreatedIDColumnToParticipant');
$this->addTask('Install Elavon Payment Processor Extension as needed', 'installElavonPaymentProcessorExtension');
}

public static function addCreatedIDColumnToParticipant($ctx): bool {
Expand All @@ -49,4 +50,40 @@ public static function addCreatedIDColumnToParticipant($ctx): bool {
return TRUE;
}

/**
* @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
WHERE cppt.name = 'Elavon'");
if ($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' => 'PaymentProcessorType_Elavon',
'entity_type' => 'PaymentProcessorType',
'entity_id' => $paymentProcessorType,
'cleanup' => NULL,
]);
CRM_Core_DAO::executeQuery($mgdInert->usingReplace()->toSQL());
CRM_Extension_System::singleton()->getManager()->refresh();
}
else {
CRM_Core_DAO::executeQuery("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 @@ -23,3 +23,4 @@ recaptcha
search_kit
sequentialcreditnotes
legacycustomsearches
evalon
28 changes: 28 additions & 0 deletions ext/elavon/CRM/Core/Payment/Elavon.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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' => 'PaymentProcessorType_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.
667 changes: 667 additions & 0 deletions ext/elavon/LICENSE.txt

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions ext/elavon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# elavon

This extension is to install the Elavon Payment Processor that used to be within the Core code base now as a core extension.

The extension is licensed under [AGPL-3.0](LICENSE.txt).

## Requirements

* PHP v7.2+
* CiviCRM (*FIXME: Version number*)

## Installation (Web UI)

Learn more about installing CiviCRM extensions in the [CiviCRM Sysadmin Guide](https://docs.civicrm.org/sysadmin/en/latest/customize/extensions/).

## Installation (CLI

Sysadmins and developers may install this core extension with the command-line tool [cv](https://github.com/civicrm/cv).

```bash
cv en elavon
```
Loading

0 comments on commit 77b49e8

Please sign in to comment.