From 68c725afeec87d4cd6bddb78323c2d5c66969901 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 13 Apr 2023 17:52:58 +0000 Subject: [PATCH] Bug 33176: Enforce RequirePaymentType with API Signed-off-by: David Nind Signed-off-by: Sam Lau Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit df4285adb2f6669ad62b0e3b1eddb04f44761d16) Signed-off-by: Martin Renvoize --- Koha/REST/V1/Patrons/Account.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm index e2d18f5824..95c998ad56 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -145,6 +145,10 @@ sub add_credit { my $note = $body->{note}; my $library_id = $body->{library_id}; + if ( C4::Context->preference("RequirePaymentType") && !defined($payment_type) ) { + Koha::Exceptions::Account::PaymentTypeRequired->throw(); + } + my $credit = $account->add_credit( { amount => $amount, -- 2.39.5