<?php

class Twocheckout_Return extends Twocheckout {

	public static function check( $params = array(), $secretWord ) {
		$hashSecretWord = $secretWord;
		$hashSid        = $params['sid'];
		$hashTotal      = $params['total'];
		//Two checkout uses order number as 1 in test orders for generating hash
		$hashOrder      = 'Y' == $params ['demo'] ? 1 : $params['order_number'];
		$StringToHash   = strtoupper( md5( $hashSecretWord . $hashSid . $hashOrder . $hashTotal ) );
		if ( $StringToHash != $params['key'] ) {
			$result = Twocheckout_Message::message( 'Fail', 'Hash Mismatch' );
		} else {
			$result = Twocheckout_Message::message( 'Success', 'Hash Matched' );
		}

		return Twocheckout_Util::returnResponse( $result );
	}

}