]> git.mjollnir.org Git - moodle.git/commitdiff
Authorize.net account verification
authorethem <ethem>
Wed, 16 Jan 2008 17:19:30 +0000 (17:19 +0000)
committerethem <ethem>
Wed, 16 Jan 2008 17:19:30 +0000 (17:19 +0000)
enrol/authorize/config_form.php
enrol/authorize/enrol.php
enrol/authorize/localfuncs.php

index 22912274fefafb3bff034ed2c71dac2324b56c58..94f0ad14d47d2ef7ddeaa743777d6905295951e0 100755 (executable)
@@ -73,7 +73,10 @@ if (!isset($frm->acceptechecktypes)) {
 
 <tr valign="top">
     <td align="right">&nbsp;&nbsp;</td>
-    <td><?php print_string("logininfo", "enrol_authorize") ?></td>
+    <td><?php print_string("logininfo", "enrol_authorize") ?><br />
+    <?php if (isset($mconfig->an_login) && (isset($mconfig->an_tran_key) || isset($mconfig->an_password))) { ?>
+        <br /><a href="enrol_config.php?enrol=authorize&verifyaccount=1"><b><?php print_string("verifyaccount", "enrol_authorize") ?></b></a><br />
+    <?php } ?></td>
 </tr>
 
 <tr valign="top">
index 3510e24781c29d769b167b76dccf7b70b7927850..d558376ec1916e571bfa7a27f2a1d4a8b50608e9 100755 (executable)
@@ -436,6 +436,17 @@ class enrolment_plugin_authorize
             return; // notice breaks the form and xhtml later
         }
 
+        if (optional_param('verifyaccount', 0, PARAM_INT))
+        {
+            $message = '';
+            if (AN_APPROVED == authorize_verify_account($message)) {
+                notify(get_string('verifyaccountresult', 'enrol_authorize', get_string('success')));
+            } else {
+                notify(get_string('verifyaccountresult', 'enrol_authorize', $message));
+            }
+            return;
+        }
+
         if (!empty($frm->an_review)) {
             $captureday = intval($frm->an_capture_day);
             $emailexpired = intval($frm->an_emailexpired);
index a10469dd6255e348868f9de063bf31ff609d5bbd..24d80b98af219925b8b62a3b29107d8926424cf9 100644 (file)
@@ -172,4 +172,43 @@ function check_openssl_loaded()
     return extension_loaded('openssl');
 }
 
+
+function authorize_verify_account(&$message)
+{
+    global $CFG, $USER, $SITE;
+    require_once('authorizenetlib.php');
+
+    $CFG->an_test = 1; // Test mode
+
+    $order = new stdClass();
+    $order->id = -1;
+    $order->paymentmethod = AN_METHOD_CC;
+    $order->refundinfo = '1111';
+    $order->ccname = 'Test User';
+    $order->courseid = $SITE->id;
+    $order->userid = $USER->id;
+    $order->status = AN_STATUS_NONE;
+    $order->settletime = 0;
+    $order->transid = 0;
+    $order->timecreated = time();
+    $order->amount = '0.01';
+    $order->currency = 'USD';
+
+    $extra = new stdClass();
+    $extra->x_card_num = '4111111111111111';
+    $extra->x_card_code = '123';
+    $extra->x_exp_date = "129999";
+    $extra->x_currency_code = $order->currency;
+    $extra->x_amount = $order->amount;
+    $extra->x_first_name = 'Test';
+    $extra->x_last_name = 'User';
+    $extra->x_country = $USER->country;
+
+    $extra->x_invoice_num = $order->id;
+    $extra->x_description = 'Verify Account';
+
+    $message = '';
+    return authorize_action($order, $message, $extra, AN_ACTION_AUTH_CAPTURE, 'vis');
+}
+
 ?>