Hi, I am having a difficult time in trying to get a post using XMLHTTP to work. I have been instructed that the issue may be cookies.
Firstly, when doing this the standard html form way, here is what happens. First the form (don t worry about the fields and values):
<form action="
https://select.worldpay.com/wcc/purchase" method="post">
<input type="hidden" name="desc" value="A product">
<input type="hidden" name="instId" value="xxxxx">
<input type="hidden" name="testMode" value="0">
<input type="hidden" name="cartId" value="5645456">
<input type="hidden" name="futurePayType" value="regular">
<input type="hidden" name="option" value="1">
<input type="hidden" name="startDelayMult" value="1">
<input type="hidden" name="startDelayUnit" value="3">
<input type="hidden" name="noOfPayments" value="0">
<input type="hidden" name="intervalMult" value="1">
<input type="hidden" name="intervalUnit" value="3">
<input type="hidden" name="normalAmount" value="9.95">
<input type="hidden" name="initialAmount" value="9.95">
<input type="hidden" name="amount" value="9.95">
<input type="hidden" name="currency" value="USD">
<input type="hidden" name="subst" value="yes">
<input type="submit" value="Continue">
</form>
If you run this and click the "continue" button it will take you to the WorldPay Secure Payment page. You then click on one of the payment buttons - the browser informs you are being redirected and then it eventually shows up a form to fill out and make your payment. All fine.
Now, I have written the following for submitting the using XMHTTP, purely so that the client can't fiddle with any of the submission fields:
<%
MC_uname = "auser"
clientname = "Some Name"
address1 = "The Address"
city = "The City"
countrystate = "The State"
countrystring = "USA"
postcode = "3000"
email1 = "me@hotmail.com"
country = "US"
tel = "123123123"
fulladdress = address1&", "&city&", "&countrystate
cartId = Session.SessionID&"_"&Sess
ion.LCID&"
_"&Now()
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("MSXML
2.ServerXM
LHTTP.6.0"
)
xml.Open "POST", "
https://select.worldpay.com/wcc/purchase", False
xml.setRequestHeader "Content-Type", "application/x-www-form-ur
lencoded"
xml.Send "desc=Subscription&instId=
xxxxx&test
Mode=0&car
tId="&cart
Id&"&futur
ePayType=r
egular&opt
ion=1&star
tDelayMult
=1&startDe
layUnit=3&
noOfPaymen
ts=0&inter
valUnit=3&
intervalMu
lt=1&norma
lAmount=9.
95&initial
Amount=9.9
5&amount=9
.95¤
cy=USD&sub
st=yes&MC_
uname="&MC
_uname&"&n
ame="&clie
ntname&"&a
ddress="&f
ulladdress
&"&postcod
e="&postco
de&"&email
="&email1&
"&country=
"&country&
"&tel="&te
l&"&countr
ystring="&
countrystr
ing
do while not xml.readyState = 4
xml.waitForResponse(1000)
Loop
getHeader = xml.getAllResponseHeaders
startCookie = InStr(getHeader, "machine=")
cookies1 = Mid(getHeader,startCookie+
8,100)
EndCookie = InStr(cookies1, ";")
cookies1 = Mid(cookies1,1,EndCookie-1
)
startCookie = InStr(getHeader, "JSESSIONID=")
cookies2 = Mid(getHeader,startCookie+
11,100)
EndCookie = InStr(cookies2, ";")
cookies2 = Mid(cookies2,1,EndCookie-1
)
theResponse = xml.responseText
response.Cookies("machine"
) = cookies1
response.Cookies("JSESSION
ID") = cookies2
Response.write(Replace(the
Response,"
<head>","<
head><base
href=""
https://select.worldpay.com/wcc/purchase"">"))
set xml = nothing
%>
I am extracting out two cookies "machine" and "JSESSIONID" and passing them back before doing a response of the xml. When you run the script above in a browser, everything seems fine. The first page to come up is the Secure Payment Page, and you go ahead and click one of the payment buttons. The next page to show (almost every time) is an error page informing me:
Sorry, there was an error in processing this transaction:
No payment information is available. This means that one of the following has occurred:
- you have completed or cancelled your payment
- you have cookies disabled. To complete your payment, enable cookies by changing the privacy settings in your browser. Then return to the merchant's site and resubmit your payment
- your session at WorldPay has timed out. Please return to the merchant's site and resubmit your payment
Every now and then it will work and take me to the final form (as with the first example above using the html form example). I have tried closing the browser and starting a whole new session, restarting my PC, trying it from a range of local and online PCs. No good. Works once in a while but mostly gives me the error page.
Can anyone see what is going wrong using the second method. Greatly appreciate any help as this has got me completely stumped, especially as it works once in a while and then stops working (i.e. gives the error page instead of the final payment form) :-(
Start Free Trial