[freeside-commits] freeside/fs_selfservice/php login.php, NONE, 1.1 process_login.php, NONE, 1.1 main.php, NONE, 1.1 order_renew.php, NONE, 1.1 process_payment_order_renew.php, NONE, 1.1 freeside.class.php, 1.1, 1.2
Ivan,,,
ivan at wavetail.420.am
Thu Jan 22 17:23:43 PST 2009
Update of /home/cvs/cvsroot/freeside/fs_selfservice/php
In directory wavetail.420.am:/tmp/cvs-serv3145
Modified Files:
freeside.class.php
Added Files:
login.php process_login.php main.php order_renew.php
process_payment_order_renew.php
Log Message:
add the start at PHP self-service as a quick early renew example
--- NEW FILE: login.php ---
<?php
require('freeside.class.php');
$freeside = new FreesideSelfService();
$login_info = $freeside->login_info();
extract($login_info);
$error = $_GET['error'];
if ( $error ) {
$username = $_GET['username'];
$domain = $_GET['domain'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Login</TITLE></HEAD>
<BODY BGCOLOR="#e8e8e8"><FONT SIZE=5>Login</FONT><BR><BR>
<FONT SIZE="+1" COLOR="#ff0000"><?php echo htmlspecialchars($error); ?></FONT>
<FORM ACTION="process_login.php" METHOD=POST>
<INPUT TYPE="hidden" NAME="session" VALUE="login">
<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TH ALIGN="right">Username </TH>
<TD>
<INPUT TYPE="text" NAME="username" VALUE="<?php echo htmlspecialchars($username); ?>"><?php if ( $single_domain ) { echo '@'.$single_domain; } ?>
</TD>
</TR>
<?php if ( $single_domain ) { ?>
<INPUT TYPE="hidden" NAME="domain" VALUE="<?php echo $single_domain ?>">
<?php } else { ?>
<TR>
<TH ALIGN="right">Domain </TH>
<TD>
<INPUT TYPE="text" NAME="domain" VALUE="<?php echo htmlspecialchars($domain); ?>">
</TD>
</TR>
<?php } ?>
<TR>
<TH ALIGN="right">Password </TH>
<TD>
<INPUT TYPE="password" NAME="password">
</TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" VALUE="Login"></TD>
</TR>
</TABLE>
</FORM>
<?php if ( $phone_login ) { ?>
<B>OR</B><BR><BR>
<FORM ACTION="process_login.php" METHOD=POST>
<INPUT TYPE="hidden" NAME="session" VALUE="login">
<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TH ALIGN="right">Phone number </TH>
<TD>
<INPUT TYPE="text" NAME="username" VALUE="<?php echo htmlspecialchars($username) ?>">
</TD>
</TR>
<INPUT TYPE="hidden" NAME="domain" VALUE="svc_phone">
<TR>
<TH ALIGN="right">PIN </TH>
<TD>
<INPUT TYPE="password" NAME="password">
</TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" VALUE="Login"></TD>
</TR>
</TABLE>
</FORM>
<?php } ?>
</BODY></HTML>
--- NEW FILE: main.php ---
<?php
require('freeside.class.php');
$freeside = new FreesideSelfService();
$session_id = $_GET['session_id'];
$response = $freeside->customer_info( array(
'session_id' => $session_id,
) );
$error = $response['error'];
if ( $error ) {
header('Location:login.php?error='. urlencode($error));
die();
}
extract($response);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>My Account</TITLE>
</HEAD>
<BODY>
<H1>My Account</H1>
Hello, <?php echo htmlspecialchars($name); ?><BR><BR>
<?php echo $small_custview; ?>
<BR>
<A HREF="order_renew.php?session_id=<?php echo $session_id; ?>">Renew early</A>
</BODY>
</HTML>
--- NEW FILE: process_payment_order_renew.php ---
<?php
require('freeside.class.php');
$freeside = new FreesideSelfService();
$response = $freeside->process_payment_order_renew( array(
'session_id' => $_POST['session_id'],
'payby' => 'CARD',
'amount' => $_POST['amount'],
'payinfo' => $_POST['payinfo'],
'paycvv' => $_POST['paycvv'],
'month' => $_POST['month'],
'year' => $_POST['year'],
'payname' => $_POST['payname'],
'address1' => $_POST['address1'],
'address2' => $_POST['address2'],
'city' => $_POST['city'],
'state' => $_POST['state'],
'zip' => $_POST['zip'],
'save' => $_POST['save'],
'auto' => $_POST['auto'],
'paybatch' => $_POST['paybatch'],
) );
#error_log("[process_payment_order_renew] received response from freeside: $response");
$error = $response['error'];
if ( $error ) {
header('Location:order_renew.php'.
'?session_id='. urlencode($_POST['session_id']).
'&payby=CARD'.
'&amount='. urlencode($_POST['amount'])
'&payinfo='. urlencode($_POST['payinfo'])
'&paycvv='. urlencode($_POST['paycvv'])
'&month='. urlencode($_POST['month'])
'&year='. urlencode($_POST['year'])
'&payname='. urlencode($_POST['payname'])
'&address1='. urlencode($_POST['address1'])
'&address2='. urlencode($_POST['address2'])
'&city='. urlencode($_POST['city'])
'&state='. urlencode($_POST['state'])
'&zip='. urlencode($_POST['zip'])
'&save='. urlencode($_POST['save'])
'&auto='. urlencode($_POST['auto'])
'&paybatch='. urlencode($_POST['paybatch'])
);
die();
}
// sucessful renewal.
$session_id = $response['session_id']'
// now what?
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Renew Early</TITLE>
</HEAD>
<BODY>
<H1>Renew Early</H1>
Renewal processed sucessfully.
</BODY>
</HTML>
--- NEW FILE: process_login.php ---
<?php
require('freeside.class.php');
$freeside = new FreesideSelfService();
$response = $freeside->login( array(
'username' => strtolower($_POST['username']),
'domain' => strtolower($_POST['domain']),
'password' => strtolower($_POST['password']),
) );
#error_log("[login] received response from freeside: $response");
$error = $response['error'];
if ( $error ) {
header('Location:login.php?username='. urlencode($username).
'&domain='. urlencode($domain).
'&error='. urlencode($error)
);
die();
}
// sucessful login
$session_id = $response['session_id'];
#error_log("[login] logged into freeside with session_id=$session_id");
// now what? for now, always redirect to the main page.
// eventually, other options?
header("Location:main.php?session_id=$session_id")
#die();
?>
Index: freeside.class.php
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/php/freeside.class.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- freeside.class.php 14 Oct 2007 01:51:06 -0000 1.1
+++ freeside.class.php 23 Jan 2009 01:23:41 -0000 1.2
@@ -2,7 +2,8 @@
class FreesideSelfService {
//Change this to match the location of your selfservice xmlrpc.cgi or daemon
- var $URL = 'https://www.example.com/selfservice/xmlrpc.cgi';
+ #var $URL = 'https://localhost/selfservice/xmlrpc.cgi';
+ var $URL = 'http://localhost/selfservice/xmlrpc.cgi';
function FreesideSelfService() {
$this;
--- NEW FILE: order_renew.php ---
<?php
require('freeside.class.php');
$freeside = new FreesideSelfService();
$session_id = $_GET['session_id'];
$renew_info = $freeside->renew_info( array(
'session_id' => $session_id,
) );
$error = $renew_info['error'];
if ( $error ) {
header('Location:login.php?error='. urlencode($error));
die();
}
#in the simple case, just deal with the first package
$bill_date = $renew_info['dates'][0]['bill_date'];
$bill_date_pretty = $renew_info['dates'][0]['bill_date_pretty'];
$renew_date = $renew_info['dates'][0]['renew_date'];
$renew_date_pretty = $renew_info['dates'][0]['renew_date_pretty'];
$amount = $renew_info['dates'][0]['amount'];
$payment_info = $freeside->payment_info( array(
'session_id' => $session_id,
) );
extract($payment_info);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Renew Early</TITLE>
</HEAD>
<BODY>
<H1>Renew Early</H1>
<FORM NAME="OneTrueForm" METHOD="POST" ACTION="process_payment_order_renew.php" onSubmit="document.OneTrueForm.process.disabled=true">
<INPUT TYPE="hidden" NAME="date" VALUE="<?php echo $date; ?>">
<INPUT TYPE="hidden" NAME="session" VALUE="<?php echo $session_id; ?>">
<INPUT TYPE="hidden" NAME="amount" VALUE="<?php echo $amount; ?>">
A payment of $<?php echo $amount; ?> will renew your account through <?php echo $renew_date_pretty; ?>.<BR><BR>
<TABLE BGCOLOR="#cccccc">
<TR>
<TD ALIGN="right">Amount</TD>
<TD>
<TABLE><TR><TD BGCOLOR="#ffffff">
$<?php echo $amount; ?>
</TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="right">Card type</TD>
<TD>
<SELECT NAME="card_type"><OPTION></OPTION>
<?php foreach ( array_keys($card_types) as $t ) { ?>
<OPTION <?php if ($card_type == $card_types[$t] ) { ?> SELECTED <?php } ?>
VALUE="<?php echo $card_types[$t]; ?>"
><?php echo $t; ?>
<?php } ?>
</SELECT>
</TD>
</TR>
<TR>
<TD ALIGN="right">Card number</TD>
<TD>
<TABLE>
<TR>
<TD>
<INPUT TYPE="text" NAME="payinfo" SIZE=20 MAXLENGTH=19 VALUE="<?php echo $payinfo; ?>"> </TD>
<TD>Exp.</TD>
<TD>
<SELECT NAME="month">
<?php foreach ( array('01','02','03','04','05','06','07','08','09','10','11','12') as $m) { ?>
<OPTION<?php if ($m == $month ) { ?> SELECTED<?php } ?>
><?php echo $m; ?>
<?php } ?>
</SELECT>
</TD>
<TD> / </TD>
<TD>
<SELECT NAME="year">
<?php $lt = localtime(); $y = $lt[5] + 1900;
for ($y = $lt[5]+1900; $y < $lt[5] + 1910; $y++ ) { ?>
<OPTION<?php if ($y == $year ) { ?> SELECTED<?php } ?>
><?php echo $y; ?>
<?php } ?>
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<?php if ( $withcvv ) { ?>
<TR>
<TD ALIGN="right">CVV2 (<A HREF="javascript:myopen('cvv2.html','cvv2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=480,height=288')">help</A>)</TD>
<TD><INPUT TYPE="text" NAME="paycvv" VALUE="" SIZE=4 MAXLENGTH=4></TD>
</TR>
<?php } ?>
<TR>
<TD ALIGN="right">Exact name on card</TD>
<TD><INPUT TYPE="text" SIZE=32 MAXLENGTH=80 NAME="payname" VALUE="<?php echo $payname; ?>"></TD>
</TR><TR>
<TD ALIGN="right">Card billing address</TD>
<TD>
<INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address1" VALUE="<?php echo $address1; ?>">
</TD>
</TR><TR>
<TD ALIGN="right">Address line 2</TD>
<TD>
<INPUT TYPE="text" SIZE=40 MAXLENGTH=80 NAME="address2" VALUE="<?php echo $address2; ?>">
</TD>
</TR><TR>
<TD ALIGN="right">City</TD>
<TD>
<TABLE>
<TR>
<TD>
<INPUT TYPE="text" NAME="city" SIZE="12" MAXLENGTH=80 VALUE="<?php echo $city; ?>">
</TD>
<TD>State</TD>
<TD>
<SELECT NAME="state">
<?php foreach ( $states as $s ) { ?>
<OPTION<?php if ($s == $state) { ?> SELECTED<?php } ?>
><?php echo $s; ?>
<?php } ?>
</SELECT>
</TD>
<TD>Zip</TD>
<TD>
<INPUT TYPE="text" NAME="zip" SIZE=11 MAXLENGTH=10 VALUE="<?php echo $zip; ?>">
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD COLSPAN=2>
<INPUT TYPE="checkbox" CHECKED NAME="save" VALUE="1">
Remember this information
</TD>
</TR><TR>
<TD COLSPAN=2>
<INPUT TYPE="checkbox"<?php if ( $payby == 'CARD' ) { ?> CHECKED<?php } ?> NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }">
Charge future payments to this card automatically
</TD>
</TR>
</TABLE>
<BR>
<INPUT TYPE="hidden" NAME="paybatch" VALUE="<?php echo $paybatch; ?>">
<INPUT TYPE="submit" NAME="process" VALUE="Process payment"> <!-- onClick="this.disabled=true"> -->
</FORM>
</BODY>
</HTML>
More information about the freeside-commits
mailing list