Codefixer - ASP tutorials, resources and software
ASP.NET Hosting with US & UK Data Centers!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Monday 6 October
MembersPro PayPal - ASP Membership software

New MS SQL 2008 Available – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

PayPal IPN Script

Below is an example of an Instant PayMent Notification (IPN) script which is freely available on the PayPal website. The script forms the basis of the IPN script used in our product MembersPro PayPal. PayPal also has a test environment called the PayPal Sandbox which provides you with an opportunity to run a test PayPal IPN script.

<%@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")
'set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
'set objHttp = Server.CreateObject("Microsoft.XMLHTTP")

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 variables
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")
Payer_email = Request.Form("payer_email")

'Check notification validation
if (objHttp.status <> 200 ) then
'HTTP error handling
elseif (objHttp.responseText = "VERIFIED") then
'check that Payment_status=Completed
'check that Txn_id has not been previously processed
'check that Receiver_email is your Primary PayPal email
'check that Payment_amount/Payment_currency are correct
'process payment

elseif (objHttp.responseText = "INVALID") then
'log for manual investigation
else
'error
end if
set objHttp = nothing
%>

Check out our page for a more detailed explanation of how PayPal Instant Payment Notification (IPN) works.

LinksPro - Directory  and Link  Management Software




If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site.

ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software