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)',
55 shortname => 'Credit card',
56 longname => 'Credit card (on-demand)',
57 cust_pay => 'CARD', #this is a customer type only, payments are CARD...
62 shortname => 'Electronic check',
63 longname => 'Electronic check (automatic)',
68 shortname => 'Electronic check',
69 longname => 'Electronic check (on-demand)',
70 cust_pay => 'CHEK', #this is a customer type only, payments are CHEK...
74 tinyname => 'phone bill',
75 shortname => 'Phone bill billing',
76 longname => 'Phone bill billing',
80 tinyname => 'billing',
81 shortname => 'Billing',
83 longname => 'Billing',
86 tinyname => 'prepaid card',
87 shortname => 'Prepaid card',
88 longname => 'Prepaid card',
89 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
93 shortname => 'Cash', # initial payment, then billing
95 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
98 tinyname => 'western union',
99 shortname => 'Western Union', # initial payment, then billing
100 longname => 'Western Union',
101 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
103 'MCRD' => { #not the same as DCRD
105 shortname => 'Manual credit card', # initial payment, then billing
106 longname => 'Manual credit card',
107 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
110 tinyname => 'apple store',
111 shortname => 'Apple Store',
112 longname => 'Apple Store',
113 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
116 tinyname => 'android market',
117 shortname => 'Android Market',
118 longname => 'Android Market',
119 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
123 shortname => 'Electronic Debit',
124 longname => 'Electronic Debit',
125 cust_main => '', #not a customer type
129 shortname => 'Complimentary',
130 longname => 'Complimentary',
131 cust_pay => '', # (free) is depricated as a payment type in cust_pay
134 tinyname => 'chargeback',
135 shortname => 'Chargeback',
136 longname => 'Chargeback',
137 cust_main => '', # not a customer type
146 my( $self, $table, $payby ) = @_;
148 #return "Illegal payby" unless $hash{$payby};
149 return 0 unless $hash{$payby};
151 $table = 'cust_pay' if $table =~ /^cust_(pay_pending|pay_batch|pay_void|refund)$/;
152 return 0 if exists( $hash{$payby}->{$table} );
157 sub realtime { # can use realtime payment facilities
158 my( $self, $payby ) = @_;
160 return 0 unless $hash{$payby};
161 return 0 unless exists( $hash{$payby}->{realtime} );
163 return $hash{$payby}->{realtime};
168 map { $_ => $hash{$_}->{longname} } $self->payby;
172 my( $self, $payby ) = @_;
173 $hash{$payby}->{shortname};
177 my( $self, $payby ) = @_;
178 #$hash{$payby}->{payname} || $hash{$payby}->{shortname};
179 exists($hash{$payby}->{payname})
180 ? $hash{$payby}->{payname}
181 : $hash{$payby}->{shortname};
185 my( $self, $payby ) = @_;
186 $hash{$payby}->{longname};
196 my( $self, $payby ) = @_;
197 $payby2bop{ $self->payby2payment($payby) };
201 my( $self, $payby ) = @_;
202 $hash{$payby}{'cust_pay'} || $payby;
207 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
210 sub cust_payby2longname {
212 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
219 This should eventually be an actual database table, and all tables that
220 currently have a char payby field should have a foreign key into here instead.