From 2e85f82d1046ea15a7d488b1f8d730969c490958 Mon Sep 17 00:00:00 2001 From: senator Date: Tue, 6 Jul 2010 19:06:56 +0000 Subject: [PATCH] CC payments: address situations where Business::CreditCard::validate() returns true yet Business::CreditCard::cardtype() returns the string "Unknown" Curse you inconsistent APIs! :-) git-svn-id: svn://svn.open-ils.org/ILS/trunk@16857 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/CreditCard.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm index d2e4c0a43..01360e07d 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm @@ -231,7 +231,15 @@ sub dispatch { # a payment processor, nor that # b) it is even necessary to supply this argument to processors in all # cases. Testing this with several processors would be a good idea. - (my $cardtype = cardtype($argshash->{cc})) =~ s/ card//; + (my $cardtype = cardtype($argshash->{cc})) =~ s/ card//i; + + if (lc($cardtype) eq "unknown") { + $logger->info("Credit card number passed validate(), " . + "yet cardtype() returned $cardtype"); + return new OpenILS::Event( + "CREDIT_PROCESSOR_INVALID_CC_NUMBER", "note" => "cardtype $cardtype" + ); + } $logger->debug( "applying payment via processor '" . $argshash->{processor} . "'" @@ -249,7 +257,10 @@ sub dispatch { ); $transaction->content(prepare_bop_content($argshash, $patron, $cardtype)); - $transaction->submit(); + + # XXX submit() does not return a value, although crashing is possible here + # with some bad input depending on the payment processor. + $transaction->submit; my $payload = { "processor" => $argshash->{"processor"}, -- 2.11.0