Newbie with worldpay

S

STEVE WARBURTON

I have recived a callback.asp from worlpay. I have set up the settings in my
world pay account pointing to the script. I am presuming the transation from
world pay fires the callback.asp.

What do I have to do to extract the data that comes back from world pay.
Idiot level instructions please.

the script is as follows:

<%@ LANGUAGE=vbscript %>
<% Response.Expires = 0 %>
<% Response.Buffer = TRUE %>
<% Response.ExpiresAbsolute=#Jan 01, 1980 00:00:00# %>
<% Response.CacheControl = "Private" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Simple Callback Script</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="Jamal Ahmed">
<META NAME="Description" CONTENT="Simple callback script demonstration">
</HEAD>

<BODY BGColor="#FFF9D5">
<!-- Please note this script is just an example. WorldPay doesn't guarantee
that it will work on your system and we don't provide support for this
script -->

<%

Response.Write "The number of variables sent in a QueryString => " &
Request.QueryString.Count() & "<BR><BR>"
Response.Write "The number of variables posted => " & Request.Form.Count()
& "<BR><BR><BR><BR>"

'You can set a callback password to check the callback is sent by WorldPay.
If you set the password
'we will send it back to you with every callback we send.
'callbackPW = Request.Form("callbackPW")

'If you are using callback to insert or get data from the database
'set obj = Server.CreateObject("ADODB.Command")
'obj.open "Your data source name"

trans = Request.form("transStatus")

' if the transaction was successful
If trans = "Y" then %>

<CENTER><B><FONT SIZE="6" COLOR="#CC0000">The Transaction Was
Successful</FONT></B><CENTER>

<!-- WorldPay receipt information -->
<WPDISPAY ITEM="banner">

<P align="center">
<%

' requesting the variables sent by WorldPay

instId = Request.Form("instId") ' Installation ID
cartId = Request.Form("cartId") ' Customer reference for the
particular transaction
amount = Request.Form("amount") ' The amount that was sent to
WorldPay in the order form
money = Request.Form("currency") ' The currency that was sent to
WorldPay in the order form
desc = Request.Form("desc") ' Description of the items purchsed
callTime = Request.Form("transTime") 'Time of the transaction
transId = Request.Form("transId") ' Transaction ID
testMode = Request.Form("testMode") ' 100 if it was a test
transaction and 0 for live
name = Request.Form("name") ' Shopper Details
address = Request.Form("address")
postcode = Request.Form("postcode")
country = Request.Form("country")
tel = Request.Form("tel")
email = Request.Form("email")
lang = Request.Form("lang") ' The language used on the payment page
cardType = Request.Form("cardType") ' The type of the card shopper
paid with
authCurrency = Request.Form("authCurrency") ' The currency that shopper
choose on payment page
authAmount = Request.Form("authAmount") ' The amount in currency the
shopper choose on payment page
authMode = Request.Form("authMode") ' Useful if you are using
pre-auth. "A" for immediate "E" for pre-auth
wafMerchMessage = Request.Form("wafMerchMessage") 'The message sent from
WorldPay to alert if it was possibly a fradulant transaction
AVS = Request.Form("AVS")' It is a four digit code for the
various checks performed by the bank
' First digit is for security code comparison, second digit is
for postcode comparison.
' third digit is for address comparison and fourth digit is for
country comparison.

'futurePayId = Request.Form("futurePayId") Agreement Id for FuturePay
if it was FuturePay transaction


' If you have got your own custom variables.
'M_variables = Request.Form("M_<variable name>")



' WorldPay will send an alert message in wafMerchMessage. It can have two
values Caution or Warning.
' If there is no value in that variable then that means the transaction
was OK

if (wafMerchMessage = "Caution") then
Response.Write "This transaction is flagged as Caution"
elseif (wafMerchMessage = "Warning") then
Response.Write "This transaction is flagged as Warning"
elseif (wafMerchMessage = "") then
Response.Write "This transaction is flagged as OK"
else
Response.Write "Invalid response for the WorldAlert"
end if
Response.Write "<BR><BR>"


