How can I save the order to Ms Access after Paypal?(Help...)

Get help with nopcart Perl, PHP or ASP checkout related issues.

Moderators: Koibito, Stefko, Randy

How can I save the order to Ms Access after Paypal?(Help...)

Postby Tone » Wed Feb 22, 2006 5:31 am

Hello....
now my website code is ASP,
and I use NOP Design Shopping cart.
when i click the submit in the "checkout.asp" page, i will go to Paypal to payment. and return to "finish.asp" page to save my order to database when i finish payment on Paypal.
but i can not save the order when it return to "finish.asp" page.
the parameter are null.
How can I do it?
Thanks a lot.
waiting for your reply!
Tone
 
Posts: 3
Joined: Wed Feb 22, 2006 4:24 am
Location: CN

working

Postby ardude » Sat Dec 23, 2006 9:38 pm

Did you ever manage to get this to work?
ardude
 
Posts: 2
Joined: Sat Dec 23, 2006 8:35 pm

Postby Koibito » Sun Dec 24, 2006 2:48 am

This can easily be done with PayPal's IPN.

Instant Payment Notification (IPN) is a means by which PayPal contacts your server directly every time a transaction completes. In other words, IPN is a call-back routine and part of an asynchronous process (in that the notification can happen any time after the transaction).

Code: Select all
<%@LANGUAGE="VBScript"%>

<%

Dim Item_name, Item_number, Payment_status, Payment_amount

Dim Txn_id, Receiver_email, Payer_email

Dim objHttp, str



' read post from PayPal system and add 'cmd'

str = Request.Form & "&cmd=_notify-validate"



' post back to PayPal system to validate

set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")

objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false

objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"

objHttp.Send str



' assign posted variables to local variables1.



1. Item_name = Request.Form("item_name")

Item_number = Request.Form("item_number")

Payment_status = Request.Form("payment_status")

Payment_amount = Request.Form("mc_gross")

Payment_currency = Request.Form("mc_currency")

Txn_id = Request.Form("txn_id")

Receiver_email = Request.Form("receiver_email")

2.  Payer_email = Request.Form("payer_email")



' Check notification validation

if (objHttp.status <> 200 ) then

 ' HTTP error handling

elseif (objHttp.responseText = "VERIFIED") then

3.  if Payment_status = "Completed" Then

4.  ' check that Txn_id has not been previously processed

  ' check that Receiver_email is your Primary PayPal email

5.  if Receiver_email = "youremail@yourisp.com" Then 'Email is correct

  ' check that Payment_amount/Payment_currency are correct

6.  ' process payment

  end If

7.  end If

elseif (objHttp.responseText = "INVALID") then

 ' log for manual investigation

else

 ' error

end if

set objHttp = nothing

%>


You'll need to check that the transaction ID has not been previously processed. One way to accomplish this is to record the txn_id value into a database. Then, query the table, pull the results into a recordset, and then check to see whether the record exists:
Code: Select all
' check that Txn_id has not been previously processed:

connStore = "DRIVER={Microsoft Access Driver (*.mdb)};

                DBQ="C:/InetPub/wwwroot/database/dbPayPal.mdb")

set rsCheck = Server.CreateObject("ADODB.Recordset")

rsCheck.ActiveConnection = connStore

rsCheck.Source = "SELECT txn_id FROM tblOrders WHERE txn_id =

                '" & txn_id & "'"

rsCheck.Open( )



If rsCheck.EOF And rsCheck.BOF Then 'Not a duplicate, continue processing

 ' check that Receiver_email is your Primary PayPal email

 ' check that Payment_amount/Payment_currency are correct

 ' process payment

End If


John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Postby Koibito » Mon Dec 25, 2006 5:03 pm

Also, don't forget to try PayPalTech's code generators when you want to implement IPN:

http://paypaltech.com/SG2/
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Postby xsiv » Sun Mar 11, 2007 10:27 am

The code that you provided above, is it just a copy and paste?

i.e. when you say " 'process payment "

what does that actually mean? I have minimal knowledge of ASP.

Can someone please help me here? Or provide a working script as example of what i need to replace the comments with?

Thanks!
xsiv
 
Posts: 8
Joined: Sun Jan 28, 2007 3:04 am

Postby Koibito » Sun Mar 11, 2007 1:17 pm

No, it is not just copy & paste. "Process Payment" is the PayPal transaction. There are a few example on the PayPal web site. PayPal also has forums for developers where they might be able to help you.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA

Postby xsiv » Sun Mar 11, 2007 1:36 pm

do you happen to have the link to the examples on the paypal website? please.. desperate..
xsiv
 
Posts: 8
Joined: Sun Jan 28, 2007 3:04 am


Return to Help: Perl/PHP/ASP Checkout

Who is online

Users browsing this forum: No registered users and 0 guests

cron