PayPal Hacks. 100 Industrial-Strength Tips and Tools Free Open Book

PayPal Hacks. 100 Industrial-Strength Tips and Tools

Previous Section  < Day Day Up >  Next Section

Hack 67 Send a Purchase Confirmation Email with IPN

figs/moderate.gif figs/hack67.gif

Automate communication with customers by sending simple order-confirmation emails.

In this hack, your web server uses IPN to learn about purchases a customer makes and sends the customer an email confirming her purchase. To use this hack, you need to have an environment that allows you to execute server-side scripts that can send email. This example uses Microsoft's Active Server Pages (ASP), but the concepts apply to any scripting language you choose.

Before using this example, set up and test the basic IPN script described in [Hack #65] . You'll add the code presented here to that basic script, giving your system the ability to send email messages to customers after each purchase.

All popular web scripting environments provide a tool for sending electronic mail. Microsoft Windows server environments, for example, have a Common Data Objects (CDO) mail component preinstalled. Regardless of the platform, the email messages require a subject, a message body, the recipient's address, and the sender's address. You can find the recipient's address and other information about the sale in the IPN posting, such as the payer_email variable:

Payer_email = Request.Form("payer_email")

7.7.1 The Code

Place this code in your IPN script after the IPN information has been verified. In PayPal's sample scripts, the following code should appear at the 'process payment comment:

'Get the customer's email address

Dim payer_email

Payer_email = Request.Form("payer_email")



'Get information about the purchase the customer made

Dim item_name, item_number

Item_name = Request.Form("item_name") 

Item_number = Request.Form("item_number")



'Create the body of the email

Dim mail_body

Mail_body = "Thank you for your order. Below are the details." & VbCrLf 

                & "Item Name: " & item_name & VbCrLf & "Item Number: " 

                & item_number & ""



'Create an email object and send the message

Dim MailCDO

Set MailCDO = Server.CreateObject("CDONTS.NewMail")

MailCDO.From = "sales@yoursite.com"

MailCDO.To = payer_email

MailCDO.Subject = "Order Information"

MailCDO.Body = mail_body

MailCDO.Send( )

Set MailCDO = Nothing

When your site makes a sale, the code is executed and an email is sent to the customer verifying her order information. Keeping your customer informed in this way is a good practice, because it assures the customer that she made the purchase she intended to, and builds your reputation as a responsive merchant.

    Previous Section  < Day Day Up >  Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y]


         Main Menu
    PayPal Hacks
    Table of Contents
    Copyright
    Credits
    Preface
    Chapter 1. Account Management
    Chapter 2. Making Payments
    Chapter 3. Selling with PayPal
    Chapter 4. Payment Buttons
    Chapter 5. Storefronts and Shopping Carts
    Chapter 6. Managing Subscriptions
    Chapter 7. IPN and PDT
    Introduction: Hacks #65-86
    What IPN and PDT Are
    How IPN Works
    Advantages of PDT
    Hack 65 Receive Instant Payment Notifications
    Hack 66 Troubleshoot Instant Payment Notifications
    Hack 67 Send a Purchase Confirmation Email with IPN
    Day Day Up
    Hack 69 Use IPN with eBay Listings
    Hack 70 Track Your eBay Products with IPN
    Hack 71 Deliver Digital Goods with IPN
    Hack 72 Deliver Digital Goods with a Return Page
    Hack 73 Implement Price Checking with IPN
    Hack 74 Provide an Order Summary with IPN
    Hack 75 Upsell Your Customers
    Hack 76 Enable Multiple IPN Pages
    Hack 77 Use Mass Pay to Create an Affiliate System
    Hack 78 Manage Your Inventory with IPN
    Hack 79 Display Donation Goals on Your Web Site
    Hack 80 Display a Recent Donor List
    Hack 81 Capture Customer Information with IPN
    Hack 82 Insert Payment Details into a Database with IPN
    Hack 83 Insert Cart Details into a Database
    Hack 84 Track Google Referrals
    Hack 85 Process Payments like a Credit Card with PDT
    Hack 86 Synchronizing PDT and IPN
    Chapter 8. The PayPal Web Services API
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele