Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | $this->adapter = new GlobalCollectAdapter(); |
31 | | - parent::__construct(); //the next layer up will know who we are. |
| 31 | + parent::__construct(); //the next layer up will know who we are. |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
— | — | @@ -79,20 +79,20 @@ |
80 | 80 | $this->paypalRedirect(); |
81 | 81 | return; |
82 | 82 | } |
83 | | - |
84 | 83 | |
| 84 | + |
85 | 85 | // dispatch forms/handling |
86 | | - if ( $this->adapter->checkTokens() ) { |
| 86 | + if ( $this->adapter->checkTokens() ) { |
87 | 87 | |
88 | 88 | if ( $this->adapter->posted ) { |
89 | | - |
| 89 | + |
90 | 90 | // The form was submitted and the payment method has been set |
91 | 91 | $payment_method = $this->adapter->getPaymentMethod(); |
92 | 92 | $payment_submethod = $this->adapter->getPaymentSubmethod(); |
93 | 93 | |
94 | 94 | // Check form for errors |
95 | 95 | $form_errors = $this->validateForm( $this->errors, $this->adapter->getPaymentSubmethodFormValidation() ); |
96 | | - |
| 96 | + |
97 | 97 | // If there were errors, redisplay form, otherwise proceed to next step |
98 | 98 | if ( $form_errors ) { |
99 | 99 | |
— | — | @@ -104,25 +104,23 @@ |
105 | 105 | if ( $payment_method == 'cc' ) { |
106 | 106 | |
107 | 107 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
108 | | - |
| 108 | + |
109 | 109 | // Display an iframe for credit cards |
110 | 110 | if ( $this->executeIframeForCreditCard() ) { |
111 | 111 | $this->displayResultsForDebug(); |
112 | 112 | // Nothing left to process |
113 | 113 | return; |
114 | 114 | } |
115 | | - } |
116 | | - elseif ( $payment_method == 'bt' ) { |
| 115 | + } elseif ( $payment_method == 'bt' ) { |
117 | 116 | |
118 | 117 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
119 | 118 | |
120 | 119 | if ( in_array( $this->adapter->getTransactionWMFStatus(), $this->adapter->getGoToThankYouOn() ) ) { |
121 | | - |
| 120 | + |
122 | 121 | return $this->displayBankTransferInformation(); |
123 | 122 | } |
124 | 123 | |
125 | | - } |
126 | | - elseif ( $payment_method == 'dd' ) { |
| 124 | + } elseif ( $payment_method == 'dd' ) { |
127 | 125 | |
128 | 126 | $this->adapter->do_transaction( 'DO_BANKVALIDATION' ); |
129 | 127 | |
— | — | @@ -136,51 +134,47 @@ |
137 | 135 | // Attach the error messages to the form |
138 | 136 | $this->adapter->setBankValidationErrors(); |
139 | 137 | } |
140 | | - } |
141 | | - elseif ( $payment_method == 'ew' ) { |
| 138 | + } elseif ( $payment_method == 'ew' ) { |
142 | 139 | |
143 | 140 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
144 | 141 | |
145 | 142 | $formAction = $this->adapter->getTransactionDataFormAction(); |
146 | | - |
| 143 | + |
147 | 144 | // Redirect to the bank |
148 | 145 | if ( !empty( $formAction ) ) { |
149 | 146 | return $wgOut->redirect( $formAction ); |
150 | 147 | } |
151 | 148 | |
152 | | - } |
153 | | - elseif ( $payment_method == 'obt' ) { |
| 149 | + } elseif ( $payment_method == 'obt' ) { |
154 | 150 | |
155 | 151 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
156 | 152 | |
157 | 153 | if ( in_array( $this->adapter->getTransactionWMFStatus(), $this->adapter->getGoToThankYouOn() ) ) { |
158 | | - |
| 154 | + |
159 | 155 | return $this->displayOnlineBankTransferInformation(); |
160 | 156 | } |
161 | 157 | |
162 | | - } |
163 | | - elseif ( $payment_method == 'rtbt' ) { |
| 158 | + } elseif ( $payment_method == 'rtbt' ) { |
164 | 159 | |
165 | 160 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
166 | 161 | |
167 | 162 | $formAction = $this->adapter->getTransactionDataFormAction(); |
168 | | - |
| 163 | + |
169 | 164 | // Redirect to the bank |
170 | 165 | if ( !empty( $formAction ) ) { |
171 | 166 | return $wgOut->redirect( $formAction ); |
172 | 167 | } |
173 | 168 | |
174 | | - } |
175 | | - else { |
| 169 | + } else { |
176 | 170 | $this->adapter->do_transaction( 'INSERT_ORDERWITHPAYMENT' ); |
177 | 171 | } |
178 | | - |
| 172 | + |
179 | 173 | return $this->resultHandler(); |
180 | 174 | |
181 | 175 | } |
182 | 176 | } else { |
183 | 177 | // Display form |
184 | | - |
| 178 | + |
185 | 179 | // See GlobalCollectAdapter::stage_returnto() |
186 | 180 | $oid = $wgRequest->getText( 'order_id' ); |
187 | 181 | if ( $oid ) { |
— | — | @@ -188,15 +182,15 @@ |
189 | 183 | $this->displayResultsForDebug(); |
190 | 184 | } |
191 | 185 | |
192 | | - //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere. |
193 | | - //All we seem to be doing with it now, is internal adapter logic outside of the adapter. |
| 186 | + //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere. |
| 187 | + //All we seem to be doing with it now, is internal adapter logic outside of the adapter. |
194 | 188 | $data = $this->adapter->getData_Raw(); |
195 | | - |
| 189 | + |
196 | 190 | // If the result of the previous transaction was failure, set the retry message. |
197 | 191 | if ( $data && array_key_exists( 'response', $data ) && $data['response'] == 'failure' ) { |
198 | 192 | $this->errors['retryMsg'] = wfMsg( 'php-response-declined' ); |
199 | 193 | } |
200 | | - |
| 194 | + |
201 | 195 | $this->displayForm( $this->errors ); |
202 | 196 | } |
203 | 197 | } else { //token mismatch |
— | — | @@ -215,7 +209,7 @@ |
216 | 210 | global $wgOut; |
217 | 211 | |
218 | 212 | $formAction = $this->adapter->getTransactionDataFormAction(); |
219 | | - |
| 213 | + |
220 | 214 | if ( $formAction ) { |
221 | 215 | |
222 | 216 | $paymentFrame = Xml::openElement( 'iframe', array( |
— | — | @@ -231,7 +225,7 @@ |
232 | 226 | $paymentFrame .= Xml::closeElement( 'iframe' ); |
233 | 227 | |
234 | 228 | $wgOut->addHTML( $paymentFrame ); |
235 | | - |
| 229 | + |
236 | 230 | return true; |
237 | 231 | } |
238 | 232 | |
— | — | @@ -259,23 +253,23 @@ |
260 | 254 | 'SWIFTCODE' => array('translation' => 'donate_interface-bt-swift_code', ), |
261 | 255 | 'SPECIALID' => array('translation' => 'donate_interface-bt-special_id', ), |
262 | 256 | ); |
263 | | - |
| 257 | + |
264 | 258 | $id = 'bank_transfer_information'; |
265 | | - |
| 259 | + |
266 | 260 | $return .= Xml::openElement( 'div', array( 'id' => $id ) ); // $id |
267 | 261 | |
268 | 262 | $return .= Xml::tags( 'h2', array(), wfMsg( 'donate_interface-bt-information' ) ); |
269 | | - |
| 263 | + |
270 | 264 | $return .= Xml::openElement( 'table', array( 'id' => $id . '_table' ) ); |
271 | 265 | |
272 | 266 | foreach ( $fields as $field => $meta ) { |
273 | | - |
| 267 | + |
274 | 268 | if ( isset( $results['data'][ $field ] ) ) { |
275 | 269 | $return .= Xml::openElement( 'tr', array() ); |
276 | | - |
| 270 | + |
277 | 271 | $return .= Xml::tags( 'th', array(), wfMsg( $meta['translation'] ) ); |
278 | 272 | $return .= Xml::tags( 'td', array(), $results['data'][ $field ] ); |
279 | | - |
| 273 | + |
280 | 274 | $return .= Xml::closeElement( 'tr' ); |
281 | 275 | } |
282 | 276 | } |
— | — | @@ -287,13 +281,13 @@ |
288 | 282 | $queryString = '?payment_method=' . $this->adapter->getPaymentMethod() . '&payment_submethod=' . $this->adapter->getPaymentSubmethod(); |
289 | 283 | |
290 | 284 | $url = $this->adapter->getThankYouPage() . $queryString; |
291 | | - |
| 285 | + |
292 | 286 | $link = HTML::input('MyButton', 'finished', 'button', array( 'onclick' => "window.location = '$url'" ) ); |
293 | | - |
| 287 | + |
294 | 288 | $return .= Xml::tags( 'p', array(), $link ); |
295 | | - |
| 289 | + |
296 | 290 | $return .= Xml::closeElement( 'div' ); // $id |
297 | | - |
| 291 | + |
298 | 292 | return $wgOut->addHTML( $return ); |
299 | 293 | } |
300 | 294 | |
— | — | @@ -302,7 +296,7 @@ |
303 | 297 | */ |
304 | 298 | protected function displayOnlineBankTransferInformation() { |
305 | 299 | |
306 | | - global $wgOut; |
| 300 | + global $wgOut, $wgScriptPath; |
307 | 301 | |
308 | 302 | $results = $this->adapter->getTransactionAllResults(); |
309 | 303 | |
— | — | @@ -311,23 +305,23 @@ |
312 | 306 | 'CUSTOMERPAYMENTREFERENCE' => array('translation' => 'donate_interface-obt-customer_payment_reference', ), |
313 | 307 | 'BILLERID' => array('translation' => 'donate_interface-obt-biller_id', ), |
314 | 308 | ); |
315 | | - |
| 309 | + |
316 | 310 | $id = 'bank_transfer_information'; |
317 | | - |
| 311 | + |
318 | 312 | $return .= Xml::openElement( 'div', array( 'id' => $id ) ); // $id |
319 | 313 | |
320 | 314 | $return .= Xml::tags( 'h2', array(), wfMsg( 'donate_interface-obt-information' ) ); |
321 | | - |
| 315 | + |
322 | 316 | $return .= Xml::openElement( 'table', array( 'id' => $id . '_table' ) ); |
323 | 317 | |
324 | 318 | foreach ( $fields as $field => $meta ) { |
325 | | - |
| 319 | + |
326 | 320 | if ( isset( $results['data'][ $field ] ) ) { |
327 | 321 | $return .= Xml::openElement( 'tr', array() ); |
328 | | - |
| 322 | + |
329 | 323 | $return .= Xml::tags( 'th', array(), wfMsg( $meta['translation'] ) ); |
330 | 324 | $return .= Xml::tags( 'td', array(), $results['data'][ $field ] ); |
331 | | - |
| 325 | + |
332 | 326 | $return .= Xml::closeElement( 'tr' ); |
333 | 327 | } |
334 | 328 | } |
— | — | @@ -379,11 +373,11 @@ |
380 | 374 | $url = $this->adapter->getThankYouPage() . $queryString; |
381 | 375 | |
382 | 376 | $link = HTML::input('MyButton', 'finished', 'button', array( 'onclick' => "window.location = '$url'" ) ); |
383 | | - |
| 377 | + |
384 | 378 | $return .= Xml::tags( 'p', array(), $link ); |
385 | | - |
| 379 | + |
386 | 380 | $return .= Xml::closeElement( 'div' ); // $id |
387 | | - |
| 381 | + |
388 | 382 | return $wgOut->addHTML( $return ); |
389 | 383 | } |
390 | 384 | |