From: Jonathan Prykop Date: Mon, 25 Jul 2016 21:32:30 +0000 (-0500) Subject: RT#42393: Verification cust_pay_pending handling in history & report X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=88e9a56677d343392416c262f976f069157b06cb RT#42393: Verification cust_pay_pending handling in history & report --- diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 0fc2cb7e0..7c1de9b69 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -1950,6 +1950,7 @@ sub realtime_verify_bop { if ( $reverse->is_success ) { $cust_pay_pending->status('done'); + $cust_pay_pending->statustext('reversed'); my $cpp_authorized_err = $cust_pay_pending->replace; return $cpp_authorized_err if $cpp_authorized_err; diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index dfb07b84d..3a8322e06 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -455,6 +455,26 @@ sub decline { $self->replace; } +=item reverse [ STATUSTEXT ] + +Sets the status of this pending payment to "done" (with statustext +"reversed (manual)" unless otherwise specified). + +Currently only used when resolving pending payments manually. + +=cut + +# almost complete false laziness with decline, +# but want to avoid confusion, in case any additional steps/defaults are ever added to either +sub reverse { + my $self = shift; + my $statustext = shift || "reversed (manual)"; + + $self->status('done'); + $self->statustext($statustext); + $self->replace; +} + # _upgrade_data # # Used by FS::Upgrade to migrate to a new database. diff --git a/httemplate/edit/cust_pay_pending.html b/httemplate/edit/cust_pay_pending.html index 0056bb925..7d480f319 100644 --- a/httemplate/edit/cust_pay_pending.html +++ b/httemplate/edit/cust_pay_pending.html @@ -4,6 +4,10 @@
Are you sure you want to delete this pending payment?
+% } elsif (( $action eq 'complete' ) and $authorized) { + +
Payment was authorized but not captured. Contact <% $cust_pay_pending->processor || 'the payment gateway' %> to establish the final disposition of this transaction.
+ % } elsif ( $action eq 'complete' ) {
No response was received from <% $cust_pay_pending->processor || 'the payment gateway' %> for this transaction. Check <% $cust_pay_pending->processor || 'the payment gateway' %>'s reporting and determine if this transaction completed successfully.
@@ -97,8 +101,6 @@ % } else { -%# if ( $action eq 'complete' ) { - @@ -106,18 +108,25 @@ -% if ( $action eq 'complete' ) { +% if ( $action eq 'complete' ) {     +% if ($authorized) { + + + +% } else { +% }     - % } + + @@ -156,6 +165,8 @@ my $cust_pay_pending = }) or die 'unknown paypendingnum'; +my $authorized = ($cust_pay_pending->status eq 'authorized') ? 1 : 0; + my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; diff --git a/httemplate/edit/process/cust_pay_pending.html b/httemplate/edit/process/cust_pay_pending.html index 1bad6cffe..0ff7d26d0 100644 --- a/httemplate/edit/process/cust_pay_pending.html +++ b/httemplate/edit/process/cust_pay_pending.html @@ -59,6 +59,15 @@ if ( $action eq 'delete' ) { $title = 'Pending payment completed (decline)'; } +} elsif ( $action eq 'reverse' ) { + + $error = $cust_pay_pending->reverse; + if ( $error ) { + $title = 'Error reversing pending payment'; + } else { + $title = 'Pending payment completed (reverse)'; + } + } else { die "unknown action $action"; diff --git a/httemplate/search/cust_pay_pending.html b/httemplate/search/cust_pay_pending.html index 8662d1989..697bdbbf0 100755 --- a/httemplate/search/cust_pay_pending.html +++ b/httemplate/search/cust_pay_pending.html @@ -17,7 +17,7 @@ my %statusaction = ( 'new' => 'delete', 'pending' => 'complete', - #'authorized' => '', + 'authorized' => 'complete', 'captured' => 'capture', #'declined' => '', #wouldn't need to take action on a done state#'done' diff --git a/httemplate/search/elements/cust_pay_or_refund.html b/httemplate/search/elements/cust_pay_or_refund.html index 236162428..d691aeb95 100755 --- a/httemplate/search/elements/cust_pay_or_refund.html +++ b/httemplate/search/elements/cust_pay_or_refund.html @@ -101,29 +101,30 @@ my $title = ''; $title = 'Unapplied ' if $unapplied; $title .= "\u$name_singular Search Results"; -my $link = ''; -if ( ( $curuser->access_right('View invoices') #remove in 2.5 (2.7?) - || ($curuser->access_right('View payments') && $table =~ /^cust_pay/) - || ($curuser->access_right('View refunds') && $table eq 'cust_refund') - ) - && ! $opt{'disable_link'} - ) -{ - - my $key; - my $q = ''; - if ( $table eq 'cust_pay_void' ) { - $key = 'paynum'; - $q .= 'void=1;'; - } elsif ( $table eq /^cust_(\w+)$/ ) { - $key = $1.'num'; - } - - if ( $key ) { - $q .= "$key="; - $link = [ "${p}view/$table.html?$q", $key ] - } -} +###NOT USED??? +#my $link = ''; +#if ( ( $curuser->access_right('View invoices') #remove in 2.5 (2.7?) +# || ($curuser->access_right('View payments') && $table =~ /^cust_pay/) +# || ($curuser->access_right('View refunds') && $table eq 'cust_refund') +# ) +# && ! $opt{'disable_link'} +# ) +#{ +# +# my $key; +# my $q = ''; +# if ( $table eq 'cust_pay_void' ) { +# $key = 'paynum'; +# $q .= 'void=1;'; +# } elsif ( $table eq /^cust_(\w+)$/ ) { +# $key = $1.'num'; +# } +# +# if ( $key ) { +# $q .= "$key="; +# $link = [ "${p}view/$table.html?$q", $key ] +# } +#} my $cust_link = sub { my $cust_thing = shift; @@ -176,12 +177,18 @@ if ( $opt{'pre_header'} ) { push @sort_fields, @{ $opt{'pre_fields'} }; } -my $sub_receipt = sub { +my $sub_receipt = $opt{'disable_link'} ? '' : sub { my $obj = shift; my $objnum = $obj->primary_key . '=' . $obj->get($obj->primary_key); + my $table = $obj->table; + my $void = ''; + if ($table eq 'cust_pay_void') { + $table = 'cust_pay'; + $void = ';void=1'; + } include('/elements/popup_link_onclick.html', - 'action' => $p.'view/cust_pay.html?link=popup;'.$objnum, + 'action' => $p.'view/'.$table.'.html?link=popup;'.$objnum.$void, 'actionlabel' => emt('Payment Receipt'), ); }; diff --git a/httemplate/view/cust_main/payment_history/pending_payment.html b/httemplate/view/cust_main/payment_history/pending_payment.html index 31149231b..cf7ef7c08 100644 --- a/httemplate/view/cust_main/payment_history/pending_payment.html +++ b/httemplate/view/cust_main/payment_history/pending_payment.html @@ -12,6 +12,7 @@ my %statusaction = ( 'new' => 'delete', 'thirdparty' => 'delete', 'pending' => 'complete', + 'authorized' => 'complete', 'captured' => 'capture', );