<%
	Dim mctSDK
	Dim nodeAuthorizationURL
	Dim messageType
	Dim addressFlag
	nodeAuthorizationURL = "https://www.yeepay.com/app-merchant-proxy/node"	'扣款请求URL 无需更改
	messageType="Buy"			'消息类型
	addressFlag="0"				'需要填写送货信息 0：不需要  1:需要

	
Function getReqHmacString(orderId,amount,cur,productId,productCat,productDesc,merchantCallbackURL,sMctProperties,frpId,needResponse)
	Dim sbOld
	'进行加密串处理，一定按照下列顺序进行
	sbOld=""
	sbOld = sbOld + messageType
	sbOld = sbOld + merchantId
	sbOld = sbOld + orderId
	sbOld = sbOld + CStr(amount)		
	sbOld = sbOld + cur					
	sbOld = sbOld + productId
	sbOld = sbOld + productCat
	sbOld = sbOld + productDesc
	sbOld = sbOld + merchantCallbackURL
	sbOld = sbOld + addressFlag
	sbOld = sbOld + sMctProperties
	sbOld = sbOld + frpId
	sbOld = sbOld + needResponse
	
	getReqHmacString = HMAC(sbOld,keyValue) 
	
End Function

Function getCallbackHmacString(sCmd,sErrorCode,sTrxId,orderId,amount,productId,userId,MP,bType)
	Dim sbOld
	'取得加密前的字符串
	sbOld = ""
	sbOld = sbOld + CStr(merchantId)
	sbOld = sbOld + sCmd
	sbOld = sbOld + sErrorCode
	sbOld = sbOld + sTrxId
	sbOld = sbOld + amount
	sbOld = sbOld + cur
	sbOld = sbOld + productId
	sbOld = sbOld + orderId
	sbOld = sbOld + userId
	sbOld = sbOld + MP
	sbOld = sbOld + bType

	getCallbackHmacString = HMAC(sbOld,keyValue)
	
End Function

Function CheckHmac(sCmd,sErrorCode,sTrxId,orderId,amount,productId,userId,MP,bType,hmac)
	if(hmac=getCallbackHmacString(sCmd,sErrorCode,sTrxId,orderId,amount,productId,userId,MP,bType)) Then
		CheckHmac = True
	ELSE
		CheckHmac = False
	END IF
End Function

'取得返回串中的所有参数
Sub getCallBackValue(ByRef sCmd,ByRef sErrorCode,ByRef sTrxId,ByRef amount,ByRef cur,ByRef productId,ByRef orderId,ByRef userId,ByRef MP,ByRef bType,ByRef svrHmac)
	sCmd = Request.QueryString("r0_Cmd")
	sErrorCode = Request.QueryString("r1_Code")
	sTrxId = Request.QueryString("r2_TrxId")
	amount = Request.QueryString("r3_Amt")
	cur = Request.QueryString("r4_Cur")
	productId = Request.QueryString("r5_Pid")
	orderId = Request.QueryString("r6_Order")
	userId = Request.QueryString("r7_Uid")
	MP = Request.QueryString("r8_MP")
	bType = Request.QueryString("r9_BType") 	
	svrHmac = Request.QueryString("hmac")
End Sub

%>