【发布时间】:2016-08-29 07:50:34
【问题描述】:
我正在使用一个支付网关,它将响应发送到成功页面。他们的文档表明他们将响应作为 POST 参数发送。我试图读取这些参数,但我无法获取这些参数。我已经向支持人员发送了一封邮件,他们说他们会在重定向到成功页面之前将数据从他们的服务器发送到我们的服务器。我在成功页面中实现了我的代码。我应该在哪里实现以及如何将这些值保存在我的代码中以供进一步使用。
我的代码在这里
protected void Page_Load(object sender, EventArgs e)
{
/// store all the posted form variables in an object to use later
response notifyresponse = new response();
notifyresponse.CreditVouchersTransactionId = Request["CreditVouchersTransactionId"];
notifyresponse.MerchantName = GetFormVariableOrNull(Request["MerchantName"]);
notifyresponse.AmountToPay = GetFormVariableOrNull(Request["AmountToPay"]);
notifyresponse.PaymentOKURL = GetFormVariableOrNull(Request["PaymentOKURL"]);
notifyresponse.OrderId = GetFormVariableOrNull(Request["OrderId"]);
notifyresponse.AmountCurrency = GetFormVariableOrNull(Request["AmountCurrency"]);
notifyresponse.PaymentType = GetFormVariableOrNull(Request["AmountType"]);
notifyresponse.PaymentStatus = GetFormVariableOrNull(Request["PaymentStatus"]);
string[] keys = Request.Form.AllKeys;
for (int i = 0; i < keys.Length; i++)
{
Session["amountpay"]=keys[i] ;
}
}
protected string GetFormVariableOrNull(object formvariable)
{
if (formvariable != null)
{
try
{
return formvariable.ToString();
}
catch (Exception ex)
{
/// log the exception in file or DB
Console.WriteLine(ex.Message);/// just for an example
return null;
}
}
else
return null;
}
谢谢
【问题讨论】:
标签: c# asp.net payment-gateway