【问题标题】:Sagepay Server .Net Integration - not seeing data in POST to Notification pageSagepay Server .Net 集成 - 在 POST 到通知页面中看不到数据
【发布时间】:2018-10-25 09:11:44
【问题描述】:

我已经下载并安装了 .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.InputStreamRequest.Form.AllKeysRequest.QueryString 找不到任何内容(除了我自己传递的客户 UID)。

我曾尝试向 sagepay 寻求帮助,但他们“......无法为套件提供直接开发支持,因为它们是示例”。

我没有想法,想知道是否有其他人可以帮助解释一下?

干杯

西蒙

【问题讨论】:

    标签: .net post webforms opayo


    【解决方案1】:

    终于有了解决办法,感谢https://www.mikesdotnetting.com/article/293/request-form-is-empty-when-posting-to-aspx-page

    问题在于友好的 URL。只需在 RouteConfig.cs 中注释掉 //settings.AutoRedirectMode = RedirectMode.Permanent; 即可解决问题!

    【讨论】:

    • 嗨西蒙,你介意分享一下项目的示例源代码吗?我收到错误 5006。
    • 嗨,Kevin - 我的代码太集成到项目中,无法提取一个像样的示例,但错误 5006 是未能提供重定向 URL。在 SagePay 发送结果的通知页面上,您是否在响应中设置了重定向 URL?
    • Response.Clear() Response.ContentType = "text/plain" Response.Write(String.Format("Status={0}" & vbLf, If(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))
    猜你喜欢
    • 1970-01-01
    • 2019-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-03
    相关资源
    最近更新 更多