Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECP-9177] Implement webhook clean-up cronjob for old webhooks #2837

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

candemiralp
Copy link
Member

@candemiralp candemiralp commented Dec 27, 2024

Description

The plugin stores asynchronous payment events (webhooks) in adyen_notification DB table. However, this table might end-up with huge amount of data and requires clean-up time to time.

This PR introduces a cronjob to clean-up old notifications older than 90 days from the database if it's enabled. Please note that this feature is disabled by default and can be enabled from the plugin configuration.

Screenshot 2024-12-31 at 15 27 43

Tested scenarios

  • Cronjob processing to clean-up notificationsx

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@candemiralp candemiralp added the Feature Indicates a new feature addition label Dec 31, 2024
# Conflicts:
#	Helper/Config.php
#	etc/di.xml
Copy link

sonarqubecloud bot commented Jan 7, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

Copy link

sonarqubecloud bot commented Jan 7, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

return $items->getItems();
} catch (LocalizedException $e) {
$errorMessage = sprintf(
__('An error occurred while providing notifications older than %s days!'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the store name or ID here? Maybe that's useful to see in the log line to be able to debug

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @acampos1916, thank you for the review.

Notification entity is independent from the stores and we don't have a store value here. Similarly, this catch block targets the issues while fetching the entities. Most probably, there won't be any notification entity for any descriptive features to add to the logs.

$isSuccessfullyDeleted = $this->adyenNotificationRepository->delete($notificationToCleanup);

if ($isSuccessfullyDeleted) {
$message = __('%1: Notification with entityId %2 has been deleted.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add also here one extra info: Notification with entityId %2 has been deleted because it was processed/received X days ago.

Probably means getting that field from the provider

$this->notificationsProvider = null;
}

public function testProvideSuccess()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method missing an assertion?

<config_path>payment/adyen_abstract/cleanup_old_webhooks</config_path>
<tooltip>
Webhooks older than certain days will be removed from the database by a cronjob if this feature is enabled.
The default value is 90 days and this can be configured by overriding `payment/adyen_abstract/required_days_old_webhooks` configuration path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we then hiding required_days_old_webhooks ?

@acampos1916
Copy link
Member

Two extra details we can add to this PR:

A confirm dialog when the config gets saved so that the admin user acknoledges that webhooks older than X will be deleted.

A message on the Webhook list view to inform that webhooks newer than X days are being listed and that older than X are being removed by this configuration (link to the config)

@candemiralp
Copy link
Member Author

Two extra details we can add to this PR:

A confirm dialog when the config gets saved so that the admin user acknoledges that webhooks older than X will be deleted.

A message on the Webhook list view to inform that webhooks newer than X days are being listed and that older than X are being removed by this configuration (link to the config)

Hey @acampos1916,

I like this idea. It will foster the merchant experience a lot. Let me have look into that one.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Indicates a new feature addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants