[freeside-commits] freeside/fs_selfservice/FS-SelfService/cgi make_thirdparty_payment.html, NONE, 1.1.2.1 verify.cgi, NONE, 1.1.2.1 change_pay.html, 1.3, 1.3.2.1 myaccount.html, 1.12, 1.12.2.1 myaccount_menu.html, 1.10, 1.10.2.1 selfservice.cgi, 1.31, 1.31.2.1 signup.cgi, 1.11, 1.11.2.1 signup.html, 1.16, 1.16.2.1

Jeff Finucane,420,, jeff at wavetail.420.am
Sun Mar 8 20:51:10 PDT 2009


Update of /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi
In directory wavetail.420.am:/tmp/cvs-serv17014/fs_selfservice/FS-SelfService/cgi

Modified Files:
      Tag: webpay_support_branch
	change_pay.html myaccount.html myaccount_menu.html 
	selfservice.cgi signup.cgi signup.html 
Added Files:
      Tag: webpay_support_branch
	make_thirdparty_payment.html verify.cgi 
Log Message:
webpay support #4103

Index: selfservice.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/selfservice.cgi,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -d -r1.31 -r1.31.2.1
--- selfservice.cgi	1 Feb 2009 12:28:45 -0000	1.31
+++ selfservice.cgi	9 Mar 2009 03:51:08 -0000	1.31.2.1
@@ -10,7 +10,7 @@
 use Date::Format;
 use Number::Format 1.50;
 use FS::SelfService qw( login_info login customer_info edit_info invoice
-                        payment_info process_payment 
+                        payment_info process_payment realtime_collect
                         process_prepay
                         list_pkgs order_pkg signup_info order_recharge
                         part_svc_info provision_acct provision_external
@@ -72,7 +72,7 @@
 
 #order|pw_list XXX ???
 $cgi->param('action') =~
-    /^(myaccount|view_invoice|make_payment|make_ach_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_support_details|change_password|process_change_password)$/
+    /^(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_support_details|change_password|process_change_password)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -98,6 +98,7 @@
 do_template($action, {
   'session_id' => $session_id,
   'action'     => $action, #so the menu knows what tab we're on...
+  %{ payment_info( 'session_id' => $session_id ) },  # cust_paybys for the menu
   %{$result}
 });
 
@@ -472,6 +473,12 @@
 
 }
 
+sub make_thirdparty_payment {
+  $cgi->param('payby_method') =~ /^(CC|ECHECK)$/
+    or die "illegal payby method";
+  realtime_collect( 'session_id' => $session_id, 'method' => $1 );
+}
+
 sub recharge_prepay {
   customer_info( 'session_id' => $session_id );
 }

