【问题标题】:How to read Post Parameters from Payment Gateway API After Successful Transaction交易成功后如何从支付网关 API 读取 Post 参数
【发布时间】: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


    【解决方案1】:

    使用 Fiddler,它会向您显示所有来回的流量,并提供更准确的图片来了解这些交易之间发生的情况

    https://www.telerik.com/download/fiddler


    编辑

    一个HTTP消息可以由两部分组成,一是标头,二是正文。

    向服务器发出 GET 请求时,它不会包含正文。另一方面,POST 请求会。标题和正文之间有换行符...我在下面演示了一个 POST 请求

    【讨论】:

    • 我刚刚下载了fiddler。我不知道如何使用它,你能告诉我在哪里可以找到帖子参数
    • 感谢您的回复。您是否显示用于从我们这边向服务器发送 POST 数据的图像。但我想要我从服务器获取的数据,你能建议我如何获取
    猜你喜欢
    • 2012-11-13
    • 1970-01-01
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 2018-08-22
    • 1970-01-01
    • 2020-06-20
    • 2017-08-04
    相关资源
    最近更新 更多