From: ethem Date: Wed, 16 Jan 2008 17:19:30 +0000 (+0000) Subject: Authorize.net account verification X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8bdd9627338527ec6e8df23cd7f68b1a0c12d95b;p=moodle.git Authorize.net account verification --- diff --git a/enrol/authorize/config_form.php b/enrol/authorize/config_form.php index 22912274fe..94f0ad14d4 100755 --- a/enrol/authorize/config_form.php +++ b/enrol/authorize/config_form.php @@ -73,7 +73,10 @@ if (!isset($frm->acceptechecktypes)) {    - +
+ an_login) && (isset($mconfig->an_tran_key) || isset($mconfig->an_password))) { ?> +

+ diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 3510e24781..d558376ec1 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -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); diff --git a/enrol/authorize/localfuncs.php b/enrol/authorize/localfuncs.php index a10469dd62..24d80b98af 100644 --- a/enrol/authorize/localfuncs.php +++ b/enrol/authorize/localfuncs.php @@ -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'); +} + ?>