summaryrefslogtreecommitdiff
path: root/FS/FS/payinfo_Mixin.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-10-19 12:51:06 -0700
committerMark Wells <mark@freeside.biz>2012-10-19 12:51:06 -0700
commit744b17e5c9a5de68ad8a24b7a35449b535f02731 (patch)
tree341a92bd2b7b20aaaa4328391c8ea8bda78beff8 /FS/FS/payinfo_Mixin.pm
parenta056cbfc08fa8491aa3c995d7053ed4574b18c50 (diff)
recurring indicator for Paymentech batches, #19571
Diffstat (limited to 'FS/FS/payinfo_Mixin.pm')
-rw-r--r--FS/FS/payinfo_Mixin.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm
index d03391f..7b713ef 100644
--- a/FS/FS/payinfo_Mixin.pm
+++ b/FS/FS/payinfo_Mixin.pm
@@ -3,6 +3,7 @@ package FS::payinfo_Mixin;
use strict;
use Business::CreditCard;
use FS::payby;
+use FS::Record qw(qsearch);
=head1 NAME
@@ -267,6 +268,30 @@ sub payby_payinfo_pretty {
}
}
+=item payinfo_used [ PAYINFO ]
+
+Returns 1 if there's an existing payment using this payinfo. This can be
+used to set the 'recurring payment' flag required by some processors.
+
+=cut
+
+sub payinfo_used {
+ my $self = shift;
+ my $payinfo = shift || $self->payinfo;
+ my %hash = (
+ 'custnum' => $self->custnum,
+ 'payby' => 'CARD',
+ );
+
+ return 1
+ if qsearch('cust_pay', { %hash, 'payinfo' => $payinfo } )
+ || qsearch('cust_pay',
+ { %hash, 'paymask' => $self->mask_payinfo('CARD', $payinfo) } )
+ ;
+
+ return 0;
+}
+
=back
=head1 BUGS