1 package FS::cust_pay_batch;
6 #use FS::UID qw(getotaker);
7 use FS::Record qw(hfields qsearch qsearchs);
8 use Business::CreditCard;
10 @ISA = qw(FS::Record);
14 FS::cust_pay_batdh - Object methods for batch cards
18 use FS::cust_pay_batch;
20 $record = create FS::cust_pay_batch \%hash;
21 $record = create FS::cust_pay_batch { 'column' => 'value' };
23 $error = $record->insert;
25 $error = $new_record->replace($old_record);
27 $error = $record->delete;
29 $error = $record->check;
33 An FS::cust_pay_batch object represents a credit card transaction ready to be
34 batched (sent to a processor). FS::cust_pay_batch inherits from FS::Record.
35 Typically called by the collect method of an FS::cust_main object. The
36 following fields are currently supported:
40 =item trancode - 77 for charges
44 =item exp - card expiration
48 =item invnum - invoice
50 =item custnum - customer
52 =item payname - name on card
78 Creates a new record. To add the record to the database, see L<"insert">.
80 Note that this stores the hash reference, not a distinct copy of the hash it
81 points to. You can ask the object for a copy with the I<hash> method.
86 my($proto,$hashref)=@_;
88 $proto->new('cust_pay_batch',$hashref);
94 Adds this record to the database. If there is an error, returns the error,
95 otherwise returns false.
102 #local $SIG{HUP} = 'IGNORE';
103 #local $SIG{INT} = 'IGNORE';
104 #local $SIG{QUIT} = 'IGNORE';
105 #local $SIG{TERM} = 'IGNORE';
106 #local $SIG{TSTP} = 'IGNORE';
116 #Delete this record from the database.
125 return "Can't (yet?) delete batched transactions!";
128 =item replace OLD_RECORD
132 #Replaces the OLD_RECORD with this one in the database. If there is an error,
133 #returns the error, otherwise returns false.
139 #return "(Old) Not a table_name record!" unless $old->table eq "table_name";
141 #return "Can't change keyfield!"
142 # unless $old->getfield('keyfield') eq $new->getfield('keyfield');
147 return "Can't (yet?) replace batched transactions!";
152 Checks all fields to make sure this is a valid example. If there is
153 an error, returns the error, otherwise returns false. Called by the insert
160 return "Not a cust_pay_batch record!" unless $self->table eq "cust_pay_batch";
163 $self->ut_numbern('trancode')
164 or $self->ut_number('cardnum')
165 or $self->ut_money('amount')
166 or $self->ut_number('invnum')
167 or $self->ut_number('custnum')
168 or $self->ut_text('address1')
169 or $self->ut_textn('address2')
170 or $self->ut_text('city')
171 or $self->ut_text('state')
174 return $error if $error;
176 $self->getfield('last') =~ /^([\w \,\.\-\']+)$/ or return "Illegal last name";
177 $self->setfield('last',$1);
179 $self->first =~ /^([\w \,\.\-\']+)$/ or return "Illegal first name";
182 my $cardnum = $self->cardnum;
184 $cardnum =~ /^(\d{13,16})$/
185 or return "Illegal credit card number";
187 $self->cardnum($cardnum);
188 validate($cardnum) or return "Illegal credit card number";
189 my $type = cardtype($cardnum);
190 return "Unknown credit card type"
191 unless ( $type =~ /^VISA/ ||
192 $type =~ /^MasterCard/ ||
193 $type =~ /^American Express/ ||
194 $type =~ /^Discover/ );
196 if ( $self->exp eq '' ) {
197 return "Expriation date required";
200 $self->exp =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/
201 or return "Illegal expiration date";
202 if ( length($2) == 4 ) {
203 $self->exp("$2-$1-01");
204 } elsif ( $2 > 98 ) { #should pry change to check for "this year"
205 $self->exp("19$2-$1-01");
207 $self->exp("20$2-$1-01");
211 if ( $self->payname eq '' ) {
212 $self->payname( $self->first. " ". $self->getfield('last') );
214 $self->payname =~ /^([\w \,\.\-\']+)$/
215 or return "Illegal billing name";
220 $self->zip =~ /^(\d{5}(-\d{4})?)$/ or return "Illegal zip";
224 $self->country =~ /^(US)$/ or return "Illegal country";
227 #check invnum, custnum, ?
236 $Id: cust_pay_batch.pm,v 1.1 1998-11-15 05:19:58 ivan Exp $
240 The author forgot to customize this manpage.
244 L<FS::cust_main>, L<FS::Record>
248 ivan@voicenet.com 97-jul-1
251 ivan@sisd.com 97-nov-13
253 $Log: cust_pay_batch.pm,v $
254 Revision 1.1 1998-11-15 05:19:58 ivan
257 Revision 1.3 1998/11/15 04:33:00 ivan
258 updates for newest versoin
260 Revision 1.2 1998/11/15 03:48:49 ivan
261 update for current version