#my @print_text = $cust_bill->print_text; #( date )
my @invoicing_list = $self->cust_main->invoicing_list;
if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice
- #false laziness w/FS::cust_pay::delete & fs_signup_server
+ #false laziness w/FS::cust_pay::delete & fs_signup_server && ::realtime_card
#$ENV{SMTPHOSTS} = $smtpmachine;
$ENV{MAILADDRESS} = $invoice_from;
my $header = new Mail::Header ( [
}
#} elsif ( $options{'report_badcard'} ) {
} else {
- return "$processor error, invnum #". $self->invnum. ': '.
- $transaction->result_code. ": ". $transaction->error_message;
+
+ my $perror = "$processor error, invnum #". $self->invnum. ': '.
+ $transaction->result_code. ": ". $transaction->error_message;
+
+ if ( $conf->exists('emaildecline')
+ && grep { $_ ne 'POST' } $cust_main->invoicing_list
+ ) {
+ my @templ = $conf->config('declinetemplate');
+ my $template = new Text::Template (
+ TYPE => 'ARRAY',
+ SOURCE => [ map "$_\n", @templ ],
+ ) or die "($perror) can't create template: $Text::Template::ERROR";
+ $template->compile()
+ or die "($perror) can't compile template: $Text::Template::ERROR";
+
+ my $error = $transaction->error_message;
+
+ #false laziness w/FS::cust_pay::delete & fs_signup_server && ::send
+ $ENV{MAILADDRESS} = $invoice_from;
+ my $header = new Mail::Header ( [
+ "From: $invoice_from",
+ "To: ". join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list ),
+ "Sender: $invoice_from",
+ "Reply-To: $invoice_from",
+ "Date: ". time2str("%a, %d %b %Y %X %z", time),
+ "Subject: Your credit card could not be processed",
+ ] );
+ my $message = new Mail::Internet (
+ 'Header' => $header,
+ 'Body' => [ $template->fill_in() ],
+ );
+ $!=0;
+ $message->smtpsend( Host => $smtpmachine )
+ or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
+ or die "($perror) (customer # ". $self->custnum.
+ ") can't send card decline email to ".
+ join(', ', grep { $_ ne 'POST' } $cust_main->invoicing_list ).
+ " via server $smtpmachine with SMTP: $!";
+ }
+
+ return $perror;
}
}
=head1 VERSION
-$Id: cust_bill.pm,v 1.27 2002-04-13 09:14:07 ivan Exp $
+$Id: cust_bill.pm,v 1.28 2002-04-16 09:38:19 ivan Exp $
=head1 BUGS
);
$!=0;
$message->smtpsend( Host => $smtpmachine )
- or die "Can't send expiration email!: $!"; #die? warn?
+ or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
+ or die "Can't send expiration email: $!";
} elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
push @body, sprintf(qq{%5d %-32.32s %4s %10s %12s %12s},
$!=0;
$message->smtpsend( Host => $smtpmachine )
or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
- or return "can't send alerter failure email to $failure_recipient".
- " via server $smtpmachine with SMTP: $!";
+ or die "can't send alerter failure email to $failure_recipient".
+ " via server $smtpmachine with SMTP: $!";
}
# subroutines
=head1 VERSION
-$Id: freeside-expiration-alerter,v 1.2 2002-03-07 19:50:24 jeff Exp $
+$Id: freeside-expiration-alerter,v 1.3 2002-04-16 09:38:19 ivan Exp $
=head1 BUGS
<li>You can bill individual customers by clicking on the <i>Bill now</i> link on the main customer view.
<li>The <a href="man/bin/freeside-daily.html"><b>freeside-daily</b></a> script should be run daily to bill customers and run invoice collection events.
<li>Real-time credit card processing: Install the <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> module for your processor. Configure the <a href="../config/config-view.cgi#business-onlinepayment">business-onlinepayment</a> configuration option. Disable the default <b>Batch card</b> <a href="../browse/part_bill_event.cgi">invoice event</a> and add one for Business::OnlinePayment.
+ <li>Optional: Credit card expiration alerts: Customize <a href="../config/config.cgi#alerter_template">alerter_template</a> configuration option and run <a href="man/bin/freeside-expiration-alerter.html">freeside-expiration-alerter</a> daily.
+ <li>Credit card decline alerts: Customize the <a href="../config/config.cgi#declinetemplate">declinetemplate</a> configuration option and set the <a href="../config/config.cgi#emaildecline">emaildecline</a> configuration option.
<li>Optional: Invoice template customization
<ul>
<li>See the <a href="http://search.cpan.org/doc/MJD/Text-Template-1.42/Template.pm">Text::Template</a> documentation for details on the substitution language.