Paypal donation/subscription

Creating and modifying plugins.
Post Reply
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Paypal donation/subscription

Post by Xanthouos »

Someone made a cool plugin in another CMS, for paypal, which works to donate once or monthly etc.
I wanted to use it on some of my S9Y sites, but don't know how to edit the code so that it runs on it's own.
Here it is:

Code: Select all

<?php
/**
* AkoDonate - A Mambo Paypal Donate Module
* @version 1.0
* @package AkoDonate
* @copyright (C) 2004 by Arthur Konze - All rights reserved!
* @license http://www.konze.de/content/view/8/26/ Copyrighted Commercial Software
*/

# Don't allow direct acces to the file
  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

# Get the right language if it exists
  if (file_exists($mosConfig_absolute_path.'/modules/mod_akodonate/'.$mosConfig_lang.'.php')) {
    include($mosConfig_absolute_path.'/modules/mod_akodonate/'.$mosConfig_lang.'.php');
  } else {
    include($mosConfig_absolute_path.'/modules/mod_akodonate/english.php');
  }

# Setup the module standard parameter settings
  $business       = $params->def( 'business', 'webmaster@konze.de' );
  $itemname       = $params->def( 'itemname', 'Donation' );
  $itemnumber     = $params->def( 'itemnumber', '0001' );
  $introduction   = $params->get( 'introduction' );
  $target         = $params->def( 'target', '_blank' );
  $usernote       = $params->def( 'usernote', 1 );
  $buttontext     = $params->def( 'buttontext', 'Donate' );
  $onceamount     = $params->def( 'onceamount', '5' );

#Bring it all to the screen
  ?>
  <!-- AkoDonate - Copyright 2004 by Arthur Konze -->
  <!-- Visit:  www.mamboportal.com & www.konze.de -->
  <!-- The REMOVAL of this note is NOT allowed!!! -->
  <!-- Contact me through my websites for details -->
  <script language="JavaScript">
    <!--
    function ShowHide(id, visibility, displaystyle) {
        obj = document.getElementsByTagName("div");
        obj[id].style.visibility = visibility;
        obj[id].style.display = displaystyle;
    }
    //-->
  </script>
  <style type="text/css">
  #sub1Div {
    visibility       : show;
    display          : block;
  }
  #sub2Div {
    visibility       : hidden;
    display          : none;
  }
  </style>
  <?php
  if ($introduction)
    echo "<p>$introduction</p>";
  ?>
  <b><?php echo _AKODONATE_DONATE; ?></b> 
  <img src="<?php echo $mosConfig_live_site;?>/modules/mod_akodonate/donate_once.png" align="absmiddle" alt="" />
  <a href="javascript:ShowHide('sub2Div','hidden', 'none');ShowHide('sub1Div','visible','block');"><?php echo _AKODONATE_ONCE; ?></a>
  <img src="<?php echo $mosConfig_live_site;?>/modules/mod_akodonate/donate_monthly.png" align="absmiddle" alt="" />
  <a href="javascript:ShowHide('sub1Div','hidden','none');ShowHide('sub2Div','visible','block');"><?php echo _AKODONATE_MONTHLY; ?></a>
  <div id="sub1Div">
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="<?php echo $target; ?>">
      <input type="hidden" name="cmd" value="_xclick" />
      <input type="hidden" name="business" value="<?php echo $business; ?>" />
      <input type="hidden" name="item_name" value="<?php echo $itemname; ?>" />
      <input type="hidden" name="item_number" value="<?php echo $itemnumber; ?>" />
      <input type="hidden" name="no_note" value="<?php echo $usernote; ?>" />
      <p class="small"><?php echo _AKODONATE_CURRENCY; ?><br />
      <select class="inputbox" name="currency_code">
        <option value="EUR" selected="selected">Euro</option>
        <option value="USD">US Dollar</option>
        <option value="GBP">Pounds Sterling</option>
        <option value="CAD">Canadian Dollars</option>
        <option value="JPY">Yen</option>
      </select></p>
      <p class="small"><?php echo _AKODONATE_AMOUNT; ?><br />
      <input class="inputbox" type="text" name="amount" size="15" style="text-align:right;" value="<?php echo $onceamount; ?>" /></p>
      <input type="hidden" name="tax" value="0" />
      <input class="button" type="submit" value="<?php echo $buttontext; ?>" style="float:right;" /></form>
    </form>
  </div>
  <div id="sub2Div">
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="<?php echo $target; ?>">
      <input type="hidden" name="cmd" value="_xclick-subscriptions" />
      <input type="hidden" name="business" value="<?php echo $business; ?>" />
      <input type="hidden" name="item_name" value="<?php echo $itemname; ?>" />
      <input type="hidden" name="item_number" value="<?php echo $itemnumber; ?>" />
      <input type="hidden" name="no_note" value="<?php echo $usernote; ?>" />
      <p class="small"><?php echo _AKODONATE_CURRENCY; ?><br />
      <select class="inputbox" name="currency_code">
        <option value="EUR" selected="selected">Euro</option>
        <option value="USD">US Dollar</option>
        <option value="GBP">Pounds Sterling</option>
        <option value="CAD">Canadian Dollars</option>
        <option value="JPY">Yen</option>
      </select></p>
      <p class="small"><?php echo _AKODONATE_AMOUNT; ?><br />
      <select class="inputbox" name="a3">
        <option value="5.00" selected="selected">5 <?php echo _AKODONATE_MONTH; ?></option>
        <option value="10.00">10 <?php echo _AKODONATE_MONTH; ?></option>
        <option value="20.00">20 <?php echo _AKODONATE_MONTH; ?></option>
        <option value="35.00">35 <?php echo _AKODONATE_MONTH; ?></option>
        <option value="50.00">50 <?php echo _AKODONATE_MONTH; ?></option>
        <option value="100.00">100 <?php echo _AKODONATE_MONTH; ?></option>
      </select></p>
      <input type="hidden" name="p3" value="1" />
      <input type="hidden" name="t3" value="M" />
      <input type="hidden" name="src" value="1" />
      <input type="hidden" name="sra" value="1" />
      <input class="button" type="submit" value="<?php echo $buttontext; ?>" style="float:right;" /></form>
    </form>
  </div>
