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

fix(gocardless): Treat Gocardless webhooks events in separate jobs #2695

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

vincent-pochet
Copy link
Collaborator

@vincent-pochet vincent-pochet commented Oct 15, 2024

This pull request focuses on improving the GoCardless webhook events management and refactoring the integration by introducing new services for handling webhooks and events using the standard call/Result pattern.

The main changes include replacing direct calls to GocardlessService with more specific services and updating the logic to treat each webhook events in isolation to avoid failling a batch if a single event is causing an error.

Refactoring and Service Extraction:

  • Refactored Webhook Handling:

    • Replaced GocardlessService.handle_incoming_webhook with Gocardless::HandleIncomingWebhookService.call in WebhooksController. (app/controllers/webhooks_controller.rb)
    • Extracted webhook handling logic into a new service HandleIncomingWebhookService. (app/services/payment_providers/gocardless/handle_incoming_webhook_service.rb)
  • Refactored Event Handling:

    • Replaced GocardlessService.handle_event with Gocardless::HandleEventService.call in HandleEventJob. (app/jobs/payment_providers/gocardless/handle_event_job.rb)
    • Extracted event handling logic into a new service HandleEventService. (app/services/payment_providers/gocardless/handle_event_service.rb)
    • Keep acception the legacy events_json input argument in HandleEventJob to avoid issues with enqueued/dead jobs for now

@vincent-pochet vincent-pochet merged commit 787c6ed into main Oct 17, 2024
6 checks passed
@vincent-pochet vincent-pochet deleted the refact-gocarless-isolation branch October 17, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants