Skip to content

Conversation

SanchithHegde
Copy link
Member

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR refactors the outgoing webhooks logic to raise errors to the analytics pipeline (involving Kafka and ClickHouse) in case the webhook was not at all sent due to API client errors, or if the merchant server returns a non-2xx HTTP response.

This was done in two steps:

  1. First, the success and error handling closures were moved out as functions within the outgoing webhooks module.
  2. Then, the error handling functions were updated to return errors.

Since it's easier to follow along when reviewing one commit at a time, I'd suggest the reviewers to do the same.

Motivation and Context

This fixes a bug where failed webhook deliveries were falsely displayed as successful on the control center, since the analytics pipeline had no information that an error had occurred.

How did you test it?

With a local Kafka and ClickHouse setup:

  1. In case of successful deliveries, the is_error field must be false and error field must not be populated in the Kafka and ClickHouse events:

    Kafke:
    Screenshot of Kafka UI for successful webhook delivery

    ClickHouse:
    Screenshot of ClickHouse record for successful webhook delivery

  2. In case of failed webhook deliveries due to errors where no HTTP response was involved (non-existent domain name, some configuration issues with the client, etc.), the is_error field must be true and the error field must be populated with CallToMerchantFailed:

    Kafka:
    Screenshot of Kafka UI for failed webhook delivery due to client error

    ClickHouse:
    Screenshot of ClickHouse record for failed webhook delivery due to client error

  3. In case of failed webhook deliveries due to the merchant server returning a non-2xx HTTP status code, the is_error field must be true and the error field must be populated with NotReceivedByMerchant:

    Kafka:
    Screenshot of Kafka UI for failed webhook delivery due to non-2xx HTTP status code from merchant server

    ClickHouse:
    Screenshot of ClickHouse record for failed webhook delivery due to non-2xx HTTP status code from merchant server

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@SanchithHegde SanchithHegde added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed C-refactor Category: Refactor A-webhooks Area: Webhook flows labels Jun 6, 2024
@SanchithHegde SanchithHegde added this to the May 2024 Release milestone Jun 6, 2024
@SanchithHegde SanchithHegde self-assigned this Jun 6, 2024
@SanchithHegde SanchithHegde requested a review from a team as a code owner June 6, 2024 05:22
Base automatically changed from webhooks-split-incoming-outgoing to main June 6, 2024 08:45
@SanchithHegde SanchithHegde requested a review from a team as a code owner June 6, 2024 08:45
@SanchithHegde SanchithHegde force-pushed the outgoing-webhooks-raise-analytics-errors branch from ecf5a83 to 18b7019 Compare June 6, 2024 09:39
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 6, 2024
Merged via the queue into main with commit 9da9202 Jun 6, 2024
@likhinbopanna likhinbopanna deleted the outgoing-webhooks-raise-analytics-errors branch June 6, 2024 18:00
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jun 6, 2024
pixincreate added a commit that referenced this pull request Jun 7, 2024
…out-fix

* 'main' of github.com:juspay/hyperswitch:
  refactor(connector): convert init payment flow to preprocessing flow for shift4 (#4884)
  ci(cypress): Add billing address for bank redirects (#4903)
  refactor(openapi): move openapi to a separate folder (#4859)
  chore(version): 2024.06.07.0
  refactor(outgoing_webhooks): raise errors in the analytics pipeline in case of API client errors or non-2xx responses (#4894)
  chore(config): [MIFINITY] add configs for Mifinity in WASM (#4895)
  feat(router): add `acquirer_country_code` in acquirer_details and send it in netcetera authentication flow (#4835)
  refactor(connector): convert init payment flow to preprocessing flow for nuvei (#4878)
  feat(connector): [MIFINITY] Implement payment flows and Mifinity payment method (#4592)
  fix(connectors): [BOA/CYBS] make avs code optional (#4898)
  feat(events): add metadata info to events (#4875)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-webhooks Area: Webhook flows C-refactor Category: Refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants