From 8196c759041bacb362575cd6a25b0fad0d2ba1e9 Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 30 Jun 2013 17:09:12 +1200 Subject: [PATCH] add some comments to the code --- CRM/Core/Payment/BaseIPN.php | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 0f08c06a1d..2edd2f1b5e 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -35,10 +35,29 @@ class CRM_Core_Payment_BaseIPN { static $_now = NULL; + + /** + * Constructor + */ function __construct() { self::$_now = date('YmdHis'); } + /** + * Validate incoming data. This function is intended to ensure that incoming data matches + * It provides a form of pseudo-authentication - by checking the calling fn already knows + * the correct contact id & contribution id (this can be problematic when that has changed in + * the meantime for transactions that are delayed & contacts are merged in-between. e.g + * Paypal allows you to resend Instant Payment Notifications if you, for example, moved site + * and didn't update your IPN URL. + * + * @param array $input interpreted values from the values returned through the IPN + * @param array $ids more interpreted values (ids) from the values returned through the IPN + * @param array $objects an empty array that will be populated with loaded object + * @param boolean $required boolean Return FALSE if the relevant objects don't exist + * @param integer $paymentProcessorID Id of the payment processor ID in use + * @return boolean + */ function validateData(&$input, &$ids, &$objects, $required = TRUE, $paymentProcessorID = NULL) { // make sure contact exists and is valid @@ -92,10 +111,16 @@ class CRM_Core_Payment_BaseIPN { return TRUE; } - /* + /** * Load objects related to contribution * * @input array information from Payment processor + * @param array $ids + * @param array $objects + * @param boolean $required + * @param integer $paymentProcessorID + * @param array $error_handling + * @return multitype:number NULL |boolean */ function loadObjects(&$input, &$ids, &$objects, $required, $paymentProcessorID, $error_handling = NULL) { if (empty($error_handling)) { @@ -139,6 +164,13 @@ class CRM_Core_Payment_BaseIPN { return $success; } + /** + * Set contribution to failed + * @param array $objects + * @param object $transaction + * @param array $input + * @return boolean + */ function failed(&$objects, &$transaction, $input = array()) { $contribution = &$objects['contribution']; $memberships = array(); @@ -195,6 +227,12 @@ class CRM_Core_Payment_BaseIPN { return TRUE; } + /** + * Handled pending contribution status + * @param array $objects + * @param object $transaction + * @return boolean + */ function pending(&$objects, &$transaction) { $transaction->commit(); CRM_Core_Error::debug_log_message("returning since contribution status is pending"); @@ -589,6 +627,13 @@ LIMIT 1;"; return $contribution->composeMessageArray($input, $ids, $values, $recur, $returnMessageText); } + /** + * Update contribution status - this is only called from one place in the code & + * it is unclear whether it is a function on the way in or on the way out + * + * @param unknown_type $params + * @return void|Ambigous + */ function updateContributionStatus(&$params) { // get minimum required values. $statusId = CRM_Utils_Array::value('contribution_status_id', $params); -- 2.25.1