r100329 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100328‎ | r100329 | r100330 >
Date:06:31, 20 October 2011
Author:jpostlethwaite
Status:ok (Comments)
Tags:fundraising 
Comment:
Cleaned up documentation. Added public declaration to classes. Added stage_transaction_type()
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -6,7 +6,10 @@
77 const COMMUNICATION_TYPE = 'xml';
88 const GLOBAL_PREFIX = 'wgGlobalCollectGateway';
99
10 - function defineAccountInfo() {
 10+ /**
 11+ * Define accountInfo
 12+ */
 13+ public function defineAccountInfo() {
1114 $this->accountInfo = array(
1215 'MERCHANTID' => self::getGlobal( 'MerchantID' ),
1316 //'IPADDRESS' => '', //TODO: Not sure if this should be OUR ip, or the user's ip. Hurm.
@@ -14,7 +17,10 @@
1518 );
1619 }
1720
18 - function defineVarMap() {
 21+ /**
 22+ * Define var_map
 23+ */
 24+ public function defineVarMap() {
1925 $this->var_map = array(
2026 'ORDERID' => 'order_id',
2127 'AMOUNT' => 'amount',
@@ -38,7 +44,10 @@
3945 );
4046 }
4147
42 - function defineReturnValueMap() {
 48+ /**
 49+ * Define return_value_map
 50+ */
 51+ public function defineReturnValueMap() {
4352 $this->return_value_map = array(
4453 'OK' => true,
4554 'NOK' => false,
@@ -57,7 +66,20 @@
5867 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 1100, 99999 );
5968 }
6069
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() {
6284 $this->transactions = array( );
6385
6486 $this->transactions['BANK_TRANSFER'] = array(
@@ -211,8 +233,10 @@
212234 * Take the entire response string, and strip everything we don't care about.
213235 * For instance: If it's XML, we only want correctly-formatted XML. Headers must be killed off.
214236 * return a string.
 237+ *
 238+ * @param string $rawResponse The raw response a string of XML.
215239 */
216 - function getFormattedResponse( $rawResponse ) {
 240+ public function getFormattedResponse( $rawResponse ) {
217241 $xmlString = $this->stripXMLResponseHeaders( $rawResponse );
218242 $displayXML = $this->formatXmlString( $xmlString );
219243 $realXML = new DomDocument( '1.0' );
@@ -223,8 +247,10 @@
224248
225249 /**
226250 * 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
227253 */
228 - function getResponseStatus( $response ) {
 254+ public function getResponseStatus( $response ) {
229255
230256 $aok = true;
231257
@@ -240,8 +266,10 @@
241267 /**
242268 * Parse the response to get the errors in a format we can log and otherwise deal with.
243269 * return a key/value array of codes (if they exist) and messages.
 270+ *
 271+ * @param array $response The response array
244272 */
245 - function getResponseErrors( $response ) {
 273+ public function getResponseErrors( $response ) {
246274 $errors = array( );
247275 foreach ( $response->getElementsByTagName( 'ERROR' ) as $node ) {
248276 $code = '';
@@ -262,8 +290,10 @@
263291 /**
264292 * Harvest the data we need back from the gateway.
265293 * return a key/value array
 294+ *
 295+ * @param array $response The response array
266296 */
267 - function getResponseData( $response ) {
 297+ public function getResponseData( $response ) {
268298 $data = array( );
269299
270300 $transaction = $this->currentTransaction();
@@ -291,7 +321,13 @@
292322 return $data;
293323 }
294324
295 - function processResponse( $response ) {
 325+
 326+ /**
 327+ * Process the response
 328+ *
 329+ * @param array $response The response array
 330+ */
 331+ public function processResponse( $response ) {
296332 //set the transaction result message
297333 $responseStatus = isset( $response['STATUSID'] ) ? $response['STATUSID'] : '';
298334 $this->setTransactionResult( "Response Status: " . $responseStatus, 'txn_message' ); //TODO: Translate for GC.
@@ -307,7 +343,7 @@
308344 * the default case. This should prevent accidental form submission with
309345 * unknown transaction types.
310346 */
311 - function defineStagedVars() {
 347+ public function defineStagedVars() {
312348
313349 //OUR field names.
314350 $this->staged_vars = array(
@@ -315,10 +351,16 @@
316352 'card_type',
317353 //'card_num',
318354 'returnto',
 355+ 'transaction_type',
319356 'order_id', //This may or may not oughta-be-here...
320357 );
321358 }
322359
 360+ /**
 361+ * Stage: amount
 362+ *
 363+ * @param string $type request|response
 364+ */
323365 protected function stage_amount( $type = 'request' ) {
324366 switch ( $type ) {
325367 case 'request':
@@ -330,6 +372,23 @@
331373 }
332374 }
333375
 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+ */
334393 protected function stage_card_type( $type = 'request' ) {
335394
336395 $types = array(
@@ -351,13 +410,25 @@
352411 }
353412 }
354413
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;
360426 }
361427
 428+ /**
 429+ * Stage: returnto
 430+ *
 431+ * @param string $type request|response
 432+ */
362433 protected function stage_returnto( $type = 'request' ) {
363434 if ( $type === 'request' ) {
364435 $this->postdata['returnto'] = $this->postdata['returnto'] . "?order_id=" . $this->postdata['order_id'];

Comments

#Comment by Jpostlethwaite (talk | contribs)   06:35, 20 October 2011

If a method is not defined as public, protected or private. It is public by default and backwards compatibility.

It may be desired, at some point, to make some of these methods protected. This would need to be propagated up to the parent class.

Status & tagging log