From a1a0800de7c69fe5ee414b79e408ceacd4a1c2c3 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 25 Apr 2013 14:45:49 -0700 Subject: changes to support PayPal, #22395 --- .../cgi/make_thirdparty_payment.html | 2 +- fs_selfservice/FS-SelfService/cgi/myaccount.html | 7 +---- .../FS-SelfService/cgi/myaccount_menu.html | 35 +++++++++++++--------- fs_selfservice/FS-SelfService/cgi/selfservice.cgi | 5 +++- fs_selfservice/FS-SelfService/cgi/verify.cgi | 17 ++++++++--- 5 files changed, 40 insertions(+), 26 deletions(-) (limited to 'fs_selfservice') diff --git a/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html index b5b9eea1f..59ee93b00 100755 --- a/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html +++ b/fs_selfservice/FS-SelfService/cgi/make_thirdparty_payment.html @@ -8,7 +8,7 @@ onSubmit="document.OneTrueForm.process.disabled=true"> diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount.html b/fs_selfservice/FS-SelfService/cgi/myaccount.html index 9ab262261..a6352e07a 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount.html @@ -6,18 +6,13 @@ Hello <%= $name %>!

<%= include('small_custview') %>
-<%= unless ( $access_pkgnum ) { - $OUT .= qq!Balance: \$$balance

!; - } - ''; -%> <%= $OUT .= qq! View All Invoices     !; %> <%= if ( $balance > 0 ) { - if (scalar(grep $_, @hide_payment_fields)) { + if (scalar(grep $_, @hide_payment_fields)) { # this sucks $OUT .= qq! Make a payment

!; } else { $OUT .= qq! Make a payment
!; diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html index 4a31b1258..cf719e849 100644 --- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html +++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html @@ -23,37 +23,44 @@ unless ( $access_pkgnum ) { url=>'customer_order_pkg', 'indent'=>2 }; } +my %payby_mode; +@payby_mode{@cust_paybys} = @hide_payment_fields; +# $payby_mode{FOO} is true if FOO is thirdparty, false if it's B::OP, +# nonexistent if it's not supported + if ( $balance > 0 ) { #XXXFIXME "enable selfservice prepay features" flag or something, eventually per-pkg or something really fancy - #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] && $cust_paybys[$i] =~ /^CARD/ ) { + if ( exists( $payby_mode{CARD} ) ) { push @menu, { title => 'Recharge my account with a credit card', - url => $hide_payment_fields[$i] + url => $payby_mode{CARD} ? '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] && $cust_paybys[$i] =~ /^CHEK/ ) { + if ( exists( $payby_mode{CHEK} ) ) { push @menu, { title => 'Recharge my account with a check', - url => $hide_payment_fields[$i] + url => $payby_mode{CHEK} ? '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); + if ( exists( $payby_mode{PREP} ) ) { + push @menu, { title => 'Recharge my account with a prepaid card', + url => 'recharge_prepay', + indent => 2, + } + } + if ( exists( $payby_mode{PPAL} ) ) { + push @menu, { title => 'Recharge my account with PayPal', + url => 'make_thirdparty_payment&payby_method=PAYPAL', + indent => 2, + } + } } push @menu, diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index f7fe308cf..40fe98af2 100755 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -667,12 +667,15 @@ sub make_thirdparty_payment { } sub post_thirdparty_payment { - $cgi->param('payby_method') =~ /^(CC|ECHECK)$/ + $cgi->param('payby_method') =~ /^(CC|ECHECK|PAYPAL)$/ or die "illegal payby method"; my $method = $1; $cgi->param('amount') =~ /^(\d+(\.\d*)?)$/ or die "illegal amount"; my $amount = $1; + # realtime_collect() returns the result from FS::cust_main->realtime_collect + # which returns realtime_bop() + # which returns a hashref of popup_url, collectitems, and reference my $result = realtime_collect( 'session_id' => $session_id, 'method' => $method, diff --git a/fs_selfservice/FS-SelfService/cgi/verify.cgi b/fs_selfservice/FS-SelfService/cgi/verify.cgi index d9346b897..ff209d2f9 100755 --- a/fs_selfservice/FS-SelfService/cgi/verify.cgi +++ b/fs_selfservice/FS-SelfService/cgi/verify.cgi @@ -87,11 +87,14 @@ my $rv = capture_payment( map { $_ => scalar($cgi->param($_)) } $cgi->param }, url => $cgi->self_url, + cancel => ($cgi->param('cancel') ? 1 : 0), ); $error = $rv->{error}; - -if ( $error eq '_decline' ) { + +if ( $error eq '_cancel' ) { + print_okay(%$rv); +} elsif ( $error eq '_decline' ) { print_decline(); } elsif ( $error ) { print_verify(); @@ -133,8 +136,14 @@ sub print_okay { $success_url .= '/signup.cgi?action=success'; } - print $cgi->header( '-expires' => 'now' ), - $success_template->fill_in( HASH => { success_url => $success_url } ); + if ( $param{error} eq '_cancel' ) { + # then the payment was canceled, so don't show a message, just redirect + # (during signup, you really need a separate landing page for this case) + print $cgi->redirect($success_url); + } else { + 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 -- cgit v1.2.1