Index: civicrm/trunk/sites/all/modules/wmf_owa/wmf_owa.module |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | */ |
34 | 34 | function wmf_owa_settings() { |
35 | 35 | $form[ 'wmf_owa_log' ] = array( |
36 | | - '#type' => 'textfield', |
37 | | - '#title' => t( 'OWA log path' ), |
| 36 | + '#type' => 'textfield', |
| 37 | + '#title' => t( 'OWA log path' ), |
38 | 38 | '#required' => TRUE, |
39 | 39 | '#default_value' => variable_get('wmf_owa_log', OWA_LOG_DEFAULT ), |
40 | 40 | ); |
— | — | @@ -88,14 +88,21 @@ |
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
| 92 | + watchdog( 'wmf_owa', 'preparing toinitialize civicrm' ); |
| 93 | + |
92 | 94 | // load the contribution object |
93 | 95 | civicrm_initialize(true); |
| 96 | + watchdog( 'wmf_owa', 'civicrm initialized' ); |
94 | 97 | require_once 'api/v2/Contribute.php'; |
95 | 98 | $params = array( 'contribution_id' => $contribution_id ); |
| 99 | + watchdog( 'wmf_owa', 'civi contribution_get params: %params', array( '%params' => print_r( $params, true )), WATCHDOG_DEBUG ); |
96 | 100 | $contribution =& civicrm_contribution_get( $params ); |
97 | 101 | |
| 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 | + |
98 | 105 | // 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 ); |
100 | 107 | |
101 | 108 | // send the query to OWA |
102 | 109 | wmf_owa_send_tracking( $query_params ); |
— | — | @@ -110,6 +117,9 @@ |
111 | 118 | * @return array The associatve array of transaction data to post to OWA |
112 | 119 | */ |
113 | 120 | 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 | + |
114 | 124 | /** |
115 | 125 | * Set the amount and owa order source fields |
116 | 126 | * |
— | — | @@ -119,7 +129,7 @@ |
120 | 130 | */ |
121 | 131 | if ( $contrib_obj->source == 'RFD' ) { |
122 | 132 | // 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'; |
124 | 134 | |
125 | 135 | // we want to send a negative amount to OWA to cancel out the original trxn, which means we need to fetch the original amount |
126 | 136 | $query = "SELECT total_amount FROM civicrm_contribution WHERE id=%d"; |
— | — | @@ -131,11 +141,11 @@ |
132 | 142 | } |
133 | 143 | |
134 | 144 | //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, " " ) ); |
136 | 146 | |
137 | 147 | // format the contribution tracking message |
138 | 148 | $query_params = array( |
139 | | - "owa_event_type" => "ecommerce.transaction", |
| 149 | + "owa_event_type" => "ecommerce.transaction", |
140 | 150 | "owa_ct_order_id" => $owa_ct_order_source, |
141 | 151 | "owa_ct_order_source" => $contrib_tracking_obj->utm_campaign, |
142 | 152 | "owa_ct_total" => $total_amount, |
— | — | @@ -149,8 +159,7 @@ |
150 | 160 | // log the query params |
151 | 161 | watchdog( 'wmf_owa', |
152 | 162 | '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 ); |
155 | 164 | |
156 | 165 | return $query_params; |
157 | 166 | } |
— | — | @@ -161,7 +170,7 @@ |
162 | 171 | * @return array |
163 | 172 | */ |
164 | 173 | 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 |
166 | 175 | FROM contribution_tracking ct, contribution_tracking_owa_ref ctor |
167 | 176 | WHERE ctor.id=ct.owa_ref && ct.contribution_id="%d"'; |
168 | 177 | $result = db_fetch_object( db_query( $query, $contribution_id )); |
— | — | @@ -203,4 +212,4 @@ |
204 | 213 | |
205 | 214 | curl_close( $ch ); |
206 | 215 | return; |
207 | | -} |
\ No newline at end of file |
| 216 | +} |