Permalink
Browse files

Card Validation and Postal Code field validation fix. (is_int & is_nu…

…meric)
  • Loading branch information...
1 parent bdc003e commit b1fa2cf2691a58db4c55a5917fe3fbde66ced31e ethem committed Jan 27, 2006
Showing with 28 additions and 18 deletions.
  1. +14 −5 enrol/authorize/enrol.html
  2. +14 −12 enrol/authorize/enrol.php
  3. +0 −1 enrol/authorize/index.php
View
@@ -23,21 +23,21 @@
<div align="center">
<p><?php print_string("paymentrequired") ?></p>
-<p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
+<p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
<p><?php print_string("paymentinstant") ?></p>
<form name="form" method="post" action="enrol.php" autocomplete="off">
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
<table align="center" width="100%" border=0>
<tr>
<td align="right"><?php print_string("ccno", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" />
+ <td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" />
<?php if (!empty($this->ccerrors['cc'])) { formerr($this->ccerrors['cc']); } ?></td>
</tr>
<tr>
<td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
- <input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" />
+ <td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
+ <input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" />
<?php if (!empty($this->ccerrors['ccfirstlast'])) { formerr($this->ccerrors['ccfirstlast']); } ?></td>
</tr>
<tr>
@@ -78,7 +78,7 @@
<?php if (!empty($CFG->an_avs)) { /* Address Verification System */ ?>
<tr>
<td align="right"><?php print_string("address") ?>: </td>
- <td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" />
+ <td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" />
<?php if (!empty($this->ccerrors['ccaddress'])) { formerr($this->ccerrors['ccaddress']); } ?></td>
</tr>
<tr>
@@ -92,6 +92,15 @@
<td align="left"><?php choose_from_menu(get_list_of_countries(), "cccountry", $usercountry, get_string("selectacountry")."..."); ?>
<?php if (!empty($this->ccerrors['cccountry'])) { formerr($this->ccerrors['cccountry']); } ?></td>
</tr>
+<?php } else { /* not AVS */ ?>
+<tr>
+<td colspan="2">
+ <input type="hidden" name="ccstate" value="" />
+ <input type="hidden" name="ccaddress" value="<?php p($useraddress) ?>" />
+ <input type="hidden" name="cccity" value="<?php p($usercity) ?>" />
+ <input type="hidden" name="cccountry" value="<?php p($usercountry) ?>" />
+</td>
+</tr>
<?php } ?>
<tr>
<td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
View
@@ -147,26 +147,28 @@ function cc_submit($form, $course)
}
$extra = new stdClass();
- $extra->x_phone = '';
- $extra->x_fax = '';
- $extra->x_first_name = $form->ccfirstname;
- $extra->x_last_name = $form->cclastname;
- $extra->x_address = $form->ccaddress;
- $extra->x_city = $form->cccity;
- $extra->x_zip = $form->cczip;
- $extra->x_state = $form->ccstate;
- $extra->x_country = $form->cccountry;
$extra->x_card_num = $form->cc;
$extra->x_card_code = $form->cvv;
$extra->x_exp_date = $exp_date;
$extra->x_currency_code = $curcost['currency'];
$extra->x_amount = $curcost['cost'];
+ $extra->x_first_name = $form->ccfirstname;
+ $extra->x_last_name = $form->cclastname;
+ $extra->x_country = $form->cccountry;
+ $extra->x_address = $form->ccaddress;
+ $extra->x_state = $form->ccstate;
+ $extra->x_city = $form->cccity;
+ $extra->x_zip = $form->cczip;
+
$extra->x_invoice_num = $order->id;
$extra->x_description = $course->shortname;
+
$extra->x_cust_id = $USER->id;
- $extra->x_customer_ip = $useripno;
$extra->x_email = $USER->email;
+ $extra->x_customer_ip = $useripno;
$extra->x_email_customer = empty($CFG->enrol_mailstudents) ? 'FALSE' : 'TRUE';
+ $extra->x_phone = '';
+ $extra->x_fax = '';
$message = '';
$an_review = !empty($CFG->an_review);
@@ -296,7 +298,7 @@ function validate_enrol_form($form)
if (empty($form->cc)) {
$this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
}
- if (empty($form->cvv) || !is_int($form->cvv)) {
+ if (empty($form->cvv) || !is_numeric($form->cvv)) {
$this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
}
if (empty($form->cctype)) {
@@ -313,7 +315,7 @@ function validate_enrol_form($form)
$this->ccerrors['cccountry'] = get_string('missingcountry');
}
}
- if (empty($form->cczip) || !is_int($form->cczip)) {
+ if (empty($form->cczip) || !is_numeric($form->cczip)) {
$this->ccerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
}
if (!empty($this->ccerrors)) {
@@ -2,7 +2,6 @@
require_once '../../config.php';
require_once $CFG->dirroot.'/enrol/authorize/const.php';
-require_once $CFG->dirroot.'/enrol/authorize/enrol.php';
require_once $CFG->dirroot.'/enrol/authorize/action.php';
define('ORDER_CAPTURE', 'capture');

0 comments on commit b1fa2cf

Please sign in to comment.