JBAS-778 Credit payment additional logging
authorBill Erickson <berickxx@gmail.com>
Thu, 25 Jun 2015 18:26:17 +0000 (14:26 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Log more info on credit card payments for better payment failure
diagnosis.

Avoid logging any credit card numbers.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/CreditCard.pm

index e4c9946..bad3525 100644 (file)
@@ -24,6 +24,7 @@ use Business::OnlinePayment;
 use UUID::Tiny qw/:std/;
 use Locale::Country;
 
+use OpenSRF::Utils::JSON;
 use OpenILS::Event;
 use OpenSRF::Utils::Logger qw/:logger/;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
@@ -254,6 +255,17 @@ sub dispatch {
 
     my %content = prepare_bop_content($argshash, $patron, $cardtype);
 
+    # KCLS CUSTOM
+    # Log more details about what we are sending to the CC processor
+    my $content_clone = OpenSRF::Utils::JSON->JSON2perl(
+        OpenSRF::Utils::JSON->perl2JSON(\%content));
+    
+    # Don't log sensitive info.
+    delete $content_clone->{$_} foreach qw/cc card_number password/;
+
+    $logger->info("CC sending payment info: " . 
+        OpenSRF::Utils::JSON->perl2JSON($content_clone));
+
     return OpenILS::Event->new(
         'CREDIT_PROCESSOR_BAD_PARAMS', note => "Missing address fields")
         if keys(%content) == 0;
@@ -281,6 +293,8 @@ sub dispatch {
         $event_name = "SUCCESS";
     } else {
         $logger->info($argshash->{processor} . " payment failed");
+        $logger->info("CC error info " . 
+            OpenSRF::Utils::JSON->perl2JSON($payload));
         $event_name = "CREDIT_PROCESSOR_DECLINED_TRANSACTION";
     }