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 my $bool = FS::payby->can_payby('cust_main', 'CARD');
23 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname
25 my @cust_payby = FS::payby->cust_payby;
27 tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname
41 # paybys can be any/all of:
42 # - a customer payment type (cust_main.payby)
43 # - a payment or refund type (cust_pay.payby, cust_pay_batch.payby, cust_refund.payby)
44 # - an event type (part_bill_event.payby)
46 tie %hash, 'Tie::IxHash',
49 shortname => 'Credit card',
50 longname => 'Credit card (automatic)',
54 shortname => 'Credit card',
55 longname => 'Credit card (on-demand)',
56 cust_pay => 'CARD', #this is a customer type only, payments are CARD...
60 shortname => 'Electronic check',
61 longname => 'Electronic check (automatic)',
65 shortname => 'Electronic check',
66 longname => 'Electronic check (on-demand)',
67 cust_pay => 'CHEK', #this is a customer type only, payments are CHEK...
70 tinyname => 'phone bill',
71 shortname => 'Phone bill billing',
72 longname => 'Phone bill billing',
75 tinyname => 'billing',
76 shortname => 'Billing',
77 longname => 'Billing',
81 shortname => 'Cash', # initial payment, then billing
83 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
86 tinyname => 'western union',
87 shortname => 'Western Union', # initial payment, then billing
88 longname => 'Western Union',
89 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
91 'MCRD' => { #not the same as DCRD
93 shortname => 'Manual credit card', # initial payment, then billing
94 longname => 'Manual credit card',
95 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
99 shortname => 'Complimentary',
100 longname => 'Complimentary',
101 cust_pay => '', # (free) is depricated as a payment type in cust_pay
104 tinyname => 'chargeback',
105 shortname => 'Chargeback',
106 longname => 'Chargeback',
107 cust_main => '', # not a customer type
109 'DCLN' => { # This is only an event.
110 tinyname => 'declined',
111 shortname => 'Batch declined payment',
112 longname => 'Batch declined payment',
114 #its neither of these..
126 my( $self, $table, $payby ) = @_;
128 #return "Illegal payby" unless $hash{$payby};
129 return 0 unless $hash{$payby};
131 $table = 'cust_pay' if $table eq 'cust_pay_batch' || $table eq 'cust_refund';
132 return 0 if exists( $hash{$payby}->{$table} );
139 map { $_ => $hash{$_}->{longname} } $self->payby;
143 my( $self, $payby ) = @_;
144 $hash{$payby}->{shortname};
148 my( $self, $payby ) = @_;
149 $hash{$payby}->{longname};
158 my( $self, $payby ) = @_;
159 $payby2bop{ $self->payby2payment($payby) };
163 my( $self, $payby ) = @_;
164 $hash{$payby}{'cust_pay'} || $payby;
169 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
172 sub cust_payby2longname {
174 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
181 This should eventually be an actual database table, and all tables that
182 currently have a char payby field should have a foreign key into here instead.