RT#30613: Can't Send E-mail [Upgrade improvements]
[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   ) );
46
47   if ( isset($payment_info['error']) && $payment_info['error'] ) {
48     $error = $payment_info['error'];
49     header('Location:index.php?error='. urlencode($error));
50     die();
51   }
52
53   extract($payment_info);
54
55   $error = $payment_error;
56
57   $tr_amount_fee = $freeside->mason_comp(array(
58       'session_id' => $_COOKIE['session_id'],
59       'comp'       => '/elements/tr-amount_fee.html',
60       'args'       => [ 'amount',  $balance ],
61   ));
62   //$tr_amount_fee = $tr_amount_fee->{'error'} || $tr_amount_fee->{'output'};
63   $tr_amount_fee = $tr_amount_fee['output'];
64
65   ?>
66
67   <? include('elements/error.php'); ?>
68
69   <FORM NAME="OneTrueForm" METHOD="POST" ACTION="payment_cc.php" onSubmit="document.OneTrueForm.process.disabled=true">
70
71   <TABLE>
72   <TR>
73     <TD ALIGN="right">Amount&nbsp;Due</TD>
74     <TD COLSPAN=7>
75       <TABLE><TR><TD>
76         $<? echo sprintf("%.2f", $balance) ?>
77       </TD></TR></TABLE>
78     </TD>
79   </TR>
80
81   <? echo $tr_amount_fee; ?>
82
83   <? //include('elements/discount_term.php') ?>
84
85   <TR>
86     <TD ALIGN="right">Card&nbsp;type</TD>
87     <TD COLSPAN=7>
88       <SELECT NAME="card_type"><OPTION></OPTION>
89         <? foreach ( $card_types AS $ct ) { ?>
90           <OPTION <? if ( $card_type == $card_types[$ct] ) { echo 'SELECTED'; } ?>
91                   VALUE="<? echo $card_types[$ct]; ?>"><? echo $ct; ?>
92         <? } ?>
93       </SELECT>
94     </TD>
95   </TR>
96
97   <? include('elements/card.php'); ?>
98
99   <TR>
100     <TD COLSPAN=8>
101       <INPUT TYPE="checkbox" <? if ( ! $save_unchecked ) { echo 'CHECKED'; } ?> NAME="save" VALUE="1">
102       Remember this card and billing address
103     </TD>
104   </TR><TR>
105     <TD COLSPAN=8>
106       <INPUT TYPE="checkbox" <? if ( $payby == 'CARD' ) { echo ' CHECKED'; } ?> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
107       Charge future payments to this card automatically
108     </TD>
109   </TR>
110   </TABLE>
111   <BR>
112   <INPUT TYPE="hidden" NAME="paybatch" VALUE="<? echo $paybatch ?>">
113   <INPUT TYPE="submit" NAME="process" VALUE="Process payment"> <!-- onClick="this.disabled=true"> -->
114   </FORM>
115
116 <? } ?>
117
118 <? include('elements/menu_footer.php'); ?>
119 <? include('elements/footer.php'); ?>