Extension:IpbWiki PayPal

From MediaWiki.org
(Redirected from Extension:PayPal)
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
PayPal

Release status: beta

Implementation Tag
Description Creates a PayPal button, which leads user to your PayPal-Donation-Site.
Author(s) Peter De Decker
Last version 1.0.2
Database changes no
License GNU public License
Download IPBWiki or this page
Check usage and version matrix; stats

The IpbWiki PayPal extension will create a PayPal-Button, which leads users to your PayPal-Donation-Site. This (simple) PayPal extension could be used for the donations-sites, if therefore you have a PayPal-Account.

  • PayPal button is defined through the means of a parser hook which means you do not have to enable HTML!
  • Support for multiple PayPal buttons through 1 tag.


Installation[edit]

  1. Download the extension: see above
  2. Create a new site in your extension-folder, named PayPal.php with following content:
    <?php
    /* IpbWiki Paypal MediaWiki extension
    ** IpbWiki (c) 2006
    ** Installation Instructions: http://www.ipbwiki.com/IpbWiki_Paypal_Extension
    */
     
    $wgExtensionCredits['parserhook'][] = array(
          'name' => 'IpbWiki PayPal',
          'version' => '1.0.2',
          'author' => 'Peter De Decker',
          'url' => 'https://www.ipbwiki.com/IpbWiki_Paypal_Extension',
          'description' => 'Creates a PayPal button, which leads user to your PayPal-Donation-Site'
    );
     
    $wgExtensionFunctions[] = "wfPayPalExtension";
     
    function wfPayPalExtension() {
       global $wgParser;
       global $ipbwiki_paypal;
       # register the extension with the WikiText parser
       $wgParser->setHook( "paypal", "renderPayPal" );
     
       $ipbwiki_paypal = array();
       # CHANGE THE LINES BELOW TO REFLECT TO YOUR PAYPAL BUTTONS!!! (there's no limit on the number of buttons you define)
       $ipbwiki_paypal[1] = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="ipbwiki@gmail.com"><input type="hidden" name="item_name" value="IpbWiki PayPal"><input type="hidden" name="no_shipping" value="1"><input type="hidden" name="cn" value="Optional Comments"><input type="hidden" name="currency_code" value="EUR"><input type="hidden" name="tax" value="0"><input type="hidden" name="bn" value="PP-DonationsBF"><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!"></form>';
       $ipbwiki_paypal[2] = '<form action="https://... - it\'s fast, free and secure!"></form>';
    }
     
    # The callback function for converting the input text to HTML output
    function renderPayPal( $input, $argv ) {
       global $ipbwiki_paypal;
       global $wgAuth;
       $pos_space=strpos($input,' ');
       if (!$pos_space) {
           if (is_numeric($input)) {  // format <paypal>number</paypal>
               $part1 = $input;
               $part2 = '';
               if (!$ipbwiki_paypal[$part1]) {
                   print_r ('warning, specified paypal button not found, defaulting to button 1');
                   $part1 = 1;
                   $part2 = $input;
               }
           } else {                   // format <paypal>text</paypal> & format <paypal></paypal>
               $part1 = 1;
               $part2 = $input;
           }
       } else {                       // format <paypal>number text</paypal>
           $part1=substr($input,0,$pos_space);
           $part2=substr($input,$pos_space+1);
           if (is_numeric($part1)) {
               if (!$ipbwiki_paypal[$part1]) {
                   print_r ('warning, specified paypal button not found, defaulting to button 1');
                   $part1 = 1;
               }
           } else {                 // format <paypal>text</paypal>
               $part1 = 1;
               $part2 = $input;
           }
       }
       $form=$ipbwiki_paypal[$part1];
       // if the ipbwiki interface is available, then use the clean function which is defined there, otherwise just clean the necessities...
       if (class_exists ('ipbwiki')) {
           $input = $wgAuth->ipbwiki->ipbwiki->clean_value ($part2);
       } else {
           $part2 = str_replace( ">"            , "&gt;"          , $part2 );
           $part2 = str_replace( "<"            , "&lt;"          , $part2 );
           $part2 = str_replace( "\""           , "&quot;"        , $part2 );
           $part2 = str_replace( "!"            , "&#33;"         , $part2 );
           $part2 = str_replace( "'"            , "&#39;"         , $part2 );
           $input = $part2;
       }
       $output = '<table border=0><tr><td>'.$form.'</td><td valign=center>'.$input.'</td></tr></table>';
       return $output;
    }
    
  3. Replace the "THIS_SHOULD_BE_REPLACED"-section with your code, brought to you by PayPal (should be something like -----BEGIN PKCS7-----MIIHNwY (.........)-----END PKCS7-----).
  4. Open your LocalSettings.php, and insert at the end of file:
    include("extensions/PayPal.php");
    

Internationalization issues[edit]

Note
Example code uses references for German solution. For US English alternative.

Substitute:

https://www.paypal.com/de_DE/i/btn/x-click-but04.gif with
https://www.paypal.com/en_US/i/btn/x-click-but21.gif

and

alt='Zahlen Sie mit PayPal - schnell, kostenlos und sicher!' with
alt='Make payments with PayPal - it's fast, free and secure!'

Usage[edit]

  • <paypal></paypal> translates to the default PayPal button (button 1)
  • <paypal>2</paypal> translates to button 2
  • <paypal>2 description</paypal> translates to button 2 and additionaly the text 'description' is placed next to the PayPal button.
  • <paypal>description</paypal> translates to the default button (button 1) and additionaly the text 'description' is placed next to the paypal button.

IPN Support (in progress)[edit]

Instant Payment Notification, included with Website Payment products, Express Checkout, and Standard Checkout, is available to PayPal Premier and Business members. Instant Payment Notification allows you to integrate your PayPal payments with your website's back-end operations, so that you get immediate notification and authentication of any PayPal payments and disputes you may receive.

The IPN functionality will be optional and enabled by setting $wgPayPalIPN to true in LocalSettings.php. When enabled it will allow a total amount donated to be display in the button and there can be any number of buttons each associated with their own total. The amount will be stored in the database and will be automatically updated upon receipt of IPN data when verified.

Task list[edit]

  • IPN support

See also[edit]