add option to limit automatic unsuspensions to a specific suspension reason type...
[freeside.git] / ng_selfservice / payment_cc.php
1 <? $title ='Credit Card Payment'; include('elements/header.php'); ?>
2 <? $current_menu = 'payment_cc.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'      => 'CARD',
10     'amount'     => $_POST['amount'],
11     'payinfo'    => $_POST['payinfo'],
12     'paycvv'     => $_POST['paycvv'],
13     'month'      => $_POST['month'],
14     'year'       => $_POST['year'],
15     'payname'    => $_POST['payname'],
16     'address1'   => $_POST['address1'],
17     'address2'   => $_POST['address2'],
18     'city'       => $_POST['city'],
19     'state'      => $_POST['state'],
20     'zip'        => $_POST['zip'],
21     'country'    => $_POST['country'],
22     'save'       => $_POST['save'],
23     'auto'       => $_POST['auto'],
24     'paybatch'   => $_POST['paybatch'],
25     //'discount_term' => $discount_term,
26   ));
27
28   if ( $payment_results['error'] ) {
29     $payment_error = $payment_results['error'];
30   } else {
31     $receipt_html = $payment_results['receipt_html'];
32   }
33
34 }
35
36 if ( $receipt_html ) { ?>
37
38   Your payment was processed successfully.  Thank you.<BR><BR>
39   <? echo $receipt_html; ?>
40
41 <? } else {
42
43   $payment_info = $freeside->payment_info( array(
44     'session_id' => $_COOKIE['session_id'],
45     'payment_payby' => 'CARD',
46   ) );
47
48   if ( isset($payment_info['error']) && $payment_info['error'] ) {
49     $error = $payment_info['error'];
50     header('Location:index.php?error='. urlencode($error));
51     die();
52   }
53
54   extract($payment_info);
55
56   $error = $payment_error;
57
58   $tr_amount_fee = $freeside->mason_comp(array(
59       'session_id' => $_COOKIE['session_id'],
60       'comp'       => '/elements/tr-amount_fee.html',
61       'args'       => [ 'amount',  $balance ],
62   ));
63   //$tr_amount_fee = $tr_amount_fee->{'error'} || $tr_amount_fee->{'output'};
64   $tr_amount_fee = $tr_amount_fee['output'];
65
66   ?>
67
68   <? include('elements/error.php'); ?>
69
70   <FORM NAME="OneTrueForm" METHOD="POST" ACTION="payment_cc.php" onSubmit="document.OneTrueForm.process.disabled=true">
71
72   <TABLE>
73   <TR>
74     <TD ALIGN="right">Amount&nbsp;Due</TD>
75     <TD COLSPAN=7>
76       <TABLE><TR><TD>
77         $<? echo sprintf("%.2f", $balance) ?>
78       </TD></TR></TABLE>
79     </TD>
80   </TR>
81
82   <? echo $tr_amount_fee; ?>
83
84   <? //include('elements/discount_term.php') ?>
85
86   <TR>
87     <TD ALIGN="right">Card&nbsp;type</TD>
88     <TD COLSPAN=7>
89       <SELECT NAME="card_type"><OPTION></OPTION>
90         <? foreach ( $card_types AS $ct ) { ?>
91           <OPTION <? if ( $card_type == $ct ) { echo 'SELECTED'; } ?>
92                   VALUE="<? echo $ct; ?>"><? echo $ct; ?>
93         <? } ?>
94       </SELECT>
95     </TD>
96   </TR>
97
98   <? include('elements/card.php'); ?>
99
100   <TR>
101     <TD COLSPAN=8>
102       <INPUT TYPE="checkbox" <? if ( ! $save_unchecked ) { echo 'CHECKED'; } ?> NAME="save" VALUE="1">
103       Remember this card and billing address
104     </TD>
105   </TR><TR>
106     <TD COLSPAN=8>
107       <INPUT TYPE="checkbox" <? if ( $payby == 'CARD' ) { echo ' CHECKED'; } ?> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
108       Charge future payments to this card automatically
109     </TD>
110   </TR>
111   </TABLE>
112   <BR>
113   <INPUT TYPE="hidden" NAME="paybatch" VALUE="<? echo $paybatch ?>">
114   <INPUT TYPE="submit" NAME="process" VALUE="Process payment"> <!-- onClick="this.disabled=true"> -->
115   </FORM>
116
117 <? } ?>
118
119 <? include('elements/menu_footer.php'); ?>
120 <? include('elements/footer.php'); ?>