Well, after driving myself crazy into the wee hours of the morning the last few nights, I finally figured out a practical way to integrate this script with Paypal. Here's how it works: after you reserve or change your time on the pop up reservation screen, you see a Paypal button along with the usual confirmation information. When clicked on, the button sends the visitor's name, e-mail address, and the cost of the event straight to Paypal. The code calculates the cost of the event automatically by multiplying the duration by the cost per minute, and assumes the Administrator e-mail address is your Paypal e-mail address.
So all you have to do is figure out your cost per minute and enter a name for your service and you have a Paypal solution! I should mention that this works best with reservation approval turned on. That way, your users will know you received payment by coming back and seeing that their reservation was approved. This is still a work in progress, and I still need to figure out a way to get this to go to Paypal in a new window so that the visitors have more screen to work with when they are making payment. So, without further adieu, the example below assumes your hourly rate is $60:
The file we are modifying is: /lib/Reservation.class.php. We are replacing the entire section that begins around line 415.
In the code below, where it says "$paypal_cost = $paypal_duration * 1" replace the number 1 with your cost per minute. And where it says "YOUR SERVICE NAME" replace that with the name of your service. Good luck, and I hope to make this even better soon!
/**
* Prints a message nofiying the user that their reservation was placed
* @param string $verb action word of what kind of reservation process just occcured
* @param array $dates dates that were added or modified. Deletions are not printed.
*/
function print_success($verb, $dates = array()) {
echo '<script language="JavaScript" type="text/javascript">' . "\n"
. 'window.opener.document.location.href = window.opener.document.URL;' . "\n"
. '</script>';
$paypal_duration = '';
$paypal_duration = $this->end - $this->start;
$paypal_cost = '';
$paypal_cost = $paypal_duration * 1;
$paypal_fname = '';
$paypal_fname = $this->user->get_fname();
$paypal_lname = '';
$paypal_lname = $this->user->get_lname();
$paypal_useremail = '';
$paypal_useremail = $this->user->get_email();
$paypal_adminemail = '';
$paypal_adminemail = $this->sched['adminemail'];
$date_text = '';
for ($i = 0; $i < count($dates); $i++) {
$date_text .= Time::formatReservationDate($dates[$i], $this->start) . '<br/>';
}
CmnFns::do_message_box(translate('Your ' . $this->word . ' was successfully ' . $verb . $res['starttime'])
. (($this->type != 'd') ? ' ' . translate('for the follwing dates') . '<br /><br />' : '.')
. $date_text . '<br/><br/>'
. '<FORM ACTION="https://www.paypal.com/cgi-bin/webscr" METHOD="POST">
<INPUT TYPE="hidden" NAME="cmd" VALUE="_ext-enter">
<INPUT TYPE="hidden" NAME="redirect_cmd" VALUE="_xclick">
<INPUT TYPE="hidden" NAME="business" VALUE="'. $paypal_adminemail .'">
<INPUT TYPE="hidden" NAME="undefined_quantity" VALUE="1">
<INPUT TYPE="hidden" NAME="item_name" VALUE="YOUR SERVICE NAME - ' . $paypal_duration .' Minute Session">
<INPUT TYPE="hidden" NAME="amount" VALUE="'. $paypal_cost . '">
<INPUT TYPE="hidden" NAME="first_name" VALUE="'. $paypal_fname .'">
<INPUT TYPE="hidden" NAME="last_name" VALUE="'. $paypal_lname .'">
<INPUT TYPE="hidden" NAME="email" VALUE="'. $paypal_useremail .'">
<INPUT TYPE="image" SRC="http://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" BORDER="0" NAME="submit">'
. '</FORM>'
. '<a href="javascript: window.close();">' . translate('Close') . '</a>'
, 'width: 90%;');
}
[/code]