Sagepay 服务器 .Net 集成 - 未在通知页面的 POST 中看到数据
Sagepay Server .Net Integration - not seeing data in POST to Notification page
我已将 .Net sagepay 集成工具包下载并安装到一个项目中,并且正在尝试实施服务器集成。
在用户转移到 sagepay 之前一切正常,您可以成功付款,但是当 sagepay POST 转到我的 Notification.aspx 页面时,我没有收到任何数据。
POST 肯定是在创建,因为服务器日志看到它进来了,redirectURL 被传回,以便 Sagepay 将用户重定向回我的网站,但我找不到任何 POST 数据来处理并知道我正在处理什么交易。
套件中应该处理此问题的代码是:
public partial class Server_Notification : System.Web.UI.Page
{
private const string OK = "OK";
private const string INVALID = "INVALID";
protected void Page_Load(object sender, EventArgs e)
{
IServerNotificationRequest serverNotificationRequest = new SagePayServerIntegration().GetServerNotificationRequest();
try
{
OrderDataService.handleNotification(serverNotificationRequest);
if (Request.QueryString["uid"] != null && !string.IsNullOrEmpty(Request.QueryString["uid"]))
{
new CardDB().Add(Convert.ToInt32(Request.QueryString["uid"]), serverNotificationRequest.Token, serverNotificationRequest.Last4Digits);
}
if (serverNotificationRequest.Status == SagePay.IntegrationKit.ResponseStatus.OK)
{
ShoppingCart.Current().Clean();
}
}
catch (Exception ex)
{
Debug.WriteLine("ERROR: " + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
}
Response.Clear();
Response.ContentType = "text/plain";
Response.Write(string.Format("Status={0}\n", serverNotificationRequest.Status == ResponseStatus.ERROR ? INVALID : OK));
Response.Write(string.Format("RedirectURL={0}server/Result.aspx?Status={1}&VendorTxCode={2}", SagePaySettings.SiteFqdn, serverNotificationRequest.Status, serverNotificationRequest.VendorTxCode));
}
}
失败的特定行是 IServerNotificationRequest serverNotificationRequest = new SagePayServerIntegration().GetServerNotificationRequest();
这将返回一个没有交易数据的空对象。
我添加了一些日志记录并尝试手动提取任何 POST 数据,但使用 Request.InputStream
、Request.Form.AllKeys
或 Request.QueryString
(除了我自己传的客户UID)。
我曾尝试向 sagepay 寻求帮助,但他们“...无法为套件提供直接开发支持,因为它们只是示例”。
我没有想法,想知道是否还有其他人可以帮助阐明一些问题,好吗?
干杯
西蒙
终于有了解决办法,感谢https://www.mikesdotnetting.com/article/293/request-form-is-empty-when-posting-to-aspx-page
问题出在友好的 URL 上。只需在 RouteConfig.cs 中注释掉 //settings.AutoRedirectMode = RedirectMode.Permanent;
即可解决问题![=12=]
我已将 .Net sagepay 集成工具包下载并安装到一个项目中,并且正在尝试实施服务器集成。
在用户转移到 sagepay 之前一切正常,您可以成功付款,但是当 sagepay POST 转到我的 Notification.aspx 页面时,我没有收到任何数据。
POST 肯定是在创建,因为服务器日志看到它进来了,redirectURL 被传回,以便 Sagepay 将用户重定向回我的网站,但我找不到任何 POST 数据来处理并知道我正在处理什么交易。
套件中应该处理此问题的代码是:
public partial class Server_Notification : System.Web.UI.Page
{
private const string OK = "OK";
private const string INVALID = "INVALID";
protected void Page_Load(object sender, EventArgs e)
{
IServerNotificationRequest serverNotificationRequest = new SagePayServerIntegration().GetServerNotificationRequest();
try
{
OrderDataService.handleNotification(serverNotificationRequest);
if (Request.QueryString["uid"] != null && !string.IsNullOrEmpty(Request.QueryString["uid"]))
{
new CardDB().Add(Convert.ToInt32(Request.QueryString["uid"]), serverNotificationRequest.Token, serverNotificationRequest.Last4Digits);
}
if (serverNotificationRequest.Status == SagePay.IntegrationKit.ResponseStatus.OK)
{
ShoppingCart.Current().Clean();
}
}
catch (Exception ex)
{
Debug.WriteLine("ERROR: " + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
}
Response.Clear();
Response.ContentType = "text/plain";
Response.Write(string.Format("Status={0}\n", serverNotificationRequest.Status == ResponseStatus.ERROR ? INVALID : OK));
Response.Write(string.Format("RedirectURL={0}server/Result.aspx?Status={1}&VendorTxCode={2}", SagePaySettings.SiteFqdn, serverNotificationRequest.Status, serverNotificationRequest.VendorTxCode));
}
}
失败的特定行是 IServerNotificationRequest serverNotificationRequest = new SagePayServerIntegration().GetServerNotificationRequest();
这将返回一个没有交易数据的空对象。
我添加了一些日志记录并尝试手动提取任何 POST 数据,但使用 Request.InputStream
、Request.Form.AllKeys
或 Request.QueryString
(除了我自己传的客户UID)。
我曾尝试向 sagepay 寻求帮助,但他们“...无法为套件提供直接开发支持,因为它们只是示例”。
我没有想法,想知道是否还有其他人可以帮助阐明一些问题,好吗?
干杯
西蒙
终于有了解决办法,感谢https://www.mikesdotnetting.com/article/293/request-form-is-empty-when-posting-to-aspx-page
问题出在友好的 URL 上。只需在 RouteConfig.cs 中注释掉 //settings.AutoRedirectMode = RedirectMode.Permanent;
即可解决问题![=12=]