Index: myaccount.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/myaccount.html,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- myaccount.html	1 Feb 2009 12:28:45 -0000	1.12
+++ myaccount.html	9 Mar 2009 03:51:08 -0000	1.12.2.1
@@ -8,7 +8,11 @@
 <%= $small_custview %>
 <BR>
 <%= if ( $balance > 0 ) {
-  $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR><BR>!;
+  if (scalar(grep $_, @hide_payment_field)) {
+    $OUT .= qq! <B><A HREF="${url}make_payment">Make a payment</A></B><BR><BR>!;
+  } else {
+    $OUT .= qq! <B><A HREF="${url}make_thirdparty_payment&payby_method=CC">Make a payment</A></B><BR><BR>!;
+  }
 } %>
 <%=
   if ( @open_invoices ) {

--- NEW FILE: verify.cgi ---
#!/usr/bin/perl -T
#!/usr/bin/perl -Tw

use strict;
use vars qw( $cgi $self_url $error
             $verify_html $verify_template
             $success_html $success_template
             $decline_html $decline_template
           );

use subs qw( print_verify print_okay print_decline
             verify_default success_default decline_default
           );
use CGI;
use Text::Template;
use FS::SelfService qw( capture_payment );

$verify_html =  -e 'verify.html'
                  ? 'verify.html'
                  : '/usr/local/freeside/verify.html';
$success_html = -e 'verify_success.html'
                  ? 'success.html'
                  : '/usr/local/freeside/success.html';
$decline_html = -e 'verify_decline.html'
                  ? 'decline.html'
                  : '/usr/local/freeside/decline.html';


if ( -e $verify_html ) {
  my $verify_txt = Text::Template::_load_text($verify_html)
    or die $Text::Template::ERROR;
  $verify_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
  $verify_txt = $1;
  $verify_template = new Text::Template ( TYPE => 'STRING',
                                          SOURCE => $verify_txt,
                                          DELIMITERS => [ '<%=', '%>' ],
                                        )
    or die $Text::Template::ERROR;
} else {
  $verify_template = new Text::Template ( TYPE => 'STRING',
                                          SOURCE => &verify_default,
                                          DELIMITERS => [ '<%=', '%>' ],
                                        )
    or die $Text::Template::ERROR;
}

if ( -e $success_html ) {
  my $success_txt = Text::Template::_load_text($success_html)
    or die $Text::Template::ERROR;
  $success_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
  $success_txt = $1;
  $success_template = new Text::Template ( TYPE => 'STRING',
                                           SOURCE => $success_txt,
                                           DELIMITERS => [ '<%=', '%>' ],
                                         )
    or die $Text::Template::ERROR;
} else {
  $success_template = new Text::Template ( TYPE => 'STRING',
                                           SOURCE => &success_default,
                                           DELIMITERS => [ '<%=', '%>' ],
                                         )
    or die $Text::Template::ERROR;
}

if ( -e $decline_html ) {
  my $decline_txt = Text::Template::_load_text($decline_html)
    or die $Text::Template::ERROR;
  $decline_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
  $decline_txt = $1;
  $decline_template = new Text::Template ( TYPE => 'STRING',
                                           SOURCE => $decline_txt,
                                           DELIMITERS => [ '<%=', '%>' ],
                                         )
    or die $Text::Template::ERROR;
} else {
  $decline_template = new Text::Template ( TYPE => 'STRING',
                                           SOURCE => &decline_default,
                                           DELIMITERS => [ '<%=', '%>' ],
                                         )
    or die $Text::Template::ERROR;
}

$cgi = new CGI;

my $rv = capture_payment(
           data => { map { $_ => scalar($cgi->param($_)) } $cgi->param },
           url  => $cgi->self_url,
);

$error = $rv->{error};
  
if ( $error eq '_decline' ) {
  print_decline();
} elsif ( $error ) {
  print_verify();
} else {
  print_okay(%$rv);
}


sub print_verify {

  $error = "Error: $error" if $error;

  my $r = { $cgi->Vars, 'error' => $error };

  $r->{self_url} = $cgi->self_url;

  print $cgi->header( '-expires' => 'now' ),
        $verify_template->fill_in( PACKAGE => 'FS::SelfService::_signupcgi',
                                   HASH    => $r
                                 );
}

sub print_decline {
  print $cgi->header( '-expires' => 'now' ),
        $decline_template->fill_in();
}

sub print_okay {
  my %param = @_;

  my @success_url = split '/', $cgi->url(-path);
  pop @success_url;

  my $success_url  = join '/', @success_url;
  if ($param{session_id}) {
    my $session_id = lc($param{session_id});
    $success_url .= "/selfservice.cgi?action=myaccount&session=$session_id";
  } else {
    $success_url .= '/signup.cgi?action=success';
  }

  print $cgi->header( '-expires' => 'now' ),
        $success_template->fill_in( HASH => { success_url => $success_url } );
}

sub success_default { #html to use if you don't specify a success file
  <<'END';
<HTML><HEAD><TITLE>Signup successful</TITLE></HEAD>
<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Signup successful</FONT><BR><BR>
Thanks for signing up!
<BR><BR>
<SCRIPT TYPE="text/javascript">
  window.top.location="<%= $success_url %>";
</SCRIPT>
</BODY></HTML>
END
}

sub verify_default { #html to use for verification response
  <<'END';
<HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
There has been an error processing your account.  Please contact customer
support.
</BODY></HTML>
END
}

sub decline_default { #html to use if there is a decline
  <<'END';
<HTML><HEAD><TITLE>Processing error</TITLE></HEAD>
<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Processing error</FONT><BR><BR>
There has been an error processing your account.  Please contact customer
support.
</BODY></HTML>
END
}

# subs for the templates...

package FS::SelfService::_signupcgi;
use HTML::Entities;


Index: signup.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/signup.html,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -d -r1.16 -r1.16.2.1
--- signup.html	2 Mar 2009 00:10:53 -0000	1.16
+++ signup.html	9 Mar 2009 03:51:08 -0000	1.16.2.1
@@ -245,7 +245,7 @@
   form_name => 'dummy',
   html_between => '</td></tr></table>',
   form_action => 'dummy.cgi',
-  layer_callback => sub { my $layer = shift; return $paybychecked{$layer}. '</TABLE>'; },
+  layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . '</TABLE>'; },
 )->html;
 
 

