|
Cookbook /
PayPalCartSummary: Provides markup for PayPal shopping cart buttons.
Version: 1.0
Prerequisites: a PayPal account
Status: in active use
Maintainer: Ben Stallings
Categories: Form Tools | Payment
Questions answered by this recipe
How can I integrate PayPal shopping cart into my site without having to code all those form fields? DescriptionEnter your recipe's description here.
Additional customization is possible by editing the forms in the recipe file. This is just a quick and dirty solution, based closely on PayPalButtons2. NotesRelease Notes
CommentsYou can add a quick-and-dirty Donate button option by adding this code to the recipe:
#Define PayPal Donate button markup
Markup('DonateButton', 'inline', '/\\(:DonateButton (.*?):\\)/e', 'PayPalDonate("$1")');
function PayPalDonate($opts) {
global $PayPal_Account;
$args = ParseArgs($opts);
$output = "<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>\n"
. "<input type='hidden' name='add' value='1'>\n"
. "<input type='hidden' name='cmd' value='_xclick'>\n"
. "<input type='hidden' name='business' value='$PayPal_Account' />\n"
. "<input type='hidden' name='item_name' value='".$args['name']."' />\n"
. "<input type='hidden' name='item_number' value='".$args['id']."' />\n"
. ($args['amount'] ? "<input type='hidden' name='amount' value='".$args['amount']."' />" : "$<input type='text' size='3' name='amount' />") ."\n"
. "<input type='hidden' name='no_note' value='1' />\n"
. "<input type='hidden' name='currency_code' value='USD' />\n"
. "<input type='hidden' name='lc' value='US'>";
$output .= "<input type='image' src='https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif'\n"
. "border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>\n"
. "<img alt='' border='0' src='https://www.paypal.com/en_US/i/scr/pixel.gif' width='1' height='1'>\n"
. "</form>";
return Keep($output);
}
The markup is then (:DonateButton name="Name of the charity or fund here" amount="optional amount to donate":) If you don't specify the amount, a small form field will appear to the left of the button so users can specify the amount before leaving your site. BenStallings December 08, 2010, at 10:06 AM See AlsoContributorsBen Stallings January 10, 2007, at 03:01 PM User notes? : 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. |