$result = NULL;
if ($paymentParams['amount'] > 0.0) {
- // force a reget of the payment processor in case the form changed it, CRM-7179
- $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
- $result = $payment->doDirectPayment($paymentParams);
- }
-
- if (is_a($result, 'CRM_Core_Error')) {
- //set the contribution mode.
- $urlParams = "action=add&cid={$this->_contactId}&id={$this->_id}&component={$this->_component}";
- if ($this->_mode) {
- $urlParams .= "&mode={$this->_mode}";
+ try {
+ // force a reget of the payment processor in case the form changed it, CRM-7179
+ $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
+ $result = $payment->doPayment($paymentParams);
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ //set the contribution mode.
+ $urlParams = "action=add&cid={$this->_contactId}&id={$this->_id}&component={$this->_component}";
+ if ($this->_mode) {
+ $urlParams .= "&mode={$this->_mode}";
+ }
+ CRM_Core_Error::displaySessionError($result);
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/payment/add', $urlParams));
}
- CRM_Core_Error::displaySessionError($result);
- CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/payment/add', $urlParams));
}
if ($result) {
$form->postProcessHook();
// this does not return
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
- $payment->doTransferCheckout($form->_params, 'contribute');
+ $payment->doPayment($form->_params, 'contribute');
}
}
else {
$payment = $form->_paymentProcessor['object'];
}
-
- if ($form->_contributeMode == 'express') {
- $result = $payment->doExpressCheckout($tempParams);
- if (is_a($result, 'CRM_Core_Error')) {
- throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result));
- }
- }
- else {
- $result = $payment->doPayment($tempParams, 'contribute');
- }
+ $result = $payment->doPayment($tempParams, 'contribute');
}
//assign receive date when separate membership payment
* the result in an nice formatted array (or an error object)
* @abstract
*/
- abstract protected function doDirectPayment(&$params);
+ protected function doDirectPayment(&$params) {}
/**
* Process payment - this function wraps around both doTransferPayment and doDirectPayment.
return $e;
}
- /**
- * NOTE: 'doTransferCheckout' not implemented
- */
- public function doTransferCheckout(&$params, $component) {
- CRM_Core_Error::fatal(ts('This function is not implemented'));
- }
-
/**
* This public function checks to see if we have the right processor config values set.
*
return $e;
}
- /**
- * NOTE: 'doTransferCheckout' not implemented
- */
- public function doTransferCheckout(&$params, $component) {
- CRM_Core_Error::fatal(ts('This function is not implemented'));
- }
-
/**
* This public function checks to see if we have the right processor config values set.
*
$this->_setParam('sequence', rand(1, 1000));
}
- /**
- * @param array $params
- *
- * @throws Exception
- */
- public function doTransferCheckout(&$params) {
- CRM_Core_Error::fatal(ts('This function is not implemented'));
- }
-
/**
* Submit a payment using Advanced Integration Method.
*
return $e;
}
- /**
- * ************************************************
- * NOTE: 'doTransferCheckout' not implemented
- * ************************************************
- */
- public function doTransferCheckout(&$params, $component) {
- CRM_Core_Error::fatal(ts('This function is not implemented'));
- }
-
/**
* *****************************************************************************************
* This public function checks to see if we have the right processor config values set
CRM_Core_Payment_Form::mapParams($this->_bltID, $params, $params, TRUE);
$params['month'] = $params['credit_card_exp_date']['M'];
$params['year'] = $params['credit_card_exp_date']['Y'];
- $result = &$payment->doDirectPayment($params);
- if (is_a($result, 'CRM_Core_Error')) {
+ try {
+ $result = $payment->doPayment($params);
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE));
- return NULL;
- }
- elseif (!$result['trxn_id']) {
- CRM_Core_Error::fatal(ts("Financial institution didn't return a transaction id."));
}
+
$trxnDetails = array(
'trxn_id' => $result['trxn_id'],
'trxn_date' => $result['now'],
$value['participant_status_id'] = $value['participant_status'] = array_search($status, $pendingStatuses);
}
}
- elseif ($this->_contributeMode == 'express' && !empty($value['is_primary'])) {
- if (is_object($payment)) {
- $result = $payment->doExpressCheckout($value);
- }
- else {
- CRM_Core_Error::fatal($paymentObjError);
- }
- }
elseif (!empty($value['is_primary'])) {
CRM_Core_Payment_Form::mapParams($this->_bltID, $value, $value, TRUE);
// payment email param can be empty for _bltID mapping
}
if (is_object($payment)) {
- $result = $payment->doDirectPayment($value);
+ try {
+ $result = $payment->doPayment($value);
+ $value = array_merge($value, $result);
+ }
+ catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
+ CRM_Core_Error::displaySessionError($result);
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
+ }
}
else {
CRM_Core_Error::fatal($paymentObjError);
}
}
- if (is_a($result, 'CRM_Core_Error')) {
- CRM_Core_Error::displaySessionError($result);
- CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
- }
-
- if ($result) {
- $value = array_merge($value, $result);
- }
-
$value['receive_date'] = $now;
if ($this->_allowConfirmation) {
$value['participant_register_date'] = $this->_values['participant']['register_date'];
// call postprocess hook before leaving
$this->postProcessHook();
// this does not return
- $payment->doTransferCheckout($primaryParticipant, 'event');
+ $payment->doPayment($primaryParticipant, 'event');
}
else {
CRM_Core_Error::fatal($paymentObjError);
* Class test_extension_manager_paymenttest
*/
class test_extension_manager_paymenttest extends CRM_Core_Payment {
- static private $_singleton = NULL;
-
- /**
- * Singleton function used to manage this object.
- *
- * @param string $mode
- * The mode of operation: live or test.
- * @param array $paymentProcessor
- * The details of the payment processor being invoked.
- * @param CRM_Core_Form $paymentForm
- * Reference to the form object if available.
- * @param bool $force
- * Should we force a reload of this payment object.
- *
- * @return object
- */
- public static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
- $processorName = $paymentProcessor['name'];
- if (self::$_singleton[$processorName] === NULL) {
- self::$_singleton[$processorName] = new test_extension_manager_paymenttest();
- }
- return self::$_singleton[$processorName];
- }
static $counts = array();
self::$counts['enable'] = 1 + (int) self::$counts['enable'];
}
- /**
- * This function collects all the information from a web/api form and invokes
- * the relevant payment processor specific functions to perform the transaction
- *
- * @param array $params
- * Assoc array of input parameters for this transaction.
- *
- */
- public function doDirectPayment(&$params) {
- }
-
public function checkConfig() {
}
// turn verifySSL off
CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
- $result = $this->processor->doDirectPayment($params);
+ $result = $this->processor->doPayment($params);
// turn verifySSL on
CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');