Solved

Trouble with xml credit card transactions

Posted on 2011-09-02
3
1,634 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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