Index: civicrm/trunk/sites/all/modules/paypal_audit/paypal_audit.module |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | $report = $audit->getCustomReport( $start_date, $end_date, $options ); |
97 | 97 | |
98 | 98 | // 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' )); |
100 | 100 | watchdog( 'paypal_audit', 'PayPal custom report run complete.', array(), WATCHDOG_DEBUG ); |
101 | 101 | //loop through trxns (each trxn is a reportDataRow object), isolate paypal v non-paypal |
102 | 102 | foreach( $report->getData() as $trxn ) { |
— | — | @@ -110,12 +110,12 @@ |
111 | 111 | watchdog( 'paypal_audit', 'PayflowPro transactions present in report: @d', array('@d' => count($pf_trxns)), WATCHDOG_DEBUG ); |
112 | 112 | |
113 | 113 | //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 ); |
115 | 115 | watchdog( 'paypal_audit', 'PayPal transactions missing: @d', array( '@d' => count($pp_trxns_missing)), WATCHDOG_DEBUG ); |
116 | 116 | $missing_trxns = array_merge( $missing_trxns, paypal_audit_format_trxns( $pp_trxns_missing, $report, 'PayPal' )); |
117 | 117 | |
118 | 118 | //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 ); |
120 | 120 | watchdog( 'paypal_audit', 'PayflowPro transactions missing: @d', array( '@d' => count($pf_trxns_missing)), WATCHDOG_DEBUG ); |
121 | 121 | $missing_trxns = array_merge( $missing_trxns, paypal_audit_format_trxns( $pf_trxns_missing, $report )); |
122 | 122 | |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | * @param array $pp_trxns |
130 | 130 | * @return array Missing transactions with full trxn data row objects |
131 | 131 | */ |
132 | | -function paypal_audit_find_missing_pp_trxns( $pp_trxns ) { |
| 132 | +function paypal_audit_find_missing_pp_trxns( $pp_trxns, $columns ) { |
133 | 133 | $missing_trxns = array(); |
134 | 134 | |
135 | 135 | $dbs = _queue2civicrm_get_dbs(); |
— | — | @@ -139,10 +139,14 @@ |
140 | 140 | $query = "SELECT {trxn_id} |
141 | 141 | FROM civicrm_contribution |
142 | 142 | 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 . "%" ); |
144 | 144 | if ( !$result->num_rows ) { |
145 | 145 | 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 ); |
147 | 151 | } else { |
148 | 152 | watchdog( 'paypal_audit', 'Found PayPal: @id', array( "@id" => $pp_trxn_id ), WATCHDOG_DEBUG ); |
149 | 153 | } |
— | — | @@ -160,7 +164,7 @@ |
161 | 165 | * @param array $pf_trxns |
162 | 166 | * @return array Missing trxns with full trxn data row objects |
163 | 167 | */ |
164 | | -function paypal_audit_find_missing_pf_trxns( $pf_trxns ) { |
| 168 | +function paypal_audit_find_missing_pf_trxns( $pf_trxns, $columns ) { |
165 | 169 | $missing_trxns = array(); |
166 | 170 | |
167 | 171 | $dbs = _queue2civicrm_get_dbs(); |
— | — | @@ -169,10 +173,14 @@ |
170 | 174 | // check for matching ids - if it doesnt match, it's missing |
171 | 175 | foreach ( array_keys( $pf_trxns ) as $pf_trxn_id ) { |
172 | 176 | $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 . "%" ); |
174 | 178 | if ( !$result->num_rows ) { |
175 | 179 | 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 ); |
177 | 185 | } else { |
178 | 186 | watchdog( 'paypal_audit', 'Found Payflow: @id', array( '@id' => $pf_trxn_id ), WATCHDOG_DEBUG ); |
179 | 187 | } |