Solved

Trouble with xml credit card transactions

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now