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 82 Insert Payment Details into a Database with IPN

figs/moderate.gif figs/hack82.gif

Record the data from IPN into a database to facilitate simple bookkeeping.

Capturing transaction-specific information is a vital part of expanding an online store, because it provides a platform of information on which to build value-added services and upselling techniques. For example, [Hack #75] provides a list of similar products purchased by other customers.

This functionality is required for complete security against spoofing in some vending applications. It allows you to check whether a transaction has already been processed.


7.22.1 The Database Table

Create a new database table, tblOrders, in which to store your order information. This table contains information about your customers' orders, but not any information related to the products your customers actually ordered.

Your database table should consist of the fields and data types shown in Table 7-5.

Table 7-5. A table to store order information retrieved with IPN

Variable

Data type

Id

An autonumber type, set as the primary key

Payer_email

Text field

Payer_id

Text field

Payment_status

Text field

Txn_id

Text field

Mc_gross

Money, or a floating point type with 2 places of precision

Mc_fee

Money


7.22.2 The IPN Page

Once the table has been created, install your IPN script to populate it with information posted by PayPal's IPN facility. Start by creating new local variables and capturing the posted values into your IPN page:

Dim payer_email, payer_id, payment_status, txn_id, mc_gross, mc_fee,

                payment_date



payer_email = Request.Form("payer_email")

payer_id = Request.Form("payer_id")

payment_status = Request.Form("payment_status")

txn_id = Request.Form("txn_id")

mc_gross = Request.Form("mc_gross")

mc_fee = Request.Form("mc_fee")

payment_date = Request.Form("payment_date")

Now that you have the values temporarily placed in your page, you can perform the database insert using the following SQL query:

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

                mc_gross, mc_fee, payment_date) VALUES ('" & payer_email & "', "' &

                payer_id & "', '" & payment_status & "', '" & txn_id & "', " & 

                mc_gross & ", " & mc_fee & ", '" & payment_date & "')

When the values are inserted into the tblOrders database table, a unique ID number will be generated by the database for the Id field. Note that the mc_gross and mc_fee variables are not surrounded by single quotes; they are inserted into your database as numeric values.

    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