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 80 Display a Recent Donor List

figs/moderate.gif figs/hack80.gif

Extend your donation system by allowing users to be recognized for their contributions.

[Hack #79] shows how to display donation goals for your web site with the intention of encouraging more and larger contributions. This hack shows how to recognize your donors for their contributions by displaying a list of the five most recent donors, the amount they donated, and a small note if the donor chooses.

7.20.1 The Donation Button

The donation button needs to be modified to present donors with two fields. The first asks whether the donor would like to have her name displayed on the web page. The second allows her to enter a short note if she wishes. As with a Buy Now button, the optional button variables on0, os0, on1, and os1 are used to pass the donor's answers along to PayPal.

As explained in PayPal's Integration Guide (https://www.paypal.com/en_US/pdf/integration_guide.pdf), the optional fields on0, os0, on1, and os1 work for donations in the same way they do for the Buy Now button. (You also won't see these options in the donation button generator under PayPal's Merchant Tools tab.)


This donation button collects the information we need. (Note the similarity to the button code in [Hack #79] .)

<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@payloadz.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="hidden" name="on0" value="Display name on donors page">

Do you want your name displayed on the "recent donors" page?

<select name="os0">

 <option value="Yes" selected>Yes</option>

 <option value="No">No</option>

</select>

<br>

<input type="hidden" name="on1" value="Public note for donors' page">

Note for "recent donors" page (optional):

<input type="text" name="os1" maxlength="255">

<input type="image" src=

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

                border="0" name="submit">

</form>

When this form is submitted to PayPal by your donor, it passes the values for the optional fields along to PayPal, where the choices are displayed on the Confirm Your Payment page. This gives your donors a chance to reread the choices and use the Cancel button if they made a mistake.

7.20.2 The Database Table

The database schema for this hack is based on [Hack #82] and [Hack #83] . Those hacks cover recording the payment information and the payment detail information.

To store the donors' recognition choices, you need to add two fields to your database. You could create a new table for this information, but for simplicity, this example assumes you have added two fields—named ShowName and DonorNote, of types integer and text, respectively—to the tblPayments table, as shown in Table 7-4.

Table 7-4. A database table to track the donations you receive

ShowName

mc_gross

DonorNote

1

$0.05

Give 'til it hurts

0

$300.00

Why not?

1

$23.05

This is our entire annual budget


To make the Confirm Your Payment page look friendly and readable to your donors, set os0 to either Yes or No. When reading option_selection1 (the value sent by the donor's browser as os0), remember to look for a Yes or a No and populate your database table with a value of 1 or 0, respectively. (By the way, why does PayPal accept a variable called os0 and send you back its value in a variable called option_selection1? Why indeed....)


7.20.3 The IPN Page

Your IPN page functions much like the IPN page described in [Hack #82] . However, you need to insert two new field values, one that indicates the donor's choice whether to display her name and one to hold the donor's note:

'Create new variables and populate them

Dim ShowName

Dim DonorNote

If Request.Form("os0") = "Yes" Then

 ShowName = 1

Else

 ShowName = 0

End

DonorNote = Request.Form("os1")

Include these values in the SQL statement to insert the values into the database.

INSERT INTO tblPayments (payer_email, payer_id, payment_status, txn_id, 

                mc_gross, mc_fee, payment_date, first_name, last_name) VALUES ('"

                & payer_email & "', "' & payer_id & "', '" & payment_status & "', '" 

                & txn_id & "', " & mc_gross & ", " & mc_fee & ", '" & payment_date 

                & "', '" & first_name & "', '" & last_name & "', " & ShowName 

                & ", '" & DonorNote & "')

7.20.4 The Donation Page

Now that you have the donation data flowing into your database, you can use it on your Donations page. Query the database table for the five most recent entries:

SELECT TOP 5 first_name, last_name, mc_gross, ShowName, DonorNote 

                FROM tblPaymnets ORDER BY Id DESC

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.


Once the query has been made, iterate over the five records and display each one, substituting Anonymous for any donors who choose not to be acknowledged publicly:

<% 

While NOT rsDonation.EOF

%>

<br>

Donor: 

<% If rsDonation("ShowName") = 1 Then 'Show the name %>

<%=rsDonation("first_name")%> <%=rsDOnation("last_name")%>

<% Else 'Do not show the name %>

Anonymous

<% End If %>

Amount: <%=rsDonation("mc_gross")%>

<% If rsDonation("DonorNote") <> "" Then 'Note is not empty, show note %>

Note: <% rsDonation("DonorNoate")%>

<% End If %>

<br>

<%

 rsDonation.MoveNext( )

End

%>

7.20.5 Hacking the Hack

You can encourage more donations—and donations of higher values—by displaying lists of the most generous and the most recent donors.

Query the database for the top five donations by amount, sorted with the largest donation first:

SELECT TOP 5 first_name, last_name, mc_gross, ShowName, DonorNote 

                FROM tblPaymnets ORDER BY mc_gross DESC

The code to display this information is identical to the code used in the previous section of this hack.

    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