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...
111 shortname => 'Complimentary',
112 longname => 'Complimentary',
113 cust_pay => '', # (free) is depricated as a payment type in cust_pay
116 tinyname => 'chargeback',
117 shortname => 'Chargeback',
118 longname => 'Chargeback',
119 cust_main => '', # not a customer type
128 my( $self, $table, $payby ) = @_;
130 #return "Illegal payby" unless $hash{$payby};
131 return 0 unless $hash{$payby};
133 $table = 'cust_pay' if $table =~ /^cust_(pay_pending|pay_batch|pay_void|refund)$/;
134 return 0 if exists( $hash{$payby}->{$table} );
139 sub realtime { # can use realtime payment facilities
140 my( $self, $payby ) = @_;
142 return 0 unless $hash{$payby};
143 return 0 unless exists( $hash{$payby}->{realtime} );
145 return $hash{$payby}->{realtime};
150 map { $_ => $hash{$_}->{longname} } $self->payby;
154 my( $self, $payby ) = @_;
155 $hash{$payby}->{shortname};
159 my( $self, $payby ) = @_;
160 #$hash{$payby}->{payname} || $hash{$payby}->{shortname};
161 exists($hash{$payby}->{payname})
162 ? $hash{$payby}->{payname}
163 : $hash{$payby}->{shortname};
167 my( $self, $payby ) = @_;
168 $hash{$payby}->{longname};
178 my( $self, $payby ) = @_;
179 $payby2bop{ $self->payby2payment($payby) };
183 my( $self, $payby ) = @_;
184 $hash{$payby}{'cust_pay'} || $payby;
189 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
192 sub cust_payby2longname {
194 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
201 This should eventually be an actual database table, and all tables that
202 currently have a char payby field should have a foreign key into here instead.