Index: myaccount_menu.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- myaccount_menu.html	23 Jan 2008 19:18:39 -0000	1.10
+++ myaccount_menu.html	9 Mar 2009 03:51:08 -0000	1.10.2.1
@@ -18,14 +18,34 @@
 
 if ( 1 ) { #XXXFIXME "enable selfservice prepay features" flag or something, eventually per-pkg or something really fancy
 
-  push @menu, (
-    { title=>'Recharge my account with a credit card',
-      url=>'make_payment', indent=>2 },
-    { title=>'Recharge my account with a check',
-      url=>'make_ach_payment', indent=>2 },
-    { title=>'Recharge my account with a prepaid card',
-      url=>'recharge_prepay', indent=>2 },
-  );
+  #XXXFIXME still a bit sloppy for multi-gateway of differing namespace
+  my $i = 0;
+  while($i < scalar(@cust_paybys)) { last if $cust_paybys[$i] =~ /^CARD/; $i++ }
+  if ( $cust_paybys[$i] =~ /^CARD/ ) {
+    push @menu, { title  => 'Recharge my account with a credit card',
+                  url    => $hide_payment_fields[$i]
+                              ? 'make_thirdparty_payment&payby_method=CC'
+                              : 'make_payment',
+                  indent => 2,
+                 }
+  }
+
+  $i = 0;
+  while($i < scalar(@cust_paybys)) { last if $cust_paybys[$i] =~ /^CHEK/; $i++ }
+  if ( $cust_paybys[$i] =~ /^CHEK/ ) {
+    push @menu, { title  => 'Recharge my account with a check',
+                  url    => $hide_payment_field[$i]
+                              ? 'make_thirdparty_payment&payby_method=ECHECK'
+                              : 'make_ach_payment',
+                  indent => 2,
+                }
+  }
+
+  push @menu, { title  => 'Recharge my account with a prepaid card',
+                url    => 'recharge_prepay',
+                indent => 2,
+              }
+    if grep(/^PREP/, @cust_paybys);
 
 }
 

Index: change_pay.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/change_pay.html,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- change_pay.html	1 Feb 2009 12:28:45 -0000	1.3
+++ change_pay.html	9 Mar 2009 03:51:07 -0000	1.3.2.1
@@ -51,10 +51,11 @@
                       'LECB'   => qq/Phone Bill Billing/,
                       'BILL'   => qq/Billing/,
                       'COMP'   => qq/Complimentary/,
+                      'PREP'   => qq/Prepaid Card/,
                       'PREPAY' => qq/Prepaid Card/,
                     );
   tie my %options, 'Tie::IxHash', ();
