【问题标题】:Aspx, C#, and Authorize.Net Payment Form - How to implement Authorize button?Aspx、C# 和 Authorize.Net 支付表单 - 如何实现授权按钮?
【发布时间】:2016-02-10 06:31:18
【问题描述】:

我正在使用 Visual Studio、c# 和 aspx。我的页面上有一个运行良好的网络表单。现在我想实现一个来自 Authorize.Net 的支付表单。 Authorize.Net 提供的代码如下(出于隐私考虑,我删除了该值):

<form name="PrePage" method = "post" action = "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx"> <input type = "hidden" name = "LinkId" value ="VALUEHERE" /> <input type = "submit" value = "Register" /> </form>

基本上我希望我的提交按钮到我已经工作的表单重定向到https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx。如果没有 value 字段,此重定向将不起作用。

流程是该人在我的表单上注册,然后他们被发送到此付款页面以支付他们的注册费,我无法做到这一点。之后,我希望它重定向到我的确认页面,但我也不确定如何让它工作。

我知道下面这个可以用 C# 重定向我,但是我如何附加值字段?

Response.Redirect("https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx");

【问题讨论】:

    标签: c# asp.net authorize.net


    【解决方案1】:

    我有类似的问题,几年前我在网上找到了这门课

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    
    public class remotepost
    {
        public remotepost()
        {
    
        }
    
        private System.Collections.Specialized.NameValueCollection Inputs = new System.Collections.Specialized.NameValueCollection();
        public string Url = "";
        public string Method = "post";
        public string FormName = "form1";
        public string Msg = "elaburating";
    
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        public void Add(string name, string value)
        {
            Inputs.Add(name, value);
        }
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        public void Post()
        {
            System.Web.HttpContext.Current.Response.Clear();
            System.Web.HttpContext.Current.Response.Write("<html><head>");
            System.Web.HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.forms[0].submit()\">", FormName));
            System.Web.HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\">", FormName, Method, Url));
    
            for(int i=0;i< Inputs.Keys.Count;i++)
            {
                System.Web.HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\" >", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
            }
            System.Web.HttpContext.Current.Response.Write("</form>");
            System.Web.HttpContext.Current.Response.Write(string.Format("<p style=\"font-family:Verdana,Arial; font-size:14px; text-align:center;\">{0}</p>",Msg));
            System.Web.HttpContext.Current.Response.Write("</body></html>");
            System.Web.HttpContext.Current.Response.End();
        }
    }
    

    然后在你的 buttonclick 事件中使用如下

    remotepost mrp = new remotepost();
    mrp.Url = "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx";
     mrp.Add("LinkId",VALUEHERE);
      mrp.Post();
    

    【讨论】:

      猜你喜欢
      • 2011-08-14
      • 2021-02-23
      • 2014-04-09
      • 2020-03-02
      • 2013-01-19
      • 2014-08-22
      • 2011-03-29
      • 2012-07-18
      • 2011-10-31
      相关资源
      最近更新 更多