PayPalButtons
Questions answered by this recipe
How can I insert encrypted PayPal "Buy Now Buttons" on my PmWiki pages?
Description
PayPal allows merchants to register for free. If you are a registered PayPal merchant, you can request "Buy Now Buttons" -- a non-dynamic instant-shopping-cart feature. If you sell something for a flat price, this is a reasonable method to encourage online payments.
The encrypted button code is ugly and rather PmWiki-markup-unfriendly, so I've come up with a way for a PmWiki admin to allow PayPal buttons on their site. This method requires admin access to the site, by adding button code supplied by PayPal into the local/config.php file.
- Requires a PayPal Merchant account.
- Get the button code from PayPal. Merchants click on "Merchant Services" tab and locate the links for "Buy Now Buttons" (currently under "Key Features").
- Fill in the amount, give your item a name so people are sure they clicked on the right button. You probably want to say "yes" to the encrypted button. Encryption protects your item prices from being changed. If you don't want to use encryption, see the PayPalButtons2 recipe which is far easier to use and maintain.
- On the following screen there's a box full of HTML form code - copy and paste to a text editor
- Search and replace single quote to escaped single quote. ' becomes \'
- Search and replace all double quote " to single quote ' in your text editor -- or replace them by hand.
- use the following text before the form:
Markup('myButton', 'inline', '/\\(:myButton:\\)/e', "Keep(\"
- "myButton is arbitrary. "inline" means that it will be a part of a paragraph. (:myButton:) is the PmWiki markup that would be used to call the button.
- add \")"); to the end after the end of the form.
- copy this text to a config file in your local directory -- either the config for the site, a group within the site, or a page in the site, where the PayPal button will be used. [Note: markup can be in individual files that are included with an
include('filename');
statement.] - use the new PmWiki markup on the page. A button should appear. Click on it, and it brings you to PayPal to verify your account information.
- To create multiple buttons, change "myButton" and the markup text on each button.
Example Code:
Markup('myButton', 'inline', '/\\(:myButton:\\)/e', "Keep(\"<form action= 'https://www.paypal.com/cgi-bin/webscr' method='post'> <input type='hidden' name='cmd' value='_s-xclick'> <input type='image' src='https://www.paypal.com/en_US/i/btn/x-click-but01.gif' border='0' name='submit' alt='Make payments with PayPal - it\'s fast, free and secure!'> <input type='hidden' name='encrypted' value='-----BEGIN PKCS7-----MIIHXwYJKoZ IhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJ ... Note: Encrypted text clipped for example. There's a lot of it. ... QEBBQAEgYAES1LUdkBEDc/aizNGSANHPGJu+XmYmzdBKgooP9PM7bwdhQKa9OyFh// ua5bfkrSnQ7vh9LQYSIt3pnLyH/bT5lJ0zFn+gFj6DmQeHSAMXtJ0TQblTfl6QBv+jX+G49 vgnyPCTqNPJIFL59f412i+R6URk/Duar5htot8v3qafQ==-----END PKCS7----- '> </form>\")");
Notes
With slight modification, this idea could allow users to add the encrypted buttons themselves, but I haven't done that. It would make very very ugly PmWiki markup -- see PayPalButtons2 for user-friendly UNencrypted PayPal button markup.
PmWiki access is not needed to edit prices on unencrypted PayPal buttons. Merchant beware.
Release Notes
- August 21, 2006
- Added cautions about unencrypted buttons, indicated PayPalButtons2 recipe as easier and far more user-friendly, but less secure.
- March 8, 2006
- Added recipe.
Comments
See Also
- Cookbook /
- PayPalButtons2 A flexible PayPal "Buy Now" button markup (Works for contributor's account)
- PayPalCart Provides markup for PayPal shopping cart buttons. (in active use)
- PPDonate Create links to accept donations via PayPal (Beta)
Contributors
User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.