http://www.mediawiki.org/wiki/Special:Code/MediaWiki/71221
Revision: 71221 Author: awjrichards Date: 2010-08-18 00:03:09 +0000 (Wed, 18 Aug 2010) Log Message: ----------- Changed payflow response parsing to explode entire response string into an array (rather than old whack string parsing), partly as per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/69650#c8461 Modified Paths: -------------- trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php Modified: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php =================================================================== --- trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php 2010-08-17 23:38:18 UTC (rev 71220) +++ trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php 2010-08-18 00:03:09 UTC (rev 71221) @@ -698,19 +698,19 @@ // prepare NVP response for sorting and outputting $responseArray = array(); - - while( strlen( $result ) ) { - // name - $namepos = strpos( $result, '=' ); - $nameval = substr( $result, 0, $namepos ); - // value - $valuepos = strpos( $result, '&' ) ? strpos( $result, '&' ) : strlen( $result ); - $valueval = substr( $result, $namepos + 1, $valuepos - $namepos - 1 ); - // decoding the respose - $responseArray[$nameval] = $valueval; - $result = substr( $result, $valuepos + 1, strlen( $result ) ); + + /** + * The result response string looks like: + * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1 + * We want to turn this into an array of key value pairs, so explode on '&' and then + * split up the resulting strings into $key => $value + */ + $result_arr = explode( "&", $result ); + foreach ( $result_arr as $result_pair ) { + list( $key, $value ) = split( "=", $result_pair ); + $responseArray[ $key ] = $value; } - + // errors fall into three categories, "try again please", "sorry it didn't work out", and "approved" // get the result code for response array $resultCode = $responseArray['RESULT']; @@ -724,7 +724,6 @@ $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg ); // if approved, display results and send transaction to the queue - if( $errorCode == '1' ) { $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ); // give user a second chance to enter incorrect data _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs