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',
87 shortname => 'PayPal',
89 cust_main => '', #not yet a customer type, but could be once we can do
90 # invoice presentment via paypal
93 tinyname => 'prepaid card',
94 shortname => 'Prepaid card',
95 longname => 'Prepaid card',
96 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
100 shortname => 'Cash', # initial payment, then billing
102 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
105 tinyname => 'western union',
106 shortname => 'Western Union', # initial payment, then billing
107 longname => 'Western Union',
108 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
110 'MCRD' => { #not the same as DCRD
112 shortname => 'Manual credit card', # initial payment, then billing
113 longname => 'Manual credit card',
114 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
117 tinyname => 'apple store',
118 shortname => 'Apple Store',
119 longname => 'Apple Store',
120 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
123 tinyname => 'android market',
124 shortname => 'Android Market',
125 longname => 'Android Market',
126 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
130 shortname => 'Electronic Debit (EDI)',
131 longname => 'Electronic Debit (EDI)',
132 cust_main => '', #not a customer type
136 shortname => 'Wire transfer',
137 longname => 'Wire transfer',
138 cust_main => '', #not a customer type
142 shortname => 'Complimentary',
143 longname => 'Complimentary',
144 cust_pay => '', # (free) is depricated as a payment type in cust_pay
147 tinyname => 'chargeback',
148 shortname => 'Chargeback',
149 longname => 'Chargeback',
150 cust_main => '', # not a customer type
159 my( $self, $table, $payby ) = @_;
161 #return "Illegal payby" unless $hash{$payby};
162 return 0 unless $hash{$payby};
164 $table = 'cust_pay' if $table =~ /^cust_(pay_pending|pay_batch|pay_void|refund)$/;
165 return 0 if exists( $hash{$payby}->{$table} );
170 sub realtime { # can use realtime payment facilities
171 my( $self, $payby ) = @_;
173 return 0 unless $hash{$payby};
174 return 0 unless exists( $hash{$payby}->{realtime} );
176 return $hash{$payby}->{realtime};
179 sub payby2shortname {
181 map { $_ => $hash{$_}->{shortname} } $self->payby;
186 map { $_ => $hash{$_}->{longname} } $self->payby;
190 my( $self, $payby ) = @_;
191 $hash{$payby}->{shortname};
195 my( $self, $payby ) = @_;
196 #$hash{$payby}->{payname} || $hash{$payby}->{shortname};
197 exists($hash{$payby}->{payname})
198 ? $hash{$payby}->{payname}
199 : $hash{$payby}->{shortname};
203 my( $self, $payby ) = @_;
204 $hash{$payby}->{longname};
215 my( $self, $payby ) = @_;
216 $payby2bop{ $self->payby2payment($payby) };
220 my( $self, $payby ) = @_;
221 $hash{$payby}{'cust_pay'} || $payby;
226 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
229 sub cust_payby2longname {
231 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
238 This should eventually be an actual database table, and all tables that
239 currently have a char payby field should have a foreign key into here instead.