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
Expand|Select|Wrap|Line Numbers
- '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
Expand|Select|Wrap|Line Numbers
- <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