-  foreach my $payby_option ( @paybys ) {
+  foreach my $payby_option ( grep { exists( $payby_index{$_} ) } @paybys ) {
     $options{$payby_option} = $payby_index{$payby_option};
   }
   $options{$payby} = $payby_index{$payby}

Index: signup.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/fs_selfservice/FS-SelfService/cgi/signup.cgi,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -d -r1.11 -r1.11.2.1
--- signup.cgi	21 Jul 2008 22:34:35 -0000	1.11
+++ signup.cgi	9 Mar 2009 03:51:08 -0000	1.11.2.1
@@ -8,11 +8,12 @@
              $ieak_file $ieak_template
              $signup_html $signup_template
              $success_html $success_template
+             $collect_html $collect_template
              $decline_html $decline_template
            );
 
 use subs qw( print_form print_okay print_decline
-             success_default decline_default
+             success_default collect_default decline_default
            );
 use CGI;
 #use CGI::Carp qw(fatalsToBrowser);
@@ -35,6 +36,9 @@
 $success_html = -e 'success.html'
                   ? 'success.html'
                   : '/usr/local/freeside/success.html';
+$collect_html = -e 'collect.html'
+                  ? 'collect.html'
+                  : '/usr/local/freeside/collect.html';
 $decline_html = -e 'decline.html'
                   ? 'decline.html'
                   : '/usr/local/freeside/decline.html';
@@ -97,6 +101,24 @@
     or die $Text::Template::ERROR;
 }
 
+if ( -e $collect_html ) {
+  my $collect_txt = Text::Template::_load_text($collect_html)
+    or die $Text::Template::ERROR;
+  $collect_txt =~ /^(.*)$/s; #untaint the template source - it's trusted
+  $collect_txt = $1;
+  $collect_template = new Text::Template ( TYPE => 'STRING',
+                                           SOURCE => $collect_txt,
+                                           DELIMITERS => [ '<%=', '%>' ],
+                                         )
+    or die $Text::Template::ERROR;
+} else {
+  $collect_template = new Text::Template ( TYPE => 'STRING',
+                                           SOURCE => &collect_default,
+                                           DELIMITERS => [ '<%=', '%>' ],
+                                         )
+    or die $Text::Template::ERROR;
+}
+
 if ( -e $decline_html ) {
   my $decline_txt = Text::Template::_load_text($decline_html)
     or die $Text::Template::ERROR;
@@ -122,9 +144,10 @@
                           'reg_code'   => uc(scalar($cgi->param('reg_code'))),
                         );
 
-if (    ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )
-     || ( defined($cgi->param('action')) && $cgi->param('action') eq 'process_signup' )
-   ) {
+my $magic  = $cgi->param('magic') || '';
+my $action = $cgi->param('action') || '';
+
+if ( $magic eq 'process' || $action eq 'process_signup' ) {
 
     $error = '';
 
@@ -218,6 +241,10 @@
     
     if ( $error eq '_decline' ) {
       print_decline();
+    } elsif ( $error eq '_collect' ) {
+      map { $cgi->param($_, $rv->{$_}) }
+        qw( popup_url reference collectitems amount );
+      print_collect();
     } elsif ( $error ) {
       #fudge the snarf info
       no strict 'refs';
@@ -230,6 +257,16 @@
       );
     }
 
+} elsif ( $magic eq 'success' || $action eq 'success' ) {
+
+  $cgi->param('username', 'username');  #hmmm temp kludge
+  $cgi->param('_password', 'password');
+  print_okay( map { /^([\w ]+)$/ ? ( $_ => $1 ) : () } $cgi->param ); #hmmm
+
+} elsif ( $magic eq 'decline' || $action eq 'decline' ) {
+
+  print_decline();
+
 } else {
   $error = '';
   print_form;
@@ -258,6 +295,27 @@
                                  );
 }
 
