Authorize.net account verification

This commit is contained in:
ethem 2008-01-16 17:19:30 +00:00
parent d4ed9c7456
commit 8bdd962733
3 changed files with 54 additions and 1 deletions

View File

@ -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">

View File

@ -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);

View 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');
}
?>