r86658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86657‎ | r86658 | r86659 >
Date:19:34, 21 April 2011
Author:awjrichards
Status:deferred
Tags:
Comment:
Added more detailed watchdog statements to do deeper double checking of missing trxns, this necessitated addint as a param for the find_missing functions; Also added 'Type' as a columen to search for to verify that we're only seeing 'Sale' types
Modified paths:
  • /civicrm/trunk/sites/all/modules/paypal_audit/paypal_audit.module (modified) (history)

Diff [purge]

Index: civicrm/trunk/sites/all/modules/paypal_audit/paypal_audit.module
@@ -95,7 +95,7 @@
9696 $report = $audit->getCustomReport( $start_date, $end_date, $options );
9797
9898 // find the 'tender type' and trxn id columns so we can tell paypal v payflow
99 - $columns = $report->getReportResponse()->findColumnNumber( array('Tender Type', 'Transaction ID', 'PayPal Transaction ID' ));
 99+ $columns = $report->getReportResponse()->findColumnNumber( array('Tender Type', 'Transaction ID', 'PayPal Transaction ID', 'Type' ));
100100 watchdog( 'paypal_audit', 'PayPal custom report run complete.', array(), WATCHDOG_DEBUG );
101101 //loop through trxns (each trxn is a reportDataRow object), isolate paypal v non-paypal
102102 foreach( $report->getData() as $trxn ) {
@@ -110,12 +110,12 @@
111111 watchdog( 'paypal_audit', 'PayflowPro transactions present in report: @d', array('@d' => count($pf_trxns)), WATCHDOG_DEBUG );
112112
113113 //check for missing non-paypal
114 - $pp_trxns_missing = paypal_audit_find_missing_pp_trxns( $pp_trxns );
 114+ $pp_trxns_missing = paypal_audit_find_missing_pp_trxns( $pp_trxns, $columns );
115115 watchdog( 'paypal_audit', 'PayPal transactions missing: @d', array( '@d' => count($pp_trxns_missing)), WATCHDOG_DEBUG );
116116 $missing_trxns = array_merge( $missing_trxns, paypal_audit_format_trxns( $pp_trxns_missing, $report, 'PayPal' ));
117117
118118 //check for missing paypal
119 - $pf_trxns_missing = paypal_audit_find_missing_pf_trxns( $pf_trxns );
 119+ $pf_trxns_missing = paypal_audit_find_missing_pf_trxns( $pf_trxns, $columns );
120120 watchdog( 'paypal_audit', 'PayflowPro transactions missing: @d', array( '@d' => count($pf_trxns_missing)), WATCHDOG_DEBUG );
121121 $missing_trxns = array_merge( $missing_trxns, paypal_audit_format_trxns( $pf_trxns_missing, $report ));
122122
@@ -128,7 +128,7 @@
129129 * @param array $pp_trxns
130130 * @return array Missing transactions with full trxn data row objects
131131 */
132 -function paypal_audit_find_missing_pp_trxns( $pp_trxns ) {
 132+function paypal_audit_find_missing_pp_trxns( $pp_trxns, $columns ) {
133133 $missing_trxns = array();
134134
135135 $dbs = _queue2civicrm_get_dbs();
@@ -139,10 +139,14 @@
140140 $query = "SELECT {trxn_id}
141141 FROM civicrm_contribution
142142 WHERE trxn_id LIKE 'PAYPAL %s' OR trxn_id LIKE 'RECURRING PAYPAL %s'";
143 - $result = db_query( $query, $pp_trxn_id . "%" );
 143+ $result = db_query( $query, $pp_trxn_id . "%", $pp_trxn_id . "%" );
144144 if ( !$result->num_rows ) {
145145 array_push( $missing_trxns, $pp_trxns[ $pp_trxn_id ] );
146 - watchdog( 'paypal_audit', 'Missing PayPal: @id', array( "@id" => $pp_trxn_id ), WATCHDOG_DEBUG );
 146+ watchdog( 'paypal_audit', 'Missing PayPal: @tx_id, @pp_tx_id, @t, @tt', array(
 147+ "@tx_id" => $pp_trxns[$pp_trxn_id][ $columns['Transaction ID']],
 148+ "@pp_tx_id" => $pp_trxns[$pp_trxn_id][ $columns['PayPal Transaction ID']],
 149+ "@t" => $pp_trxns[$pp_trxn_id][ $columns['Type']],
 150+ "@tt" => $pp_trxns[$pp_trxn_id][ $columns['Tender Type']] ), WATCHDOG_DEBUG );
147151 } else {
148152 watchdog( 'paypal_audit', 'Found PayPal: @id', array( "@id" => $pp_trxn_id ), WATCHDOG_DEBUG );
149153 }
@@ -160,7 +164,7 @@
161165 * @param array $pf_trxns
162166 * @return array Missing trxns with full trxn data row objects
163167 */
164 -function paypal_audit_find_missing_pf_trxns( $pf_trxns ) {
 168+function paypal_audit_find_missing_pf_trxns( $pf_trxns, $columns ) {
165169 $missing_trxns = array();
166170
167171 $dbs = _queue2civicrm_get_dbs();
@@ -169,10 +173,14 @@
170174 // check for matching ids - if it doesnt match, it's missing
171175 foreach ( array_keys( $pf_trxns ) as $pf_trxn_id ) {
172176 $query = "SELECT {trxn_id} FROM civicrm_contribution WHERE trxn_id LIKE 'PAYFLOWPRO %s'";
173 - $result = db_query( $query, $pf_trxn_id . "%" );
 177+ $result = db_query( $query, $pf_trxn_id . "%", $pf_trxn_id . "%" );
174178 if ( !$result->num_rows ) {
175179 array_push( $missing_trxns, $pf_trxns[ $pf_trxn_id ] );
176 - watchdog( 'paypal_audit', 'Missing Payflow: @id', array( '@id' => $pf_trxn_id ), WATCHDOG_DEBUG );
 180+ watchdog( 'paypal_audit', 'Missing PayflowPro: @tx_id, @pp_tx_id, @t, @tt', array(
 181+ "@tx_id" => $pf_trxns[$pf_trxn_id][ $columns['Transaction ID']],
 182+ "@pp_tx_id" => $pf_trxns[$pf_trxn_id][ $columns['PayPal Transaction ID']],
 183+ "@t" => $pf_trxns[$pf_trxn_id][ $columns['Type']],
 184+ "@tt" => $pf_trxns[$pf_trxn_id][ $columns['Tender Type']] ), WATCHDOG_DEBUG );
177185 } else {
178186 watchdog( 'paypal_audit', 'Found Payflow: @id', array( '@id' => $pf_trxn_id ), WATCHDOG_DEBUG );
179187 }

Status & tagging log