[open-ils-commits] r16857 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jul 6 15:07:01 EDT 2010


Author: senator
Date: 2010-07-06 15:06:56 -0400 (Tue, 06 Jul 2010)
New Revision: 16857

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm
Log:
CC payments: address situations where Business::CreditCard::validate() returns
true yet Business::CreditCard::cardtype() returns the string "Unknown"

Curse you inconsistent APIs! :-)


Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm	2010-07-06 18:58:54 UTC (rev 16856)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/CreditCard.pm	2010-07-06 19:06:56 UTC (rev 16857)
@@ -231,8 +231,16 @@
     #   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,8 +257,11 @@
     );
 
     $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"},
         "card_type" => $cardtype,



More information about the open-ils-commits mailing list