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 tie %hash, 'Tie::IxHash',
41 shortname => 'Credit card',
42 longname => 'Credit card (automatic)',
46 shortname => 'Credit card',
47 longname => 'Credit card (on-demand)',
48 cust_pay => 'CARD', #this is a customer type only, payments are CARD...
52 shortname => 'Electronic check',
53 longname => 'Electronic check (automatic)',
57 shortname => 'Electronic check',
58 longname => 'Electronic check (on-demand)',
59 cust_pay => 'CHEK', #this is a customer type only, payments are CHEK...
62 tinyname => 'phone bill',
63 shortname => 'Phone bill billing',
64 longname => 'Phone bill billing',
67 tinyname => 'billing',
68 shortname => 'Billing',
69 longname => 'Billing',
73 shortname => 'Cash', # initial payment, then billing
75 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
78 tinyname => 'western union',
79 shortname => 'Western Union', # initial payment, then billing
80 longname => 'Western Union',
81 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
83 'MCRD' => { #not the same as DCRD
85 shortname => 'Manual credit card', # initial payment, then billing
86 longname => 'Manual credit card',
87 cust_main => 'BILL', #this is a payment type only, customers go to BILL...
91 shortname => 'Complimentary',
92 longname => 'Complimentary',
94 'DCLN' => { # This is only an event.
95 tinyname => 'declined',
96 shortname => 'Declined payment',
97 longname => 'Declined payment',
107 map { $_ => $hash{$_}->{longname} } $self->payby;
117 grep { ! exists $hash{$_}->{cust_main} } $self->payby;
120 sub cust_payby2longname {
122 map { $_ => $hash{$_}->{longname} } $self->cust_payby;
126 my($payby, $payinforef) = @_;
128 if ($payby eq 'CARD') {
129 $$payinforef =~ s/\D//g;
131 $$payinforef =~ /^(\d{13,16})$/
132 or return "Illegal (mistyped?) credit card number (payinfo)";
134 validate($$payinforef) or return "Illegal credit card number";
135 return "Unknown card type" if cardype($$payinforef) eq "Unknown";
140 $$payinforef =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=]*)$/
141 or return "Illegal text (payinfo)";
151 This should eventually be an actual database table, and all tables that
152 currently have a char payby field should have a foreign key into here instead.