RADIUSdesk WiFi Hotspot Manager and GUI for FreeRADIUS
MESHdesk Streamlined Mesh Controller

PayPal hookup - Connecting the buttons with vouchers and profiles

Information gathering

  • We assume the following options on our PayPal button:
Option Value
1 50MB
2 100MB
3 200MB
3 1GB
  • We also assume you have the following Profiles defined in the Profiles applet:
Value Item ID in SQL
Data_50MB 6
Data_100MB 7
Data_200MB 8
Data-Standard-1G 9

Finding the Item ID in SQL:

  • Go to the sql command and select the rd database.
SELECT * FROM profiles;
SELECT * FROM realms;
SELECT * FROM users;
  • Node the value of the id column.
  • We further assume you have a Realm with the following detail:
Value Item ID in SQL
College 35
  • Finally we want to make the owner of these vouchers an Access Provider called admin_college
Value Item ID in SQL
admin_college 182

Config file editing

  • We can now use the above info and edit the /usr/share/nginx/html/cake2/rd_cake/Config/RadiusDesk.php file to look like this:
//Use this as a reference to complete the other three
//From Paypal data 'item_name' (RDVoucher') 'item_number' (rd_v1) option_selection1 ('1GB')
$config['paypal']['RDVoucher']['rd_v1']['1GB'] = array(
                                                        'precede'           => '',
                                                        'profile_id'        => 9,
                                                        'profile'           => 'Data-Standard-1G',
                                                        'realm_id'          => 34,
                                                        'realm'             => 'Residence Inn',
                                                        'sel_language'      => '4_4',
                                                        'user_id'           => '182'
  • Be sure to use revision 1073 or higher for the FinPaypalTransactionsController.php controller in order to include support for single field vouchers.
  • Also ensure that you supply both the realm name and id as well as the profile name and id in the voucher definition.
  • Next we will configure the SMTP setup for the CakePHP application in order for us to email the voucher details to the person who purchased the voucher.

Configure SMTP server in CakePHP application

Install Postfix and Mutt

  • If you want to run your own SMTP server then the following section is for you.
  • You will install Postfix as an SMTP server and also install Mutt as an SMTP client to test everything.
sudo apt-get install postfix
#Choose the defaults which works just fine if you simply want to send email from your server over the Internet while **NOT** relaying for other domains.
sudo apt-get install mutt
touch mail.txt
mutt -s "Test PayPal SMTP setup" dirkvanderwalt@gmail.com < mail.txt 
  • When you use the Server as an SMTP server be aware that many spam checking engines are most likely to label your email as SPAM!
  • Rather make use of a dedicated SMTP server like Gmail in order to avoid disappointment.

Configure CakePHP app

  • Refer to the following URL as reference to specify your own choice of SMTP provider
  • We can configure the SMTP server that the rd_cake CakePHP application will use by editing two files:
    • To create or modify an SMTP provider definition we edit the /usr/share/nginx/html/cake2/rd_cake/Config/email.php file. Here's a snippet from that file:
 public $default = array(
                'transport' => 'Mail',
                'from' => 'you@localhost',
                //'charset' => 'utf-8',
                //'headerCharset' => 'utf-8',
  • To select one of those definitions we in the PayPal Controller we specify it in the usr/share/nginx/html/cake2/rd_cake/Controller/FinPaypalTransactionsController.php file.
  • Here we changed the value form smtp to default.
//Around line 321...
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->subject('Your voucher detail');

Be sure you covered all the $Email→config('whatever') in the file. There are more than one!

  • Now our SMTP configuration for PayPal integration is completed and we can test it out.
  • Next we will do the final testing to confirm everything work as intended.

Specify a test email

  • Most of the transactions in the PayPal Sandbox are with non-existing email addresses.
  • To overcome this we override them with a test email address to whom emails will be addressed to.
  • Edit the usr/share/nginx/html/cake2/rd_cake/Controller/FinPaypalTransactionsController.php file and look for the following part where you can add the test email of your choice.
 //FIXME replace with real one when going live!!!
 //$payer_email  = $q_r['FinPaypalTransaction']['payer_email'];
 $payer_email    =  'dirkvanderwalt@gmail.com';
 $data           = Configure::read('paypal.'.$item_name.'.'.$item_number.'.'.$option_selection1);
  • When we go live we will use the real ones from the PayPal transactions.