-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(events): add APIs to list webhook events and webhook delivery attempts #4131
Conversation
…mon_enums` crate
… initial attempt ID
…e specified initial event ID
…ls with `attach_printable()`
…primary object ID and by constraints
…based on constraints
…in `EventRetrieveResponse`
…ve_path_order` feature flag
…CHANT_DETAILS_MANAGE` group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dashboard related changes looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api event generation part looks good to me
2cd3a54
Type of Change
Description
This PR introduces two API endpoints, one to list (and filter) webhook events and one to list webhook delivery attempts:
Events List:
/events/{merchant_id}
object_id
: Primary object ID (such as payment ID, refund ID, mandate ID, dispute ID) used to filter events related to that object.limit
offset
created_after
,created_before
: Specify date and time range to include events from.Webhook Delivery Attempts List
/events/{merchant_id}/{initial_event_id}/attempts
This PR includes the following changes:
events
table now include themerchant_id
field everywhere.events
table that would be queried by the newly introduced endpoints.delivery_attempt
column to theevents
table to indicate the type of delivery attempt for the webhook.In addition this PR has a few changes not directly related to the PR:
EncryptionStratergy
toEncryptionStrategy
.ext_traits
module.attach_printable_lazy()
calls in thegenerics
module withattach_printable()
.utoipa
dependency from version3.3.0
to3.5.0
and enables thepreserve_path_order
feature flag.The PR can easily be reviewed one commit at a time.
Known Issues
The above endpoints can be used to retrieve information on events created by the application versions newer than
2024.03.15.0
, since events are now queried with the merchant ID, and the merchant ID field is populated in the database table starting version2024.03.15.0
. The application will throw an internal server error when older events are being retrieved.Additional Changes
The database migrations for this PR can be found in the
up.sql
anddown.sql
files.Motivation and Context
These endpoints would better allow users to view the recently delivered webhooks and debug issues with webhook deliveries to their application servers.
How did you test it?
Ensuring that the
delivery_attempt
field is being populated correctly in theevents
table for initial attempt and automatic retries via the scheduler:This can be verified using a SQL query like so:
Listing events related to a specific object (say payment intent, refund, dispute):
You should see a response like so, with events sorted in descending order of creation:
Listing and filtering events based on time range:
created_after
,created_before
,limit
andoffset
are optional, and one or more of them may be specified together.created_after
,created_before
,limit
andoffset
cannot be specified ifobject_id
is specified, the application throws a bad request error in this case.Specifying all query params:
Specifying a subset of the query params (only
created_after
):Error when
object_id
is specified with any of the other query params:Listing delivery attempts for a specific initial event ID:
Checklist
cargo +nightly fmt --all
cargo clippy