fix long package locations showing up as line item on typeset invoices, RT#10093
[freeside.git] / FS / FS / cust_main / Billing_Realtime.pm
index bfcba69..2124075 100644 (file)
@@ -2,6 +2,10 @@ package FS::cust_main::Billing_Realtime;
 
 use strict;
 use vars qw( $conf $DEBUG $me );
+use vars qw( $realtime_bop_decline_quiet ); #ugh
+use Data::Dumper;
+use Digest::MD5 qw(md5_base64);
+use Business::CreditCard 0.28;
 use FS::UID qw( dbh );
 use FS::Record qw( qsearch qsearchs );
 use FS::Misc qw( send_email );
@@ -10,7 +14,7 @@ use FS::cust_pay;
 use FS::cust_pay_pending;
 use FS::cust_refund;
 
-#$realtime_bop_decline_quiet = 0;
+$realtime_bop_decline_quiet = 0;
 
 # 1 is mostly method/subroutine entry and options
 # 2 traces progress of some operations
@@ -29,7 +33,7 @@ FS::cust_main::Billing_Realtime - Realtime billing mixin for cust_main
 
 =head1 SYNOPSIS
 
-=head1 DESCRIPTIONS
+=head1 DESCRIPTION
 
 These methods are available on FS::cust_main objects.
 
@@ -85,6 +89,8 @@ I<depend_jobnum> allows payment capture to unlock export jobs
 sub realtime_collect {
   my( $self, %options ) = @_;
 
+  local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
+
   if ( $DEBUG ) {
     warn "$me realtime_collect:\n";
     warn "  $_ => $options{$_}\n" foreach keys %options;
@@ -135,6 +141,8 @@ I<session_id> is a session identifier associated with this payment.
 
 I<depend_jobnum> allows payment capture to unlock export jobs
 
+I<discount_term> attempts to take a discount by prepaying for discount_term
+
 (moved from cust_bill) (probably should get realtime_{card,ach,lec} here too)
 
 =cut
@@ -281,6 +289,8 @@ my %bop_method2payby = (
 sub realtime_bop {
   my $self = shift;
 
+  local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
   my %options = ();
   if (ref($_[0]) eq 'HASH') {
     %options = %{$_[0]};
@@ -706,6 +716,9 @@ sub fake_bop {
 
 sub _realtime_bop_result {
   my( $self, $cust_pay_pending, $transaction, %options ) = @_;
+
+  local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
+
   if ( $DEBUG ) {
     warn "$me _realtime_bop_result: pending transaction ".
       $cust_pay_pending->paypendingnum. "\n";
@@ -743,6 +756,7 @@ sub _realtime_bop_result {
        'paybatch' => $paybatch,
        'paydate'  => $cust_pay_pending->paydate,
        'pkgnum'   => $cust_pay_pending->pkgnum,
+       'discount_term' => $options{'discount_term'},
     } );
     #doesn't hurt to know, even though the dup check is in cust_pay_pending now
     $cust_pay->payunique( $options{payunique} )
@@ -887,7 +901,7 @@ sub _realtime_bop_result {
 
     }
 
-    if ( !$options{'quiet'} && !$FS::cust_main::realtime_bop_decline_quiet
+    if ( !$options{'quiet'} && !$realtime_bop_decline_quiet
          && $conf->exists('emaildecline')
          && grep { $_ ne 'POST' } $self->invoicing_list
          && ! grep { $transaction->error_message =~ /$_/ }
@@ -985,6 +999,9 @@ upon success) and session_id of any associated session.
 
 sub realtime_botpp_capture {
   my( $self, $cust_pay_pending, %options ) = @_;
+
+  local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
+
   if ( $DEBUG ) {
     warn "$me realtime_botpp_capture: pending transaction $cust_pay_pending\n";
     warn "  $_ => $options{$_}\n" foreach keys %options;
@@ -1140,6 +1157,8 @@ gateway is attempted.
 sub realtime_refund_bop {
   my $self = shift;
 
+  local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG;
+
   my %options = ();
   if (ref($_[0]) eq 'HASH') {
     %options = %{$_[0]};