Skip to content

Commit

Permalink
Remove usage of deprecated function and duplicated code in getPayment()
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Apr 28, 2018
1 parent 38b02a4 commit de00d48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
51 changes: 21 additions & 30 deletions CRM/Financial/BAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,34 +218,6 @@ public static function del($paymentProcessorID) {
public static function getPayment($paymentProcessorID, $mode = 'based_on_id') {
$capabilities = ($mode == 'test') ? array('TestMode') : array();
$processors = self::getPaymentProcessors($capabilities, array($paymentProcessorID));
$processor = $processors[$paymentProcessorID];
$fields = array(
'id',
'name',
'payment_processor_type_id',
'user_name',
'password',
'signature',
'url_site',
'url_api',
'url_recur',
'url_button',
'subject',
'class_name',
'is_recur',
'billing_mode',
'is_test',
'payment_type',
'is_default',
);
// Just to prevent e-Notices elsewhere we set all fields.
foreach ($fields as $name) {
if (!isset($processor)) {
$processor[$name] = NULL;
}
}
$processor['payment_processor_type'] = CRM_Core_PseudoConstant::paymentProcessorType(FALSE,
$processor['payment_processor_type_id'], 'name');
return $processors[$paymentProcessorID];
}

Expand Down Expand Up @@ -326,7 +298,25 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i

$processors = civicrm_api3('payment_processor', 'get', $retrievalParameters);
foreach ($processors['values'] as $processor) {
$fieldsToProvide = array('user_name', 'password', 'signature', 'subject', 'is_recur');
$fieldsToProvide = array(
'id',
'name',
'payment_processor_type_id',
'user_name',
'password',
'signature',
'url_site',
'url_api',
'url_recur',
'url_button',
'subject',
'class_name',
'is_recur',
'billing_mode',
'is_test',
'payment_type',
'is_default',
);
foreach ($fieldsToProvide as $field) {
// Prevent e-notices in processor classes when not configured.
if (!isset($processor[$field])) {
Expand Down Expand Up @@ -548,7 +538,8 @@ public static function getProcessorForEntity($entityID, $component = 'contribute
// The function looks to load the payment processor ID from the contribution page, which
// can support multiple processors.
}
$paymentProcessor['payment_processor_type'] = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, $paymentProcessor['payment_processor_type_id'], 'name');

$paymentProcessor['payment_processor_type'] = CRM_Core_PseudoConstant::getName('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', $paymentProcessor['payment_processor_type_id']);
$result = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
}
return $result;
Expand Down
7 changes: 3 additions & 4 deletions CRM/Utils/VersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ private function getPayProcStats() {
$dao->find();
$ppTypes = array();

// Get title and id for all processor types
$ppTypeNames = CRM_Core_PseudoConstant::paymentProcessorType();

// Get title for all processor types
// FIXME: This should probably be getName, but it has always returned translated label so we stick with that for now as it would affect stats
while ($dao->fetch()) {
$ppTypes[] = $ppTypeNames[$dao->payment_processor_type_id];
$ppTypes[] = CRM_Core_PseudoConstant::getLabel('CRM_Financial_BAO_PaymentProcessor', 'payment_processor_type_id', $dao->payment_processor_type_id);
}
// add the .-separated list of the processor types
$this->stats['PPTypes'] = implode(',', array_unique($ppTypes));
Expand Down

0 comments on commit de00d48

Please sign in to comment.