Automating Digital Delivery with Paypal Payment Processing System #Classic ASP

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1283&title=Automating%20Digital%20Delivery%20with%20Paypal%20Payment%20Processing%20System

the time-period: 2007 – 2008

In the past, I implemented an automatic notification and digital product delivery system with Paypal Payment Processing System. The concept is, when a person buys products from your web-sites, he gets his products automatically as email attachments after you have confirmed the transaction. The most important part is – collecting payment data and buyer information from Paypal to ensure that the transaction is legitimate and the payment really went through. You can use either Paypal IPN or Paypal PDT to collect these data and email products on successful verification. Either will/should work. For me, PDT worked alright. Check the following web-pages/documents. Also, from PDT section, check the sample examples. For me the sample example with ASP/VBSCript worked alright.

In the past, I have worked with MiraServ, and Moneris payment processing systems. You can find short-notes and video tutorials in this web-site on them. Just search through our web-sites.

A relevant code in ASP is provided below. The code collects the payer’s information just after someone has paid. The code also checks, if the payment was successful, if so prints some details about the transaction and the payer

The flow of actions (in terms of code and operations)

  • Create a paypal button, provide return URL for successful payment and canceled payment.
  • In your successful payment page, write down the following code
  • Your paypal account needs to be configured properly to make the following code work – consult the documents as listed above
  • You need to use the authentication code from your paypal account to/in the following code
  • The follwing code section
    authToken = "ytrtyrtr45654hgfhgfjhfsfdsfdsfds;ljlk" 'auth code for your paypal account
    	txToken = Request.Querystring("tx") 'as sent from paypal 
    
    query = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken
    
    	set objectHttp = Server.CreateObject("Microsoft.XMLHTTP")
    	objectHttp.open "POST", "http://www.paypal.com/cgi-bin/webscr", false
    	objectHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
    	objectHttp.Send query
    

    submits to the paypal to grab transaction details. (remember, after payment the control is required to come to this page, then based on authentication code and tx-id, the code grabs detail transaction information)

<% @LANGUAGE="VBScript" %>
<%	
	Dim query
	Dim objectHttp
	Dim strQuerystring
	Dim i, result
	Dim firstName, lastName, itemName, curGross, mcCurrency, email
	Dim authToken, txToken
	Dim strParts, intParts, aParts
	Dim strResults, strKey, strValue
	

	authToken = "ytrtyrtr45654hgfhgfjhfsfdsfdsfds;ljlk" 'auth code for your paypal account
	txToken = Request.Querystring("tx") 'as sent from paypal 

	query = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken

	set objectHttp = Server.CreateObject("Microsoft.XMLHTTP")
	objectHttp.open "POST", "http://www.paypal.com/cgi-bin/webscr", false
	objectHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
	objectHttp.Send query

	strQuerystring = objectHttp.responseText

	If Mid(strQuerystring,1,7) = "SUCCESS" Then
		strQuerystring = Mid(strQuerystring,9)
		strParts = Split(strQuerystring, vbLf)
		intParts = UBound(strParts) - 1
		ReDim strResults(intParts, 1)
		For i = 0 To intParts
			aParts = Split(strParts(i), "=")
			strKey = aParts(0)
			strValue = aParts(1)
			strResults(i, 0) = strKey
			strResults(i, 1) = strValue

			Select Case strKey
				Case "first_name"
					firstName = strValue
				Case "last_name"
					lastName = strValue
				Case "item_name"
					itemName = strValue
				Case "mc_gross"
					curGross = strValue
				Case "mc_currency"
					mcCurrency = strValue
				Case "payer_email"
					email = strValue
					email = Replace(email, "%40", "@")
			End Select
		Next

		email = Replace(email, "%40", "@")
		Response.Write("

We have received your order

") Response.Write("Details
") Response.Write("
  • Name: " & firstName & " " & lastName & "
  • ") Response.Write("
  • Description: " & itemName & "
  • ") Response.Write("
  • Amount: " & mcCurrency & " " & curGross & "
  • ") Response.Write("
  • Email: " & email & "
") Response.Write("
Home Page
") 'send email to customer Dim myObject Set myObject = Server.CreateObject("CDO.Message") 'set the To and From myObject.To = email myObject.From = "webmaster@justetc.net" myObject.Bcc = "sayed@justetc.net" myObject.Subject = "Please download your product" myObject.TextBody = "Dear Customer, Thank you for purchasing from us. Download from the link belownn" myObject.AddAttachment "http://www.justetc.net/test.pdf" myObject.Send() 'Set objects to "nothing" to free up the computer memory Set myObject = nothing 'send email to the seller Set myObject = Server.CreateObject("CDO.Message") 'set the To and From properties myObject.To = "webmaster@justetc.net" myObject.From = "webmaster@justetc.net" myObject.Bcc = "sayed@justetc.net" myObject.Subject = "You got one customer: Product emailed to the customer" myObject.TextBody = "Customer email address: " & email myObject.Send() 'Set your objects to "nothing" to free up the computer memory Set myObject = nothing Else 'log Response.Write("ERROR") End If %>

From: http://sitestree.com/?p=3716
Categories:Classic ASP
Tags:
Post Data:2016-07-16 10:05:06

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada