Amit Kumar
Amit Kumar

Reputation: 5962

redirect to payment express site from actionresult

I'm trying to open Payment express site when use click on billing submit button. for this I have written this code

 [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;
        }

But don't how to redirect it to payment express site. How can i do this.

Upvotes: 1

Views: 297

Answers (1)

bhuvin
bhuvin

Reputation: 1402

See what you were trying to Do is Using their own Component to Go through payment. Please download the Sample code from the 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.

Upvotes: 2

Related Questions