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 79 Display Donation Goals on Your Web Site

figs/moderate.gif figs/hack79.gif

Use donation buttons and IPN to display actively updated donation goals.

As a web site owner, you might want to provide information or entertainment to your visitors without charging for the service or cluttering up your site with advertising. However, you might also need funds to pay site expenses or to support a worthy cause. The PayPal Donate Now button enables webmasters to collect payments from willing donors.

Donation buttons on web sites do not give visitors much information apart from the cause to which they are donating. Contributors have no idea how many other people have donated or how much has been raised already. Visitors might be more inclined to donate once they know others have, or if they believe their donation will make a difference in achieving a goal for a fund drive. Providing donation goals and a tally of the amount collected to date can induce potential donors to contribute—and contribute in larger amounts.

Another way to entice donors is to offer several suggested donation levels [Hack #40] .


This hack illustrates how to use your donation button to display a donation goal and the current amount collected. To implement this hack, you need to set up your site to receive Instant Payment Notifications [Hack #65] and connect the notifications to a local database using dynamic server page technology. This example uses VBScript for ASP, but it could as easily be done with PHP, Perl, Python, or Java.

7.19.1 Recording Donations

To keep a record of donations as they are made, first install a script to process PayPal's IPN feature and add a record to your database for each transaction [Hack #82] .

Next, use a SQL query such as this one to get the sum of all donations in your database:

SELECT SUM(mc_gross) AS TotalDonated FROM tblOrders

See the "Database Coding and Platform Choices" section of the Preface for the additional information needed to put this SQL statement to work with this and the other hacks in this book.


For instance, if you have a table that looks like Table 7-3, the SUM(mc_gross) function returns the sum of the mc_gross column ($323.10 in this case).

Table 7-3. A database table to track the donations

ShowName

mc_gross

date

Monty

$0.05

12/7/1943

Barney

$300.00

5/6/2004

Seymour

$23.05

7/10/2004


Put the result into the rsDonationGoal("TotalDonated") variable. If you've received three donations for $3, $5, and $7, respectively, the value for rsDonationGoal("TotalDonated") will be $15.

Naturally, if you're accepting donations for more than one cause, you'll need to narrow the SQL query so that it returns only donations that relate to the donation goal at hand.


7.19.2 Building the Donation Page

The donation page consists of three items: your donation goal (in dollars) as static text, the total amount collected thus far (drawn from your database), and the PayPal donation button (displayed somewhere prominently, of course):

<p>Please help us achieve our donation goal of $10,000.</p>

Total Amount collected so far: <%=rsDonationGoal("TotalDonated")%>

<br>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_xclick">

<input type="hidden" name="business" value="sales@paypalhacks.com">

<input type="hidden" name="item_name" value="Donation">

<input type="hidden" name="item_number" value="Donation-001">

<input type="hidden" name="no_note" value="1">

<input type="hidden" name="currency_code" value="USD">

<input type="hidden" name="tax" value="0">

<input type="image" src=

                "https://www.paypal.com/en_US/i/btn/x-click-but21.gif"

                border="0" name="submit">

</form>

7.19.3 Hacking the Hack

You might also want to display the number of donations you have already received. Start by adding another SQL query to calculate the count of donations table:

SELECT COUNT(Id) AS CountDonated FROM tblOrders

Then, use this new CountDonated variable in your ASP page:

Total number of donations collected so far: <%=rsDonationGoal("CountDonated")%>

Or, calculate the average donation with this bit of SQL:

SELECT AVG(mc_gross) AS AverageDonated FROM tblOrders

and display it on your ASP page:

Average Donation Amount: <%=rsDonationGoal("AverageDonated")%>

All this extra information makes your cause appear more credible and helps donors pony up the dough. If you really want to make it fancy, you can display a recent donor list [Hack #80] on the same page.

    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