From 32db3ad86bcf04e4f34705a396b718061d333f20 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 10 Mar 2009 16:14:11 +0000 Subject: merge webpay support in with autoselection of old realtime_bop and realtime_refund_bop --- fs_selfservice/FS-SelfService/cgi/change_pay.html | 3 +- .../cgi/make_thirdparty_payment.html | 38 +++++ fs_selfservice/FS-SelfService/cgi/myaccount.html | 6 +- .../FS-SelfService/cgi/myaccount_menu.html | 36 ++++- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 11 +- fs_selfservice/FS-SelfService/cgi/signup.cgi | 97 +++++++++++- fs_selfservice/FS-SelfService/cgi/signup.html | 2 +- fs_selfservice/FS-SelfService/cgi/verify.cgi | 175 +++++++++++++++++++++ 8 files changed, 351 insertions(+), 17 deletions(-) create mode 100755 fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html create mode 100755 fs_selfservice/FS-SelfService/cgi/verify.cgi (limited to 'fs_selfservice/FS-SelfService/cgi') 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 @@ +My Account +MyAccount

+ + + + + + +<%= $url = "$selfurl?session=$session_id;action="; ''; %> +<%= include('myaccount_menu') %> + +Pay now

+ +<%= if ( $error ) { + $OUT .= qq!$error

!; +}else{ + $OUT .= <
+ Your transaction reference number is $reference

+
+EOF + + my %itemhash = @collectitems; + foreach my $input (keys %itemhash) { + $OUT .= qq!!; + } + + $OUT .= qq!!; + $OUT .= qq!
!; +} +%> + + 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 %>!

<%= $small_custview %>
<%= if ( $balance > 0 ) { - $OUT .= qq! Make a payment

!; + if (scalar(grep $_, @hide_payment_field)) { + $OUT .= qq! Make a payment

!; + } else { + $OUT .= qq! Make a payment

!; + } } %> <%= 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 %>
END } +sub collect_default { #html to use if there is a collect phase + <<'END'; +Pay now +Pay now

+ + + + + + +You are about to contact our payment processor to pay <%= $amount %> for +<%= $pkg %>.

+Your transaction reference number is <%= $reference %>

+
+<%= + my %itemhash = @collectitems; + foreach my $input (keys %itemhash) { + $OUT .= qq!!; + } +%> + +
+ +END +} + sub decline_default { #html to use if there is a decline <<'END'; Processing error 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 => '', form_action => 'dummy.cgi', - layer_callback => sub { my $layer = shift; return $paybychecked{$layer}. ''; }, + layer_callback => sub { my $layer = shift; return ( shift @hide_payment_fields ? '' : $paybychecked{$layer} ) . ''; }, )->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'; +Signup successful +Signup successful

+Thanks for signing up! +

+ + +END +} + +sub verify_default { #html to use for verification response + <<'END'; +Processing error +Processing error

+There has been an error processing your account. Please contact customer +support. + +END +} + +sub decline_default { #html to use if there is a decline + <<'END'; +Processing error +Processing error

+There has been an error processing your account. Please contact customer +support. + +END +} + +# subs for the templates... + +package FS::SelfService::_signupcgi; +use HTML::Entities; + -- cgit v1.2.1