diff options
author | steve <steve> | 2002-12-14 11:13:54 +0000 |
---|---|---|
committer | steve <steve> | 2002-12-14 11:13:54 +0000 |
commit | 8696d75137d1cbdcf40bf66af0438f45f20f1d1a (patch) | |
tree | a2e856406bfdbb7b86379154b3497ddb89cdfaaa | |
parent | 67a97182cbc7a33b6a39cb1ea4e8def95f61c8af (diff) |
add quiet signup and selfservice, and cancel emails to user.
-rw-r--r-- | FS/FS/Conf.pm | 37 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 39 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 46 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 45 |
4 files changed, 109 insertions, 58 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e805c8ee7..be5d4ec7d 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -815,7 +815,7 @@ httemplate/docs/config.html { 'key' => 'username_policy', - 'section' => 'deprecated', + 'section' => '', 'description' => 'This file controls the mechanism for preventing duplicate usernames in passwd/radius files exported from svc_accts. This should be one of \'prepend domsvc\' \'append domsvc\' \'append domain\' or \'append @domain\'', 'type' => 'select', 'select_enum' => [ 'prepend domsvc', 'append domsvc', 'append domain', 'append @domain' ], @@ -894,6 +894,20 @@ httemplate/docs/config.html }, { + 'key' => 'selfservice_server-quiet', + 'section' => '', + 'description' => 'Disable decline and cancel emails generated by transactions initiated by the selfservice server. Not recommended, unless the customer will get instant feedback from a customer service UI, and receiving an email would be confusing/overkill.', + 'type' => 'checkbox', + }, + + { + 'key' => 'signup_server-quiet', + 'section' => '', + 'description' => 'Disable decline and cancel emails generated by transactions initiated by the signup server. Not recommended, unless the customer will get instant feedback from a customer service UI, and receiving an email would be confusing/overkill. Does not disable welcome emails.', + 'type' => 'checkbox', + }, + + { 'key' => 'signup_server-payby', 'section' => '', 'description' => 'Acceptable payment types for the signup server', @@ -938,6 +952,27 @@ httemplate/docs/config.html }, { + 'key' => 'cancelmessage', + 'section' => 'billing', + 'description' => 'Template file for cancellation emails.', + 'type' => 'textarea', + }, + + { + 'key' => 'cancelsubject', + 'section' => 'billing', + 'description' => 'Subject line for cancellation emails.', + 'type' => 'text', + }, + + { + 'key' => 'emailcancel', + 'section' => 'billing', + 'description' => 'Enable emailing of cancellation notices.', + 'type' => 'checkbox', + }, + + { 'key' => 'require_cardname', 'section' => 'billing', 'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index bff33afd5..01d0f1790 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -656,28 +656,6 @@ sub realtime_ach { ); } -=item realtime_lec - -Attempts to pay this invoice with phone bill (LEC) payment via a -Business::OnlinePayment realtime gateway. See -http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment -for supported processors. - -=cut - -sub realtime_lec { - my $self = shift; - $self->realtime_bop( - 'LEC', - $bop_processor, - $bop_login, - $bop_password, - $bop_action, - \@bop_options, - @_ - ); -} - sub realtime_bop { my( $self, $method, $processor, $login, $password, $action, $options ) = @_; my $cust_main = $self->cust_main; @@ -736,13 +714,12 @@ sub realtime_bop { ( $content{account_number}, $content{routing_code} ) = split('@', $cust_main->payinfo); $content{bank_name} = $cust_main->payname; - } elsif ( $method eq 'LEC' ) { - $content{phone} = $cust_main->payinfo; } my $transaction = new Business::OnlinePayment( $processor, @$options ); $transaction->content( + %content, 'type' => $method, 'login' => $login, 'password' => $password, @@ -762,7 +739,6 @@ sub realtime_bop { 'referer' => 'http://cleanwhisker.420.am/', 'email' => $email, 'phone' => $cust_main->daytime || $cust_main->night, - %content, #after ); $transaction->submit(); @@ -814,7 +790,6 @@ sub realtime_bop { my %method2payby = ( 'CC' => 'CARD', 'ECHECK' => 'CHEK', - 'LEC' => 'LECB', ); my $cust_pay = new FS::cust_pay ( { @@ -842,9 +817,11 @@ sub realtime_bop { my $perror = "$processor error, invnum #". $self->invnum. ': '. $transaction->result_code. ": ". $transaction->error_message; - if ( $conf->exists('emaildecline') + if ( !($ENV{SIGNUP_SERVER} && $conf->exists('signup_server-quiet')) + && !($ENV{SELFSERVICE_SERVER} && $conf->exists('selfservice_server-quiet')) + && $conf->exists('emaildecline') && grep { $_ ne 'POST' } $cust_main->invoicing_list - ) { + ) { my @templ = $conf->config('declinetemplate'); my $template = new Text::Template ( TYPE => 'ARRAY', @@ -1184,14 +1161,16 @@ sub print_text { # ); #and subroutine for the template + sub FS::cust_bill::_template::invoice_lines { - my $lines = shift || scalar(@buf); + my $lines = shift or return @buf; map { scalar(@buf) ? shift @buf : [ '', '' ]; } ( 1 .. $lines ); } + #and fill it in $FS::cust_bill::_template::page = 1; my $lines; @@ -1211,7 +1190,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.41.2.13 2002-12-04 12:31:50 ivan Exp $ +$Id: cust_bill.pm,v 1.41.2.14 2002-12-14 11:13:53 steve Exp $ =head1 BUGS diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index fdb06200a..9ee243789 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -158,7 +158,7 @@ FS::Record. The following fields are currently supported: =item ship_fax - phone (optional) -=item payby - `CARD' (credit cards), `CHEK' (electronic check), `LECB' (Phone bill billing), `BILL' (billing), `COMP' (free), or `PREPAY' (special billing type: applies a credit - see L<FS::prepay_credit> and sets billing type to BILL) +=item payby - `CARD' (credit cards), `CHEK' (electronic check), `BILL' (billing), `COMP' (free), or `PREPAY' (special billing type: applies a credit - see L<FS::prepay_credit> and sets billing type to BILL) =item payinfo - card number, P.O., comp issuer (4-8 lowercase alphanumerics; think username) or prepayment identifier (see L<FS::prepay_credit>) @@ -482,15 +482,14 @@ sub replace { $self->invoicing_list( $invoicing_list ); } - if ( $self->payby =~ /^(CARD|CHEK|LECB)$/ && + if ( $self->payby =~ /^(CARD|CHEK)$/ && grep { $self->get($_) ne $old->get($_) } qw(payinfo paydate payname) ) { # card info has changed, want to retry realtime_card invoice events #false laziness w/collect foreach my $cust_bill_event ( grep { #$_->part_bill_event->plan eq 'realtime-card' - $_->part_bill_event->eventcode =~ - /^\$cust_bill\->realtime_(card|ach|lec)\(\);$/ + $_->part_bill_event->eventcode eq '$cust_bill->realtime_card();' && $_->status eq 'done' && $_->statustext } @@ -665,14 +664,14 @@ sub check { } } - $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREPAY)$/ + $self->payby =~ /^(CARD|CHEK|BILL|COMP|PREPAY)$/ or return "Illegal payby: ". $self->payby; $self->payby($1); if ( $self->payby eq 'CARD' ) { my $payinfo = $self->payinfo; - $payinfo =~ s/\D//g; + $payinfo =~ s/[^\d\@]//g; $payinfo =~ /^(\d{13,16})$/ or return gettext('invalid_card'); # . ": ". $self->payinfo; $payinfo = $1; @@ -685,19 +684,11 @@ sub check { } elsif ( $self->payby eq 'CHEK' ) { my $payinfo = $self->payinfo; - $payinfo =~ s/[^\d\@]//g; + #$payinfo =~ s/[\D\@]//g; $payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba'; $payinfo = "$1\@$2"; $self->payinfo($payinfo); - } elsif ( $self->payby eq 'LECB' ) { - - my $payinfo = $self->payinfo; - $payinfo =~ s/\D//g; - $payinfo =~ /^1?(\d{10})$/ or return 'invalid btn billing telephone number'; - $payinfo = $1; - $self->payinfo($payinfo); - } elsif ( $self->payby eq 'BILL' ) { $error = $self->ut_textn('payinfo'); @@ -722,7 +713,7 @@ sub check { if ( $self->paydate eq '' || $self->paydate eq '-' ) { return "Expriation date required" - unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB)$/; + unless $self->payby =~ /^(BILL|PREPAY|CHEK)$/; $self->paydate(''); } else { $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ @@ -1054,25 +1045,26 @@ sub bill { || $self->payby eq 'COMP' || $taxable_charged == 0 ) { - my $cust_main_county = qsearchs('cust_main_county',{ + my $cust_main_county = + qsearchs('cust_main_county',{ 'state' => $self->state, 'county' => $self->county, 'country' => $self->country, 'taxclass' => $part_pkg->taxclass, - } ); - $cust_main_county ||= qsearchs('cust_main_county',{ + } ) + or qsearchs('cust_main_county',{ 'state' => $self->state, 'county' => $self->county, 'country' => $self->country, 'taxclass' => '', - } ); - unless ( $cust_main_county ) { - $dbh->rollback if $oldAutoCommit; - return - "fatal: can't find tax rate for state/county/country/taxclass ". - join('/', ( map $self->$_(), qw(state county country) ), - $part_pkg->taxclass ). "\n"; - } + } ) + or do { + $dbh->rollback if $oldAutoCommit; + return + "fatal: can't find tax rate for state/county/country/taxclass ". + join('/', ( map $self->$_(), qw(state county country) ), + $part_pkg->taxclass ). "\n"; + }; if ( $cust_main_county->exempt_amount ) { my ($mon,$year) = (localtime($sdate) )[4,5]; diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 24b96c6e3..7a248256a 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -20,6 +20,13 @@ use FS::svc_domain; use FS::svc_www; use FS::svc_forward; +# need all this for sending cancel emails in sub cancel + +use FS::Conf; +use Date::Format; +use Mail::Internet 1.44; +use Mail::Header; + @ISA = qw( FS::Record ); sub _cache { @@ -291,7 +298,45 @@ sub cancel { $dbh->commit or die $dbh->errstr if $oldAutoCommit; + my $conf = new FS::Conf; + + if ( !($ENV{SIGNUP_SERVER} && $conf->exists('signup_server-quiet')) + && !($ENV{SELFSERVICE_SERVER} && $conf->exists('selfservice_server-quiet')) + && $conf->exists('emailcancel') + && grep { $_ ne 'POST' } $self->cust_main->invoicing_list) { + + my @invoicing_list = $self->cust_main->invoicing_list; + + my $invoice_from = $conf->config('invoice_from'); + my @print_text = map "$_\n", $conf->config('cancelmessage'); + my $subject = $conf->config('cancelsubject'); + my $smtpmachine = $conf->config('smtpmachine'); + + if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice + #false laziness w/FS::cust_pay::delete & fs_signup_server && ::realtime_card + #$ENV{SMTPHOSTS} = $smtpmachine; + $ENV{MAILADDRESS} = $invoice_from; + my $header = new Mail::Header ( [ + "From: $invoice_from", + "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ), + "Sender: $invoice_from", + "Reply-To: $invoice_from", + "Date: ". time2str("%a, %d %b %Y %X %z", time), + "Subject: $subject", + ] ); + my $message = new Mail::Internet ( + 'Header' => $header, + 'Body' => [ @print_text ], + ); + $!=0; + $message->smtpsend( Host => $smtpmachine ) + or $message->smtpsend( Host => $smtpmachine, Debug => 1 ); + #should this return an error? + } + } + ''; #no errors + } =item suspend |