fixed auto approved, set paypal option, added invoice back in, updated readme, cleane...
authorgreg gay <ggay@ocad.ca>
Mon, 4 Jun 2007 17:30:25 +0000 (17:30 -0000)
committergreg gay <ggay@ocad.ca>
Mon, 4 Jun 2007 17:30:25 +0000 (17:30 -0000)
mods/ecomm/include/payments.lib.php
mods/ecomm/index.php
mods/ecomm/index_admin.php
mods/ecomm/index_instructor.php
mods/ecomm/invoice.php
mods/ecomm/module.php
mods/ecomm/module.sql
mods/ecomm/payment.php
mods/ecomm/payments_admin.php
mods/ecomm/readme
mods/ecomm/response_ipn.php

index 3a4be48..2fd5364 100644 (file)
@@ -1,59 +1,74 @@
 <?php
 if (!defined('AT_INCLUDE_PATH')) { exit; }
 
+
+/**
+* Collects purchase information for PayPal -
+* @access  public
+* @param   int $payment_id             Payment Identifier generated by ATutor  
+* @param   dbl $amount the fee for the course
+* @param   int $format_type            timestamp format, an AT_DATE constant
+* @return  $_POST data         Pruchase information sent to Paypal
+* @author  Greg Gay
+*/
+
 function paypal_print_form($payment_id, $amount, $course_id) {
        global $_config, $system_courses;
+       if($_config['ec_gateway'] == 'PayPal'){
 ?>
-       <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
-       <input type="hidden" name="add" value="1">
-       <input type="hidden" name="cmd" value="_cart"/>
-       <input type="hidden" name="business" value="<?php echo $_config['ec_email']; ?>"/>
-       <input type="hidden" name="item_number" value="<?php echo $payment_id; ?>"/>
-       <input type="hidden" name="amount" value="<?php echo $amount; ?>"/>
-       <input type="hidden" name="item_name" value="<?php echo htmlspecialchars($system_courses[$course_id]['title']); ?>"/>
-       <input type="hidden" name="page_style" value="PayPal"/>
-       <input type="hidden" name="no_shipping" value="1"/>
-       <input type="hidden" name="return" value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_user.php"/>
-       <input type="hidden" name="currency_code" value="CAD"/>
-       <input type="hidden" name="lc" value="CA"/>
-       <input type="hidden" name="bn" value="PP-ShopCartBF"/>
-       <input type="hidden" name="no_note" value="0"/>
-       <input type="hidden" name="quantity"" value="1"/>
-       <input type="hidden" name="undefined_quantity" value="1"/>
-
-       <input type="submit" name="confirm" class="button" value="<?php echo _AT('ec_paypal'); ?>"/>
-
-       </form>
-<?php
-}
 
-function paypal_authenticate_ipn() {
-       // real authentication goes here
+               <form action="<?php echo $_config['ec_uri']; ?>" method="post">
+                       <input type="hidden" name="cmd" value="_xclick">
+                       <input type="hidden" name="business" value="<?php echo $_config['ec_vendor_id']; ?>">
+                       <input type="hidden" name="item_name" value="<?php echo htmlspecialchars($system_courses[$course_id]['title']); ?>">
+                       <input type="hidden" name="item_number" value="<?php echo $payment_id; ?>">
+                       <input type="hidden" name="amount" value="<?php echo $amount; ?>">
+                       <input type="hidden" name="page_style" value="Primary">
+                       <input type="hidden" name="no_shipping" value="0">
+                       <input type="hidden" name="return" value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_ipn.php?pid=<?php echo $payment_id; ?>">
+                       <input type="hidden" name="cancel_return" value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_ipn.php">
+                       <input type="hidden" name="no_note" value="1">
+                       <input type="hidden" name="currency_code" value="<?php echo $_config['ec_currency']; ?>">
+                       <input type="hidden" name="lc" value="CA">
+                       <input type="hidden" name="bn" value="PP-BuyNowBF">
+                       <input type="submit" src="https://www.sandbox.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" value="<?php echo _AT('ec_paybypaypal'); ?>">
+                       <img src="<?php echo $_base_path; ?>mods/ecomm/images/visa_42x27.gif" title="<?php echo _AT('ec_acceptvisa'); ?>" alt="<?php echo _AT('ec_acceptvisa'); ?>" align="middle" /> <img src="<?php echo $_base_path; ?>mods/ecomm/images/mc_42x27.gif" title="<?php echo _AT('ec_acceptmastercard'); ?>" alt="<?php echo _AT('ec_acceptmastercard'); ?>" align="middle" />
+               </form>
+       
+       <?php
+       }
 }
 
 function paypal_authenticate_user_response() {
        // nothing to do but set the feedback
-       $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+       global $_config, $msg;
+       if($_config['ec_gateway'] == 'PayPal'){ 
+               if (isset($_GET['pid'], $_GET['amt'], $_GET['tx'], $_GET['sig'])) {
+                               approve_payment($_GET['pid'], $_GET['tx']);
+                               $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+               }else{
+                               $msg->addError('EC_PAYMENT_FAILED');
+               }
+       }
 }
