拆分字符串(格式:MerId=001&OrderNo=20031106100001&OrderAmount=59.32& CurrCode=CNY&CallBackUrl=http://www.001.com/GNETPG/OvRcv.asp& ResultMode=0& Reserved01=&Reserved02=)
拆分字符串(格式:MerId=001&OrderNo=20031106100001&OrderAmount=59.32& CurrCode=CNY&CallBackUrl=http://www.001.com/GNETPG/OvRcv.asp& ResultMode=0& Reserved01=&Reserved02=)
private string GetValue(string TobeGetStr, string FieldName)
{
if (TobeGetStr == "" || FieldName == "")
{
return "";
}
string[] tempArr= TobeGetStr.Split(new char[]{'&'});
for (int i = 0; i < tempArr.Length; i++)
{
string tmpFieldName = tempArr[i].Split(new char[] { '=' })[0];
string tmpFieldValue = tempArr[i].Split(new char[] { '=' })[1];
if (FieldName.ToUpper() == tmpFieldName.ToUpper())
{
return tmpFieldValue;
}
}
return "";
}
调用如下:
OrderNo = GetValue(DecryptedMsg, "OrderNo"); //商户订单号
PayNo = GetValue(DecryptedMsg, "PayNo"); //支付单号
PayAmount = GetValue(DecryptedMsg, "PayAmount"); //支付金额,格式:元.角分
CurrCode = GetValue(DecryptedMsg, "CurrCode"); //货币代码
SystemSSN = GetValue(DecryptedMsg, "SystemSSN");