summaryrefslogtreecommitdiff
path: root/fs_selfservice
diff options
context:
space:
mode:
Diffstat (limited to 'fs_selfservice')
-rw-r--r--fs_selfservice/FS-SelfService/SelfService.pm12
-rw-r--r--fs_selfservice/FS-SelfService/cgi/discount_term.html17
-rw-r--r--fs_selfservice/FS-SelfService/cgi/make_ach_payment.html1
-rw-r--r--fs_selfservice/FS-SelfService/cgi/make_payment.html4
-rw-r--r--fs_selfservice/FS-SelfService/cgi/myaccount.html10
-rw-r--r--fs_selfservice/FS-SelfService/cgi/selfservice.cgi24
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/signup.html7
-rw-r--r--fs_selfservice/drupal/admin.inc56
-rw-r--r--fs_selfservice/drupal/freeside.class.php33
-rw-r--r--fs_selfservice/drupal/freeside.info3
-rw-r--r--fs_selfservice/drupal/freeside.module32
-rw-r--r--fs_selfservice/drupal/signup.inc354
-rw-r--r--fs_selfservice/php/freeside_order_pkg_example.php38
13 files changed, 584 insertions, 7 deletions
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 7e6821b..a0e632c 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -1393,6 +1393,18 @@ END
my $county_html = $script_html;
if ( $countyflag ) {
$county_html .= qq!<SELECT NAME="${prefix}county" onChange="$param->{'onchange'}">!;
+ foreach my $county (
+ sort keys %{ $cust_main_county{$param->{'selected_country'}}{$param->{'selected_state'}} }
+ ) {
+ my $text = $county || '(n/a)';
+ $county_html .= qq!<OPTION VALUE="$county"!.
+ ($county eq $param->{'selected_county'} ?
+ ' SELECTED>' :
+ '>'
+ ).
+ $text.
+ '</OPTION>';
+ }
$county_html .= '</SELECT>';
} else {
$county_html .=
diff --git a/fs_selfservice/FS-SelfService/cgi/discount_term.html b/fs_selfservice/FS-SelfService/cgi/discount_term.html
new file mode 100644
index 0000000..7d9ee4d
--- /dev/null
+++ b/fs_selfservice/FS-SelfService/cgi/discount_term.html
@@ -0,0 +1,17 @@
+<%=
+if ( scalar(keys %discount_terms_hash) ) {
+ $OUT .= '<TR>';
+ $OUT .= '<TD ALIGN="right">Prepayment for</TD>';
+ $OUT .= '<TD>';
+ $OUT .= '<SELECT NAME="discount_term">';
+ $OUT .= qq(<OPTION VALUE="">1 month\n);
+ foreach ( keys %discount_terms_hash ) {
+ $selected = $discount_term eq $_ ? ' SELECTED' : '';
+ $OUT .= qq(<OPTION$selected VALUE="$_">$_ months\n);
+ }
+ $OUT .= '</SELECT>';
+ $OUT .= '</TD>';
+ $OUT .= '</TR>';
+}
+$OUT .= '';
+%>
diff --git a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
index 09391e7..5b81b00 100644
--- a/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
+++ b/fs_selfservice/FS-SelfService/cgi/make_ach_payment.html
@@ -21,6 +21,7 @@
</TD></TR></TABLE>
</TD>
</TR>
+<%= include('discount_term') %>
<%= include('check') %>
<TR>
<TD COLSPAN=2>
diff --git a/fs_selfservice/FS-SelfService/cgi/make_payment.html b/fs_selfservice/FS-SelfService/cgi/make_payment.html
index e454647..645b68e 100644
--- a/fs_selfservice/FS-SelfService/cgi/make_payment.html
+++ b/fs_selfservice/FS-SelfService/cgi/make_payment.html
@@ -20,7 +20,9 @@
$<INPUT TYPE="text" NAME="amount" SIZE=8 VALUE="<%=sprintf("%.2f",$balance)%>">
</TD></TR></TABLE>
</TD>
-</TR><TR>
+</TR>
+<%= include('discount_term') %>
+<TR>
<TH ALIGN="right">Card&nbsp;type</TH>
<TD COLSPAN=7>
<SELECT NAME="card_type"><OPTION></OPTION>
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html
index 0de7385..6b4187f 100644
--- a/fs_selfservice/FS-SelfService/cgi/myaccount.html
+++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html
@@ -14,7 +14,15 @@ Hello <%= $name %>!<BR><BR>
if (scalar(grep $_, @hide_payment_fields)) {
$OUT .= qq! <B><A HREF="${url}make_thirdparty_payment&payby_method=CC">Make a payment</A></B><BR><BR>!;
} else {
- $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR><BR>!;
+ $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR>!;
+ foreach my $term ( sort { $b <=> $a } keys %discount_terms_hash ) {
+ my $saved = $discount_terms_hash{$term}->[1];
+ my $amount = $discount_terms_hash{$term}->[2];
+ my $savings = ( $amount + $saved > 0 )
+ ? sprintf('%d', $saved / ( $amount + $saved ) * 100 ) : '0';
+ $OUT .= qq! <B><A HREF="${url}make_term_payment;discount_term=$term;amount=$amount">Save $savings\% by paying for $term months: $amount</A></B><BR>!;
+ }
+ $OUT .= qq! <BR>!;
}
} %>
<%=
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index 2252852..711bd4e 100644
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -73,7 +73,7 @@ $session_id = $cgi->param('session');
#order|pw_list XXX ???
$cgi->param('action') =~
- /^(myaccount|view_invoice|make_payment|make_ach_payment|make_thirdparty_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_cdr_details|view_support_details|change_password|process_change_password)$/
+ /^(myaccount|view_invoice|make_payment|make_ach_payment|make_term_payment|make_thirdparty_payment|payment_results|ach_payment_results|recharge_prepay|recharge_results|logout|change_bill|change_ship|change_pay|process_change_bill|process_change_ship|process_change_pay|customer_order_pkg|process_order_pkg|customer_change_pkg|process_change_pkg|process_order_recharge|provision|provision_svc|process_svc_acct|process_svc_external|delete_svc|view_usage|view_usage_details|view_cdr_details|view_support_details|change_password|process_change_password)$/
or die "unknown action ". $cgi->param('action');
my $action = $1;
@@ -105,7 +105,8 @@ do_template($action, {
#--
-sub myaccount { customer_info( 'session_id' => $session_id ); }
+use Data::Dumper;
+sub myaccount { my $result = customer_info( 'session_id' => $session_id ); warn Dumper($result); $result;}
sub change_bill { my $payment_info =
payment_info( 'session_id' => $session_id );
@@ -427,6 +428,10 @@ sub payment_results {
$cgi->param('paybatch') =~ /^([\w\-\.]+)$/ or die "illegal paybatch";
my $paybatch = $1;
+ $cgi->param('discount_term') =~ /^(\d*)$/ or die "illegal discount_term";
+ my $discount_term = $1;
+
+
process_payment(
'session_id' => $session_id,
'payby' => 'CARD',
@@ -445,6 +450,7 @@ sub payment_results {
'save' => $save,
'auto' => $auto,
'paybatch' => $paybatch,
+ 'discount_term' => $discount_term,
);
}
@@ -529,6 +535,20 @@ sub make_thirdparty_payment {
realtime_collect( 'session_id' => $session_id, 'method' => $1 );
}
+sub make_term_payment {
+ $cgi->param('amount') =~ /^(\d+\.\d{2})$/
+ or die "illegal payment amount";
+ my $balance = $1;
+ $cgi->param('discount_term') =~ /^(\d+)$/
+ or die "illegal discount term";
+ my $discount_term = $1;
+ $action = 'make_payment';
+ ({ %{payment_info( 'session_id' => $session_id )},
+ 'balance' => $balance,
+ 'discount_term' => $discount_term,
+ })
+}
+
sub recharge_prepay {
customer_info( 'session_id' => $session_id );
}
diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html
index 375137b..7a56a31 100755
--- a/fs_selfservice/FS-SelfService/cgi/signup.html
+++ b/fs_selfservice/FS-SelfService/cgi/signup.html
@@ -74,8 +74,6 @@ Contact Information
<TR>
<TH ALIGN="right"><font color="#ff0000">*</font>City</TH>
<TD><INPUT TYPE="text" NAME="city" VALUE="<%= $city %>"></TD>
- <TH ALIGN="right"><font color="#ff0000">*</font>State/Country</TH>
- <TD>
<%=
($county_html, $state_html, $country_html) =
regionselector( {
@@ -87,8 +85,11 @@ Contact Information
locales => \@cust_main_county,
} );
- "$county_html $state_html";
%>
+ <TH ALIGN="right"><font color="#ff0000">*</font>
+ <%= ($county_html =~ /SELECT/) ? 'County/State' : 'State' %></TH>
+ <TD>
+ <%= "$county_html $state_html"; %>
</TD>
<TH><font color="#ff0000">*</font>Zip</TH>
<TD><INPUT TYPE="text" NAME="zip" SIZE=10 VALUE="<%= $zip %>"></TD>
diff --git a/fs_selfservice/drupal/admin.inc b/fs_selfservice/drupal/admin.inc
new file mode 100644
index 0000000..1fb7925
--- /dev/null
+++ b/fs_selfservice/drupal/admin.inc
@@ -0,0 +1,56 @@
+<?php
+
+function freeside_admin() {
+ return drupal_get_form('freeside_admin_form');
+}
+
+function freeside_admin_form() {
+ $hostname = variable_get('freeside_hostname','');
+
+ $form = array(
+ 'freeside_hostname'=> array(
+ '#type' => 'textfield',
+ '#title' => t('Freeside server address'),
+ '#default_value'=>variable_get('freeside_hostname',''),
+ '#required'=>1,
+ ),
+ );
+
+ if($hostname) {
+ $freeside = new FreesideSelfService();
+ $signup_info = $freeside->signup_info(
+ array(
+ 'keys' => array('agent')
+ )
+ ); // no agent in this request
+
+ $agents = array();
+ foreach((array)$signup_info['agent'] as $a) {
+ $agents[$a['agentnum']] = $a['agent'];
+ }
+
+ $form['freeside_agentnum'] = array(
+ '#type' => 'select',
+ '#title' => t('Signup agent'),
+ '#default_value'=>variable_get('freeside_agentnum',''),
+ '#required'=>1,
+ '#options'=> $agents,
+ );
+
+ $form['freeside_debug'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable debugging'),
+ '#default_value'=>variable_get('freeside_debug',0),
+ );
+
+ $form['freeside_redirect_after_signup'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Success page (URL or Drupal path)'),
+ '#default_value'=>variable_get('freeside_redirect_after_signup','/'),
+ );
+ }
+
+ return system_settings_form($form);
+}
+
+?>
diff --git a/fs_selfservice/drupal/freeside.class.php b/fs_selfservice/drupal/freeside.class.php
new file mode 100644
index 0000000..161156a
--- /dev/null
+++ b/fs_selfservice/drupal/freeside.class.php
@@ -0,0 +1,33 @@
+<?php
+
+class FreesideSelfService {
+
+ public $URL = '';
+ function FreesideSelfService() {
+ $this->URL = 'http://' . variable_get('freeside_hostname','') . ':8080';
+ $this;
+ }
+
+ public function __call($name, $arguments) {
+
+ error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
+
+ $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", $arguments);
+ $context = stream_context_create( array( 'http' => array(
+ 'method' => "POST",
+ 'header' => "Content-Type: text/xml",
+ 'content' => $request
+ )));
+ $file = file_get_contents($this->URL, false, $context);
+ $response = xmlrpc_decode($file);
+ if (xmlrpc_is_fault($response)) {
+ trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
+ } else {
+ //error_log("[FreesideSelfService] $response");
+ return $response;
+ }
+ }
+
+}
+
+?>
diff --git a/fs_selfservice/drupal/freeside.info b/fs_selfservice/drupal/freeside.info
new file mode 100644
index 0000000..957c7b9
--- /dev/null
+++ b/fs_selfservice/drupal/freeside.info
@@ -0,0 +1,3 @@
+name = Freeside
+description = Freeside self-service
+core = 6.x
diff --git a/fs_selfservice/drupal/freeside.module b/fs_selfservice/drupal/freeside.module
new file mode 100644
index 0000000..a806e3b
--- /dev/null
+++ b/fs_selfservice/drupal/freeside.module
@@ -0,0 +1,32 @@
+<?php
+// init freeside API
+require('freeside.class.php');
+
+// menu actions and node paths
+function freeside_menu() {
+ $items = array();
+ $items['freeside/signup'] = array(
+ 'title' => t('New customer'),
+ 'page callback' => 'freeside_signup',
+ 'access arguments' => array('access content'),
+ 'description' => t('New Customer Signup'),
+ 'file' => 'signup.inc',
+ );
+ $items['admin/settings/freeside'] = array(
+ 'title' => t('Configure Freeside'),
+ 'page callback' => 'freeside_admin',
+ 'access arguments' => array('administer freeside'),
+ 'description' => t('Configure Freeside self-service'),
+ 'file' => 'admin.inc',
+ );
+ return $items;
+}
+
+// access control
+function freeside_perm() {
+ return array(
+ 'administer freeside'
+ );
+}
+
+?>
diff --git a/fs_selfservice/drupal/signup.inc b/fs_selfservice/drupal/signup.inc
new file mode 100644
index 0000000..b3e54f0
--- /dev/null
+++ b/fs_selfservice/drupal/signup.inc
@@ -0,0 +1,354 @@
+<?php
+function freeside_signup() {
+ return drupal_get_form('freeside_signup_form');
+}
+
+function dkpr($var) {
+ /* "debug kpr": Krumo-print $var if debugging is on */
+ static $debug;
+ if(empty($debug)) $debug = variable_get('freeside_debug','');
+ if($debug) {
+ kpr($var);
+ }
+}
+
+function signup_info($keys) {
+ /* local cache, because transporting the entire signup_info
+ through XML-RPC is incredibly slow. If you change the config,
+ you can flush the local cache with the "Clear cached data"
+ button on the Drupal "Performance" menu. */
+ $cid = 'FS_signup_info';
+ $info = cache_get($cid);
+ if($info) {
+ return($info->data);
+ }
+ else {
+ $packet = array(
+ 'agentnum' => variable_get('freeside_agentnum',''),
+ 'promo_code' => '',
+ 'reg_code' => '',
+ 'keys' => $keys,
+ );
+
+ $freeside = new FreesideSelfService();
+ $freeside->clear_signup_cache();
+ $info = $freeside->signup_info($packet);
+ cache_set($cid, $info, 'cache', CACHE_TEMPORARY);
+ return($info);
+ }
+}
+
+function subextract($array, $key) {
+ // map { $_->{$key} } (...)
+ $out = array();
+ foreach ($array as $i) {
+ $out[] = $i[$key];
+ }
+ return $out;
+}
+
+function freeside_signup_form($form_state) {
+ dkpr($form_state);
+
+ $agentnum = variable_get('freeside_agentnum','');
+ if( !$agentnum || !(variable_get('freeside_hostname','')) ) {
+ drupal_set_message(t('Freeside self-service is not yet configured.'),'error');
+ return array();
+ }
+
+ $freeside = new FreesideSelfService();
+ $keys = array(
+ // all the signup_info that we need
+ 'part_referral',
+ 'refnum',
+ 'emailinvoiceonly',
+ 'payby',
+ 'payby_longname',
+ 'part_pkg',
+ 'default_pkgpart',
+ 'signup_service',
+ );
+ $signup_info = signup_info($keys);
+ dkpr($signup_info);
+
+ $form = array();
+
+ $refs = $signup_info['part_referral'];
+ $form['refnum'] = count($refs) > 1 ?
+ array(
+ '#type' => 'select',
+ '#title' => t('How did you hear about us?'),
+ '#options'=> array_combine(
+ subextract($refs, 'refnum'),
+ subextract($refs, 'referral')
+ ),
+ '#default_value'=>$signup_info['refnum'],
+ ) : array (
+ '#type' => 'hidden',
+ '#value' => $refs[0]['refnum'],
+ );
+
+ $form['contact'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Contact Information'),
+ 'last' => array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => t('Contact name (last, first)'),
+ '#size' => 20,
+ '#required' => 1,
+ ),
+ 'first' => array(
+ '#type' => 'textfield',
+ '#size' => 20,
+ '#required' => 1,
+ '#suffix' => '</div>',
+ ),
+ 'company' => array(
+ '#type' => 'textfield',
+ '#title' => t('Company'),
+ '#size' => 20,
+ ),
+ 'address1'=> array(
+ '#type' => 'textfield',
+ '#title' => t('Address'),
+ '#size' => 30,
+ '#required'=>1,
+ ),
+ 'address2'=> array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ ),
+ 'city' => array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => t('City'),
+ '#size' => 15,
+ '#required'=>1,
+ ),
+ 'state' => array(
+ '#type' => 'textfield',
+ '#title' => t('State'),
+ '#size' => 2,
+ '#required'=>1,
+ '#default_value'=>$info['statedefault'],
+ ),
+ 'zip' => array(
+ '#type' => 'textfield',
+ '#title' => t('Zip'),
+ '#size' => 10,
+ '#required'=>1,
+ '#suffix' => '</div>',
+ ),
+ 'daytime' => array(
+ '#type' => 'textfield',
+ '#title' => t('Daytime Phone'),
+ '#size' => 18,
+ ),
+ 'night' => array(
+ '#type' => 'textfield',
+ '#title' => t('Night Phone'),
+ '#size' => 18,
+ ),
+ );
+
+ $emailinvoiceonly = $signup_info['emailinvoiceonly'];
+
+ $form['billing'] = array(
+ 'invoicing_list' => array(
+ '#type' => 'textfield',
+ '#title' => t('Email invoice to'),
+ '#size' => '40',
+ '#required'=>$emailinvoiceonly,
+ ),
+ '#type' => 'fieldset',
+ '#title' => t('Billing Information'),
+ 'invoicing_list_POST' => array(
+ '#type' => $emailinvoiceonly ? 'hidden' : 'checkbox',
+ '#title' => t('Send a paper invoice'),
+ '#default_value' => 0,
+ ),
+ );
+
+ if( count($signup_info['payby']) > 1 ) {
+ $form['billing']['payby'] = array(
+ '#type' => 'select',
+ '#title' => t('Payment method'),
+ '#options'=> array_combine(
+ $signup_info['payby'],
+ $signup_info['payby_longname']
+ ),
+ );
+ }
+ else {
+ $form['billing']['payby'] = array(
+ '#type' => 'hidden',
+ '#value' => $signup_info['payby'][0],
+ );
+ }
+ $form['billing']['payby_CARD'] = array(
+ '#type' => 'fieldset',
+ 'cardnum' => array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => t('Credit card number'),
+ '#size' => 20,
+ '#maxlength'=>20,
+ '#required'=>1,
+ '#suffix' => '</div>',
+ ),
+ 'expmonth' => array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => t('Expiration date'),
+ '#size' => 2,
+ '#required'=>1,
+ '#maxlength' => 2,
+ ),
+ 'expyear' => array(
+ '#field_prefix' => '/',
+ '#type' => 'textfield',
+ '#size' => 2,
+ '#maxlength' => 2,
+ '#required'=>1,
+ '#suffix' => '</div>',
+ ),
+ 'paycvv' => array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => 'CVV',
+ '#size' => 3,
+ '#maxlength' => 3,
+ '#required'=>1,
+ '#suffix' => '</div>',
+ ),
+ 'cardname'=> array(
+ '#prefix' => '<div class="container-inline">',
+ '#type' => 'textfield',
+ '#title' => t('Exact name on card'),
+ '#size' => 40,
+ '#maxlength'=>60,
+ '#suffix' => '</div>',
+ ),
+ );
+
+ $pkgs = $signup_info['part_pkg'];
+ $form['package'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('First Package'),
+ 'pkgpart' => (count($pkgs) > 1 ?
+ array(
+ '#type' => 'select',
+ '#title' => '',
+ '#options'=> array_combine(
+ subextract($pkgs, 'pkgpart'),
+ subextract($pkgs, 'pkg')
+ ),
+ '#default_value'=>$signup_info['default_pkgpart'],
+ ) : array (
+ '#type' => 'hidden',
+ '#value' => $pkgs[0]['pkgpart'],
+ )
+ ),
+ );
+
+ switch($signup_info['signup_service']) {
+ case 'svc_acct':
+ $form['package'] += array(
+ 'username'=> array(
+ '#type' => 'textfield',
+ '#title' => t('Username'),
+ '#size' => 20,
+ '#required'=>1,
+ ),
+ 'password'=> array(
+ '#type' => 'password_confirm',
+ '#size' => 20,
+ '#required'=>1,
+ '#process'=> array('freeside_expand_password_confirm'),
+ )
+ );
+ break;
+ case 'svc_pbx':
+ break; // nothing yet implemented
+ }
+ $form['package']['pkgpart']['#default_value'] = $signup_info['default_pkgpart'];
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => 'Sign me up!',
+ );
+ return $form;
+}
+
+/* workaround for silly Drupal behavior */
+function freeside_expand_password_confirm($element) {
+ $element = expand_password_confirm($element);
+ $element['pass1']['#attributes']['value'] = $element['#value']['pass1'];
+ $element['pass2']['#attributes']['value'] = $element['#value']['pass2'];
+ return $element;
+}
+
+function freeside_signup_form_submit($form, &$form_state) {
+ $freeside = new FreesideSelfService();
+ $values = $form_state['values'];
+ dkpr($values);
+
+ $customer = array();
+ $customer['agentnum'] = variable_get('freeside_agentnum','');
+ foreach( array( 'first',
+ 'last',
+ 'address1',
+ 'address2',
+ 'city',
+ 'state',
+ 'zip',
+ 'daytime',
+ 'night',
+ 'fax',
+ 'payby',
+ 'refnum',
+ 'invoicing_list',
+ 'pkgpart',
+ 'username'
+ )
+ as $field ) {
+ $customer[$field] = $values[$field];
+ }
+ if($values['invoicing_list_POST']) {
+ $customer['invoicing_list'] =
+ implode(',', array($customer['invoicing_list'], 'POST'));
+ }
+ $customer['_password'] = $values['password'];
+ $customer['country'] = 'US';
+ if($customer['payby'] == 'CARD') {
+ $customer['payinfo'] = preg_replace('/\D/','',$values['cardnum']);
+ $customer['paydate'] = $values['expmonth'] . '/' . $values['expyear'];
+ $customer['payname'] = isset($values['cardname']) ?
+ $values['cardname'] :
+ ($values['first'] . ' ' . $values['last']);
+ $customer['paycvv'] = $values['paycvv'];
+ }
+ /* other paybys not implemented */
+
+ dkpr($customer);
+ $response = $freeside->new_customer($customer);
+ dkpr($response);
+ error_log("[new_customer] received response from Freeside: $response");
+ $error = $response['error'];
+
+ if ( $error ) {
+ drupal_set_message(t("Signup error: $error"), 'error');
+ $form_state['redirect'] = FALSE;
+ }
+ else {
+ drupal_set_message(t("Signup successful!"),'status');
+ $form_state['redirect'] = array(
+ variable_get('freeside_redirect_after_signup','/'),
+ //query string would go here
+ //'custnum='.$response['custnum'].'&svcnum='.$response['svcnum'],
+ );
+ }
+}
+
+?>
diff --git a/fs_selfservice/php/freeside_order_pkg_example.php b/fs_selfservice/php/freeside_order_pkg_example.php
new file mode 100644
index 0000000..395ad11
--- /dev/null
+++ b/fs_selfservice/php/freeside_order_pkg_example.php
@@ -0,0 +1,38 @@
+<?php
+
+require('freeside.class.php');
+$freeside = new FreesideSelfService();
+
+$response = $freeside->order_pkg( array(
+ 'session_id' => $_POST['session_id'],
+ 'pkgpart' => 15, #Freesize 25
+ #if needed# 'svcpart' =>
+ 'id' => $_POST['id'], #unique integer ID
+ 'name' => $_POST['name'], #text name
+) );
+
+$error = $response['error'];
+
+if ( ! $error ) {
+
+ // sucessful order
+
+ $pkgnum = $response['pkgnum'];
+ $svcnum = $response['svcnum'];
+
+ error_log("[order_pkg] package ordered pkgnum=$pkgnum, svcnum=$svcnum");
+
+ // store svcnum, to be used for the customer_status call
+
+} else {
+
+ // unsucessful order
+
+ error_log("[order_pkg] error ordering package: $error");
+
+ // display error message to user
+
+}
+
+
+?>