summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2009-03-15 07:33:06 +0000
committerivan <ivan>2009-03-15 07:33:06 +0000
commit5cf0508a1ec3dafaeef8a4bd206ef5e5b51235c8 (patch)
treef818e8226cdabdaa1886e90c02fba520d4f8b77a /FS
parentdae7ad7ff2a06ae047de9fd6d88e74edc526b4ad (diff)
cust_main::payment_info, for ClientAPI::MyAccount
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main.pm80
1 files changed, 80 insertions, 0 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 2bad5ec3e..69126956a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -6032,6 +6032,86 @@ sub in_transit_payments {
sprintf( "%.2f", $in_transit_payments );
}
+=item payment_info
+
+Returns a hash of useful information for making a payment.
+
+=over 4
+
+=item balance
+
+Current balance.
+
+=item payby
+
+'CARD' (credit card - automatic), 'DCRD' (credit card - on-demand),
+'CHEK' (electronic check - automatic), 'DCHK' (electronic check - on-demand),
+'LECB' (Phone bill billing), 'BILL' (billing), or 'COMP' (free).
+
+=back
+
+For credit card transactions:
+
+=over 4
+
+=item card_type 1
+
+=item payname
+
+Exact name on card
+
+=back
+
+For electronic check transactions:
+
+=over 4
+
+=item stateid_state
+
+=back
+
+=cut
+
+sub payment_info {
+ my $self = shift;
+
+ my %return = ();
+
+ $return{balance} = $self->balance;
+
+ $return{payname} = $self->payname
+ || ( $self->first. ' '. $self->get('last') );
+
+ $return{$_} = $self->get($_) for qw(address1 address2 city state zip);
+
+ $return{payby} = $self->payby;
+ $return{stateid_state} = $self->stateid_state;
+
+ if ( $self->payby =~ /^(CARD|DCRD)$/ ) {
+ $return{card_type} = cardtype($self->payinfo);
+ $return{payinfo} = $self->paymask;
+
+ @return{'month', 'year'} = $self->paydate_monthyear;
+
+ }
+
+ if ( $self->payby =~ /^(CHEK|DCHK)$/ ) {
+ my ($payinfo1, $payinfo2) = split '@', $self->paymask;
+ $return{payinfo1} = $payinfo1;
+ $return{payinfo2} = $payinfo2;
+ $return{paytype} = $self->paytype;
+ $return{paystate} = $self->paystate;
+
+ }
+
+ #doubleclick protection
+ my $_date = time;
+ $return{paybatch} = "webui-MyAccount-$_date-$$-". rand() * 2**32;
+
+ %return;
+
+}
+
=item paydate_monthyear
Returns a two-element list consisting of the month and year of this customer's