+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
}
}
+ /**
+ * Getter for the payment processor.
+ *
+ * The payment processor array is based on the civicrm_payment_processor table entry.
+ *
+ * @return array
+ * Payment processor array.
+ */
+ public function getPaymentProcessor() {
+ return $this->_paymentProcessor;
+ }
+
+ /**
+ * Setter for the payment processor.
+ *
+ * @param array $processor
+ */
+ public function setPaymentProcessor($processor) {
+ $this->_paymentProcessor = $processor;
+ }
+
/**
* Setter for the payment form that wants to use the processor.
*
/**
* Getter for accessing member vars.
+ *
* @todo believe this is unused
+ *
* @param string $name
*
* @return null
'size' => 20,
'maxlength' => 20,
'autocomplete' => 'off',
+ 'class' => 'creditcard',
),
'is_required' => TRUE,
),
abstract protected function doDirectPayment(&$params);
/**
- * Process payment - this function wraps around both doTransferPayment and doDirectPayment
- * it ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms more agnostic
+ * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
+ *
+ * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
+ * more agnostic.
*
* @param array $params
*
abstract protected function checkConfig();
/**
+ * Redirect for paypal.
+ *
+ * @todo move to paypal class or remove
+ *
* @param $paymentProcessor
- * @todo move to paypal class or remover
+ *
* @return bool
*/
public static function paypalRedirect(&$paymentProcessor) {
}
/**
+ * Handle incoming payment notification.
+ *
+ * IPNs, also called silent posts are notifications of payment outcomes or activity on an external site.
+ *
* @todo move to0 \Civi\Payment\System factory method
* Page callback for civicrm/payment/ipn
*/
'mode' => @$_GET['mode'],
)
);
+ CRM_Utils_System::civiExit();
}
/**
}
self::logPaymentNotification($params);
- // Query db for processor ..
- $mode = @$params['mode'];
-
$sql = "SELECT ppt.class_name, ppt.name as processor_name, pp.id AS processor_id
FROM civicrm_payment_processor_type ppt
INNER JOIN civicrm_payment_processor pp
ON pp.payment_processor_type_id = ppt.id
- AND pp.is_active
- AND pp.is_test = %1";
- $args[1] = array($mode == 'test' ? 1 : 0, 'Integer');
+ AND pp.is_active";
if (isset($params['processor_id'])) {
$sql .= " WHERE pp.id = %2";
$notFound = "No active instances of payment processor ID#'{$params['processor_id']}' were found.";
}
else {
- $sql .= " WHERE ppt.name = %2";
+ // This is called when processor_name is passed - passing processor_id instead is recommended.
+ $sql .= " WHERE ppt.name = %2 AND pp.is_test = %1";
+ $args[1] = array(
+ (CRM_Utils_Array::value('mode', $params) == 'test') ? 1 : 0,
+ 'Integer',
+ );
$args[2] = array($params['processor_name'], 'String');
$notFound = "No active instances of the '{$params['processor_name']}' payment processor were found.";
}
}
}
- $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($dao->processor_id, $mode);
+ $processorInstance = Civi\Payment\System::singleton()->getById($dao->processor_id);
// Should never be empty - we already established this processor_id exists and is active.
- if (empty($paymentProcessor)) {
+ if (empty($processorInstance)) {
continue;
}
- // Instantiate PP
- $processorInstance = new $paymentClass($mode, $paymentProcessor);
-
// Does PP implement this method, and can we call it?
if (!method_exists($processorInstance, $method) ||
!is_callable(array($processorInstance, $method))
"$method method is unsupported in legacy payment processors."
);
}
-
- // Exit here on web requests, allowing just the plain text response to be echoed
- if ($method == 'handlePaymentNotification') {
- CRM_Utils_System::civiExit();
- }
}
/**