diff options
-rw-r--r-- | FS/FS/Conf.pm | 12 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 47 | ||||
-rwxr-xr-x | FS/bin/freeside-expiration-alerter | 9 | ||||
-rw-r--r-- | conf/declinetemplate | 10 | ||||
-rw-r--r-- | httemplate/docs/billing.html | 2 |
5 files changed, 72 insertions, 8 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index f9a49ca04..dc1cbb820 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -895,7 +895,19 @@ httemplate/docs/config.html 'type' => 'checkbox', }, + { + 'key' => 'declinetemplate' + 'section' => 'billing', + 'description' => 'Template file for credit card decline emails.', + 'type' => 'textarea', + }, + { + 'key' => 'emaildecline' + 'section' => 'billing', + 'description' => 'Enable emailing of credit card decline notices.', + 'type' => 'checkbox', + }, ); diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index f157f86f6..cb2aa4629 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -373,7 +373,7 @@ sub send { #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 ( [ @@ -571,8 +571,47 @@ sub realtime_card { } #} 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; } } @@ -905,7 +944,7 @@ sub print_text { =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 diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter index 365b96467..ee3c1fb92 100755 --- a/FS/bin/freeside-expiration-alerter +++ b/FS/bin/freeside-expiration-alerter @@ -142,7 +142,8 @@ foreach my $customer (@customers) ); $!=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}, @@ -166,8 +167,8 @@ if (scalar(@body)) { $!=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 @@ -199,7 +200,7 @@ user: From the mapsecrets file - see config.html from the base documentation =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 diff --git a/conf/declinetemplate b/conf/declinetemplate new file mode 100644 index 000000000..9a356ea0f --- /dev/null +++ b/conf/declinetemplate @@ -0,0 +1,10 @@ +Hi, + +Your credit card could not be processed for the following reason: + { $error } + +Please provide us with new billing infromation so that we may continue your +service uninterrupted. + +Thanks. + diff --git a/httemplate/docs/billing.html b/httemplate/docs/billing.html index c6ef7a869..c78a87f04 100644 --- a/httemplate/docs/billing.html +++ b/httemplate/docs/billing.html @@ -7,6 +7,8 @@ <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. |