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 69 Use IPN with eBay Listings

figs/moderate.gif figs/hack69.gif

Include additional variables with auction payments to help fortify the connection between eBay and your PayPal transaction history.

When the IPN system is activated for auction payments, your IPN script receives a form post with the transaction information. If you have your IPN profile preferences set to On, your processing script always gets hit when a payment is made, even for auction payments.

In order to process posts for auctions, your IPN script needs to be able to recognize that the payment is being made for an auction and adjust accordingly. In some cases, you might want to process only certain sections of code for auctions, or you might want to omit certain sections of your IPN page in the case of auction payments. There are five additional variables you need to watch for while dealing with IPN pages that can potentially receive posts for auction payments: item_number, auction_buyer_id, auction_closing_date, and auction_multi_item, and for_auction.

The item_number variable, which is normally populated with your user-defined unique ID-tracking value, is sent populated with the auction number. If these new variables are not accounted for, or you do not have a way of dealing with the item_number value as passed back by auctions, you might have a problem with your entire system.

7.9.1 The Code

This hack shows you how to set up your IPN script to look for an auction payment, process one block of code for an auction payment, and process another section of code for nonauction payments. This example illustrates how to insert the auction buyer ID, the auction number, the auction closing date, and the multi-item counter variable for the auction into the separate database table tblAuctions.

'Process payment

If Request.Form(for_auction) = "true" then 'Auction payment received

 'Insert into tblAuctions table

 'Create and populate auction variables

 Dim auction_id, auction_buyer_id, auction_closing_date, auction_multi_item

 auction_id = Request.Form("item_number")

 auction_buyer_id = Request.Form("auction_buyer_id")

 auction_closing_date = Request.Form("auction_closing_date")

 auction_multi_item = Request.Form("auction_multi_item")



 'Database connection info here

 set cInsAuction = Server.CreateObject("ADODB.Command")

 cInsAuction.ActiveConnection = "DRIVER={Microsoft Access Driver (*.mdb)};

                DBQ="C:/InetPub/wwwroot/database/dbPayPal.mdb")

 cInsAuction.CommandText = "INSERT INTO tblAuctions (auction_id, 

                auction_buyer_id, auction_closing_date, auction_multi_item) VALUES 

                ('" & auction_id & "', '" & auction_buyer_id & "', '" & 

                auction_closing_date & "', '" & auction_multi_item & "')"

 cInsAuction.CommandType = 1

 cInsAuction.CommandTimeout = 0

 cInsAuction.Prepared = true

 cInsAuction.Execute( )



End If

If for_auction <> "true" Then 'Normal payment

 'Create and populate normal variables

 Dim item_number

 Item_number = Request.Form("item_number")

 'Normal payment code here

End If

7.9.2 The Results

When you place the code in your IPN processing page, it enables your script to handle payment calls for both auctions and normal Web Accept payments. If you did not build this type of functionality into your script, your system might not function properly, because the item_number variable is populated with different information in the case of an auction.

The first section uses an If/Then statement to determine whether the post is being made for an auction. The for_auction variable lets your page determine whether this is the case. If the variable has a value of 1, the payment is for an auction, and the code uses the aforementioned additional variables (including the modified item_number variable) to make a database insertion into a table created to track auction payments. If the payment is not for an auction, the for_auction variable has a value of 0 and the section of code is not activated.

The second block of code does the exact opposite of the first section. It checks to see if the for_auction variable has a value other than 1 (true). If it has a value other than 1, the code block that handles the processing of your normal payments is activated. You should place all of your normal transaction processing code in this section.

    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