C# mvc 在线付款接口返回时出现Object reference not set to an instance of an object.
付款成功了,也返回到了改页面,但是每次返回都出现Object reference not set to an instance of an object.各位大神。用的是快汇宝智付.[HttpPost]
public ActionResult Return()
{
string ResponseText = "";
string m_id = "";
string m_orderid = "";
string m_oamount = "";
string m_ocurrency = "";
string m_url = "";
string m_language = "";
string s_name = "";
string s_addr = "";
string s_postcode = "";
string s_tel = "";
string s_eml = "";
string r_name = "";
string r_addr = "";
string r_postcode = "";
string r_eml = "";
string r_tel = "";
string m_ocomment = "";
string m_status = "";
string modate = "";
string newmd5info = "";
try
{
m_id = Request.Form["m_id"].ToString();
m_orderid = Request.Form["m_orderid"].ToString();
m_oamount = Request.Form["m_oamount"].ToString();
m_ocurrency = Request.Form["m_ocurrency"].ToString();
m_url = Request.Form["m_url"].ToString();
m_language = Request.Form["m_language"].ToString();
s_name = Request.Form["s_name"].ToString();
s_addr = Request.Form["s_addr"].ToString();
s_postcode = Request.Form["s_postcode"].ToString();
s_tel = Request.Form["s_tel"].ToString();
s_eml = Request.Form["s_eml"].ToString();
r_name = Request.Form["r_name"].ToString();
r_addr = Request.Form["r_addr"].ToString();
r_postcode = Request.Form["r_postcode"].ToString();
r_eml = Request.Form["r_eml"].ToString();
r_tel = Request.Form["r_tel"].ToString();
m_ocomment = Request.Form["m_ocomment"].ToString();
m_status = Request.Form["m_status"].ToString();
modate = Request.Form["modate"].ToString();
newmd5info = Request.Form["newmd5info"].ToString();
if (newmd5info == "")
{
ResponseText = "认证签名为空值";
}
else
{
string newOrderMessage = m_id + m_orderid + m_oamount + Key + m_status;
string newMD5text = FormsAuthentication.HashPasswordForStoringInConfigFile(newOrderMessage, "md5").Trim().ToUpper();
string Upnewmd5info = newmd5info.ToUpper();
if (newMD5text != Upnewmd5info)
{
ResponseText = "认证失败!!!";
}
else
{
if (m_status == "2")
{
ResponseText = "恭喜您,支付成功!!!";
ResponseText += "m_id =" + m_id + "<br>";
ResponseText += "m_orderid =" + m_orderid + "<br>";
ResponseText += "m_oamount =" + m_oamount + "<br>";
ResponseText += "m_ocurrency =" + m_ocurrency + "<br>";
ResponseText += "m_language =" + m_language + "<br>";
ResponseText += "s_name =" + s_name + "<br>";
ResponseText += "s_addr =" + s_addr + "<br>";
ResponseText += "s_postcode =" + s_postcode + "<br>";
ResponseText += "s_tel =" + s_tel + "<br>";
ResponseText += "s_eml =" + s_eml + "<br>";
ResponseText += "r_name =" + r_name + "<br>";
ResponseText += "r_addr =" + r_addr + "<br>";
ResponseText += "r_postcode =" + r_postcode + "<br>";
ResponseText += "r_eml =" + r_eml + "<br>";
ResponseText += "r_tel =" + r_tel + "<br>";
ResponseText += "m_ocomment =" + m_ocomment + "<br>";
ResponseText += "m_status =" + m_status + "<br>";
ResponseText += "modate =" + modate + "<br>";
ResponseText += "newmd5info=" + newmd5info + "<br>";
}
else
{
ResponseText = "支付失败!!!";
}
}
}
ViewBag.Message = ResponseText;
return View();
}
finally
{
}
} C# MVC 对象 实例 --------------------编程问答-------------------- public ActionResult Send()
{
var orderID = (int)TempData["sc_OrderNo"];
var order = orderService.GetOrder(orderID);
try
{
var dinPay = new DinPay();
dinPay.M_ID = "*******"; //<----商家号-------->
dinPay.MODate = DateTime.Now.ToString(); //<---不可以为空的--->
dinPay.MOrderID = order.OrderID.ToString(); //<----定单号-------->
dinPay.MOAmount = order.TotalAmount.ToString(); //<----定单金额------>
dinPay.MOCurrency = "1"; //<----币种-默认为1---->
dinPay.M_URL = "http://www.globalwinds.com.cn/Dinpay/Return"; //<--返回地址-此项默认为空不起作用-->
dinPay.M_Language = "1";
dinPay.S_Name = order.ShippingName.ToString();
dinPay.S_Address = order.ShippingAddress1.ToString();
dinPay.S_PostCode = order.PostCode;
dinPay.S_Telephone = order.Phone;
dinPay.S_Email = order.Email;
dinPay.R_Name = order.ShippingName;
dinPay.R_Address = order.ShippingAddress1.ToString();
dinPay.R_PostCode = order.PostCode;
dinPay.R_Telephone = order.Phone;
dinPay.R_Email = order.Email;
dinPay.MOComment = order.Remark;
dinPay.State = "0";
dinPay.P_Bank = "";
string OrderMessage = dinPay.M_ID + dinPay.MOrderID + dinPay.MOAmount + dinPay.MOCurrency + dinPay.M_URL + dinPay.M_Language + dinPay.S_PostCode + dinPay.S_Telephone + dinPay.S_Email + dinPay.R_PostCode + dinPay.R_Telephone + dinPay.R_Email + dinPay.MODate + Key;
Response.Write("串起来的订单信息为:" + OrderMessage + "<br>");
string digest = FormsAuthentication.HashPasswordForStoringInConfigFile(OrderMessage, "md5").Trim().ToUpper();
Response.Write("加密认证为:" + digest);
dinPay.Digest = digest;
return View(dinPay);
}
finally
{
}
}
补充:.NET技术 , C#