-
 function mirapay_print_form($payment_id, $amount, $course_id) {
        global $_config;
-       $mkey = md5($payment_id.$amount.$_config['ec_password']);
-?>
-       <form method="post" action="<?php echo $_config['ec_uri']; ?>">
-               <input type="hidden" name="MTID"        value="<?php echo $payment_id; ?>"/>
-               <input type="hidden" name="Merchant_ID" value="<?php echo $_config['ec_vendor_id']; ?>"/>
-               <input type="hidden" name="MKEY"        value="<?php echo $mkey; ?>"/>
-               <input type="hidden" name="Amount1"     value="<?php echo $amount; ?>"/>
-               <input type="hidden" name="SuccessURL"  value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_user.php"/>
-               <input type="hidden" name="FailURL"     value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_user.php"/>
-               <input type="hidden" name="Currency"    value="<?php if ($_config['ec_currency'] == 'CAD') { echo 'CA'; } else { echo 'US'; } ?>"/>
-
-               <input type="submit" name="confirm" class="button" value="<?php echo _AT('ec_paybycredit'); ?>"/> 
-
-               <img src="<?php echo $_base_path; ?>mods/ecomm/images/visa_42x27.gif" title="<?php echo _AT('ec_acceptvisa'); ?>" alt="<?php echo _AT('ec_acceptvisa'); ?>" align="middle" /> <img src="<?php echo $_base_path; ?>mods/ecomm/images/mc_42x27.gif" title="<?php echo _AT('ec_acceptmastercard'); ?>" alt="<?php echo _AT('ec_acceptmastercard'); ?>" align="middle" />
-       </form>
-<?php
+       if($_config['ec_gateway'] == 'MiraPay'){
+               $mkey = md5($payment_id.$amount.$_config['ec_password']);
+       ?>
+               <form method="post" action="<?php echo $_config['ec_uri']; ?>">
+                       <input type="hidden" name="MTID"        value="<?php echo $payment_id; ?>"/>
+                       <input type="hidden" name="Merchant_ID" value="<?php echo $_config['ec_vendor_id']; ?>"/>
+                       <input type="hidden" name="MKEY"        value="<?php echo $mkey; ?>"/>
+                       <input type="hidden" name="Amount1"     value="<?php echo $amount; ?>"/>
+                       <input type="hidden" name="SuccessURL"  value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_user.php"/>
+                       <input type="hidden" name="FailURL"     value="<?php echo AT_BASE_HREF; ?>mods/ecomm/response_user.php"/>
+                       <input type="hidden" name="Currency"    value="<?php echo $_config['ec_currency'];  ?>"/>
+                       <input type="submit" name="confirm" class="button" value="<?php echo _AT('ec_paybycredit'); ?>"/> 
+                       <img src="<?php echo $_base_path; ?>mods/ecomm/images/visa_42x27.gif" title="<?php echo _AT('ec_acceptvisa'); ?>" alt="<?php echo _AT('ec_acceptvisa'); ?>" align="middle" /> <img src="<?php echo $_base_path; ?>mods/ecomm/images/mc_42x27.gif" title="<?php echo _AT('ec_acceptmastercard'); ?>" alt="<?php echo _AT('ec_acceptmastercard'); ?>" align="middle" />
+               </form>
+       <?php
+       }
 }
 
 function mirapay_authenticate_ipn() {
@@ -74,7 +89,7 @@ function mirapay_authenticate_user_response( ) {
 }
 
 function approve_payment($payment_id, $transaction_id) {
-       global $db, $system_courses, $_config;
+       global $db, $system_courses, $_config, $msg;
 
        $sql = "UPDATE ".TABLE_PREFIX."payments SET transaction_id='$transaction_id', approved=1 WHERE payment_id=$payment_id";
        $result = mysql_query($sql, $db);
@@ -87,12 +102,17 @@ function approve_payment($payment_id, $transaction_id) {
        $member_id = $row['member_id'];
 
        $sql = "SELECT * FROM ".TABLE_PREFIX."ec_course_fees WHERE course_id=$course_id";
-       $result = mysql_query($sql,$db);
+       if($result = mysql_query($sql,$db)){
        $course_fee_row = mysql_fetch_assoc($result);
+       }
+       if($course_fee_row['auto_approve'] == '1'){
+               $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET approved='y' WHERE member_id=$member_id AND course_id=$course_id";
+               mysql_query($sql, $db);
+                               $msg->addFeedback('EC_PAYMENT_CONFIRMED_AUTO');
+       }else{
 
-       $sql = "UPDATE ".TABLE_PREFIX."course_enrollment SET approved='y' WHERE member_id=$member_id AND course_id=$course_id";
-       mysql_query($sql, $db);
-
+                               $msg->addFeedback('EC_PAYMENT_CONFIRMED_MANUAL');
+       }
        /// Get the course title
        $course_title  = $system_courses[$course_id]['title'];
 
@@ -144,15 +164,14 @@ function approve_payment($payment_id, $transaction_id) {
 function check_payment_print_form($payment_id, $amount, $course_id){
 global $db, $system_courses, $_config, $payment_id;
 
-if($_config['ec_contact_address'] != ''){ 
-echo _AT('or');
-?>
-
-       <form  method="GET">
-               <input type="hidden"  name="Amount1" value="<?php echo $amount; ?>">
-               <input type="hidden"  name="payment_id" value="<?php echo $payment_id; ?>">
-               <input class="button" type="submit" name="bycheque" value="<?php echo _AT('ec_paybycheque'); ?>" onclick="window.open('mods/ecomm/invoice.php?payment_id=<?php echo $payment_id.SEP; ?>course_title=<?php echo $system_courses[$course_id]['title'].SEP; ?>amount=<?php echo $amount; ?>','invwindow','height=425px, width=520px'); return false" /> 
-       </form><br/><br />
-<?php }
+       if($_config['ec_contact_address'] != ''){
+       echo _AT('or');
+       ?>
+               <form  method="GET">
+                       <input type="hidden"  name="Amount1" value="<?php echo $amount; ?>">
+                       <input type="hidden"  name="payment_id" value="<?php echo $payment_id; ?>">
+                       <input class="button" type="submit" name="bycheque" value="<?php echo _AT('ec_paybycheque'); ?>" onclick="window.open('mods/ecomm/invoice.php?payment_id=<?php echo $payment_id.SEP; ?>course_title=<?php echo $system_courses[$course_id]['title'].SEP; ?>amount=<?php echo $amount; ?>','invwindow','height=425px, width=520px'); return false" /> 
+               </form><br/><br />
+       <?php }
 }
 ?>
\ No newline at end of file
index f7d601a..4e83164 100644 (file)
@@ -13,6 +13,7 @@ $payment_count = 0; // num listed courses
 $sql = "SELECT course_id, approved FROM ".TABLE_PREFIX."course_enrollment WHERE member_id=$_SESSION[member_id]";\r
 $result = mysql_query($sql,$db);\r
 \r
+\r
 if (mysql_num_rows($result)) { ?>\r
        <table class="data static" rules="rows" summary="">\r
        <thead>\r
@@ -42,7 +43,7 @@ if (mysql_num_rows($result)) { ?>
 \r
                        echo '<tr>';\r
                        echo '<td>'.$system_courses[$row['course_id']]['title'].'</td>';\r
-                       echo '<td align="right">'.$_config['ec_currency_symbol'].number_format($this_course_fee, 2).' '.$_config['ec_currency'].'</td>';\r
+                       echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($this_course_fee, 2).' '.$_config['ec_currency'].'</td>';\r
 \r
                        $sql4 = "SELECT SUM(amount) AS total_amount FROM ".TABLE_PREFIX."payments WHERE course_id='$row[course_id]' AND member_id = '$_SESSION[member_id]' AND approved=1";\r
                        $result4 = mysql_query($sql4,$db);\r
@@ -50,7 +51,7 @@ if (mysql_num_rows($result)) { ?>
                        $row4 = mysql_fetch_assoc($result4);\r
                        $amount_paid = $row4['total_amount'];\r
 \r
-                       echo '<td align="right">'.$_config['ec_currency_symbol'].number_format($amount_paid, 2).'</td>';\r
+                       echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($amount_paid, 2).'</td>';\r
                                \r
                        if ($row['approved'] == 'y'){\r
                                echo '<td align="center">'._AT('yes').'</td>';\r
@@ -59,9 +60,9 @@ if (mysql_num_rows($result)) { ?>
                        }\r
                        \r
                        if ($amount_paid >= $this_course_fee){\r
-                               echo '<td>'._AT('ec_full_payment_recieved').'</td>';\r
+                               echo '<td align="center">'._AT('ec_full_payment_recieved').'</td>';\r
                        }else{\r
-                               echo '<td><a href="mods/ecomm/payment.php?course_id='.$row['course_id'].'">'._AT('ec_make_payment').'</a></td>';\r
+                               echo '<td align="center"><a href="mods/ecomm/payment.php?course_id='.$row['course_id'].'">'._AT('ec_make_payment').'</a></td>';\r
                        }\r
                }       \r
                echo '</table>';\r
@@ -72,4 +73,5 @@ if (mysql_num_rows($result)) { ?>
        $msg->printInfos('EC_NO_PAID_COURSES');\r
 }\r
 \r
+\r
  require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file
index 8c33745..0b27029 100644 (file)
@@ -8,6 +8,7 @@ if (isset($_POST['cancel'])) {
        header('Location: payments_admin.php');\r
        exit;\r
 } else if (isset($_POST['submit'])) {\r
+\r
        $_POST['ec_uri']               = trim($_POST['ec_uri']);\r
        $_POST['ec_vendor_id']         = trim($_POST['ec_vendor_id']);\r
        $_POST['ec_password']          = trim($_POST['ec_password']);\r
@@ -26,6 +27,10 @@ if (isset($_POST['cancel'])) {
                $msg->addError('EC_PASSWORD_EMPTY');\r
        }               \r
        if (!$msg->containsErrors()) {\r
+               $_POST['ec_gateway'] = $addslashes($_POST['ec_gateway']);\r
+               $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_gateway', '$_POST[ec_gateway]')";\r
+               mysql_query($sql, $db);\r
+\r
                $_POST['ec_uri'] = $addslashes($_POST['ec_uri']);\r
                $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_uri', '$_POST[ec_uri]')";\r
                mysql_query($sql, $db);\r
@@ -42,7 +47,16 @@ if (isset($_POST['cancel'])) {
                $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency', '$_POST[ec_currency]')";\r
                mysql_query($sql, $db);\r
 \r
-               $_POST['ec_currency_symbol'] = '$';\r
+               $_POST['ec_currency_other'] = $addslashes($_POST['ec_currency_other']);\r
+               $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency_other', '$_POST[ec_currency_other]')";\r
+               mysql_query($sql, $db);\r
+\r
+               if($_POST['ec_currency_other']){\r
+                       $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency', '')";\r
+                       mysql_query($sql, $db);\r
+               }\r
+\r
+               $_POST['ec_currency_symbol'] = $_POST['ec_currency_symbol'];\r
                $sql = "REPLACE INTO ".TABLE_PREFIX."config VALUES ('ec_currency_symbol', '$_POST[ec_currency_symbol]')";\r
                mysql_query($sql, $db);\r
 \r
@@ -71,32 +85,52 @@ $_config['ec_allow_instructors'] = isset($_config['ec_allow_instructors']) ? $_c
 $_config['ec_email_admin']       = isset($_config['ec_email_admin'])       ? $_config['ec_email_admin']       : 0;\r
 $_config['ec_uri']               = isset($_config['ec_uri'])               ? $_config['ec_uri']               : '';\r
 $_config['ec_currency']          = isset($_config['ec_currency'])          ? $_config['ec_currency']          : 'USD';\r
+$_config['ec_currency_symbol']          = isset($_config['ec_currency_symbol'])          ? $_config['ec_currency_symbol']          : '$';\r
+\r
+require (AT_INCLUDE_PATH.'header.inc.php');\r
 \r
-require (AT_INCLUDE_PATH.'header.inc.php'); \r
 ?>\r
 \r
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">\r
        <div class="input-form">\r
+\r
                <div class="row">\r
                        <p><?php echo _AT('ec_location_text'); ?></p>\r
                </div>\r
+               <div class="row">\r
+                       <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="uri"><?php echo _AT('ec_gateway'); ?></label><br/>\r
+                       <select name="ec_gateway">\r
+                               <option value="PayPal" <?php if($_config['ec_gateway']  == "PayPal"){ echo ' selected="selected"';} ?>>PayPal</option>\r
+                               <option value="MiraPay"<?php if($_config['ec_gateway']  == "MiraPay"){ echo ' selected="selected"';} ?>>MiraPay</option>\r
+                       </select>\r
+               </div>\r
+\r
                <div class="row">\r
                        <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="uri"><?php echo _AT('ec_location'); ?></label><br/>\r
                        <input type="text" name="ec_uri" value="<?php echo htmlspecialchars($_config['ec_uri']); ?>" id="uri" size="80"  />\r
                </div>\r
                <div class="row">\r
                        <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="ec_vendor_id"><?php echo _AT('ec_vendor_id'); ?></label><br/>\r
-       \r
                        <input type="text" name="ec_vendor_id" value="<?php echo htmlspecialchars($_config['ec_vendor_id']); ?>" id="ec_vendor_id" size="40"/>\r
                </div>\r
                <div class="row">\r
-                       <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="ec_password"><?php echo _AT('ec_password'); ?></label><br/>\r
+                       <label for="ec_password"><?php echo _AT('ec_password'); ?></label><br/>\r
                                <input type="password" name="ec_password" value="<?php echo htmlspecialchars($_config['ec_password']); ?>" id="ec_password" size="20" />\r
                </div>\r
                <div class="row">\r
                        <?php echo _AT('ec_currency'); ?><br/>\r
                        <input type="radio" name="ec_currency" value="USD" id="currusd" <?php if ($_config['ec_currency'] == 'USD') { echo 'checked="checked"'; } ?>><label for="currusd">USD</label>\r
                        <input type="radio" name="ec_currency" value="CAD" id="currcad" <?php if ($_config['ec_currency'] == 'CAD') { echo 'checked="checked"'; } ?>><label for="currcad">CAD</label>\r
+                       <input type="radio" name="ec_currency" value="EUR" id="curreur" <?php if ($_config['ec_currency'] == 'EUR') { echo 'checked="checked"'; } ?>><label for="curreur">EUR</label>&nbsp;&nbsp;\r
+\r
+                       <?php echo _AT('or'); ?>\r
+\r
+                       <label for="ec_currency_other"><?php echo _AT('ec_currency_other'); ?></label>\r
+                       <input type="text" name="ec_currency_other" size="3" value="<?php echo $_config['ec_currency_other']; ?>" id="ec_currency_other" size="3" />\r
+               </div>\r
+               <div class="row">\r
+                       <label for="ec_currency_symbol"><?php echo _AT('ec_currency_symbol'); ?></label><br/>\r
+                       <input type="text" name="ec_currency_symbol" size="3" value="<?php echo $_config['ec_currency_symbol']; ?>" id="ec_currency_symbol" size="3" />\r
                </div>\r
                <div class="row">\r
                        <label for="ec_contact_email"><?php echo _AT('ec_contact_email'); ?></label><br/>\r
@@ -118,7 +152,7 @@ require (AT_INCLUDE_PATH.'header.inc.php');
                        <?php echo _AT('ec_email_admin'); ?><br/>\r
                        <input type="radio" name="ec_email_admin" value="1" id="email1" <?php if ($_config['ec_email_admin']){ echo 'checked="checked"'; } ?>/><label for="email1"><?php echo _AT('enable'); ?></label>\r
 \r
-                       <input type="radio" name="ec_email_admin" value="0" id="email0" <?php if (!$_config['ec_email_admin']){ echo 'checked="checked"'; } ?>/><label for="email0"><?php echo _AT('enable'); ?></label>\r
+                       <input type="radio" name="ec_email_admin" value="0" id="email0" <?php if (!$_config['ec_email_admin']){ echo 'checked="checked"'; } ?>/><label for="email0"><?php echo _AT('disable'); ?></label>\r
                </div>\r
                <div class="row buttons">\r
                        <input type="submit" name="submit" value="<?php echo _AT('save'); ?>"  class="button" accesskey="s" />\r
@@ -127,4 +161,8 @@ require (AT_INCLUDE_PATH.'header.inc.php');
        </div>\r
 </form>\r
 \r
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file
+<?php \r
+\r
+\r
+\r
+require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file
index 96787a8..8ea2e40 100644 (file)
@@ -26,6 +26,18 @@ if (isset($_POST['submit'])) {
        exit;\r
 }\r
 \r
+if($_GET['func'] == 'enroll'){\r
+       $_GET['func']   = $addslashes($_GET['func']);\r
+       $sql = "REPLACE INTO ".TABLE_PREFIX."course_enrollment SET approved = 'y' WHERE course_id= '$_GET[course_id]' AND member_id = '$_GET[id0]'";\r
+       $result = mysql_query($sql,$db);\r
+}else if($_GET['func'] == 'unenroll'){\r
+\r
+       $_GET['func']   = $addslashes($_GET['func']);\r
+       $sql = "REPLACE INTO ".TABLE_PREFIX."course_enrollment SET approved = 'n' WHERE course_id= '$_GET[course_id]' AND member_id = '$_GET[id0]'";\r
+       $result = mysql_query($sql,$db);\r
+}\r
+\r
+\r
 $sql = "SELECT * from ".TABLE_PREFIX."ec_course_fees WHERE course_id='$_SESSION[course_id]'";\r
 $result = mysql_query($sql,$db);\r
 if ($row = mysql_fetch_assoc($result)){\r
@@ -64,18 +76,20 @@ require (AT_INCLUDE_PATH.'header.inc.php');
 $sql2 = "SELECT  P.member_id,  P.amount, M.login FROM ".TABLE_PREFIX."payments AS P INNER JOIN ".TABLE_PREFIX."members M USING (member_id) WHERE P.course_id=$_SESSION[course_id] AND P.approved=1";\r
 $result = mysql_query($sql2,$db);\r
 if (mysql_num_rows($result)) { ?>\r
-       <table class="data static" summary="" border="1">\r
+       <table class="data static"  rules="rows" summary="">\r
+       <thead>\r
        <tr>\r
-               <th scope="col"><?php echo _AT('login_name'); ?></th>\r
-               <th scope="col"><?php echo _AT('ec_payment_made'); ?></th>\r
-               <th scope="col"><?php echo _AT('enrolled'); ?></th>\r
+               <th scope="col"><?php echo  _AT('login_name'); ?></th>\r
+               <th scope="col"><?php echo  _AT('ec_payment_made'); ?></th>\r
+               <th scope="col"><?php echo  _AT('enrolled'); ?></th>\r
        </tr>\r
+       </thead>\r
        <?php\r
                while($row = mysql_fetch_assoc($result)){\r
                        echo '<tr>';\r
-                       echo '<td>'.$row['login'].'</td>';\r
+                       echo '<td align="center"><a href="profile.php?id='.$row['member_id'].'">'.$row['login'].'</a></td>';\r
        \r
-                       echo '<td align="right">'.$_config['ec_currency_symbol'].number_format($row['amount'],2).' '.$_config['ec_currency'].'</td>';\r
+                       echo '<td align="center">'.$_config['ec_currency_symbol'].number_format($row['amount'],2).' '.$_config['ec_currency'].'</td>';\r
                        \r
                        $sql4 = "SELECT * from ".TABLE_PREFIX."course_enrollment WHERE course_id = '$_SESSION[course_id]' AND member_id = '$row[member_id]'";\r
                        if($result4 = mysql_query($sql4, $db)){\r
@@ -83,16 +97,16 @@ if (mysql_num_rows($result)) { ?>
                                        while($row4 = mysql_fetch_assoc($result4)){\r
        \r
                                                if($row4['approved'] == 'y'){\r
-                                                       echo '<td>'._AT('yes').'<small> (<a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=unenroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('unenroll').'</a>)</small></td>';\r
+                                                       echo '<td align="center">'._AT('yes').'<small> (<a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=unenroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('unenroll').'</a>)</small></td>';\r
                                                }else{\r
-                                                       echo '<td>'._AT('no').' <small>( <a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=enroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('enroll').'</a>)</small>';\r
+                                                       echo '<td align="center">'._AT('no').' <small>( <a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=enroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('enroll').'</a>)</small>';\r
                                                }\r
                                        }\r
                                }else{\r
-                                       echo '<td>'._AT('no').'<small> (<a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=enroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('enroll').'</a>)</small></td>';\r
+                                       echo '<td align="center">'._AT('no').'<small> (<a href="tools/enrollment/enroll_edit.php?id0='.$row['member_id'].';func=enroll;tab=0;course_id='.$_SESSION['course_id'].'">'._AT('enroll').'</a>)</small></td>';\r
                                }\r
                        } else {\r
-                               echo '<td>'._AT('no').'</td>';\r
+                               echo '<td align="center">'._AT('no').'</td>';\r
                        }\r
                }\r
                echo '</tr></table>';\r
index 7c28b1e..f354c8e 100644 (file)
@@ -20,7 +20,7 @@ $date = date("F d, Y ");
 <tr><td><?php echo _AT('ec_invoice'); ?># AT_<?php echo $_GET['payment_id']; ?></td><td><?php echo $date;  ?></td></tr>
 <tr>
        <td width="50%" valign="top">
-       To: <br /><?php
+       <?php echo _AT('to'); ?>: <br /><?php
        while($row = mysql_fetch_assoc($result)){
                if($row['last_name']){
                        $contribinfo .= ''.$row['first_name'].' ' .$row['last_name'].'<br />';
@@ -56,7 +56,7 @@ $date = date("F d, Y ");
 
        </td>
        <td width="50%" valign="top">
-       From:<br />
+       <?php echo _AT('from'); ?><br />
        <?php echo nl2br($_config['ec_contact_address']); 
 
                ?>
@@ -69,7 +69,7 @@ $date = date("F d, Y ");
                        echo '<tr><td>'. $_GET['course_title'].'</td>';
                        echo '<td>'.$_config['ec_currency_symbol'].$amount.'</td></tr>';
                        echo '<tr><td colspan="2"><hr /></td></tr>';    
-                       echo '<tr><td><strong>Total including taxes:</strong?></td><td>'.$_config['ec_currency_symbol'].$amount.' '.$_config['ec_currency'].'</td></tr>';
+                       echo '<tr><td><strong>'._AT('ec_course_name').':</strong></td><td>'.$_config['ec_currency_symbol'].$amount.' '.$_config['ec_currency'].'</td></tr>';
        ?>
 </table>
 
index 155a984..e0d1c7a 100644 (file)
@@ -35,7 +35,8 @@ if (admin_authenticate(AT_ADMIN_PRIV_ECOMM, TRUE) || admin_authenticate(AT_ADMIN
 /*******\r
  * instructor Manage section:\r
  */\r
-\r
+$this->_pages['mods/ecomm/response_ipn.php']['title_var'] = 'ec_payments';\r
+$this->_pages['mods/ecomm/response_user.php']['title_var'] = 'ec_payments';\r
 $this->_pages['mods/ecomm/index_instructor.php']['title_var'] = 'ec_payments';\r
 $this->_pages['mods/ecomm/index_instructor.php']['parent']   = 'tools/index.php';\r
 $this->_pages['mods/ecomm/index_instructor.php']['children'] = array('tools/enrollment/index.php');\r
@@ -49,8 +50,11 @@ $this->_pages['mods/ecomm/index.php']['parent'] = AT_NAV_START;
 \r
 $this->_pages['mods/ecomm/payment.php']['title_var'] = 'ec_payments';\r
 $this->_pages['mods/ecomm/payment.php']['parent']    = 'mods/ecomm/index.php';\r
+$this->_pages['mods/ecomm/index.php']['children'] = array('users/index.php','users/browse.php');\r
 \r
 $this->_pages['mods/ecomm/failure.php']['title_var'] = 'ec_payments';\r
 $this->_pages['mods/ecomm/invoice.php']['title_var'] = 'ec_payments';\r
 \r
+//$this->_pages['mods/ecomm/payment.php']['title_var'] = 'browse';\r
+//$this->_pages['mods/ecomm/payment.php']['parent']    = 'users/browse.php';\r
 ?>
\ No newline at end of file
index 7991c55..b2fc0e3 100644 (file)
@@ -67,6 +67,10 @@ INSERT INTO `language_text` VALUES ('en', '_module','ec_this_course_fee','Course
 INSERT INTO `language_text` VALUES ('en', '_module','ec_vendor_id','Vendor ID assigned by credit card payment service ',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_password','Password assigned by credit card payment service ',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_currency','Currency ',NOW(),'');\r
+INSERT INTO `language_text` VALUES ('en', '_module','ec_currency_symbol','Currency Symbol ',NOW(),'');\r
+INSERT INTO `language_text` VALUES ('en', '_module','ec_currency_other','Other Currency ',NOW(),'');\r
+INSERT INTO `language_text` VALUES ('en', '_module','ec_gateway','Payment Gateway ',NOW(),'');\r
+\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_course_fee','Fee to charge for this course ',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_auto_approve','Auto approve enrollment when fee has been paid ',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_payment_made','Course Fees Received ',NOW(),'');\r
@@ -101,6 +105,7 @@ INSERT INTO `language_text` VALUES ('en', '_module','ec_end_date','End Date',NOW
 INSERT INTO `language_text` VALUES ('en', '_module','ec_set_date','Set Dates',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_invoice','Invoice',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_print_invoice','Print_invoice',NOW(),'');\r
+INSERT INTO `language_text` VALUES ('en', '_module','ec_paybypaypal','Pay by PayPal',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_export_data','Export Data Displayed Below',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_date_picker','Select a date range to display. (e.g. 2007-2-6)',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_module','ec_contact_email','EMail notification of payments to: (if different from the ATutor contact email, set in System Preferences)',NOW(),'');\r
@@ -115,6 +120,6 @@ INSERT INTO `language_text` VALUES ('en', '_msgs','AT_FEEDBACK_EC_COURSE_PAYMENT
 INSERT INTO `language_text` VALUES ('en', '_msgs','AT_FEEDBACK_EC_COURSE_PAYMENT_SETTINGS_NOT_SAVED','Unable to save course payment settings. Contact your system administrator to report the problem',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_msgs','AT_ERROR_EC_PAYMENT_FAILED','The payment was cancelled or  failed.',NOW(),'');\r
 INSERT INTO `language_text` VALUES ('en', '_msgs','AT_INFOS_EC_PAYMENTS_TURNED_OFF','Course fees are being managed by the systems administrator.',NOW(),'');\r
-INSERT INTO `language_text` VALUES ('en', '_c_msgs','AT_INFOS_EC_PAYMENTS_TURNED_OFF','Your request has been made. You will be notifed when your request has been approved. If course fees are pending, they will be listed under the <a href="mods/ecomm/index_mystart.php">Payments</a> tab above, where they can be paid.',NOW(),'');\r
+INSERT INTO `language_text` VALUES ('en', '_c_msgs','AT_INFOS_EC_PAYMENTS_TURNED_OFF','Your request has been made. You will be notifed when your request has been approved. If course fees are pending, they will be listed under the <a href="mods/ecomm/index.php">Payments</a> tab above, where they can be paid.',NOW(),'');\r
 \r
 \r
index 4d696bc..0017b44 100644 (file)
@@ -78,7 +78,7 @@ $payment_id = mysql_insert_id($db);
        ?>
 
        <div class="row buttons">
-               <?php //paypal_print_form($payment_id, $balance_course_fee, $course_id); ?>
+               <?php paypal_print_form($payment_id, $balance_course_fee, $course_id); ?>
                <?php mirapay_print_form($payment_id, $balance_course_fee, $course_id); ?>
                <?php check_payment_print_form($payment_id, $balance_course_fee, $course_id); ?>
 
index 3452d95..217b5ab 100644 (file)
@@ -32,6 +32,19 @@ if (!$page) {
 $count  = (($page-1) * $results_per_page) + 1;
 $offset = ($page-1)*$results_per_page;
 
+// enroll/unenroll students
+
+if($_GET['func'] == 'enroll'){
+       $_GET['func']   = $addslashes($_GET['func']);
+       $sql = "REPLACE INTO ".TABLE_PREFIX."course_enrollment SET approved = 'y' WHERE course_id= '$_GET[course_id]' AND member_id = '$_GET[id0]'";
+       $result = mysql_query($sql,$db);
+}else if($_GET['func'] == 'unenroll'){
+
+       $_GET['func']   = $addslashes($_GET['func']);
+       $sql = "REPLACE INTO ".TABLE_PREFIX."course_enrollment SET approved = 'n' WHERE course_id= '$_GET[course_id]' AND member_id = '$_GET[id0]'";
+       $result = mysql_query($sql,$db);
+}
+
 /// Get a list of those who have made payments
 if ($_GET['reset_filter']) {
        unset($_GET);
@@ -59,9 +72,9 @@ require (AT_INCLUDE_PATH.'header.inc.php'); ?>
 </thead>
 <?php while($row = mysql_fetch_assoc($result)): ?>
 <tr>
-       <td><?php echo $row['timestamp']; ?></td>
-       <td><?php echo $row['login']; ?></td>
-       <td><?php echo $system_courses[$row['course_id']]['title']; ?></td>
+       <td align="center"><?php echo $row['timestamp']; ?></td>
+       <td align="center"><a href="profile.php?id=<?php echo $row['member_id']; ?>"><?php echo $row['login']; ?></a></td>
+       <td align="center"><?php echo $system_courses[$row['course_id']]['title']; ?></td>
        <td align="center">
                <?php if (is_enrolled($row['member_id'], $row['course_id'])): ?>
                        <?php echo _AT('yes'); ?> - <a href="admin/enrollment/enroll_edit.php?id0=<?php echo $row['member_id'].SEP.'func=unenroll'.SEP.'tab=0'.SEP.'course_id='.$row['course_id']; ?>"><?php echo _AT('unenroll'); ?></a>
@@ -69,8 +82,8 @@ require (AT_INCLUDE_PATH.'header.inc.php'); ?>
                        <?php echo _AT('no'); ?> - <a href="admin/enrollment/enroll_edit.php?id0=<?php echo $row['member_id'].SEP.'func=enroll'.SEP.'tab=0'.SEP.'course_id='.$row['course_id']; ?>"><?php echo _AT('enroll'); ?></a>
                <?php endif; ?>
        </td>
-       <td align="right"><?php echo $_config['ec_currency_symbol'].number_format($row['amount'], 2); ?> <?php echo $_config['ec_currency']; ?></td>
-       <td align="right"><?php echo $row['transaction_id']; ?></td>
+       <td align="center"><?php echo $_config['ec_currency_symbol'].number_format($row['amount'], 2); ?> <?php echo $_config['ec_currency']; ?></td>
+       <td align="center"><?php echo $row['transaction_id']; ?></td>
 </tr>
 <?php endwhile; ?>
 </table>
index 1cd091e..fafd946 100644 (file)
@@ -3,11 +3,20 @@
 ##This moldule is intended for use with ATutor 1.5.4+, though it should work with
 ## older versions except for the admin enrollment functions, which were added in 1.5.4.
 
-This module allows for payment of course fees, and automated enrollment when payments are recieved.
+This module allows for payment of course fees, and automated enrollment when payments are recieved. It can be used with one (and only one at a time) of the following payment gateways.
 
+Payment Gateways Supported
 It is currently setup to run with the MiraPay credit card processing service:
 https://ws1.eigendev.com/mira/
 
+Or
+
+It can be used with your PayPal account
+https://www.paypal.com/cgi-bin/webscr 
+
+
+---------------
+MiraPay Test Account
 #A test account is available. Enter the following information into the admin payments settings screen. You will need to setup a proper merchant account with Mirapay to actually use the system for collecting your own payments, but to test the module the test account works well enough.
 
 Test Location:
@@ -27,7 +36,26 @@ Test Credit Card #
 Test Expiry Date
 2222
 
+------------------
+PayPal Merchant Account Setup
+See the details for setting up a PayPal account at:
+http://www.paypal.com/cgi-bin/webscr?cmd=_merchant-outside
+
+The ATutor Payments module is written to run with PayPal "Buy Now Buttons" which allows customers to purchase one item at a time, in the case of ATutor, a single course at a time.
 
+Once you have your paypal account setup, enter the URL to the PayPal Credit Card processing in the Payments>Settings screen, followed theVendor ID (leave the password field empty)
+
+PayPal Location
+(for production)
+https://www.paypal.com/cgi-bin/webscr 
+or
+(for testing)
+https://www.sandbox.paypal.com/cgi-bin/webscr
+
+See details on setting up a sandbox for testing the modules at:
+https://www.paypal.com/en_US/ebook/PP_Sandbox_UserGuide/wwhelp/wwhimpl/js/html/wwhelp.htm
+
+--------------------
 Installation & Setup
 1. Unpack the downloaded module into the ATutor mods directory. This will create an ecomm/ directory which contains all the module files.
 
@@ -45,9 +73,9 @@ Installation & Setup
 
 
 How the module works
-Payments are course fees associated with an enrollment in a Private course. When a student attempts to enroll in a private course that has a fee associated with it, an entry will be added to the student's Payments screen, accessed through a tab in MyStart page. If the student clicks on Make Payment, they are asked to fill in some personal information, confirm that information, then they are redirectled to the secure payment site, where they enter their visa or master card number (availability of either depending on what the merchant account supports), and submit the payment. Just before being redirected to the secure site the information entered by the student is stored in the ec_shop table in ATutor, and it is updated when the payment service has confirmed the payment
+Payments are course fees associated with an enrollment in a Private course. When a student attempts to enroll in a private course that has a fee associated with it, an entry will be added to the student's Payments screen, accessed through a tab in MyStart page. If the student clicks on Make Payment, and confirms the information as correct, they are redirectled to the secure payment site, where they enter their visa or master card number (availability of either depending on what the merchant account supports), and submit the payment. Just before being redirected to the secure site the information entered by the student is stored in the ec_shop table in ATutor, and it is updated when the payment service has confirmed the payment. Payments that have been completed will be updated with a confirmation code from the payment gateway
 
-If the course has been set to auto-enroll students, they will immediately be given access to the course. If manual enrollment is set, they will recieve a notice of their pending enrolment, which the instructor, or administrator must approve. 
+If the course has been set to auto-enroll students, they will immediately be given access to the course. If manual enrollment is set, they will receive a notice of their pending enrolment, which the instructor, or administrator must approve. 
 
 Administrators can manage individual course payments and settings by logging into a specific course, then managing the course payment settings as describe below for Instructors.
 
@@ -57,4 +85,3 @@ To make a payment students must first click on Enter Course in the Browse Course
 
 
 
-
index af27c8a..88ce724 100644 (file)
@@ -3,8 +3,18 @@ $_user_location        = 'public';
 define('AT_INCLUDE_PATH', '../../include/');
 require(AT_INCLUDE_PATH.'vitals.inc.php');
 require('include/payments.lib.php');
+//require(AT_INCLUDE_PATH.'header.inc.php');
 
-paypal_authenticate_ipn();
+//echo "success";
+//paypal_authenticate_ipn();
 
+paypal_authenticate_user_response();
+//mirapay_authenticate_user_response();
+//print_r($_GET);
+//exit;
+header('Location: index.php');
 exit;
+
+
+
 ?>
\ No newline at end of file