Solved

Trouble with xml credit card transactions

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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