summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Action
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-02-16 00:01:07 -0800
committerIvan Kohler <ivan@freeside.biz>2015-02-16 00:01:07 -0800
commit24cc2801560aa110a077ee7f3a6e50d6aa40fc36 (patch)
tree146bcf0c0ad323d7fedee137fa148c35b25a85d8 /FS/FS/part_event/Action
parent0870a4c1fb02be43ea5524f58650d99c81477681 (diff)
multiple payment options (event action migration), RT#23741
Diffstat (limited to 'FS/FS/part_event/Action')
-rw-r--r--FS/FS/part_event/Action/realtime_auto.pm41
1 files changed, 41 insertions, 0 deletions
diff --git a/FS/FS/part_event/Action/realtime_auto.pm b/FS/FS/part_event/Action/realtime_auto.pm
new file mode 100644
index 0000000..3902319
--- /dev/null
+++ b/FS/FS/part_event/Action/realtime_auto.pm
@@ -0,0 +1,41 @@
+package FS::part_event::Action::realtime_auto;
+
+use strict;
+use base qw( FS::part_event::Action );
+
+sub description {
+ #'Run card with a <a href="http://420.am/business-onlinepayment/">Business::OnlinePayment</a> realtime gateway';
+ 'Run card or check with a Business::OnlinePayment realtime gateway';
+}
+
+sub eventtable_hashref {
+ { 'cust_bill' => 1,
+ 'cust_main' => 1,
+ };
+}
+
+sub default_weight { 30; }
+
+sub do_action {
+ my( $self, $object ) = @_;
+
+ my $cust_main = $self->cust_main($object);
+
+ my %opt = ('cc_surcharge_from_event' => 1);
+
+ my $amount;
+ my $balance = $cust_main->balance;
+ if ( ref($object) eq 'FS::cust_main' ) {
+ $amount = $balance;
+ } elsif ( ref($object) eq 'FS::cust_bill' ) {
+ $amount = ( $balance < $object->owed ) ? $balance : $object->owed;
+ $opt{'invnum'} = $object->invnum;
+ } else {
+ die 'guru meditation #5454.au';
+ }
+
+ $cust_main->realtime_cust_payby( 'amount' => $amount, %opt, );
+
+}
+
+1;