+sub print_collect {
+
+  $error = "Error: $error" if $error;
+
+  my $r = {
+    $cgi->Vars,
+    %{$init_data},
+    'error' => $error,
+  };
+
+  $r->{pkgpart} ||= $r->{default_pkgpart};
+
+  $r->{referral_custnum} = $r->{'ref'};
+  $r->{self_url} = $cgi->self_url;
+
+  print $cgi->header( '-expires' => 'now' ),
+        $collect_template->fill_in( PACKAGE => 'FS::SelfService::_signupcgi',
+                                    HASH    => $r
+                                  );
+}
+
 sub print_decline {
   print $cgi->header( '-expires' => 'now' ),
         $decline_template->fill_in();
@@ -369,6 +427,37 @@
 END
 }
 
+sub collect_default { #html to use if there is a collect phase
+  <<'END';
+<HTML><HEAD><TITLE>Pay now</TITLE></HEAD>
+<BODY BGCOLOR="#e8e8e8"><FONT SIZE=7>Pay now</FONT><BR><BR>
+<SCRIPT TYPE="text/javascript">
+  function popcollect() {
+    overlib( OLiframeContent('<%= $popup_url %>', 336, 550, 'Secure Payment Area', 0, 'auto' ), CAPTION, 'Pay now', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '#333399', CGCOLOR, '#333399', CLOSETEXT, 'Close' );
+    return false;
+  }
+</SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="overlibmws.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="overlibmws_iframe.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="overlibmws_draggable.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="overlibmws_crossframe.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" SRC="iframecontentmws.js"></SCRIPT>
+You are about to contact our payment processor to pay <%= $amount %> for
+<%= $pkg %>.<BR><BR>
+Your transaction reference number is <%= $reference %><BR><BR>
+<FORM NAME="collect_popper" method="post" action="javascript:void(0)" onSubmit="popcollect()">
+<%=
+  my %itemhash = @collectitems;
+  foreach my $input (keys %itemhash) {
+    $OUT .= qq!<INPUT NAME="$input" TYPE="hidden" VALUE="$itemhash{$input}">!;
+  }
+%>
+<INPUT NAME="submit" type="submit" value="Pay now">
+</FORM>
+</BODY></HTML>
+END
+}
+
 sub decline_default { #html to use if there is a decline
   <<'END';
 <HTML><HEAD><TITLE>Processing error</TITLE></HEAD>

--- NEW FILE: make_thirdparty_payment.html ---
<HTML><HEAD><TITLE>My Account</TITLE></HEAD>
<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
<SCRIPT TYPE="text/javascript">
  function popcollect() {
    overlib( OLiframeContent('<%= $popup_url %>', 336, 550, 'Secure Payment Area', 0, 'auto' ), CAPTION, 'Pay now', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK, BGCOLOR, '#333399', CGCOLOR, '#333399', CLOSETEXT, 'Close' );
    return false;
  }
</SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="overlibmws.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="overlibmws_iframe.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="overlibmws_draggable.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="overlibmws_crossframe.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="iframecontentmws.js"></SCRIPT>
<%= $url = "$selfurl?session=$session_id;action="; ''; %>
<%= include('myaccount_menu') %>
<TD VALIGN="top">
<FONT SIZE=4>Pay now</FONT><BR><BR>

<%= if ( $error ) {
  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">$error</FONT><BR><BR>!;
}else{
  $OUT .= <<EOF;
    You are about to contact our payment processor to pay $amount.<BR><BR>
    Your transaction reference number is $reference <BR><BR>
    <FORM NAME="collect_popper" method="post" action="javascript:void(0)" onSubmit="popcollect()">
EOF

  my %itemhash = @collectitems;
  foreach my $input (keys %itemhash) {
    $OUT .= qq!<INPUT NAME="$input" TYPE="hidden" VALUE="$itemhash{$input}">!;
  }

  $OUT .= qq!<INPUT NAME="submit" type="submit" value="Pay now">!;
  $OUT .= qq!</FORM>!;
}
%>
</TD></TR></TABLE>
</BODY></HTML>



More information about the freeside-commits mailing list