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 28 Create a Buy Now Button

figs/beginner.gif figs/hack28.gif

Accept payments on your web site with a simple button that sends the customer, along with all necessary payment information, to PayPal.

The most basic way to accept payments on your web site is to deploy a Buy Now button, which essentially consists of an HTML form.

In order to use the Buy Now system, you need to have a Business or Premier account at PayPal.

Use the Merchant Tools section of the PayPal web site to generate the necessary code to sell goods from your web site. Once you have the code for one item, you can modify that code for any of your other products by changing a few variable values.

4.2.1 The Code

To generate a simple block of button code, follow these steps:

  1. Go to http://www.paypal.com, log into your account, and click the Merchant Tools tab.

  2. Click the Buy Now link under the Website Payments section to open the PayPal Button Factory, as shown in Figure 4-1.

    Figure 4-1. Using the PayPal Button Factory to create generic button code you can modify later
    figs/pph_0401.gif


  3. Create a basic button by entering the item name and item number. Leave the Buyer Country as is, and enter 1 for the amount. Skip the rest of the settings, but make sure to change the Encrypt Button option to No.

  4. When you're done, click Create Button Now to generate the code.

The resulting code should look like this:

<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">

1.  <input type="hidden" name="item_name" value="Widget">

2.  <input type="hidden" name="item_number" value="Wid-001">

3.  <input type="hidden" name="amount" value="1.00">

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

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

   <input type="image" src=

"https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0"

                name="submit">

</form>

Most of the variables will not change, regardless of the item you're selling. The variables on lines 1 ,2 , and 3 are the only ones you'll need to customize for each particular product.

Modifications to the variables are straightforward and can be done directly in the HTML. For instance, to specify a price, replace 1.00 with the price of your item, in dollars and cents (but no dollar sign). Likewise, set the item_name variable to the name of the product, and set the item_number variable to a unique product number or SKU code that makes sense for your store.

4.2.2 Hacking the Hack

In addition to the aforementioned variables, there are also other PayPal-supported options you can add to your purchase buttons. For example, the return and cancel_return variables define the addresses of web pages to which the user should be taken after the payment process has been completed or if the process is cancelled, respectively:

<input type="hidden" name="return" value="http://yoursite.com/thankyou.html">

<input type="hidden" name="cancel_return" value=

                "http://yoursite.com/cancel.html">

Simply insert additional variables anywhere in your button code, so long as they appear between the opening <form> and closing </form> tags. Other variables include:


cn

The text label to appear above the note field (maximum of 40 characters).


cs

Sets the background color of your payment pages to black (1); the default is white (0).


currency_code

The three-digit code indicating the currency in which the payment is to be made.


custom and invoice

Both custom and invoice are pass-through variables, never shown to customers, to be returned to you when the payment process is complete.


handling

The shipping surcharge, applied regardless of the number of items ordered.


image_url

The address (URL) of your company logo. The image can be up to 150x50 pixels. If this variable is omitted, the customer will see your business name if you have a Business account or your email address if you have a Premier account.


no_note

If this variable is set to 1, the customer will not be allowed to include a note. It's probably best to specify the no_note option (as in the example earlier in this hack) if you'll be automating your operation and are unlikely to see any notes your customers would enter here.


no_shipping

See [Hack #34] for more information on this setting.


on0, on1, os0, and os1

See [Hack #33] for more information on these four settings.


page_style

Sets the Custom Payment Page style for payment pages. This variable should be the name of one of the styles listed on the Custom Payment Page Styles page. To add or edit custom payment pages, click the My Account tab, click Profile, and click the Custom Payment Pages link. See [Hack #51] for further details.


return

The URL of the page on your web site to which the customer will be sent when the transaction is complete.


rm

Specifies the behavior of the return URL (see the return option). If this variable is set to 1, the buyer will be sent back to the return URL using a GET method, and no transaction variables will be submitted. If rm is set to 2, the buyer will be sent back to the return URL using a POST method, to which all available transaction variables will also be posted. If rm is omitted or set to 0, GET methods will be used for all Shopping Cart transactions in which IPN is not enabled and POST methods with variables will be used for the rest.


shipping, shipping2

The amount to charge the customer for shipping, per item. If you specify an amount for shipping2, the shipping amount will be charged only for the first item ordered and shipping2 amount will be charged for each additional item (all of which applies only if the customer orders a quantity of more than one).


tax

If this variable is omitted, the sales tax specified in your account preferences will take effect. Otherwise, use tax to specify a flat tax (in dollars and cents, rather than a percentage) to apply to the order.

    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
    Introduction: Hacks #28-44
    Hack 28 Create a Buy Now Button
    Hack 29 Use a Custom Button Image
    Hack 30 Create a Purchase Button for Services
    Hack 31 Create an Auction Payment Button
    Hack 32 Provide Purchase Options with Drop-Down Listboxes
    Hack 33 Include More Than Two Option Fields
    Hack 34 Override Shipping and Handling Preferences
    Hack 35 Build Notification Tracking
    Hack 36 Hack-Proof Your Payment
    Hack 37 Hack-Proof Your Buttons with Encryption
    Hack 38 Include Payment Buttons in Email Messages
    Hack 39 Hide Your Email Address from Spammers
    Hack 40 Accept Donations
    Hack 41 PayPal-Enable Your Flash
    Hack 42 Get More Out of Dreamweaver and PayPal
    Hack 43 Provide Options with ASP.NET Web Controls
    Hack 44 Try Accepting Payments in a Bogus Currency
    Chapter 5. Storefronts and Shopping Carts
    Chapter 6. Managing Subscriptions
    Chapter 7. IPN and PDT
    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