从 actionresult 重定向到支付快递网站
redirect to payment express site from actionresult
我正在尝试在点击账单提交按钮时打开支付快递网站。为此我写了这段代码
[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;
}
但不知道如何将其重定向到支付快递网站。
我怎样才能做到这一点。
看看你想做的是使用他们自己的组件来完成付款。
请从 Given Link and Hence you will be able to Solve the same. (Check the Whole Code. They have added the same since this works.) Also find the Relevant Link for the whole Documentation regarding the same : Link to documentation.
下载示例代码
我正在尝试在点击账单提交按钮时打开支付快递网站。为此我写了这段代码
[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;
}
但不知道如何将其重定向到支付快递网站。 我怎样才能做到这一点。
看看你想做的是使用他们自己的组件来完成付款。 请从 Given Link and Hence you will be able to Solve the same. (Check the Whole Code. They have added the same since this works.) Also find the Relevant Link for the whole Documentation regarding the same : Link to documentation.
下载示例代码