[freeside-commits] freeside/FS/FS banned_pay.pm, 1.3, 1.3.2.1 Schema.pm, 1.239.2.51, 1.239.2.52 cust_main.pm, 1.568.2.9, 1.568.2.10 Conf.pm, 1.397.2.58, 1.397.2.59
Ivan,,,
ivan at wavetail.420.am
Fri Jul 15 14:10:22 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv5187/FS/FS
Modified Files:
Tag: FREESIDE_2_1_BRANCH
banned_pay.pm Schema.pm cust_main.pm Conf.pm
Log Message:
add signup-duplicate_cc-warn_hours to warn about duplicate signups in a time span, RT#12011
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.239.2.51
retrieving revision 1.239.2.52
diff -u -w -d -r1.239.2.51 -r1.239.2.52
--- Schema.pm 12 Jul 2011 23:00:33 -0000 1.239.2.51
+++ Schema.pm 15 Jul 2011 21:10:19 -0000 1.239.2.52
@@ -2483,13 +2483,15 @@
'payinfo', 'varchar', '', 128, '', '', #say, a 512-big digest _hex encoded
#'paymask', 'varchar', 'NULL', $char_d, '', ''
'_date', @date_type, '', '',
+ 'end_date', @date_type, '', '',
'otaker', 'varchar', 'NULL', 32, '', '',
'usernum', 'int', 'NULL', '', '', '',
+ 'bantype', 'varchar', 'NULL', $char_d, '', '',
'reason', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'bannum',
- 'unique' => [ [ 'payby', 'payinfo' ] ],
- 'index' => [ [ 'usernum' ] ],
+ 'unique' => [],
+ 'index ' => [ [ 'payby', 'payinfo' ], [ 'usernum' ], ],
},
'pkg_category' => {
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.397.2.58
retrieving revision 1.397.2.59
diff -u -w -d -r1.397.2.58 -r1.397.2.59
--- Conf.pm 14 Jul 2011 22:22:07 -0000 1.397.2.58
+++ Conf.pm 15 Jul 2011 21:10:19 -0000 1.397.2.59
@@ -3881,11 +3881,18 @@
{
'key' => 'signup-recommend_daytime',
'section' => 'self-service',
- 'description' => 'Encourage the entry of a daytime phone number invoicing email address on signup.',
+ 'description' => 'Encourage the entry of a daytime phone number on signup.',
'type' => 'checkbox',
},
{
+ 'key' => 'signup-duplicate_cc-warn_hours',
+ 'section' => 'self-service',
+ 'description' => 'Issue a warning if the same credit card is used for multiple signups within this many hours.',
+ 'type' => 'text',
+ },
+
+ {
'key' => 'svc_phone-radius-default_password',
'section' => 'telephony',
'description' => 'Default password when exporting svc_phone records to RADIUS',
Index: banned_pay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/banned_pay.pm,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -w -d -r1.3 -r1.3.2.1
--- banned_pay.pm 24 Aug 2010 02:27:46 -0000 1.3
+++ banned_pay.pm 15 Jul 2011 21:10:19 -0000 1.3.2.1
@@ -2,6 +2,7 @@
use strict;
use base qw( FS::otaker_Mixin FS::Record );
+use Digest::MD5 qw(md5_base64);
use FS::Record qw( qsearch qsearchs );
use FS::UID qw( getotaker );
use FS::CurrentUser;
@@ -42,8 +43,12 @@
=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
L<Time::Local> and L<Date::Parse> for conversion functions.
+=item end_date - optional end date, also specified as a UNIX timestamp.
+
=item usernum - order taker (assigned automatically, see L<FS::access_user>)
+=item bantype - Ban type: "" or null (regular ban), "warn" (warning)
+
=item reason - reason (text)
=back
@@ -110,6 +115,8 @@
|| $self->ut_enum('payby', [ 'CARD', 'CHEK' ] )
|| $self->ut_text('payinfo')
|| $self->ut_numbern('_date')
+ || $self->ut_numbern('end_date')
+ || $self->ut_enum('bantype', [ '', 'warn' ] )
|| $self->ut_textn('reason')
;
return $error if $error;
@@ -121,6 +128,31 @@
$self->SUPER::check;
}
+=back
+
+=head1 CLASS METHODS
+
+=item ban_search OPTION => VALUE ...
+
+Takes two parameters: payby and payinfo, and searches for an (un-expired) ban
+matching those items.
+
+Returns the ban, or false if no ban was found.
+
+=cut
+
+sub ban_search {
+ my( $class, %opt ) = @_;
+ qsearchs({
+ 'table' => 'banned_pay',
+ 'hashref' => {
+ 'payby' => $opt{payby},
+ 'payinfo' => md5_base64($opt{payinfo}),
+ },
+ 'extra_sql' => 'AND end_date IS NULL OR end_date >= '. time,
+ });
+}
+
# Used by FS::Upgrade to migrate to a new database.
sub _upgrade_data { # class method
my ($class, %opts) = @_;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.568.2.9
retrieving revision 1.568.2.10
diff -u -w -d -r1.568.2.9 -r1.568.2.10
--- cust_main.pm 23 Jun 2011 04:08:50 -0000 1.568.2.9
+++ cust_main.pm 15 Jul 2011 21:10:19 -0000 1.568.2.10
@@ -743,7 +743,7 @@
$prepay_credit = qsearchs(
'prepay_credit',
- { 'identifier' => $prepay_credit },
+ { 'identifier' => $identifier },
'',
'FOR UPDATE'
);
@@ -1831,14 +1831,19 @@
&& cardtype($self->payinfo) eq "Unknown";
unless ( $ignore_banned_card ) {
- my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
+ my $ban = FS::banned_pay->ban_search( %{ $self->_banned_pay_hashref } );
if ( $ban ) {
+ if ( $ban->bantype eq 'warn' ) {
+ #or others depending on value of $ban->reason ?
+ return '_duplicate_card' unless $self->override_ban_warn;
+ } else {
return 'Banned credit card: banned on '.
time2str('%a %h %o at %r', $ban->_date).
' by '. $ban->otaker.
' (ban# '. $ban->bannum. ')';
}
}
+ }
if (length($self->paycvv) && !$self->is_encrypted($self->paycvv)) {
if ( cardtype($self->payinfo) eq 'American Express card' ) {
@@ -1897,14 +1902,19 @@
$self->paycvv('');
unless ( $ignore_banned_card ) {
- my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
+ my $ban = FS::banned_pay->ban_search( %{ $self->_banned_pay_hashref } );
if ( $ban ) {
+ if ( $ban->bantype eq 'warn' ) {
+ #or others depending on value of $ban->reason ?
+ return '_duplicate_ach' unless $self->override_ban_warn;
+ } else {
return 'Banned ACH account: banned on '.
time2str('%a %h %o at %r', $ban->_date).
' by '. $ban->otaker.
' (ban# '. $ban->bannum. ')';
}
}
+ }
} elsif ( $self->payby eq 'LECB' ) {
@@ -2170,7 +2180,7 @@
return ( "Can't (yet) ban encrypted credit cards" )
if $self->is_encrypted($self->payinfo);
- my $ban = new FS::banned_pay $self->_banned_pay_hashref;
+ my $ban = new FS::banned_pay $self->_new_banned_pay_hashref;
my $error = $ban->insert;
return ( $error ) if $error;
@@ -2204,11 +2214,18 @@
{
'payby' => $payby2ban{$self->payby},
- 'payinfo' => md5_base64($self->payinfo),
+ 'payinfo' => $self->payinfo,
#don't ever *search* on reason! #'reason' =>
};
}
+sub _new_banned_pay_hashref {
+ my $self = shift;
+ my $hr = $self->_banned_pay_hashref;
+ $hr->{payinfo} = md5_base64($hr->{payinfo});
+ $hr;
+}
+
=item notes
Returns all notes (see L<FS::cust_main_note>) for this customer.
More information about the freeside-commits
mailing list