Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Newbie with worldpay

Reply
Thread Tools

Newbie with worldpay

 
 
STEVE WARBURTON
Guest
Posts: n/a
 
      05-27-2005
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>


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      05-27-2005
"STEVE WARBURTON" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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?


 
Reply With Quote
 
 
 
 
STEVE WARBURTON
Guest
Posts: n/a
 
      05-27-2005
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" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> "STEVE WARBURTON" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> 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?
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      05-27-2005
"STEVE WARBURTON" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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/a...ohandlevar.asp


 
Reply With Quote
 
Kyle Peterson
Guest
Posts: n/a
 
      05-27-2005
[ Please don't bottom post. ]


"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "STEVE WARBURTON" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> 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/a...ohandlevar.asp
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      05-28-2005
"Kyle Peterson" <(E-Mail Removed)> wrote in message
news:eeM#(E-Mail Removed)...
> [ 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


 
Reply With Quote
 
Kyle Peterson
Guest
Posts: n/a
 
      05-28-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Kyle Peterson" <(E-Mail Removed)> wrote in message
> news:eeM#(E-Mail Removed)...
>> [ 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
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      05-28-2005
"Kyle Peterson" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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.


 
Reply With Quote
 
Bob Lehmann
Guest
Posts: n/a
 
      05-30-2005
[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

"McKirahan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Kyle Peterson" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > 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.
>
>



 
Reply With Quote
 
terje
Guest
Posts: n/a
 
      05-30-2005
Bob Lehmann wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WorldPay Integration Andy Everett via .NET 247 ASP .Net 2 12-12-2008 09:57 AM
Worldpay integration in classic asp sajit ASP .Net 0 08-04-2008 09:44 AM
post form data to worldpay using c# Anthony ASP .Net 0 10-21-2004 11:43 AM
setting up worldpay Rudi Ahlers ASP .Net 0 03-07-2004 08:21 AM
Worldpay Rudi Ahlers ASP .Net 0 03-06-2004 08:02 PM



Advertisments