4 use vars qw(%hash %payby2bop);
10 FS::payby - Object methods for payment type records
18 my @payby = FS::payby->payby;
20 tie my %payby, 'Tie::IxHash', FS::payby->payby2longname
22 my @cust_payby = FS::payby->cust_payby;
24 tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname
38 # paybys can be any/all of:
39 # - a customer payment type (cust_main.payby)
40 # - a payment or refund type (cust_pay.payby)
41 # - an event type (part_bill_event.payby)
43 tie %hash, 'Tie::IxHash',
46 shortname => 'Credit card',
47 longname => 'Credit card (automatic)',
51 shortname => 'Credit card',
52 longname => 'Credit card (on-demand)',
53 cust_pay => 'CARD', #this is a customer type only, payments are CARD...
57 shortname => 'Electronic check',
58 longname => 'Electronic check (automatic)',
62 shortname => 'Electronic check',
63 longname => 'Electronic check (on-demand)',
64 cust_pay => 'CHEK', #this is a customer type only, payments are CHEK...
67 tinyname => 'phone bill',
68 shortname => 'Phone bill billing',
69 longname => 'Phone bill billing',
72 tinyname => 'billing',
73 shortname => 'Billing',
74 longname => 'Billing',
78 shortname => 'Cash', # initial payment, then billing
80 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
83 tinyname => 'western union',
84 shortname => 'Western Union', # initial payment, then billing
85 longname => 'Western Union',
86 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
88 'MCRD' => { #not the same as DCRD
90 shortname => 'Manual credit card', # initial payment, then billing
91 longname => 'Manual credit card',
92 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
96 shortname => 'Complimentary',
97 longname => 'Complimentary',
99 'DCLN' => { # This is only an event.
100 tinyname => 'declined',
101 shortname => 'Declined payment',
102 longname => 'Declined payment',
104 #its neither of these..
117 map { $_ => $hash{$_}->{longname} } $self->payby;
127 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
130 sub cust_payby2longname {
132 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
136 my($payby, $payinforef) = @_;
138 if ($payby eq 'CARD') {
139 $$payinforef =~ s/\D//g;
141 $$payinforef =~ /^(\d{13,16})$/
142 or return "Illegal (mistyped?) credit card number (payinfo)";
144 validate($$payinforef) or return "Illegal credit card number";
145 return "Unknown card type" if cardype($$payinforef) eq "Unknown";
150 $$payinforef =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
151 or return "Illegal text (payinfo)";
161 This should eventually be an actual database table, and all tables that
162 currently have a char payby field should have a foreign key into here instead.