从actionresult重定向到付款快递网站

时间:2015-07-03 06:45:39

标签: c# asp.net asp.net-mvc payment-gateway

我在点击结算提交按钮时尝试打开付款快递网站。为此我写了这段代码

 [HttpPost]
        public ActionResult Billing()   
        {
            string URI = ConfigurationManager.AppSettings["paymentexpressUrl"].ToString();

            var PxPayUserId = ConfigurationManager.AppSettings["PxPayUserId"].ToString();
            var PxPayKey = ConfigurationManager.AppSettings["PxPayKey"].ToString();

            // form the PXPost Xml message
            StringWriter sw = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw);
            xtw.WriteStartElement("Txn");
            xtw.WriteElementString("PostUsername", PxPayUserId);
            xtw.WriteElementString("PostPassword", PxPayKey);
            xtw.WriteElementString("Amount", "100");
            xtw.WriteElementString("InputCurrency", "USD");
            xtw.WriteElementString("TxnType", "Purchase");
            xtw.WriteElementString("TxnId", "");
            xtw.WriteElementString("MerchantReference", "Test Transaction");
            xtw.WriteEndElement();
            xtw.Close();



            // Send the Xml message to PXPost
            WebRequest wrq = WebRequest.Create(URI);
            wrq.Method = "POST";
            wrq.ContentType = "application/x-www-form-urlencoded";

            byte[] b = Encoding.ASCII.GetBytes(sw.ToString());
            wrq.ContentLength = b.Length;

            Stream s = wrq.GetRequestStream();
            s.Write(b, 0, b.Length);
            s.Close();

            return wrq;
        }

但不知道如何将其重定向到付款快递网站。 我怎样才能做到这一点。

1 个答案:

答案 0 :(得分:2)

查看您尝试执行的操作是使用自己的组件来完成付款。 请从Given Link下载示例代码,因此您将能够解决相同的问题。 (检查整个代码。他们已添加相同的内容,因为这样做。)还可以找到整个文档的相关链接:Link to documentation

相关问题