r75561 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75560‎ | r75561 | r75562 >
Date:17:05, 27 October 2010
Author:awjrichards
Status:deferred
Tags:
Comment:
Added additional watchdog logging statements; Updated incorrect variable names/references; Updated gateway detection code to search for an actual space rather than \s...
Modified paths:
  • /civicrm/trunk/sites/all/modules/wmf_owa/wmf_owa.module (modified) (history)

Diff [purge]

Index: civicrm/trunk/sites/all/modules/wmf_owa/wmf_owa.module
@@ -32,8 +32,8 @@
3333 */
3434 function wmf_owa_settings() {
3535 $form[ 'wmf_owa_log' ] = array(
36 - '#type' => 'textfield',
37 - '#title' => t( 'OWA log path' ),
 36+ '#type' => 'textfield',
 37+ '#title' => t( 'OWA log path' ),
3838 '#required' => TRUE,
3939 '#default_value' => variable_get('wmf_owa_log', OWA_LOG_DEFAULT ),
4040 );
@@ -88,14 +88,21 @@
8989 return;
9090 }
9191
 92+ watchdog( 'wmf_owa', 'preparing toinitialize civicrm' );
 93+
9294 // load the contribution object
9395 civicrm_initialize(true);
 96+ watchdog( 'wmf_owa', 'civicrm initialized' );
9497 require_once 'api/v2/Contribute.php';
9598 $params = array( 'contribution_id' => $contribution_id );
 99+ watchdog( 'wmf_owa', 'civi contribution_get params: %params', array( '%params' => print_r( $params, true )), WATCHDOG_DEBUG );
96100 $contribution =& civicrm_contribution_get( $params );
97101
 102+ watchdog( 'wmf_owa', 'contribution array: %array', array( '%array' => print_r( $contribution, true )), WATCHDOG_DEBUG );
 103+ watchdog( 'wmf_owa', 'contribution object: %object', array( '%object' => print_r( (object) $contribution, true )), WATCHDOG_DEBUG );
 104+
98105 // note that we cast the contribution as an object so wmf_owa_prepare_owa_query can work with it correctly
99 - $query_params = wmf_owa_prepare_owa_query( $contrib_tacking_data, (object) $contribution );
 106+ $query_params = wmf_owa_prepare_owa_query( $contrib_tracking_data, (object) $contribution );
100107
101108 // send the query to OWA
102109 wmf_owa_send_tracking( $query_params );
@@ -110,6 +117,9 @@
111118 * @return array The associatve array of transaction data to post to OWA
112119 */
113120 function wmf_owa_prepare_owa_query( $contrib_tracking_obj, $contrib_obj ) {
 121+ watchdog( 'wmf_owa', 'contrib_tracking_obj: %contrib_tracking_obj', array( '%contrib_tracking_obj' => print_r( $contrib_tracking_obj, true)), WATCHDOG_DEBUG );
 122+ watchdog( 'wmf_owa', 'contrib_obj: %contrib_obj', array( '%contrib_obj' => print_r( $contrib_obj, true )), WATCHDOG_DEBUG );
 123+
114124 /**
115125 * Set the amount and owa order source fields
116126 *
@@ -119,7 +129,7 @@
120130 */
121131 if ( $contrib_obj->source == 'RFD' ) {
122132 // append RFD to the order source - this allows to send a unique trxn using the same OWA session
123 - $owa_ct_order_source = $contrib_tracking_obj->contribution_tracing_id . '-RFD';
 133+ $owa_ct_order_source = $contrib_tracking_obj->contribution_tracking_id . '-RFD';
124134
125135 // we want to send a negative amount to OWA to cancel out the original trxn, which means we need to fetch the original amount
126136 $query = "SELECT total_amount FROM civicrm_contribution WHERE id=%d";
@@ -131,11 +141,11 @@
132142 }
133143
134144 //fetch the gateway from the transaction id - it's the first element in the trxn_id
135 - $gateway = substr( $trxn_id, 0, strpos( $trxn_id, "\s" ) );
 145+ $gateway = substr( $contrib_obj->trxn_id, 0, strpos( $contrib_obj->trxn_id, " " ) );
136146
137147 // format the contribution tracking message
138148 $query_params = array(
139 - "owa_event_type" => "ecommerce.transaction",
 149+ "owa_event_type" => "ecommerce.transaction",
140150 "owa_ct_order_id" => $owa_ct_order_source,
141151 "owa_ct_order_source" => $contrib_tracking_obj->utm_campaign,
142152 "owa_ct_total" => $total_amount,
@@ -149,8 +159,7 @@
150160 // log the query params
151161 watchdog( 'wmf_owa',
152162 'OWA tracking params for contribution_id %objectId: %query_params',
153 - array( '%objectId' => $objectId, '%query_params' => print_r( $query_params, true ) ),
154 - WATCHDOG_DEBUG );
 163+ array( '%objectId' => $objectId, '%query_params' => print_r( $query_params, true ) ), WATCHDOG_DEBUG );
155164
156165 return $query_params;
157166 }
@@ -161,7 +170,7 @@
162171 * @return array
163172 */
164173 function wmf_owa_get_contribution_tracking_data( $contribution_id ) {
165 - $query = 'SELECT ct.id as "contribuion_tracking_id", ct.owa_session, ctor.url, ct.utm_campaign
 174+ $query = 'SELECT ct.id as "contribution_tracking_id", ct.owa_session, ctor.url, ct.utm_campaign
166175 FROM contribution_tracking ct, contribution_tracking_owa_ref ctor
167176 WHERE ctor.id=ct.owa_ref && ct.contribution_id="%d"';
168177 $result = db_fetch_object( db_query( $query, $contribution_id ));
@@ -203,4 +212,4 @@
204213
205214 curl_close( $ch );
206215 return;
207 -}
\ No newline at end of file
 216+}

Status & tagging log