X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=f969460a9890a89f2307f49bc0c14ec33aeb2fbb;hb=7ed55804735f4f687cd64139db7bae9746282a89;hp=5d31d2cde63ce7a4e5b42979db156187b1e73f0f;hpb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 5d31d2cde..f969460a9 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -7,6 +7,7 @@ use Business::CreditCard; use Text::Template; use FS::Misc qw(send_email); use FS::Record qw( dbh qsearch qsearchs ); +use FS::payby; use FS::cust_main_Mixin; use FS::payinfo_Mixin; use FS::cust_bill; @@ -408,15 +409,16 @@ sub check { $self->_date(time) unless $self->_date; - # UNIQUE index should catch this too, without race conditions, but this - # should give a better error message the other 99.9% of the time... - if ( length($self->payunique) - && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) ) { - #well, it *could* be a better error message - return "duplicate transaction". - " - a payment with unique identifer ". $self->payunique. - " already exists"; - } +#i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it +# # UNIQUE index should catch this too, without race conditions, but this +# # should give a better error message the other 99.9% of the time... +# if ( length($self->payunique) +# && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) ) { +# #well, it *could* be a better error message +# return "duplicate transaction". +# " - a payment with unique identifer ". $self->payunique. +# " already exists"; +# } $self->SUPER::check; } @@ -548,6 +550,74 @@ sub cust_main { qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); } +=item payby_name + +Returns a name for the payby field. + +=cut + +sub payby_name { + my $self = shift; + FS::payby->shortname( $self->payby ); +} + +=item gatewaynum + +Returns a gatewaynum for the processing gateway. + +=item processor + +Returns a name for the processing gateway. + +=item authorization + +Returns a name for the processing gateway. + +=item order_number + +Returns a name for the processing gateway. + +=cut + +sub gatewaynum { shift->_parse_paybatch->{'gatewaynum'}; } +sub processor { shift->_parse_paybatch->{'processor'}; } +sub authorization { shift->_parse_paybatch->{'authorization'}; } +sub order_number { shift->_parse_paybatch->{'order_number'}; } + +#sucks that this stuff is in paybatch like this in the first place, +#but at least other code can start to use new field names +#(code nicked from FS::cust_main::realtime_refund_bop) +sub _parse_paybatch { + my $self = shift; + + $self->paybatch =~ /^((\d+)\-)?(\w+):\s*([\w\-\/ ]*)(:([\w\-]+))?$/ + or return {}; + #"Can't parse paybatch for paynum $options{'paynum'}: ". + # $cust_pay->paybatch; + + my( $gatewaynum, $processor, $auth, $order_number ) = ( $2, $3, $4, $6 ); + + if ( $gatewaynum ) { #gateway for the payment to be refunded + + my $payment_gateway = + qsearchs('payment_gateway', { 'gatewaynum' => $gatewaynum } ); + + die "payment gateway $gatewaynum not found" #? + unless $payment_gateway; + + $processor = $payment_gateway->gateway_module; + + } + + { + 'gatewaynum' => $gatewaynum, + 'processor' => $processor, + 'authorization' => $auth, + 'order_number' => $order_number, + }; + +} + =back =head1 CLASS METHODS @@ -586,8 +656,8 @@ Delete and replace methods. =head1 SEE ALSO -L, L, L, schema.html from the -base documentation. +L, L, L, L, +schema.html from the base documentation. =cut