[FIX] payment_adyen: stop logging stacktrace for invalid reference

as Adyen sends the same notification data for POS and online payments
that can not be distiguished, the webhook controller logs a stacktrace
for every POS payment. If the payment_adyen is installed it generates
noise in logs as the POS transaction can not be found in online
payments. To clear the log we make missing transaction as warning to
not log the stacktrace.

task-2960381

closes odoo/odoo#123282

X-original-commit: 4754895ac7901c497f33a6bf9be6d18c0b4b55d8
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Valeriya Chuprina (vchu) <vchu@odoo.com>
This commit is contained in:
Valeriya(vchu)
2023-06-01 17:55:23 +02:00
parent 06c8a16114
commit 565e18c946
+12 -5
View File
@@ -268,6 +268,11 @@ class AdyenController(http.Controller):
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data(
'adyen', notification_data
)
except ValidationError:
# Warn rather than log the traceback to avoid noise when a POS payment notification
# is received and the corresponding `payment.transaction` record is not found.
_logger.warning("unable to find the transaction; skipping to acknowledge")
else:
self._verify_notification_signature(notification_data, tx_sudo)
# Check whether the event of the notification succeeded and reshape the notification
@@ -285,11 +290,13 @@ class AdyenController(http.Controller):
notification_data['resultCode'] = 'Error'
else:
continue # Don't handle unsupported event codes and failed events
# Handle the notification data as if they were feedback of a S2S payment request
tx_sudo._handle_notification_data('adyen', notification_data)
except ValidationError: # Acknowledge the notification to avoid getting spammed
_logger.exception("unable to handle the notification data; skipping to acknowledge")
try:
# Handle the notification data as if they were feedback of a S2S payment request
tx_sudo._handle_notification_data('adyen', notification_data)
except ValidationError: # Acknowledge the notification to avoid getting spammed
_logger.exception(
"unable to handle the notification data;skipping to acknowledge"
)
return request.make_json_response('[accepted]') # Acknowledge the notification