1 package FS::banned_pay;
4 use base qw( FS::otaker_Mixin FS::Record );
5 use Digest::MD5 qw(md5_base64);
6 use FS::Record qw( qsearch qsearchs );
7 use FS::UID qw( getotaker );
12 FS::banned_pay - Object methods for banned_pay records
18 $record = new FS::banned_pay \%hash;
19 $record = new FS::banned_pay { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
31 An FS::banned_pay object represents an banned credit card or ACH account.
32 FS::banned_pay inherits from FS::Record. The following fields are currently
37 =item bannum - primary key
39 =item payby - I<CARD> or I<CHEK>
41 =item payinfo - fingerprint of banned card (base64-encoded MD5 digest)
43 =item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
44 L<Time::Local> and L<Date::Parse> for conversion functions.
46 =item end_date - optional end date, also specified as a UNIX timestamp.
48 =item usernum - order taker (assigned automatically, see L<FS::access_user>)
50 =item bantype - Ban type: "" or null (regular ban), "warn" (warning)
52 =item reason - reason (text)
62 Creates a new ban. To add the ban to the database, see L<"insert">.
64 Note that this stores the hash reference, not a distinct copy of the hash it
65 points to. You can ask the object for a copy with the I<hash> method.
69 # the new method can be inherited from FS::Record, if a table method is defined
71 sub table { 'banned_pay'; }
75 Adds this record to the database. If there is an error, returns the error,
76 otherwise returns false.
80 # the insert method can be inherited from FS::Record
84 Delete this record from the database.
88 # the delete method can be inherited from FS::Record
90 =item replace OLD_RECORD
92 Replaces the OLD_RECORD with this one in the database. If there is an error,
93 returns the error, otherwise returns false.
97 # the replace method can be inherited from FS::Record
101 Checks all fields to make sure this is a valid ban. If there is
102 an error, returns the error, otherwise returns false. Called by the insert
107 # the check method should currently be supplied - FS::Record contains some
108 # data checking routines
114 $self->ut_numbern('bannum')
115 || $self->ut_enum('payby', [ 'CARD', 'CHEK' ] )
116 || $self->ut_text('payinfo')
117 || $self->ut_numbern('_date')
118 || $self->ut_numbern('end_date')
119 || $self->ut_enum('bantype', [ '', 'warn' ] )
120 || $self->ut_textn('reason')
122 return $error if $error;
124 $self->_date(time) unless $self->_date;
126 $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum;
135 =item ban_search OPTION => VALUE ...
137 Takes two parameters: payby and payinfo, and searches for an (un-expired) ban
138 matching those items.
140 Returns the ban, or false if no ban was found.
145 my( $class, %opt ) = @_;
147 'table' => 'banned_pay',
149 'payby' => $opt{payby},
150 'payinfo' => md5_base64($opt{payinfo}),
152 'extra_sql' => 'AND ( end_date IS NULL OR end_date >= '. time. ' ) ',
156 # Used by FS::Upgrade to migrate to a new database.
157 sub _upgrade_data { # class method
158 my ($class, %opts) = @_;
159 $class->_upgrade_otaker(%opts);
168 L<FS::Record>, schema.html from the base documentation.