diff options
| -rw-r--r-- | FS/FS/ClientAPI/Signup.pm | 4 | ||||
| -rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 16 | ||||
| -rw-r--r-- | FS/FS/cust_pay_pending.pm | 4 | ||||
| -rw-r--r-- | httemplate/view/cust_main/payment_history/pending_payment.html | 1 | 
4 files changed, 23 insertions, 2 deletions
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index b18f21f74..6c9e81261 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -904,8 +904,8 @@ sub capture_payment {      return { error => '_decline', bill_error => $bill_error };    } -  if ($cust_pay_pending->status ne 'pending') { -    my $bill_error = "Payment with id $paypendingnum is not pending, but ". +  if ($cust_pay_pending->status ne 'thirdparty') { +    my $bill_error = "Payment with id $paypendingnum is not thirdparty, but ".                       $cust_pay_pending->status.  "; Transaction aborted.";      return { error => '_decline', bill_error => $bill_error };    } diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index caa3ab37d..fd192416d 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -522,6 +522,19 @@ sub realtime_bop {      'custnum' => $self->custnum,      'status'  => { op=>'!=', value=>'done' }     }); + +  #for third-party payments only, remove pending payments if they're in the  +  #'thirdparty' (waiting for customer action) state. +  if ( $namespace eq 'Business::OnlineThirdPartyPayment' ) { +    foreach ( grep { $_->status eq 'thirdparty' } @pending ) { +      my $error = $_->delete; +      warn "error deleting unfinished third-party payment ". +          $_->paypendingnum . ": $error\n" +        if $error; +    } +    @pending = grep { $_->status ne 'thirdparty' } @pending; +  } +    return "A payment is already being processed for this customer (".           join(', ', map 'paypendingnum '. $_->paypendingnum, @pending ).           "); $options{method} transaction aborted." @@ -594,6 +607,9 @@ sub realtime_bop {    if ( $transaction->is_success() && $namespace eq 'Business::OnlineThirdPartyPayment' ) { +    $cust_pay_pending->status('thirdparty'); +    my $cpp_err = $cust_pay_pending->replace; +    return { error => $cpp_err } if $cpp_err;      return { reference => $cust_pay_pending->paypendingnum,               map { $_ => $transaction->$_ } qw ( popup_url collectitems ) }; diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index e54690e4b..f03ed1f3a 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -96,6 +96,10 @@ Aquires basic lock on payunique  Transaction is pending with the gateway +=item thirdparty + +Customer has been sent to an off-site payment gateway to complete processing +  =item authorized  Only used for two-stage transactions that require a separate capture step diff --git a/httemplate/view/cust_main/payment_history/pending_payment.html b/httemplate/view/cust_main/payment_history/pending_payment.html index 40805b1aa..7d21f899f 100644 --- a/httemplate/view/cust_main/payment_history/pending_payment.html +++ b/httemplate/view/cust_main/payment_history/pending_payment.html @@ -33,6 +33,7 @@ my $info = $payby ? "($payby$payinfo)" : '';  my %statusaction = (    'new'        => 'delete', +  'thirdparty' => 'delete',    'pending'    => 'complete',    'captured'   => 'capture',  );  | 
