3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of payment processors.
21 class CRM_Admin_Page_PaymentProcessor
extends CRM_Core_Page_Basic
{
24 * The action links that we need to display for the browse screen.
28 public static $_links = NULL;
36 public function getBAOName() {
37 return 'CRM_Financial_BAO_PaymentProcessor';
44 * (reference) of action links
46 public function &links() {
47 if (!(self
::$_links)) {
48 self
::$_links = array(
49 CRM_Core_Action
::UPDATE
=> array(
51 'url' => 'civicrm/admin/paymentProcessor',
52 'qs' => 'action=update&id=%%id%%&reset=1',
53 'title' => ts('Edit Payment Processor'),
55 CRM_Core_Action
::DISABLE
=> array(
56 'name' => ts('Disable'),
57 'ref' => 'crm-enable-disable',
58 'title' => ts('Disable Payment Processor'),
60 CRM_Core_Action
::ENABLE
=> array(
61 'name' => ts('Enable'),
62 'ref' => 'crm-enable-disable',
63 'title' => ts('Enable Payment Processor'),
65 CRM_Core_Action
::DELETE
=> array(
66 'name' => ts('Delete'),
67 'url' => 'civicrm/admin/paymentProcessor',
68 'qs' => 'action=delete&id=%%id%%',
69 'title' => ts('Delete Payment Processor'),
79 * This method is called after the page is created. It checks for the
80 * type of action and executes that action.
81 * Finally it calls the parent's run method.
83 public function run() {
84 // set title and breadcrumb
85 CRM_Utils_System
::setTitle(ts('Settings - Payment Processor'));
87 $paymentProcessorTypes = CRM_Core_PseudoConstant
::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array(
88 'labelColumn' => 'name',
91 $this->assign('defaultPaymentProcessorType', $paymentProcessorTypes['PayPal']);
94 'title' => ts('Administration'),
95 'url' => CRM_Utils_System
::url('civicrm/admin',
100 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
101 return parent
::run();
105 * Browse all payment processors.
107 * @param null $action
109 public function browse($action = NULL) {
110 // get all custom groups sorted by weight
111 $paymentProcessor = [];
112 $dao = new CRM_Financial_DAO_PaymentProcessor();
114 $dao->domain_id
= CRM_Core_Config
::domainID();
115 $dao->orderBy('name');
118 while ($dao->fetch()) {
119 $paymentProcessor[$dao->id
] = [];
120 CRM_Core_DAO
::storeValues($dao, $paymentProcessor[$dao->id
]);
121 $paymentProcessor[$dao->id
]['payment_processor_type'] = CRM_Core_PseudoConstant
::getLabel(
122 'CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', $dao->payment_processor_type_id
125 // form all action links
126 $action = array_sum(array_keys($this->links()));
128 // update enable/disable links.
129 if ($dao->is_active
) {
130 $action -= CRM_Core_Action
::ENABLE
;
133 $action -= CRM_Core_Action
::DISABLE
;
136 $paymentProcessor[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
137 array('id' => $dao->id
),
140 'paymentProcessor.manage.action',
144 $paymentProcessor[$dao->id
]['financialAccount'] = CRM_Contribute_PseudoConstant
::getRelationalFinancialAccount($dao->id
, NULL, 'civicrm_payment_processor', 'financial_account_id.name');
147 $paymentProcessor[$dao->id
]['test_id'] = CRM_Financial_BAO_PaymentProcessor
::getTestProcessorId($dao->id
);
149 catch (CiviCRM_API3_Exception
$e) {
150 CRM_Core_Session
::setStatus(ts('No test processor entry exists for %1. Not having a test entry for each processor could cause problems', [$dao->name
]));
154 $this->assign('rows', $paymentProcessor);
158 * Get name of edit form.
161 * Classname of edit form.
163 public function editForm() {
164 return 'CRM_Admin_Form_PaymentProcessor';
168 * Get edit form name.
173 public function editName() {
174 return 'Payment Processors';
185 public function userContext($mode = NULL) {
186 return 'civicrm/admin/paymentProcessor';