diff options
| author | jeff <jeff> | 2009-03-09 03:51:10 +0000 | 
|---|---|---|
| committer | jeff <jeff> | 2009-03-09 03:51:10 +0000 | 
| commit | fca3dd0b189baa394dd73d58d868d065a2b36cf7 (patch) | |
| tree | 3025e96892cad7256fb9e5415a6994f81bbb2df1 /fs_selfservice/FS-SelfService/cgi | |
| parent | 097a12385d80ef52f37d4cc2bb93bc3f81e6f8e6 (diff) | |
webpay support #4103webpay_support_branch
Diffstat (limited to 'fs_selfservice/FS-SelfService/cgi')
| -rw-r--r-- | fs_selfservice/FS-SelfService/cgi/change_pay.html | 3 | ||||
| -rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html | 38 | ||||
| -rw-r--r-- | fs_selfservice/FS-SelfService/cgi/myaccount.html | 6 | ||||
| -rw-r--r-- | fs_selfservice/FS-SelfService/cgi/myaccount_menu.html | 36 | ||||
| -rw-r--r-- | fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 11 | ||||
| -rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/signup.cgi | 97 | ||||
| -rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/signup.html | 2 | ||||
| -rwxr-xr-x | fs_selfservice/FS-SelfService/cgi/verify.cgi | 175 | 
8 files changed, 351 insertions, 17 deletions
diff --git a/fs_selfservice/FS-SelfService/cgi/change_pay.html b/fs_selfservice/FS-SelfService/cgi/change_pay.html index 2bea9550b..7283cb850 100644 --- a/fs_selfservice/FS-SelfService/cgi/change_pay.html +++ b/fs_selfservice/FS-SelfService/cgi/change_pay.html @@ -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} diff --git a/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html new file mode 100755 index 000000000..042b8b37c --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html @@ -0,0 +1,38 @@ +<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> diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index cb5ed352e..c9ca0c5f0 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -8,7 +8,11 @@ Hello <%= $name %>!<BR><BR>  <%= $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 ) { diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index ec5a8fa42..cc9f255ce 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -18,14 +18,34 @@ my @menu = (  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);  } diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 865b5cecd..bb3db12c6 100644 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -10,7 +10,7 @@ use HTML::Entities;  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 @@ $session_id = $cgi->param('session');  #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 @@ warn "processing template $action\n"  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 ach_payment_results {  } +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 );  } diff --git a/fs_selfservice/FS-SelfService/cgi/signup.cgi b/fs_selfservice/FS-SelfService/cgi/signup.cgi index 47857f0a7..12452e686 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.cgi +++ b/fs_selfservice/FS-SelfService/cgi/signup.cgi @@ -8,11 +8,12 @@ use vars qw( @payby $cgi $init_data               $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 @@ $signup_html = -e 'signup.html'  $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 @@ if ( -e $success_html ) {      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 @@ $init_data = signup_info( 'agentnum'   => $agentnum,                            '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 (    ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )      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 @@ if (    ( defined($cgi->param('magic')) && $cgi->param('magic') eq 'process' )        );      } +} 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_form {                                   );  } +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 @@ Package: <%= $pkg %><BR>  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> diff --git a/fs_selfservice/FS-SelfService/cgi/signup.html b/fs_selfservice/FS-SelfService/cgi/signup.html index 1b97121c6..ae7b2226a 100755 --- a/fs_selfservice/FS-SelfService/cgi/signup.html +++ b/fs_selfservice/FS-SelfService/cgi/signup.html @@ -245,7 +245,7 @@ HTML::Widgets::SelectLayers->new(    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; diff --git a/fs_selfservice/FS-SelfService/cgi/verify.cgi b/fs_selfservice/FS-SelfService/cgi/verify.cgi new file mode 100755 index 000000000..0f8bfccc8 --- /dev/null +++ b/fs_selfservice/FS-SelfService/cgi/verify.cgi @@ -0,0 +1,175 @@ +#!/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; +  | 
