Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trouble with xml credit card transactions

Posted on 2011-09-02
3
Medium Priority
?
1,675 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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/…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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