Joomla is one of the world’ s most popular open source CMS (content management system).
Developer: Open Source Matters, Inc.
Nice PayPal Downloads
The Nice PayPal Downloads extension is a robust download manager that allows you to distribute files for free or for paid download.
In this article you're going to be learning how to modify the Nice Paypal Downloads extension to allow buyers to specify their own purchase amounts for any particular download of your choosing. Now, you need to be careful, because the Nice Paypal Downloads extension has security features that would normally not allow for variable pricing. Normally, these features will prohibit would-be scammers from specifying their own amounts and getting downloads for less than the seller wanted to charge. So, in moving forward with this modification, it's important that you maintain the security features for downloads that do not allow for variable pricing.
Before you get started, it is important to understand that many of the files and folders for this extension are named similarly and it's easy to accidentally modify the wrong file. So, pay careful attention to the file names and file paths cited in this tutorial.
IMPORTANT: Before you proceed make a full back up of your web site files and database.
The first thing that you want to do is establish a flag that the admin can set when they want to sell an item and allow the buyer to set their own pricing. For the purposes of this demonstration, you'll use an item price of -$1.00 as this flag. So, when the system sees a price of -$1.00, it will know that the buyer is allowed to set their own price. Using -$1.00 as a flag works well, because there is never going to be an occasion that a seller will need to use a negative price. Plus, the extension already accepts negative numbers. So, there are no code modifications needed.
Altering the PayPal Button Generation
Now that you have established a flag you want to modify the button generator to have the correct behavior when it encounters the flag. For this you need to modify the Nice PayPal Downloads Button plugin. Do the following.
1. FTP to your site and download the file found here plugins/system/nicepaypaldownloadsbtn/nicepaypaldownloadsbtn.php
2. Make a local copy of this file and name it nicepaypaldownloadsbtn-backup.php
3. Open the file in a simple text editor.
4. Around line 165, you should see a block of code that looks like the following one.
5. Note the line that sets the amount input for the form, about line 171. This is the line that you need to modify.
6. Recognize that the entire block is one long string. So, you need to break the block up into three strings before make our modification.
7. Now, you can freely change the amount field. You need to add an exception that looks for the -1.00 value. Once your finished the modified block of code should look something like the one below.
8. Save your changes and upload your modifed script back to its original location on your site.
That is it for modifying the button plugin. All items with a price of -1.00 will generate a button like the one below.
Modifying the PayPal IPN Validation Script
Now, you need to edit the extensions IPN validation process. You need to do this so that the extension will except IPN messages from PayPal that have a variable purchase amount.
1. Open the file found at components/com_nicepaypaldownloads/models/ipn.php
2. Find the function named "function itemValidate()" around line 449.
3. You need to add just a little bit of code to your MySQL query. This exta bit of code tells MySQL to look for the item record with either an price amount that matchs the IPN message amount, or that matches the -1.00 flag.
DB Query, Line 473
Change to the following, note lines 478 and 488
4. Save your changes and upload your modified script back to its original location on your site.
That should do it. No more modifications are needed to make buyer specified prices work. Keep in mind that we did not make any changes to the IPN Log.