Commit bcb1d953 authored by mattwire's avatar mattwire Committed by mattwire
Browse files

Add IPN getters/setters to provide object oriented initialisation

parent 02348ab1
......@@ -40,11 +40,34 @@ trait CRM_Core_Payment_MJWIPNTrait {
*/
protected $eventType = NULL;
/**
* The IPN event ID
* @var string
*/
protected $eventID = NULL;
/**
* Exit on exceptions (TRUE), or just throw them (FALSE).
*
* @var bool
*/
protected $exitOnException = TRUE;
/**
* Should we verify (re-retrieve) the object that we have been given.
* Usually TRUE when an IPN request is received.
*
* @var bool
*/
protected $verifyData = TRUE;
/**
* The data provided by the IPN
*
* @var array|Object
*/
protected $data;
/**
* Set the value of is_email_receipt to use when a new contribution is received for a recurring contribution
* If not set, we respect the value set on the ContributionRecur entity.
......@@ -106,25 +129,87 @@ trait CRM_Core_Payment_MJWIPNTrait {
}
/**
* Get the payment processor
* The $_GET['processor_id'] value is set by CRM_Core_Payment::handlePaymentMethod.
* Set and initialise the paymentProcessor object
* @param int $paymentProcessorID
*
* @throws \CRM_Core_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
protected function getPaymentProcessor() {
$paymentProcessorID = CRM_Utils_Request::retrieveValue('processor_id', 'Positive', NULL, FALSE, 'GET');
if (!$paymentProcessorID) {
$this->exception('Failed to get payment processor ID');
}
public function setPaymentProcessor($paymentProcessorID) {
try {
$this->_paymentProcessor = \Civi\Payment\System::singleton()->getById($paymentProcessorID);
}
catch(Exception $e) {
catch (Exception $e) {
$this->exception('Failed to get payment processor');
}
}
/**
* Get the payment processor object
*/
public function getPaymentProcessor() {
return $this->_paymentProcessor;
}
/**
* @param bool $verify
*/
public function setVerifyData($verify) {
$this->verifyData = $verify;
}
/**
* @return bool
*/
public function getVerifyData() {
return $this->verifyData;
}
/**
* @param string $eventID
*/
public function setEventID($eventID) {
$this->eventID = $eventID;
}
/**
* @return string
*/
public function getEventID() {
return $this->eventID;
}
/**
* Set the eventType. Returns TRUE if event is supported. FALSE otherwise.
* @param string $eventType
*
* @return bool
*/
public function setEventType($eventType) {
$this->eventType = $eventType;
return TRUE;
}
/**
* @return string
*/
public function getEventType() {
return $this->eventType;
}
/**
* @param array|Object $data
*/
public function setData($data) {
$this->data = $data;
}
/**
* @return array|Object
*/
public function getData() {
return $this->data;
}
/**
* Check that required params are present
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment