add more/clearer logging for Stripe payments
authorChris Sharp <csharp@georgialibraries.org>
Thu, 20 Apr 2023 17:46:45 +0000 (13:46 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Thu, 20 Apr 2023 17:48:00 +0000 (13:48 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index b96c398..3dd4e43 100644 (file)
@@ -106,10 +106,10 @@ sub process_stripe_or_bop_payment {
         my $stripe = Business::Stripe->new(-api_key => $psettings->{secretkey});
         $stripe->api('post','payment_intents/' . $cc_args->{stripe_payment_intent});
         if ($stripe->success) {
-            $logger->info('Stripe payment intent retrieved');
+            $logger->info('STRIPE: Stripe payment intent retrieved');
             my $intent = $stripe->success;
             if ($intent->{status} eq 'succeeded') {
-                $logger->info('Stripe payment succeeded');
+                $logger->info('STRIPE: Stripe payment succeeded');
                 return OpenILS::Event->new(
                     'SUCCESS', payload => {
                         invoice => $intent->{invoice},
@@ -121,15 +121,15 @@ sub process_stripe_or_bop_payment {
                     }
                 );
             } else {
-                $logger->info('Stripe payment failed');
+                $logger->info('STRIPE: Stripe payment failed');
                 return OpenILS::Event->new(
                     'CREDIT_PROCESSOR_DECLINED_TRANSACTION',
                     payload => $intent->{last_payment_error}
                 );
             }
         } else {
-            $logger->info('Stripe payment intent not retrieved');
-            $logger->info('Stripe payment failed');
+            $logger->info('STRIPE: Stripe payment intent not retrieved');
+            $logger->info('STRIPE: Stripe payment failed');
             return OpenILS::Event->new(
                 "CREDIT_PROCESSOR_DECLINED_TRANSACTION",
                 payload => $stripe->error  # XXX what happens if this contains
index ffcda9a..83d4b71 100644 (file)
@@ -2341,6 +2341,7 @@ sub load_myopac_payment_form {
         && $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'credit.processor.default') eq 'Stripe') {
         my $skey = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'credit.processor.stripe.secretkey');
         my $currency = $self->ctx->{get_org_setting}->($e->requestor->home_ou, 'credit.processor.stripe.currency');
+        $logger->info("STRIPE: about to start Stripe with amount = $self->ctx->{fines}->{balance_owed} * 100 " . ($currency || 'usd') . " for user " . $self->ctx->{user}->id);
         my $stripe = Business::Stripe->new(-api_key => $skey);
         my $intent = $stripe->api('post', 'payment_intents',
             amount                => $self->ctx->{fines}->{balance_owed} * 100,
@@ -2349,8 +2350,9 @@ sub load_myopac_payment_form {
         );
         if ($stripe->success) {
             $self->ctx->{stripe_client_secret} = $stripe->success()->{client_secret};
+            $logger->info("STRIPE: Success for user " . $self->ctx->{user}->id);
         } else {
-            $logger->error('Error initializing Stripe: ' . Dumper($stripe->error));
+            $logger->error('STRIPE: Error initializing Stripe: ' . Dumper($stripe->error));
             $self->ctx->{cc_configuration_error} = 1;
         }
     }