3 /// Prevent double paid
4 prevent_double_paid($course);
6 /// Get payment methods enabled and use the first method as default payment method
7 $paymentmethodsenabled = get_list_of_payment_methods(); // methods enabled
8 $paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA
); // user's payment preference
10 if (!in_array($paymentmethod, $paymentmethodsenabled)) {
11 error("Invalid payment method: $paymentmethod");
14 switch ($paymentmethod)
22 case AN_METHOD_ECHECK
:
24 print_echeck_form($this);
29 function print_cc_form($classreference)
31 global $form, $course;
35 'ccaddress', 'cccity', 'ccstate', 'cccountry', 'cczip',
36 'ccfirstname', 'cclastname', 'cc', 'ccexpiremm', 'ccexpireyyyy', 'cctype', 'cvv'
38 foreach ($formvars as $var) {
39 if (!isset($form->$var)) {
44 $curcost = get_course_cost($course);
45 $userfirstname = empty($form->ccfirstname
) ?
$USER->firstname
: $form->ccfirstname
;
46 $userlastname = empty($form->cclastname
) ?
$USER->lastname
: $form->cclastname
;
47 $useraddress = empty($form->ccaddress
) ?
$USER->address
: $form->ccaddress
;
48 $usercity = empty($form->cccity
) ?
$USER->city
: $form->cccity
;
49 $usercountry = empty($form->cccountry
) ?
$USER->country
: $form->cccountry
;
52 <p align=
"center"><?php if (!empty($classreference->authorizeerrors
['header'])) { formerr($classreference->authorizeerrors
['header']); } ?></p>
55 <p align=
"right"><?php print_other_method(AN_METHOD_CC
) ?></p>
56 <p><?php print_string("paymentrequired") ?></p>
57 <p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
58 <p><?php print_string("paymentinstant") ?></p>
60 <form name=
"form" method=
"post" action=
"enrol.php" autocomplete=
"off">
61 <input type=
"hidden" name=
"id" value=
"<?php p($course->id) ?>" />
62 <input type
="hidden" name
="paymentmethod" value
="<?php p(AN_METHOD_CC) ?>" />
63 <table align
="center" width
="100%" border
=0>
65 <td align
="right"><?php
print_string("ccno", "enrol_authorize") ?>:
</td>
66 <td align=
"left"><input type=
"text" name=
"cc" size=
"16" value=
"<?php p($form->cc) ?>" />
67 <?php
if (!empty($classreference->authorizeerrors
['cc'])) { formerr($classreference->authorizeerrors
['cc']); } ?></td>
70 <td align=
"right"><?php print_string("nameoncard", "enrol_authorize") ?>:
</td>
71 <td align=
"left"><input type=
"text" name=
"ccfirstname" size=
"8" value=
"<?php p($userfirstname) ?>" />
72 <input type
="text" name
="cclastname" size
="8" value
="<?php p($userlastname) ?>" />
73 <?php
if (!empty($classreference->authorizeerrors
['ccfirstlast'])) { formerr($classreference->authorizeerrors
['ccfirstlast']); } ?></td>
76 <td align=
"right"><?php print_string("ccexpire", "enrol_authorize") ?>:
</td>
77 <td align=
"left"><?php
78 for ($i=1; $i<=12; $i++
) {
79 $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
81 choose_from_menu($months, 'ccexpiremm', $form->ccexpiremm
);
83 $nowyear = $nowdate["year"]-1;
84 for ($i=$nowyear; $i<=$nowyear+
11; $i++
) {
87 choose_from_menu($years, 'ccexpireyyyy', $form->ccexpireyyyy
);
88 if (!empty($classreference->authorizeerrors
['ccexpire'])) { formerr($classreference->authorizeerrors
['ccexpire']); }
92 <td align=
"right"><?php print_string("cctype", "enrol_authorize") ?>:
</td>
93 <td align=
"left"><?php
94 choose_from_menu(get_list_of_creditcards(), 'cctype', $form->cctype
);
95 if (!empty($classreference->authorizeerrors
['cctype'])) { formerr($classreference->authorizeerrors
['cctype']); }
100 <td align=
"right"><?php print_string("ccvv", "enrol_authorize") ?>:
</td>
101 <td align=
"left"><input type=
"text" name=
"cvv" size=
"4" maxlength=
"4" value=
"<?php p($form->cvv) ?>" />
102 <?php
helpbutton('cvv', '', 'enrol/authorize'); ?>
103 <?php if (!empty($classreference->authorizeerrors
['cvv'])) { formerr($classreference->authorizeerrors
['cvv']); } ?></td>
105 <?php if (!empty($CFG->an_avs
)) { /* Address Verification System */ ?>
107 <td align=
"right"><?php print_string("address") ?>:
</td>
108 <td align=
"left"><input type=
"text" name=
"ccaddress" size=
"32" value=
"<?php p($useraddress) ?>" />
109 <?php
if (!empty($classreference->authorizeerrors
['ccaddress'])) { formerr($classreference->authorizeerrors
['ccaddress']); } ?></td>
112 <td align=
"right"><?php print_string("city") ?> /
<?php print_string(
"state")
?>:
</td>
113 <td align=
"left"><input type=
"text" name=
"cccity" size=
"16" value=
"<?php p($usercity) ?>" /> /
114 <input type
="text" name
="ccstate" size
="2" maxlength
="2" value
="<?php p($form->ccstate) ?>" />
115 <?php
if (!empty($classreference->authorizeerrors
['cccity'])) { formerr($classreference->authorizeerrors
['cccity']); } ?></td>
118 <td align=
"right"><?php print_string("country") ?>:
</td>
119 <td align=
"left"><?php choose_from_menu(get_list_of_countries(), "cccountry", $usercountry, get_string("selectacountry")."..."); ?>
120 <?php if (!empty($classreference->authorizeerrors
['cccountry'])) { formerr($classreference->authorizeerrors
['cccountry']); } ?></td>
122 <?php } else { /* not AVS */ ?>
125 <input type=
"hidden" name=
"ccstate" value=
"" />
126 <input type=
"hidden" name=
"ccaddress" value=
"<?php p($useraddress) ?>" />
127 <input type
="hidden" name
="cccity" value
="<?php p($usercity) ?>" />
128 <input type
="hidden" name
="cccountry" value
="<?php p($usercountry) ?>" />
133 <td align=
"right"><?php print_string("zipcode", "enrol_authorize") ?>:
</td>
134 <td align=
"left"><input type=
"text" name=
"cczip" size=
"5" value=
"<?php p($form->cczip) ?>" />
135 <?php
if (!empty($classreference->authorizeerrors
['cczip'])) { formerr($classreference->authorizeerrors
['cczip']); } ?></td>
138 <input type=
"submit" value=
"<?php print_string("sendpaymentbutton
", "enrol_authorize
") ?>">
145 function print_echeck_form($classreference)
147 global $form, $course;
150 $formvars = array('abacode', 'accnum', 'acctype', 'bankname', 'firstname', 'lastname');
151 foreach ($formvars as $var) {
152 if (!isset($form->$var)) {
157 $curcost = get_course_cost($course);
158 $userfirstname = empty($form->firstname
) ?
$USER->firstname
: $form->firstname
;
159 $userlastname = empty($form->lastname
) ?
$USER->lastname
: $form->lastname
;
161 <!-- BEGIN ECHECK -->
162 <p align=
"center"><?php if (!empty($classreference->authorizeerrors
['header'])) { formerr($classreference->authorizeerrors
['header']); } ?></p>
165 <p align=
"right"><?php print_other_method(AN_METHOD_ECHECK
) ?></p>
166 <p><?php print_string("paymentrequired") ?></p>
167 <p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
168 <p><?php print_string("paymentinstant") ?></p>
170 <form name=
"form" method=
"post" action=
"enrol.php" autocomplete=
"off">
171 <input type=
"hidden" name=
"id" value=
"<?php p($course->id) ?>" />
172 <input type
="hidden" name
="paymentmethod" value
="<?php p(AN_METHOD_ECHECK) ?>" />
173 <table align
="center" width
="100%" border
=0>
175 <td align
="right"><?php
print_string("echeckabacode", "enrol_authorize") ?>:
</td>
176 <td align=
"left"><input type=
"text" name=
"abacode" size=
"9" maxlength=
"9" value=
"<?php p($form->abacode) ?>" />
177 <?php
helpbutton('aba', '', 'enrol/authorize'); ?>
178 <?php if (!empty($classreference->authorizeerrors
['abacode'])) { formerr($classreference->authorizeerrors
['abacode']); } ?></td>
181 <td align=
"right"><?php print_string("echeckaccnum", "enrol_authorize") ?>:
</td>
182 <td align=
"left"><input type=
"text" name=
"accnum" size=
"20" maxlength=
"20" value=
"<?php p($form->accnum) ?>" />
183 <?php
if (!empty($classreference->authorizeerrors
['accnum'])) { formerr($classreference->authorizeerrors
['accnum']); } ?></td>
186 <td align=
"right"><?php print_string("echeckacctype", "enrol_authorize") ?>:
</td>
187 <td align=
"left"><?php
189 $acctypesenabled = get_list_of_bank_account_types();
190 foreach ($acctypesenabled as $key) {
191 $acctypes[$key] = get_string("echeck".strtolower($key), "enrol_authorize");
193 choose_from_menu($acctypes, 'acctype', $form->acctype
);
194 if (!empty($classreference->authorizeerrors
['acctype'])) { formerr($classreference->authorizeerrors
['acctype']); }
199 <td align=
"right"><?php print_string("echeckbankname", "enrol_authorize") ?>:
</td>
200 <td align=
"left"><input type=
"text" name=
"bankname" size=
"20" maxlength=
"50" value=
"<?php p($form->bankname) ?>" />
201 <?php
if (!empty($classreference->authorizeerrors
['bankname'])) { formerr($classreference->authorizeerrors
['bankname']); } ?></td>
204 <td align=
"right"><?php print_string("echeckfirslasttname", "enrol_authorize") ?>:
</td>
205 <td align=
"left"><input type=
"text" name=
"firstname" size=
"8" value=
"<?php p($userfirstname) ?>" />
206 <input type
="text" name
="lastname" size
="8" value
="<?php p($userlastname) ?>" />
207 <?php
if (!empty($classreference->authorizeerrors
['firstlast'])) { formerr($classreference->authorizeerrors
['firstlast']); } ?></td>
210 <input type=
"submit" value=
"<?php print_string("sendpaymentbutton
", "enrol_authorize
") ?>">
217 function print_other_method($currentmethod)
221 if ($currentmethod == AN_METHOD_CC
) {
222 $otheravailable = in_array(AN_METHOD_ECHECK
, get_list_of_payment_methods());
223 $url = 'enrol.php?id='.$course->id
.'&paymentmethod='.AN_METHOD_ECHECK
;
224 $stringtofetch = 'usingecheckmethod';
227 $otheravailable = in_array(AN_METHOD_CC
, get_list_of_payment_methods());
228 $url = 'enrol.php?id='.$course->id
.'&paymentmethod='.AN_METHOD_CC
;
229 $stringtofetch = 'usingccmethod';
231 if ($otheravailable) {
234 print_string($stringtofetch, "enrol_authorize", $a);