Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php |
— | — | @@ -6,7 +6,10 @@ |
7 | 7 | const COMMUNICATION_TYPE = 'xml'; |
8 | 8 | const GLOBAL_PREFIX = 'wgGlobalCollectGateway'; |
9 | 9 | |
10 | | - function defineAccountInfo() { |
| 10 | + /** |
| 11 | + * Define accountInfo |
| 12 | + */ |
| 13 | + public function defineAccountInfo() { |
11 | 14 | $this->accountInfo = array( |
12 | 15 | 'MERCHANTID' => self::getGlobal( 'MerchantID' ), |
13 | 16 | //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm. |
— | — | @@ -14,7 +17,10 @@ |
15 | 18 | ); |
16 | 19 | } |
17 | 20 | |
18 | | - function defineVarMap() { |
| 21 | + /** |
| 22 | + * Define var_map |
| 23 | + */ |
| 24 | + public function defineVarMap() { |
19 | 25 | $this->var_map = array( |
20 | 26 | 'ORDERID' => 'order_id', |
21 | 27 | 'AMOUNT' => 'amount', |
— | — | @@ -38,7 +44,10 @@ |
39 | 45 | ); |
40 | 46 | } |
41 | 47 | |
42 | | - function defineReturnValueMap() { |
| 48 | + /** |
| 49 | + * Define return_value_map |
| 50 | + */ |
| 51 | + public function defineReturnValueMap() { |
43 | 52 | $this->return_value_map = array( |
44 | 53 | 'OK' => true, |
45 | 54 | 'NOK' => false, |
— | — | @@ -57,7 +66,20 @@ |
58 | 67 | $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 1100, 99999 ); |
59 | 68 | } |
60 | 69 | |
61 | | - function defineTransactions() { |
| 70 | + /** |
| 71 | + * Define transactions |
| 72 | + * |
| 73 | + * Please do not add more transactions to this array. |
| 74 | + * This method should define: |
| 75 | + * - INSERT_ORDERWITHPAYMENT: used for payments |
| 76 | + * - TEST_CONNECTION: testing connections - is this still valid? |
| 77 | + * - GET_ORDERSTATUS |
| 78 | + * |
| 79 | + * @todo |
| 80 | + * - Remove BANK_TRANSFER |
| 81 | + * |
| 82 | + */ |
| 83 | + public function defineTransactions() { |
62 | 84 | $this->transactions = array( ); |
63 | 85 | |
64 | 86 | $this->transactions['BANK_TRANSFER'] = array( |
— | — | @@ -211,8 +233,10 @@ |
212 | 234 | * Take the entire response string, and strip everything we don't care about. |
213 | 235 | * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off. |
214 | 236 | * return a string. |
| 237 | + * |
| 238 | + * @param string $rawResponse The raw response a string of XML. |
215 | 239 | */ |
216 | | - function getFormattedResponse( $rawResponse ) { |
| 240 | + public function getFormattedResponse( $rawResponse ) { |
217 | 241 | $xmlString = $this->stripXMLResponseHeaders( $rawResponse ); |
218 | 242 | $displayXML = $this->formatXmlString( $xmlString ); |
219 | 243 | $realXML = new DomDocument( '1.0' ); |
— | — | @@ -223,8 +247,10 @@ |
224 | 248 | |
225 | 249 | /** |
226 | 250 | * Parse the response to get the status. Not sure if this should return a bool, or something more... telling. |
| 251 | + * |
| 252 | + * @param array $response The response array |
227 | 253 | */ |
228 | | - function getResponseStatus( $response ) { |
| 254 | + public function getResponseStatus( $response ) { |
229 | 255 | |
230 | 256 | $aok = true; |
231 | 257 | |
— | — | @@ -240,8 +266,10 @@ |
241 | 267 | /** |
242 | 268 | * Parse the response to get the errors in a format we can log and otherwise deal with. |
243 | 269 | * return a key/value array of codes (if they exist) and messages. |
| 270 | + * |
| 271 | + * @param array $response The response array |
244 | 272 | */ |
245 | | - function getResponseErrors( $response ) { |
| 273 | + public function getResponseErrors( $response ) { |
246 | 274 | $errors = array( ); |
247 | 275 | foreach ( $response->getElementsByTagName( 'ERROR' ) as $node ) { |
248 | 276 | $code = ''; |
— | — | @@ -262,8 +290,10 @@ |
263 | 291 | /** |
264 | 292 | * Harvest the data we need back from the gateway. |
265 | 293 | * return a key/value array |
| 294 | + * |
| 295 | + * @param array $response The response array |
266 | 296 | */ |
267 | | - function getResponseData( $response ) { |
| 297 | + public function getResponseData( $response ) { |
268 | 298 | $data = array( ); |
269 | 299 | |
270 | 300 | $transaction = $this->currentTransaction(); |
— | — | @@ -291,7 +321,13 @@ |
292 | 322 | return $data; |
293 | 323 | } |
294 | 324 | |
295 | | - function processResponse( $response ) { |
| 325 | + |
| 326 | + /** |
| 327 | + * Process the response |
| 328 | + * |
| 329 | + * @param array $response The response array |
| 330 | + */ |
| 331 | + public function processResponse( $response ) { |
296 | 332 | //set the transaction result message |
297 | 333 | $responseStatus = isset( $response['STATUSID'] ) ? $response['STATUSID'] : ''; |
298 | 334 | $this->setTransactionResult( "Response Status: " . $responseStatus, 'txn_message' ); //TODO: Translate for GC. |
— | — | @@ -307,7 +343,7 @@ |
308 | 344 | * the default case. This should prevent accidental form submission with |
309 | 345 | * unknown transaction types. |
310 | 346 | */ |
311 | | - function defineStagedVars() { |
| 347 | + public function defineStagedVars() { |
312 | 348 | |
313 | 349 | //OUR field names. |
314 | 350 | $this->staged_vars = array( |
— | — | @@ -315,10 +351,16 @@ |
316 | 352 | 'card_type', |
317 | 353 | //'card_num', |
318 | 354 | 'returnto', |
| 355 | + 'transaction_type', |
319 | 356 | 'order_id', //This may or may not oughta-be-here... |
320 | 357 | ); |
321 | 358 | } |
322 | 359 | |
| 360 | + /** |
| 361 | + * Stage: amount |
| 362 | + * |
| 363 | + * @param string $type request|response |
| 364 | + */ |
323 | 365 | protected function stage_amount( $type = 'request' ) { |
324 | 366 | switch ( $type ) { |
325 | 367 | case 'request': |
— | — | @@ -330,6 +372,23 @@ |
331 | 373 | } |
332 | 374 | } |
333 | 375 | |
| 376 | + /** |
| 377 | + * Stage: card_num |
| 378 | + * |
| 379 | + * @param string $type request|response |
| 380 | + */ |
| 381 | + protected function stage_card_num( $type = 'request' ) { |
| 382 | + //I realize that the $type isn't used. Voodoo. |
| 383 | + if ( array_key_exists( 'card_num', $this->postdata ) ) { |
| 384 | + $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] ); |
| 385 | + } |
| 386 | + } |
| 387 | + |
| 388 | + /** |
| 389 | + * Stage: card_type |
| 390 | + * |
| 391 | + * @param string $type request|response |
| 392 | + */ |
334 | 393 | protected function stage_card_type( $type = 'request' ) { |
335 | 394 | |
336 | 395 | $types = array( |
— | — | @@ -351,13 +410,25 @@ |
352 | 411 | } |
353 | 412 | } |
354 | 413 | |
355 | | - protected function stage_card_num( $type = 'request' ) { |
356 | | - //I realize that the $type isn't used. Voodoo. |
357 | | - if ( array_key_exists( 'card_num', $this->postdata ) ) { |
358 | | - $this->postdata['card_num'] = str_replace( ' ', '', $this->postdata['card_num'] ); |
359 | | - } |
| 414 | + /** |
| 415 | + * Stage: transaction_type |
| 416 | + * |
| 417 | + * @param string $type request|response |
| 418 | + * |
| 419 | + * @todo |
| 420 | + * - This still needs to be deployed. This will alter the paymentproductid. |
| 421 | + */ |
| 422 | + protected function stage_transaction_type( $type = 'request' ) { |
| 423 | + |
| 424 | + //$this->postdata['transaction_type'] = $this->currentTransaction(); |
| 425 | + //$this->var_map['PAYMENTPRODUCTID'] = 0; |
360 | 426 | } |
361 | 427 | |
| 428 | + /** |
| 429 | + * Stage: returnto |
| 430 | + * |
| 431 | + * @param string $type request|response |
| 432 | + */ |
362 | 433 | protected function stage_returnto( $type = 'request' ) { |
363 | 434 | if ( $type === 'request' ) { |
364 | 435 | $this->postdata['returnto'] = $this->postdata['returnto'] . "?order_id=" . $this->postdata['order_id']; |