Advertisement

05.14.2008 at 04:47AM PDT, ID: 23400989
[x]
Attachment Details

Doing a post using XMLHTTP - help needed with cookies.

Asked by georgep7 in VB Script, JavaScript, Active Server Pages (ASP)

Tags: ASP VBSCRIPT XML, IE/FF/Safari

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&"_"&Session.LCID&"_"&Now()

Response.Buffer = True
  Dim objXMLHTTP, xml
  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")        
 
  xml.Open "POST", "https://select.worldpay.com/wcc/purchase", False
  xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

  xml.Send "desc=Subscription&instId=xxxxx&testMode=0&cartId="&cartId&"&futurePayType=regular&option=1&startDelayMult=1&startDelayUnit=3&noOfPayments=0&intervalUnit=3&intervalMult=1&normalAmount=9.95&initialAmount=9.95&amount=9.95&currency=USD&subst=yes&MC_uname="&MC_uname&"&name="&clientname&"&address="&fulladdress&"&postcode="&postcode&"&email="&email1&"&country="&country&"&tel="&tel&"&countrystring="&countrystring
 
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("JSESSIONID") = cookies2
Response.write(Replace(theResponse,"<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
[+][-]05.16.2008 at 07:13PM PDT, ID: 21587747

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 10:04PM PDT, ID: 21588048

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 11:21PM PDT, ID: 21588162

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:06AM PDT, ID: 21588244

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:23AM PDT, ID: 21588267

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:27AM PDT, ID: 21588274

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:50AM PDT, ID: 21588322

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:51AM PDT, ID: 21588327

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 12:54AM PDT, ID: 21588334

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 01:31AM PDT, ID: 21588437

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 07:18AM PDT, ID: 21589412

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 02:40PM PDT, ID: 21590846

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 04:02PM PDT, ID: 21591027

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 01:35AM PDT, ID: 21591960

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 01:48AM PDT, ID: 21591991

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 04:12AM PDT, ID: 21592277

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 04:18AM PDT, ID: 21592292

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 04:21AM PDT, ID: 21592299

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 04:38AM PDT, ID: 21592331

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, JavaScript, Active Server Pages (ASP)
Tags: ASP VBSCRIPT XML, IE/FF/Safari
Sign Up Now!
Solution Provided By: mplungjan
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.18.2008 at 04:58AM PDT, ID: 21592378

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:18AM PDT, ID: 21592423

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:21AM PDT, ID: 21592433

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:26AM PDT, ID: 21592454

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:34AM PDT, ID: 21592476

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 05:47AM PDT, ID: 21592516

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628