Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php |
— | — | @@ -698,19 +698,19 @@ |
699 | 699 | |
700 | 700 | // prepare NVP response for sorting and outputting |
701 | 701 | $responseArray = array(); |
702 | | - |
703 | | - while( strlen( $result ) ) { |
704 | | - // name |
705 | | - $namepos = strpos( $result, '=' ); |
706 | | - $nameval = substr( $result, 0, $namepos ); |
707 | | - // value |
708 | | - $valuepos = strpos( $result, '&' ) ? strpos( $result, '&' ) : strlen( $result ); |
709 | | - $valueval = substr( $result, $namepos + 1, $valuepos - $namepos - 1 ); |
710 | | - // decoding the respose |
711 | | - $responseArray[$nameval] = $valueval; |
712 | | - $result = substr( $result, $valuepos + 1, strlen( $result ) ); |
| 702 | + |
| 703 | + /** |
| 704 | + * The result response string looks like: |
| 705 | + * RESULT=7&PNREF=E79P2C651DC2&RESPMSG=Field format error&HOSTCODE=10747&DUPLICATE=1 |
| 706 | + * We want to turn this into an array of key value pairs, so explode on '&' and then |
| 707 | + * split up the resulting strings into $key => $value |
| 708 | + */ |
| 709 | + $result_arr = explode( "&", $result ); |
| 710 | + foreach ( $result_arr as $result_pair ) { |
| 711 | + list( $key, $value ) = split( "=", $result_pair ); |
| 712 | + $responseArray[ $key ] = $value; |
713 | 713 | } |
714 | | - |
| 714 | + |
715 | 715 | // errors fall into three categories, "try again please", "sorry it didn't work out", and "approved" |
716 | 716 | // get the result code for response array |
717 | 717 | $resultCode = $responseArray['RESULT']; |
— | — | @@ -724,7 +724,6 @@ |
725 | 725 | $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg ); |
726 | 726 | |
727 | 727 | // if approved, display results and send transaction to the queue |
728 | | - |
729 | 728 | if( $errorCode == '1' ) { |
730 | 729 | $this->fnPayflowDisplayApprovedResults( $data, $responseArray, $responseMsg ); |
731 | 730 | // give user a second chance to enter incorrect data |