Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / ng_selfservice / payment_ach.php
1 <? $title ='Electronic Check Payment'; include('elements/header.php'); ?>
2 <? $current_menu = 'payment_ach.php'; include('elements/menu.php'); ?>
3 <?
4
5 if ( isset($_POST['amount']) && $_POST['amount'] ) {
6
7   $payment_results = $freeside->process_payment(array(
8     'session_id'    => $_COOKIE['session_id'],
9     'payby'         => 'CHEK',
10     'amount'        => $_POST['amount'],
11     'payinfo1'      => $_POST['payinfo1'],
12     'payinfo2'      => $_POST['payinfo2'],
13     'month'         => 12,
14     'year'          => 2037,
15     'payname'       => $_POST['payname'],
16     'paytype'       => $_POST['paytype'],
17     'paystate'      => $_POST['paystate'],
18     'ss'            => $_POST['ss'],
19     'stateid'       => $_POST['stateid'],
20     'stateid_state' => $_POST['stateid_state'],
21     'save'          => $_POST['save'],
22     'auto'          => $_POST['auto'],
23     'paybatch'      => $_POST['paybatch'],
24     //'discount_term' => $discount_term,
25   ));
26
27   if ( $payment_results['error'] ) {
28     $payment_error = $payment_results['error'];
29   } else {
30     $receipt_html = $payment_results['receipt_html'];
31   }
32
33 }
34
35 if ( $receipt_html ) { ?>
36
37   Your payment was processed successfully.  Thank you.<BR><BR>
38   <? echo $receipt_html; ?>
39
40 <? } else {
41
42   $payment_info = $freeside->payment_info( array(
43     'session_id' => $_COOKIE['session_id'],
44   ) );
45
46   if ( isset($payment_info['error']) && $payment_info['error'] ) {
47     $error = $payment_info['error'];
48     header('Location:index.php?error='. urlencode($error));
49     die();
50   }
51
52   extract($payment_info);
53
54   $error = $payment_error;
55
56   ?>
57
58   <? include('elements/error.php'); ?>
59
60   <FORM NAME="OneTrueForm" METHOD="POST" ACTION="payment_ach.php" onSubmit="document.OneTrueForm.process.disabled=true">
61
62   <TABLE>
63   <TR>
64     <TD ALIGN="right">Amount&nbsp;Due</TD>
65     <TD>
66       <TABLE><TR><TD BGCOLOR="#ffffff">
67         $<? echo sprintf("%.2f", $balance) ?>
68       </TD></TR></TABLE>
69     </TD>
70   </TR>
71
72   <TR>
73     <TD ALIGN="right">Payment&nbsp;amount</TD>
74     <TD>
75       <TABLE><TR><TD BGCOLOR="#ffffff">
76         $<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<? echo sprintf("%.2f", $balance) ?>">
77       </TD></TR></TABLE>
78     </TD>
79   </TR>
80   <? // include('elements/discount_term.php') ?>
81
82   <? include('elements/check.php') ?>
83
84   <TR>
85     <TD COLSPAN=2>
86       <INPUT TYPE="checkbox" <? if ( ! $save_unchecked ) { echo 'CHECKED'; } ?> NAME="save" VALUE="1">
87       Remember this information
88     </TD>
89   </TR><TR>
90     <TD COLSPAN=2>
91       <INPUT TYPE="checkbox" <? if ( $payby == 'CARD' ) { echo ' CHECKED'; } ?> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
92       Charge future payments to this account automatically
93     </TD>
94   </TR>
95   </TABLE>
96   <BR>
97   <INPUT TYPE="hidden" NAME="paybatch" VALUE="<? echo $paybatch; ?>">
98   <INPUT TYPE="submit" NAME="process" VALUE="Process payment"> <!-- onClick="this.disabled=true"> -->
99   </FORM>
100
101 <? } ?>
102   
103 <? include('elements/menu_footer.php'); ?>
104 <? include('elements/footer.php'); ?>