]> git.mjollnir.org Git - moodle.git/commitdiff
+ Show "Payments" and "Go to Course" buttons after purchased instead of redirect...
authorethem <ethem>
Fri, 10 Oct 2008 21:01:27 +0000 (21:01 +0000)
committerethem <ethem>
Fri, 10 Oct 2008 21:01:27 +0000 (21:01 +0000)
+ Restore an_test to original state after account verification. If admin clicks Save Changes after account verification, all transactions go to test mode.

enrol/authorize/enrol.php
enrol/authorize/localfuncs.php

index 33f0805175f5c56c5ca07aaef5b81014d441a95f..e50be2eaa3995f4d66b9e7cdddff289abd196e40 100755 (executable)
@@ -69,7 +69,6 @@ class enrolment_plugin_authorize
             print_heading(get_string('choosemethod', 'enrol_authorize'), 'center');
         }
 
-        print_box_start();
         if ($USER->username == 'guest') { // only real guest user, not for users with guest role
             $curcost = get_course_cost($course);
             echo '<div align="center">';
@@ -96,9 +95,11 @@ class enrolment_plugin_authorize
                     print_error('authorizeerror', 'enrol_authorize', '', $authorizeerror);
                 }
             }
+
+            print_box_start();
             $frmenrol->display();
+            print_box_end();
         }
-        print_box_end();
 
         if ($course->password) {
             $password = '';
@@ -311,16 +312,17 @@ class enrolment_plugin_authorize
                         message_to_admin("Error while trying to enrol " . fullname($USER) . " in '$course->fullname'", $order);
                     }
 
-                    if ($SESSION->wantsurl) {
-                        $destination = $SESSION->wantsurl;
-                        unset($SESSION->wantsurl);
-                    } else {
-                        $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
-                    }
-
                     load_all_capabilities();
-                    redirect($destination, get_string('paymentthanks', 'moodle', $course->fullname), 10);
-                    break;
+
+                    print_box_start('generalbox', 'notice');
+                    echo '<p>'. get_string('paymentthanks', 'moodle', $course->fullname) .'</p>';
+                    echo '<div class="buttons">';
+                    print_single_button("$CFG->wwwroot/enrol/authorize/index.php", array('order'=>$order->id), get_string('payments'));
+                    print_single_button("$CFG->wwwroot/course/view.php", array('id'=>$course->id), $course->fullname);
+                    echo '</div>';
+                    print_box_end();
+                    print_footer($course);
+                    exit; // break;
                 }
             }
             return NULL;
index 67c3ca0ca4b9ca32a16099ea722c7d2da1fe4184..be4b7a17ef6e0a8e45f9fea03cb2bcb871c72400 100644 (file)
@@ -130,7 +130,7 @@ function message_to_admin($subject, $data)
     $eventdata->fullmessage       = $emailmessage;
     $eventdata->fullmessageformat = FORMAT_PLAIN;
     $eventdata->fullmessagehtml   = '';
-    $eventdata->smallmessage      = '';    
+    $eventdata->smallmessage      = '';
     events_trigger('message_send', $eventdata);
 }
 
@@ -188,7 +188,7 @@ function send_welcome_messages($orderdata)
                 $a->profileurl = "$CFG->wwwroot/user/view.php?id=$lastuserid";
                 $a->paymenturl = "$CFG->wwwroot/enrol/authorize/index.php?user=$lastuserid";
                 $emailmessage = get_string('welcometocoursesemail', 'enrol_authorize', $a);
-                
+
                 $eventdata = new object();
                 $eventdata->modulename        = 'moodle';
                 $eventdata->userfrom          = $sender;
@@ -197,7 +197,7 @@ function send_welcome_messages($orderdata)
                 $eventdata->fullmessage       = $emailmessage;
                 $eventdata->fullmessageformat = FORMAT_PLAIN;
                 $eventdata->fullmessagehtml   = '';
-                $eventdata->smallmessage      = '';    
+                $eventdata->smallmessage      = '';
                 events_trigger('message_send', $eventdata);
             }
         }
@@ -219,6 +219,7 @@ function authorize_verify_account()
     global $CFG, $USER, $SITE;
     require_once('authorizenet.class.php');
 
+    $original_antest = $CFG->an_test;
     $CFG->an_test = 1; // Test mode
 
     $order = new stdClass();
@@ -238,7 +239,7 @@ function authorize_verify_account()
     $extra = new stdClass();
     $extra->x_card_num = '4111111111111111';
     $extra->x_card_code = '123';
-    $extra->x_exp_date = "129999";
+    $extra->x_exp_date = "12" . intval(date("Y")) + 5;
     $extra->x_currency_code = $order->currency;
     $extra->x_amount = $order->amount;
     $extra->x_first_name = 'Test';
@@ -246,15 +247,18 @@ function authorize_verify_account()
     $extra->x_country = $USER->country;
 
     $extra->x_invoice_num = $order->id;
-    $extra->x_description = 'Verify Account';
+    $extra->x_description = $SITE->shortname . ' - Authorize.net Merchant Account Verification Test';
 
+    $ret = '';
     $message = '';
     if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_AUTH_CAPTURE)) {
-        return get_string('verifyaccountresult', 'enrol_authorize', get_string('success'));
+        $ret = get_string('verifyaccountresult', 'enrol_authorize', get_string('success'));
     }
     else {
-        return get_string('verifyaccountresult', 'enrol_authorize', $message);
+        $ret = get_string('verifyaccountresult', 'enrol_authorize', $message);
     }
+    $CFG->an_test = $original_antest;
+    return $ret;
 }
 
 ?>