<%
'============================================================================
'getKey()/setKey(),获取/设置密钥
'getParameter()/setParameter(),获取/设置参数值
'getAllParameters(),获取所有参数
'============================================================================
'
Class PayResponseHandler

	'应答的参数
	Private parameters

	
	'初始构造函数
	Private Sub class_initialize()
		Set parameters = Server.CreateObject("Scripting.Dictionary")	'设置集合
		parameters.RemoveAll
	End Sub


		Public Function getall()

		'接受post过来的xml数据
			Dim signParams

		Set signParams = Server.CreateObject("Scripting.Dictionary") 
		Dim varCount,varReq,xmldom
		varCount = Request.TotalBytes
		varReq = Request.BinaryRead(varCount)
		Dim content
		If varCount > 0 And Request.ServerVariables("REQUEST_METHOD") = "POST" Then
			Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
			xmlDoc.load varReq

			Set obj =  xmlDoc.selectSingleNode("xml")
			For Each node in obj.childnodes
				If node.nodename<>"sign"  Then
					If node.text<>"" And node.text<>"null"   then
						signParams.Add node.nodename, node.Text
				    End If 
				End If 
				setParameter node.nodename,node.Text
				content = content & node.nodename &"=" &node.text & chr(10)
			Next
			'记录接收到的文本类型参数
			'log()
		
     
        keys = signParams.keys()
        '按字母顺序排序
        For i = 0 To UBound(keys) - 1
            For j = i + 1 To UBound(keys)
                If StrComp(keys(i), keys(j)) > 0 Then
                    tmp = keys(i)
                    keys(i) = keys(j)
                    keys(j) = tmp
                End If
            Next
        Next
        '组合签名字符串
        For Each k In keys
            If signStr = "" Then
                signStr = k & "=" & signParams(k)
            Else
                signStr = signStr & "&" & k & "=" & signParams(k)
            End If
        Next

		'记录MD5原始加密串日志
		'log()
        getall = signStr
		End If
	End Function

	'获取参数值
	Public Function getParameter(parameter)
		getParameter = parameters.Item(parameter)
	End Function
	
	'设置参数值
	Public Sub setParameter(parameter, parameterValue)
		If parameters.Exists(parameter) = True Then
			parameters.Remove(parameter)
		End If
		parameters.Add parameter, parameterValue	
	End Sub
	'清空参数值
	Public Sub clearParameter()
		parameters.RemoveAll
	End Sub
	
	'获取所有请求的参数,返回Scripting.Dictionary
	Public Function getAllParameters()
		getAllParameters = parameters
	End Function


End class

%>