4 use vars qw(%hash %payby2bop);
6 use Business::CreditCard;
11 FS::payby - Object methods for payment type records
19 my @payby = FS::payby->payby;
21 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname
23 my @cust_payby = FS::payby->cust_payby;
25 tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname
39 # paybys can be any/all of:
40 # - a customer payment type (cust_main.payby)
41 # - a payment or refund type (cust_pay.payby)
42 # - an event type (part_bill_event.payby)
44 tie %hash, 'Tie::IxHash',
47 shortname => 'Credit card',
48 longname => 'Credit card (automatic)',
52 shortname => 'Credit card',
53 longname => 'Credit card (on-demand)',
54 cust_pay => 'CARD', #this is a customer type only, payments are CARD...
58 shortname => 'Electronic check',
59 longname => 'Electronic check (automatic)',
63 shortname => 'Electronic check',
64 longname => 'Electronic check (on-demand)',
65 cust_pay => 'CHEK', #this is a customer type only, payments are CHEK...
68 tinyname => 'phone bill',
69 shortname => 'Phone bill billing',
70 longname => 'Phone bill billing',
73 tinyname => 'billing',
74 shortname => 'Billing',
75 longname => 'Billing',
79 shortname => 'Cash', # initial payment, then billing
81 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
84 tinyname => 'western union',
85 shortname => 'Western Union', # initial payment, then billing
86 longname => 'Western Union',
87 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
89 'MCRD' => { #not the same as DCRD
91 shortname => 'Manual credit card', # initial payment, then billing
92 longname => 'Manual credit card',
93 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
97 shortname => 'Complimentary',
98 longname => 'Complimentary',
100 'DCLN' => { # This is only an event.
101 tinyname => 'declined',
102 shortname => 'Batch declined payment',
103 longname => 'Batch declined payment',
105 #its neither of these..
118 map { $_ => $hash{$_}->{longname} } $self->payby;
122 my( $self, $payby ) = @_;
123 $hash{$payby}->{shortname};
127 my( $self, $payby ) = @_;
128 $hash{$payby}->{longname};
137 my( $self, $payby ) = @_;
138 $payby2bop{ $self->payby2payment($payby) };
142 my( $self, $payby ) = @_;
143 $hash{$payby}{'cust_pay'} || $payby;
148 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
151 sub cust_payby2longname {
153 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
157 my($payby, $payinforef) = @_;
159 if ($payby eq 'CARD') {
160 $$payinforef =~ s/\D//g;
162 $$payinforef =~ /^(\d{13,16})$/
163 or return "Illegal (mistyped?) credit card number (payinfo)";
165 validate($$payinforef) or return "Illegal credit card number";
166 return "Unknown card type" if cardtype($$payinforef) eq "Unknown";
171 $$payinforef =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
172 or return "Illegal text (payinfo)";
182 This should eventually be an actual database table, and all tables that
183 currently have a char payby field should have a foreign key into here instead.