Permalink
Browse files

New feature: Autoconfigure credit card types, if the merchant does no…

…t accept this type of credit card; Backported from HEAD.
  • Loading branch information...
1 parent b02b2f7 commit 0ee157451276c2ae939915dd3b1646e02dfe680a ethem committed Aug 31, 2006
Showing with 14 additions and 5 deletions.
  1. +13 −4 enrol/authorize/authorizenetlib.php
  2. +1 −1 enrol/authorize/enrol.php
@@ -82,11 +82,12 @@ function authorize_expired(&$order)
* @param string &$message Information about error message if this function returns false.
* @param object &$extra Extra data that used for refunding and credit card information.
* @param int $action Which action will be performed. See AN_ACTION_*
+ * @param string $cctype Credit card type, used internally to configure types automatically.
* @return bool true Transaction was successful, false otherwise. Use $message for reason.
* @author Ethem Evlice <ethem a.t evlice d.o.t com>
* @uses $CFG
*/
-function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE)
+function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE, $cctype=NULL)
{
global $CFG;
static $conststring;
@@ -331,11 +332,19 @@ function authorize_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE)
}
else
{
- $reason = "reason" . $response[2];
- $message = get_string($reason, "enrol_authorize");
- if ($message == '[[' . $reason . ']]') {
+ $reasonno = $response[2];
+ $reasonstr = "reason" . $reasonno;
+ $message = get_string($reasonstr, "enrol_authorize");
+ if ($message == '[[' . $reasonstr . ']]') {
$message = isset($response[3]) ? $response[3] : 'unknown error';
}
+ if (!$test && !empty($cctype) && ($reasonno == 17 or $reasonno == 28)) {
+ $ccaccepts = enrolment_plugin_authorize::get_list_of_creditcards();
+ unset($ccaccepts[$cctype]);
+ set_config('an_acceptccs', array_keys($ccaccepts));
+ enrolment_plugin_authorize::email_to_admin("Autoconfigure; This card type " .
+ "isn't accepted: $cctype. New config:", $ccaccepts);
+ }
if (!empty($CFG->an_avs)) {
$avs = "avs" . strtolower($response[5]);
$stravs = get_string($avs, "enrol_authorize");
@@ -206,7 +206,7 @@ function cc_submit($form, $course)
$message = '';
$an_review = !empty($CFG->an_review);
$action = $an_review ? AN_ACTION_AUTH_ONLY : AN_ACTION_AUTH_CAPTURE;
- $success = authorize_action($order, $message, $extra, $action);
+ $success = authorize_action($order, $message, $extra, $action, $form->cctype);
if (!$success) {
enrolment_plugin_authorize::email_to_admin($message, $order);
$this->ccerrors['header'] = $message;

0 comments on commit 0ee1574

Please sign in to comment.