CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'
);
if ($rfp) {
- $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
$expressParams = $payment->getPreApprovalDetails($this->get('pre_approval_parameters'));
$this->_params['payer'] = CRM_Utils_Array::value('payer', $expressParams);
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
- $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+ $payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
$payment->doTransferCheckout($form->_params, 'contribute');
}
}
$result = NULL;
if ($form->_values['is_monetary'] && !$form->_params['is_pay_later'] && $minimumFee > 0.0) {
- $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+ $payment = $form->_paymentProcessor['object'];
if ($form->_contributeMode == 'express') {
$result = $payment->doExpressCheckout($tempParams);
continue;
}
- // note that we are passing a CRM_Core_Page object ($this) as if it were a form here:
- $paymentObject = CRM_Core_Payment::singleton($mode, $paymentProcessor, $this);
require_once 'api/v3/utils.php';
//@todo calling api functions directly is not supported
protected $_paymentProcessor;
- /**
- * Singleton function used to manage this object.
- *
- * We will migrate to calling Civi\Payment\System::singleton()->getByProcessor($paymentProcessor)
- * & Civi\Payment\System::singleton()->getById($paymentProcessor) directly as the main access methods & work
- * to remove this function all together
- *
- * @param string $mode
- * The mode of operation: live or test.
- * @param array $paymentProcessor
- * The details of the payment processor being invoked.
- * @param object $paymentForm
- * Deprecated - avoid referring to this if possible. If you have to use it document why as this is scary interaction.
- * @param bool $force
- * Should we force a reload of this payment object.
- *
- * @return CRM_Core_Payment
- * @throws \CRM_Core_Exception
- */
- public static function singleton($mode = 'test', &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) {
- // make sure paymentProcessor is not empty
- // CRM-7424
- if (empty($paymentProcessor)) {
- return CRM_Core_DAO::$_nullObject;
- }
- //we use two lines because we can't remove the '&singleton' without risking breakage
- //of extension classes that extend this one
- $object = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
- return $object;
- }
-
/**
* Opportunity for the payment processor to override the entire form build.
*
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($ids['paymentProcessor'],
$input['is_test'] ? 'test' : 'live'
);
- $paymentObject = CRM_Core_Payment::singleton($input['is_test'] ? 'test' : 'live', $paymentProcessor);
+ $paymentObject = $paymentProcessor['object'];
if (!$paymentObject->checkMD5($input['MD5_Hash'], $input['trxn_id'], $input['amount'], TRUE)) {
CRM_Core_Error::debug_log_message("MD5 Verification failed.");
$errors = array();
if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
- $payment = CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, CRM_Core_DAO::$_nullObject);
- $error = $payment->checkConfig($self->_mode);
- if ($error) {
- $errors['_qf_default'] = $error;
- }
CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
// validate payment instrument values (e.g. credit card number)
$params['ip_address'] = CRM_Utils_System::ipAddress();
$params['currencyID'] = $config->defaultCurrency;
- $payment = &CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
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'];
$mapParams = array_merge(array('contact_id' => $contactID), $this->_params);
CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE);
- $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = $this->_paymentProcessor['object'];
// CRM-15622: fix for incorrect contribution.fee_amount
$paymentParams['fee_amount'] = NULL;
//we lost rfp in case of additional participant. So set it explicitly.
if ($rfp || CRM_Utils_Array::value('additional_participants', $this->_params[0], FALSE)) {
- $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = $this->_paymentProcessor['object'];
$paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.');
if (is_object($payment)) {
$expressParams = $payment->getExpressCheckoutDetails($this->get('token'));
// required only if paid event
if ($this->_values['event']['is_monetary'] && !($this->_allowWaitlist || $this->_requireApproval)) {
if (is_array($this->_paymentProcessor)) {
- $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = $this->_paymentProcessor['object'];
}
$result = NULL;
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
- $payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
+ $payment = $this->_paymentProcessor['object'];
}
// default mode is direct
$this->set('contributeMode', 'direct');
// call postProcess hook before leaving
$form->postProcessHook();
// this does not return
- $payment = CRM_Core_Payment::singleton($form->_mode, $form->_paymentProcessor, $form);
+ $payment = $form->_paymentProcessor['object'];
$payment->doTransferCheckout($form->_params, 'contribute');
}
}