Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Trouble with xml credit card transactions

Posted on 2011-09-02
3
Medium Priority
?
1,697 Views
Last Modified: 2012-06-21
I'm trying to add credit card processing to an ASP page of mine.  The payment gateway is myvirtual merchant.  Basically I'm trying to post an XML file to the payment processor and print out the response.  I keep getting the following response.  Which is the same response you get if you just go to https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do in your webbrowser so I dont think my xml file is posting.  Help!

<?xml version="1.0"?>
-<txn><errorCode>6042</errorCode><errorName>Invalid Request Format</errorName><errorMessage>XML request is not well-formed or request is incomplete.</errorMessage></txn>
ProcessCreditCard "12341234123412344","0713", "27560","6051","1.00","Joe","Test" 
	
	Function ProcessCreditCard(ccnumber,ccexp, cczip,cccvv2,ccamount,ccFirstName,ccLastName)
		CCResponse = ""
		MerchantID = "111111"
		UserID = "myuserid"
		UserPin = "XXXXXX"
		TestMode = "True"

		strxml = 	"<txn>" & _
					"<ssl_merchant_ID>" & MerchantID & "</ssl_merchant_ID>" & _
					"<ssl_result_format>ASCII</ssl_result_format>" & _
					"<ssl_user_id>" & UserID & "</ssl_user_id>" & _
					"<ssl_pin>" & UserPin & "</ssl_pin>" & _
					"<ssl_test_mode>" & TestMode & "</ssl_test_mode>" & _
					"<ssl_transaction_type>CCSALE</ssl_transaction_type>" & _
					"<ssl_card_number>" & ccnumber & "</ssl_card_number>" & _
					"<ssl_exp_date>" & ccexp & "</ssl_exp_date>" & _
					"<ssl_amount>" & ccamount & "</ssl_amount>" & _ 
					"</txn>"
					
		'Load the XML into an XMLDOM object 
		Set SendDoc = server.createobject("Microsoft.XMLDOM") 
		SendDoc.ValidateOnParse= True 
		SendDoc.LoadXML(strxml) 

		'Set the URL of the receiver 
		sURL = "https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do" 
		
		'Call the XML Send function (defined below) 
		set NewDoc = xmlSend (sURL, SendDoc) 


		response.write (NewDoc.Xml) 

		'return ccresponse
		ProcessCreditCard = CCResponse
	End Function
	
	Function xmlsend(url, docSubmit) 
		Set poster = server.CreateObject("MSXML2.SERVERXMLHttp.3.0") 
		poster.open "POST", url, false 
		poster.setRequestHeader "CONTENT_TYPE", "text/xml"
		
		poster.send docSubmit 
		
		Set NewDoc = server.createobject("Microsoft.XMLDOM") 
		newDoc.ValidateOnParse= True 
		newDoc.LoadXML(poster.responseTEXT) 
		
		Set XMLSend = NewDoc 
		Set poster = Nothing 
	End Function

Open in new window

0
Comment
Question by:blaze2342
  • 2
3 Comments
 
LVL 1

Author Comment

by:blaze2342
ID: 36473167
0
 
LVL 6

Accepted Solution

by:
c1nmo earned 2000 total points
ID: 36474439
Try:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Net;
namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string xml = "?xmldata=<txn><ssl_merchant_ID>XXXXXX</ssl_merchant_ID><ssl_user_id>YYYYYY</ssl_user_id><ssl_pin>ZZZZZZ</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>5421213556478745</ssl_card_number>%20%20%20<ssl_exp_date>0212</ssl_exp_date><ssl_amount>42.3</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>212</ssl_cvv2cvc2><ssl_customer_code>8745</ssl_customer_code><ssl_first_name>John</ssl_first_name><ssl_last_name>Muir</ssl_last_name><ssl_avs_address>1254%20Las%20Positas%20Dr</ssl_avs_address><ssl_address2></ssl_address2><ssl_city>concord</ssl_city><ssl_state>CA</ssl_state><ssl_avs_zip>94521</ssl_avs_zip><ssl_test_mode>true</ssl_test_mode><policynumber>5039740</policynumber></txn>";
            string url = "https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do";

WebRequest request = WebRequest.Create(url + xml);

request.Method = "POST";

request.ContentType = "text/xml";


System.Net.WebResponse response = request.GetResponse();

System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream());

string str = reader.ReadToEnd();


        }
    }
}


This gives a response of:

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<txn><errorCode>4012</errorCode><errorName>VID/UID Invalid</errorName><errorMessage>The VirtualMerchant ID and/or User ID supplied in the authorization request is invalid.</errorMessage></txn>"
0
 
LVL 1

Author Comment

by:blaze2342
ID: 36474629
That did the trick.  I wasn't putting it in the querystring.  The following code was the result.  Thanks!
Function ProcessWebinarCreditCard(ccnumber,ccexp,cczip,cccvv2,ccamount,ccFirstName,ccLastName)
		CCResponse = ""
		MerchantID = "111111"
		UserID = "xxxxxxx"
		UserPin = "xxxxxx"
		TestMode = "True"

		strxml = 	"<txn>" & _
					"<ssl_merchant_ID>" & MerchantID & "</ssl_merchant_ID>" & _
					"<ssl_result_format>ASCII</ssl_result_format>" & _
					"<ssl_user_id>" & UserID & "</ssl_user_id>" & _
					"<ssl_pin>" & UserPin & "</ssl_pin>" & _
					"<ssl_test_mode>" & TestMode & "</ssl_test_mode>" & _
					"<ssl_transaction_type>CCSALE</ssl_transaction_type>" & _
					"<ssl_card_number>" & ccnumber & "</ssl_card_number>" & _
					"<ssl_exp_date>" & ccexp & "</ssl_exp_date>" & _
					"<ssl_amount>" & ccamount & "</ssl_amount>" & _ 
					"<ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator>" & _
					"<ssl_cvv2cvc2>" & cccvv2 & "</ssl_cvv2cvc2>" & _
					"</txn>"

		'Set the URL of the receiver 
		sURL = "https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do?xmldata=" & strxml 
		
		'Call the XML Send function (defined below) 
		set NewDoc = xmlSend (sURL) 

		response.write ParseXMLResponse(NewDoc, "ssl_result")
		response.write ParseXMLResponse(NewDoc, "ssl_result_message")

		'return ccresponse
		ProcessCreditCard = NewDoc
	End Function
	
	Function xmlsend(url) 
		Set poster = server.CreateObject("MSXML2.SERVERXMLHttp.3.0") 
		poster.open "GET", url, false 
		poster.send docSubmit 
		
		Set NewDoc = server.createobject("Microsoft.XMLDOM") 
		newDoc.ValidateOnParse= True 
		newDoc.LoadXML(poster.responseTEXT) 
		
		Set XMLSend = NewDoc 
		Set poster = Nothing 
	End Function

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question