' Each of the digit in AVS can have 5 possible values. "0" for not
supported, "1" for not checked, "2" for matched
' "4" for not matched and "8" for partially matched.

Dim avsR(3)
avsR(0) = "Security code check: "
avsR(1) = "Postcode check: "
avsR(2) = "Address check: "
avsR(3) = "Country check: "

Response.Write "<H3 align=center>AVS Results</H3>"

for i=0 to 3
if MID(AVS,i+1,1) = "0" then
Response.Write avsR(i) & " not supported"
elseif MID(AVS,i+1,1) = "1" then
Response.Write avsR(i) & " not checked"
elseif MID(AVS,i+1,1) = "2" then
Response.Write avsR(i) & " matched"
elseif MID(AVS,i+1,1) = "4" then
Response.Write avsR(i) & " not matched"
elseif MID(AVS,i+1,1) = "8" then
Response.Write avsR(i) & " partially matched"
else
Response.Write MID(AVS,i+1,1) & " : not a valid response for " & avsR(i)
end If
Response.Write "<BR><BR>"
next
Response.Write "<BR><BR>"


' In the callback transTime is returned as the number of milliseconds
since the start of 1970 GMT.
' To change it to ASP format you can use dateAdd function

transTime = callTime/1000
transTime = dateAdd("s",transTime,#Jan 01, 1970 00:00:00#)

Response.Write "<H3 align=center>Other Variables</H3>"

Response.Write "Installation ID: " & instId & "<BR><BR>"
Response.Write "Cart Id: " & cartId & "<BR><BR>"
Response.Write "amount: " & amount & "<BR><BR>"
Response.Write "currency: " & money & "<BR><BR>"
Response.Write "desc: " & desc & "<BR><BR>"
Response.Write "Transaction Time: " & transTime & "<BR><BR>"
Response.Write "Transaction ID: " & transId & "<BR><BR>"
Response.Write "testMode: " & testMode & "<BR><BR>"
Response.Write "name: " & name & "<BR><BR>"
Response.Write "address: " & address & "<BR><BR>"
Response.Write "postcode: " & postcode & "<BR><BR>"
Response.Write "country: " & country & "<BR><BR>"
Response.Write "Phone: " & tel & "<BR><BR>"
Response.Write "email: " & email & "<BR><BR>"
Response.Write "Language: " & lang & "<BR><BR>"
Response.Write "Card Type: " & cardType & "<BR><BR>"
Response.Write "Auth Currency: " & authCurrency & "<BR><BR>"
Response.Write "Auth Amount: " & authAmount & "<BR><BR>"
Response.Write "Auth Mode: " & authMode & "<BR><BR>"
'Response.Write "FuturePay Id: " & futurePayId & "<BR><BR>"
%>
</P>

<!-- If you would like to display images on the response page please
upload the images to WorldPay administration area
and you can reference them like <img src="/i/<installation Id>/<image
name> -->


<!-- If you would like to send your shopper to a access the particular
part of your web site after they have made the
the payment then you can use WPDISPLAY tags to take your shopper to your
selected portion

<A href="http://www.mysite.com/mypage.asp?transId=<WPDISPLAY
item=transId>&cartId=<WPDISPLAY item=cartId>">mysite</A>

-->



<% 'If the transaction was not successful
elseif trans = "C" then %>

<WPDISPLAY ITEM="banner">
<CENTER><B><FONT SIZE="6" COLOR="#CC0000">The Transaction was
cancelled</FONT></B><CENTER>

<% ' If the value transStatus of is neither "Y" or "C"
else %>

<CENTER><B><FONT SIZE="6" COLOR="#CC0000">Transaction didn't return the
correct value<BR>
of transStatus that is it is neither "Y" or "C"</FONT></B><CENTER>

<% end if %>



</BODY>
</HTML>
 
M

McKirahan

STEVE WARBURTON said:
I have recived a callback.asp from worlpay. I have set up the settings in my
world pay account pointing to the script. I am presuming the transation from
world pay fires the callback.asp.

What do I have to do to extract the data that comes back from world pay.
Idiot level instructions please.

the script is as follows:

[snip]

The page stores values in variables; see this section of code:

' requesting the variables sent by WorldPay

instId = Request.Form("instId") ' Installation ID
cartId = Request.Form("cartId") ' Customer reference for the
particular transaction
amount = Request.Form("amount") ' The amount that was sent to
WorldPay in the order form
money = Request.Form("currency") ' The currency that was sent to
WorldPay in the order form
desc = Request.Form("desc") ' Description of the items purchsed
callTime = Request.Form("transTime") 'Time of the transaction
transId = Request.Form("transId") ' Transaction ID
testMode = Request.Form("testMode") ' 100 if it was a test
transaction and 0 for live
name = Request.Form("name") ' Shopper Details
address = Request.Form("address")
postcode = Request.Form("postcode")
country = Request.Form("country")
tel = Request.Form("tel")
email = Request.Form("email")
lang = Request.Form("lang") ' The language used on the payment page
cardType = Request.Form("cardType") ' The type of the card shopper
paid with
authCurrency = Request.Form("authCurrency") ' The currency that shopper
choose on payment page
authAmount = Request.Form("authAmount") ' The amount in currency the
shopper choose on payment page
authMode = Request.Form("authMode") ' Useful if you are using
pre-auth. "A" for immediate "E" for pre-auth
wafMerchMessage = Request.Form("wafMerchMessage") 'The message sent from
WorldPay to alert if it was possibly a fradulant transaction
AVS = Request.Form("AVS")' It is a four digit code for the
various checks performed by the bank
' First digit is for security code comparison, second digit is
for postcode comparison.
' third digit is for address comparison and fourth digit is for
country comparison.


What do you want to do -- store them in a database?
 
S

STEVE WARBURTON

Initially into a text file would be fine. I could then import into the main
database at a later time.
The main database at the moment is paradox tables, but we will be
converting to MSQL eventually over the next few weeks (or will that be
months).

I just need to grasp how asp works in this context without having to spend
weeks learning the language.

Cheers

Steve




McKirahan said:
STEVE WARBURTON said:
I have recived a callback.asp from worlpay. I have set up the settings in my
world pay account pointing to the script. I am presuming the transation from
world pay fires the callback.asp.

What do I have to do to extract the data that comes back from world pay.
Idiot level instructions please.

the script is as follows:

[snip]

The page stores values in variables; see this section of code:

' requesting the variables sent by WorldPay

instId = Request.Form("instId") ' Installation ID
cartId = Request.Form("cartId") ' Customer reference for the
particular transaction
amount = Request.Form("amount") ' The amount that was sent to
WorldPay in the order form
money = Request.Form("currency") ' The currency that was sent
to
WorldPay in the order form
desc = Request.Form("desc") ' Description of the items
purchsed
callTime = Request.Form("transTime") 'Time of the transaction
transId = Request.Form("transId") ' Transaction ID
testMode = Request.Form("testMode") ' 100 if it was a test
transaction and 0 for live
name = Request.Form("name") ' Shopper Details
address = Request.Form("address")
postcode = Request.Form("postcode")
country = Request.Form("country")
tel = Request.Form("tel")
email = Request.Form("email")
lang = Request.Form("lang") ' The language used on the payment
page
cardType = Request.Form("cardType") ' The type of the card shopper
paid with
authCurrency = Request.Form("authCurrency") ' The currency that
shopper
choose on payment page
authAmount = Request.Form("authAmount") ' The amount in currency the
shopper choose on payment page
authMode = Request.Form("authMode") ' Useful if you are using
pre-auth. "A" for immediate "E" for pre-auth
wafMerchMessage = Request.Form("wafMerchMessage") 'The message sent from
WorldPay to alert if it was possibly a fradulant transaction
AVS = Request.Form("AVS")' It is a four digit code for the
various checks performed by the bank
' First digit is for security code comparison, second digit is
for postcode comparison.
' third digit is for address comparison and fourth digit is for
country comparison.


What do you want to do -- store them in a database?
 
M

McKirahan

STEVE WARBURTON said:
Initially into a text file would be fine. I could then import into the main
database at a later time.
The main database at the moment is paradox tables, but we will be
converting to MSQL eventually over the next few weeks (or will that be
months).

I just need to grasp how asp works in this context without having to spend
weeks learning the language.

Cheers

Steve

[ Please don't top post. ]

Try adding the following; watch for word-wrap.

<% If Request.Form("instId") <> "" Then Form2File()

Sub Form2File()
'*
'* Declare Constants
'*
Const cOTF ="callback.txt"
'*
'* Declare Variables
'*
Dim Field
Dim strFSO
strFSO = Server.MapPath(cOTF)
Dim booOTF
booOTF = False
Dim strOTF
strOTF = ""
Dim strRFF
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFSO) Then booOTF = True
Dim objOTF
Set objOTF = objFSO.OpenTextFile(strFSO,8,True)
'*
'* Write Form Head
'*
If booOTF Then
For Each Field in Request.Form
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & Field
Next
objOTF.WriteLine(strOTF)
End If
'*
'* Append Form Data
'*
strOTF = ""
For Each Field in Request.Form
strRFF = Request.Form(Field)
If InStr(strRFF,Chr(34)) > 0 Then strRFF =
Replace(strRFF,Chr(34),"`")
If InStr(strRFF,",") > 0 Then strRFF = Chr(34) & strRFF & Chr(34)
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & strRFF
Next
objOTF.WriteLine(strOTF)
'*
'* Destroy Objects
'*
Set objOTF = Nothing
Set objFSO = Nothing
End Sub
%>

This will append a record to a text file.
If the file doesn't exist, then a header record will be added first.

The filename could be changed to have a ".csv" extension which,
when double-clicked, will open the file up in MS-Excel.
If yopu do this then remember to Save As an MS-Excel file (".xls").


Here's a link about Request.Form:
http://www.aspwebpro.com/tutorials/asp/newwaytohandlevar.asp
 
K

Kyle Peterson

[ Please don't bottom post. ]


McKirahan said:
STEVE WARBURTON said:
Initially into a text file would be fine. I could then import into the main
database at a later time.
The main database at the moment is paradox tables, but we will be
converting to MSQL eventually over the next few weeks (or will that be
months).

I just need to grasp how asp works in this context without having to
spend
weeks learning the language.

Cheers

Steve

[ Please don't top post. ]

Try adding the following; watch for word-wrap.

<% If Request.Form("instId") <> "" Then Form2File()

Sub Form2File()
'*
'* Declare Constants
'*
Const cOTF ="callback.txt"
'*
'* Declare Variables
'*
Dim Field
Dim strFSO
strFSO = Server.MapPath(cOTF)
Dim booOTF
booOTF = False
Dim strOTF
strOTF = ""
Dim strRFF
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFSO) Then booOTF = True
Dim objOTF
Set objOTF = objFSO.OpenTextFile(strFSO,8,True)
'*
'* Write Form Head
'*
If booOTF Then
For Each Field in Request.Form
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & Field
Next
objOTF.WriteLine(strOTF)
End If
'*
'* Append Form Data
'*
strOTF = ""
For Each Field in Request.Form
strRFF = Request.Form(Field)
If InStr(strRFF,Chr(34)) > 0 Then strRFF =
Replace(strRFF,Chr(34),"`")
If InStr(strRFF,",") > 0 Then strRFF = Chr(34) & strRFF & Chr(34)
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & strRFF
Next
objOTF.WriteLine(strOTF)
'*
'* Destroy Objects
'*
Set objOTF = Nothing
Set objFSO = Nothing
End Sub
%>

This will append a record to a text file.
If the file doesn't exist, then a header record will be added first.

The filename could be changed to have a ".csv" extension which,
when double-clicked, will open the file up in MS-Excel.
If yopu do this then remember to Save As an MS-Excel file (".xls").


Here's a link about Request.Form:
http://www.aspwebpro.com/tutorials/asp/newwaytohandlevar.asp
 
K

Kyle Peterson

I'm quite aware of the whole issue and have read most of those articles, so
your link means nothing to me.
Why do poeple like you feel like you need to police the newgroups ?

If someone asks a question help them.
There is no reason to lecture people on how you think things should be.

As you'll notice about 50% of the people in the newgroups bottom post and
50% top post.
Big deal.





McKirahan said:
Kyle Peterson said:
[ Please don't bottom post. ]

Is that your contribution to this thread?

Take a look at this link:

Bottom vs. top posting and quotation style on Usenet
http://www.cs.tut.fi/~jkorpela/usenet/brox.html
 
M

McKirahan

Kyle Peterson said:
I'm quite aware of the whole issue and have read most of those articles, so
your link means nothing to me.
Why do poeple like you feel like you need to police the newgroups ?

Adding a parenthetical comment along with a solution is "policing"?
If someone asks a question help them.
There is no reason to lecture people on how you think things should be.

So when you're parents said "Please clean up your room." they were
lecturing?
As you'll notice about 50% of the people in the newgroups bottom post and
50% top post.

Most who use newsgroups regularly use bottom-posting.
Big deal.

It just makes postings easier to follow, that's all.
 
B

Bob Lehmann

[top posted mostly to annoy McKirahan]

Most who regularly use the Microsoft groups top-post.

Most adapt their posting style to the norm for the group - top, bottom,
sideways, whatever.

Most mind their own business on off-topic matters.

When my parents told me to clean up my room, they didn't specify the order
in which to clean it up. Toys first, or make the bed the bed first? It
didn't really matter, as long as I cleaned it up. Most parents behave the
same way.

Take a look at this link..
http://www.ocfoundation.org/

PS -
(Most people know that these - [] - are square brackets (speaking
parenthetically, of course), not parentheses.)

Bob Lehmann
 
T

terje

Bob said:
Most adapt their posting style to the norm for the group - top, bottom,
sideways, whatever.

Most mind their own business on off-topic matters.

If there is no "best practice" in a news group like this, I guess there
is no best practice in coding either. I wonder if people posting in this
sloppy manner also write sloppy code?

I'm tired of having to scroll down 400 lines just to read the one line
reply.

Terje :)
 
B

Bob Lehmann

Not sure what you're getting at, terje. For the most part, you sound like
you agree with my point.

I think it's kind of a stretch on your sloppy posting == slopping coding,
though.

Bob Lehmann
 
B

Bob Lehmann

Yes, complaining (whining?) is an effective teaching tool.

Especially when you are trying to inflict your not-neccessarily-correct
opinions on people who don't give a shit what you think. The elitist,
holier-than-thou attitude is a real plus too.

Oops! I forgot that you plonked me, Adrienne, so I've ceased to exist as far
as you're concerned. Thanks for the input anyway. It's very entertaining.

Bob Lehmann
 
B

Bob Lehmann

Yes, complaining (whining?) is an effective teaching tool.

Especially when you are trying to inflict your not-neccessarily-correct
opinions on people who don't give a s**t what you think. The elitist,
holier-than-thou attitude is a real plus too.

Oops! I forgot that you plonked me, Adrienne, so I've ceased to exist as far
as you're concerned. Thanks for the input anyway. It's very entertaining.

Bob Lehmann
 
S

SteveW

Sorry for the dumb question, but where in the callback.asp file do I add the
text.?




McKirahan said:
STEVE WARBURTON said:
Initially into a text file would be fine. I could then import into the main
database at a later time.
The main database at the moment is paradox tables, but we will be
converting to MSQL eventually over the next few weeks (or will that be
months).

I just need to grasp how asp works in this context without having to
spend
weeks learning the language.

Cheers

Steve

[ Please don't top post. ]

Try adding the following; watch for word-wrap.

<% If Request.Form("instId") <> "" Then Form2File()

Sub Form2File()
'*
'* Declare Constants
'*
Const cOTF ="callback.txt"
'*
'* Declare Variables
'*
Dim Field
Dim strFSO
strFSO = Server.MapPath(cOTF)
Dim booOTF
booOTF = False
Dim strOTF
strOTF = ""
Dim strRFF
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(strFSO) Then booOTF = True
Dim objOTF
Set objOTF = objFSO.OpenTextFile(strFSO,8,True)
'*
'* Write Form Head
'*
If booOTF Then
For Each Field in Request.Form
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & Field
Next
objOTF.WriteLine(strOTF)
End If
'*
'* Append Form Data
'*
strOTF = ""
For Each Field in Request.Form
strRFF = Request.Form(Field)
If InStr(strRFF,Chr(34)) > 0 Then strRFF =
Replace(strRFF,Chr(34),"`")
If InStr(strRFF,",") > 0 Then strRFF = Chr(34) & strRFF & Chr(34)
If strOTF <> "" Then strOTF = strOTF & ","
strOTF = strOTF & strRFF
Next
objOTF.WriteLine(strOTF)
'*
'* Destroy Objects
'*
Set objOTF = Nothing
Set objFSO = Nothing
End Sub
%>

This will append a record to a text file.
If the file doesn't exist, then a header record will be added first.

The filename could be changed to have a ".csv" extension which,
when double-clicked, will open the file up in MS-Excel.
If yopu do this then remember to Save As an MS-Excel file (".xls").


Here's a link about Request.Form:
http://www.aspwebpro.com/tutorials/asp/newwaytohandlevar.asp
 
M

McKirahan

SteveW said:
Sorry for the dumb question, but where in the callback.asp file do I add the
text.?

[snip]

Try adding it at the end -- after all of their code.
 
M

Mark J. McGinty

Adrienne said:
Gazing into my crystal ball I observed terje <[email protected]> writing in

[snip]

Then you need to complain about snipping, not bottom posting.

[snip]

What's wrong with snipping out irrelevant chunks? Personally, I think some
posts lend themselves to top posting, some to inline, some to bottom,
calling any of them "best practice" for all posts across an entire NG seems
artificially restrictive to me.

-Mark
 
S

SteveW

No callback.txt is produced. Does the asp file have to be in a certain
directory, are there any other requirments?

Cheers

SteveW


McKirahan said:
SteveW said:
Sorry for the dumb question, but where in the callback.asp file do I add the
text.?

[snip]

Try adding it at the end -- after all of their code.
 
M

McKirahan

SteveW said:
No callback.txt is produced. Does the asp file have to be in a certain
directory, are there any other requirments?

Cheers

SteveW

[snip]

"Server.MapPath(cOTF)" will put it in the same folder as the page.

Write permission must be set on the folder.
 
D

Dave Anderson

Mark said:
Personally, I think some posts lend themselves to top posting,
some to inline, some to bottom, calling any of them "best
practice" for all posts across an entire NG seems artificially
restrictive to me.

While I generally agree with this, I think a small amount of paraphrasing
can eliminate the need for top-post responses. For example,

[argument in favor of using something]

While I agree with your reasoning, I still think you are ignoring
the non-technical part of the argument. What does your solution
utimately cost in developer hours?

Etc.




--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top