Hi, I'm building an e-commerce website for a friend and am having a bit of trouble. I'm on the checkout part where I need to submit the information to the payment gateway. The gateway has no support for php. I have the script in VBScript and JavaScript, but have run into dead ends with both. Here is what the script needs to do:
1. Create the XML object.
2. Set the objects address to the api and the request header also
3. Send the data.
4. Have the Response Text Avaliable to stick on page
Here's the code in VBScript
Here it is in JavaScript
Due to Compatibility issues and security issues with browsers neither will work for what I want them to do. Thanks for any and all help,
Mikael
1. Create the XML object.
2. Set the objects address to the api and the request header also
3. Send the data.
4. Have the Response Text Avaliable to stick on page
Here's the code in VBScript
Code:
'create the XML object
set objXML=createobject("MSXML2.XMLHTTP")
'set the XML object's address to the PayTrace API
objXML.Open "POST", "https://paytrace.com/api/default.pay", false
objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
posteddata="parmList=un~demo123|pswd~demo123|method~processtranx|tranxtype~sale|terms~Y|test~Y|"
posteddata=posteddata & "CC~4012881888818888|expmnth~12|expyr~03|amount~1.00|baddress~1234 Main#3|"
'send the request to the PayTrace API
objXML.Send posteddata
'Catch the reponse from the PayTrace API
str = objXML.ResponseText
'Clean up and destroy the XML object
set objXML = nothing
Code:
<script type="text/javascript">
<!--
function checkout()
{
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera
} else if(window.ActiveXObject) {
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); // Internet Explorer
} else {
return false;
}
xmlhttp.open("POST", "https://paytrace.com/api/default.pay", false);
xmlhttp.setRequestHeader ("Content-Type" , "application/x-www-form-urlencoded");
xmlhttp.send ("parmList=un~demo123|pswd~demo123|method~processtranx|tranxtype~sale|terms~Y|test~Y|CC~4012881888818888|expmnth~12|expyr~03|amount~1.00|baddress~1234 Main#3|");
alert(xmlhttp.ResponseText);
}
//-->
</script>
Mikael
Comment