suspend event option to skip packages with a start_date, RT#83847
[freeside.git] / FS / FS / part_event / Action / realtime_auto.pm
1 package FS::part_event::Action::realtime_auto;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   #'Run card with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
8   'Run card or check with a Business::OnlinePayment realtime gateway';
9 }
10
11 sub eventtable_hashref {
12   { 'cust_bill' => 1,
13     'cust_main' => 1,
14   };
15 }
16
17 sub default_weight { 30; }
18
19 sub do_action {
20   my( $self, $object ) = @_;
21
22   my $cust_main = $self->cust_main($object);
23
24   my %opt = ('cc_surcharge_from_event' => 1);
25
26   my $amount;
27   my $balance = $cust_main->balance;
28   if ( ref($object) eq 'FS::cust_main' ) {
29     $amount = $balance;
30   } elsif ( ref($object) eq 'FS::cust_bill' ) {
31     $amount = ( $balance < $object->owed ) ? $balance : $object->owed;
32     $opt{'invnum'} = $object->invnum;
33   } else {
34     die 'guru meditation #5454.au';
35   }
36
37   $cust_main->realtime_cust_payby( 'amount' => $amount, %opt, );
38
39 }
40
41 1;