and...

Code: Select all

<?php
/**
* AkoDonate - A Mambo Paypal Donate Module
* @version 1.0
* @package AkoDonate
* @copyright (C) 2004 by Arthur Konze - All rights reserved!
* @license http://www.konze.de/content/view/8/26/ Copyrighted Commercial Software
*/

# Language definitions
  DEFINE("_AKODONATE_DONATE","Donate");
  DEFINE("_AKODONATE_ONCE","Once");
  DEFINE("_AKODONATE_MONTHLY","Monthly");
  DEFINE("_AKODONATE_CURRENCY","Currency");
  DEFINE("_AKODONATE_AMOUNT","Amount");
  DEFINE("_AKODONATE_MONTH","per month");
?>
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Paypal donation/subscription

Post by garvinhicking »

Hi!

Hm, that plugin is so simple that IMHO it's not even necessary to turn it into a s9y plugin.

You could just copy+paste this (resp. the output of it) into a HTML nugget plugin. All the output is just simple HTML plus some javascript that would work without any PHP at all.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Re: Paypal donation/subscription

Post by Xanthouos »

garvinhicking wrote:Hi!


You could just copy+paste this (resp. the output of it) into a HTML nugget plugin. All the output is just simple HTML plus some javascript that would work without any PHP at all.

Best regards,
Garvin
I tried runing the file on my localhost, and I get errors:

Code: Select all

Fatal error: Call to a member function def() on a non-object in /opt/lampp/htdocs/mod/mod_akodonate.php on line 29
That's why I asked for help. :wink:
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Paypal donation/subscription

Post by garvinhicking »

Hi!

That's right, the PHP file uses Mambo framework code calls, you cannot use it in s9y context.

Use it in a mambo installation and then copy+paste the HTML output. Really, the plugin does nothing more than emit very simple HTML, IMHO there's no reason to involve a specific plugin when it's all just HTML that is shown...

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Xanthouos
Regular
Posts: 115
Joined: Wed Mar 02, 2005 6:59 pm
Contact:

Post by Xanthouos »

:roll: Of course. I could have thought of that. Anyway, thank you Garvin, that worked.
I agree, it doesn't need to be a plugin...wrong forum I guess.

But again, thank you for your prompt answers & solutions.

:wink:
If you can't be a missionary, you can support a missionary.
~~~~~~~~~~~~~~~~~~~~~
www.GetMepis.com
Post Reply