From a288c2733ae05f04af707133671e79f32efd9eb2 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 23 Jan 2009 01:23:41 +0000 Subject: [PATCH] add the start at PHP self-service as a quick early renew example --- fs_selfservice/php/freeside.class.php | 3 +- fs_selfservice/php/login.php | 90 +++++++++++ fs_selfservice/php/main.php | 39 +++++ fs_selfservice/php/order_renew.php | 164 +++++++++++++++++++++ fs_selfservice/php/process_login.php | 38 +++++ fs_selfservice/php/process_payment_order_renew.php | 71 +++++++++ 6 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 fs_selfservice/php/login.php create mode 100644 fs_selfservice/php/main.php create mode 100644 fs_selfservice/php/order_renew.php create mode 100644 fs_selfservice/php/process_login.php create mode 100644 fs_selfservice/php/process_payment_order_renew.php diff --git a/fs_selfservice/php/freeside.class.php b/fs_selfservice/php/freeside.class.php index 21e89b47f..bb2ac98ee 100644 --- a/fs_selfservice/php/freeside.class.php +++ b/fs_selfservice/php/freeside.class.php @@ -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; diff --git a/fs_selfservice/php/login.php b/fs_selfservice/php/login.php new file mode 100644 index 000000000..d9609147e --- /dev/null +++ b/fs_selfservice/php/login.php @@ -0,0 +1,90 @@ +login_info(); + +extract($login_info); + +$error = $_GET['error']; +if ( $error ) { + $username = $_GET['username']; + $domain = $_GET['domain']; +} + +?> + +Login +Login

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Username + +
Domain + +
Password + +
+
+ + + + OR

+ +
+ + + + + + + + + + + + + + +
Phone number + +
PIN + +
+
+ + + + + diff --git a/fs_selfservice/php/main.php b/fs_selfservice/php/main.php new file mode 100644 index 000000000..b34a47730 --- /dev/null +++ b/fs_selfservice/php/main.php @@ -0,0 +1,39 @@ +customer_info( array( + 'session_id' => $session_id, +) ); + +$error = $response['error']; + +if ( $error ) { + header('Location:login.php?error='. urlencode($error)); + die(); +} + +extract($response); + +?> + + + + My Account + + +

My Account

+ + Hello,

+ + + +
+ + Renew early + + + diff --git a/fs_selfservice/php/order_renew.php b/fs_selfservice/php/order_renew.php new file mode 100644 index 000000000..fa2a4e504 --- /dev/null +++ b/fs_selfservice/php/order_renew.php @@ -0,0 +1,164 @@ +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); + +?> + + + + Renew Early + + +

Renew Early

+ +
+ + + + + + A payment of $ will renew your account through .

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Amount +
+ $ +
+
Card type + +
Card number + + + + + + + + +
+ Exp. + + / + +
+
CVV2 (help)
Exact name on card
Card billing address + +
Address line 2 + +
City + + + + + + + + +
+ + State + + Zip + +
+
+ + Remember this information +
+ CHECKED NAME="auto" VALUE="1" onClick="if (this.checked) { document.OneTrueForm.save.checked=true; }"> + Charge future payments to this card automatically +
+
+ + +
+ + + diff --git a/fs_selfservice/php/process_login.php b/fs_selfservice/php/process_login.php new file mode 100644 index 000000000..1f4fd9a6b --- /dev/null +++ b/fs_selfservice/php/process_login.php @@ -0,0 +1,38 @@ +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(); + +?> diff --git a/fs_selfservice/php/process_payment_order_renew.php b/fs_selfservice/php/process_payment_order_renew.php new file mode 100644 index 000000000..1c01af66c --- /dev/null +++ b/fs_selfservice/php/process_payment_order_renew.php @@ -0,0 +1,71 @@ +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? + +?> + + + + Renew Early + + +

Renew Early

+ + Renewal processed sucessfully. + + + -- 2.11.0