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

refactor(webhook): add jwt authenticated endpoint to list unique webhook events for a profile #7325

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

Conversation

Aishwariyaa-Anand
Copy link

Type of Change

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

Description

This PR introduces a new JWT authenticated endpoint for listing unique webhook events for a profile. The endpoint URL is /events/profile/list and it will support only JWT authentication.
The profile ID and merchant ID will be extracted directly from JWT token. The router handler will call the existing list_initial_delivery_attempts() supporting other filtering constraints, same as in the existing endpoint.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  • List initial delivery attempts
curl --location 'http://localhost:8080/events/profile/list' \
--header 'Authorization: Bearer eyJBdXRob3JpemF0aW9uIjoicnJyIiwiYWxnIjoiSFMyNTYifQ.eyJ1c2VyX2lkIjoiZDk1NTcyN2ItNDQxYi1iNjVmLWE2NTA5ZWZiYjQ0YiIsIm1lcmNoYW50X2lkIjoibWVyY2hhbnRfMTczOTUyMDc2NSIsInJvbGVfaWQiOiJvcmdfYWRtaW4iLCJleHAiOjE3NDAxMzYxNTUsIm9yZ19pZCI6Im9yZ19IY3gzRUlMcWVXSFhGN2V3bE91dyIsInByb2ZpbGVfaWQiOiJwcm9fWHpGb2lhaDFNbHNDbVJqY3ViUXEiLCJ0ZW5hbnRfaWQiOiJwdWJsaWMifQ.UwdflL4JuswgoPSLDFEGkXg0IUHMdqiftn1HS5arGhc' \
--header 'Cookie: login_token=eyJBdXRob3JpemF0aW9uIjoicnJyIiwiYWxnIjoiSFMyNTYifQ.eyJ1c2VyX2lkIjoiZDk1NTcyN2ItNDQxYi1iNjVmLWE2NTA5ZWZiYjQ0YiIsIm1lcmNoYW50X2lkIjoibWVyY2hhbnRfMTczOTUyMDc2NSIsInJvbGVfaWQiOiJvcmdfYWRtaW4iLCJleHAiOjE3NDAxMzYxNTUsIm9yZ19pZCI6Im9yZ19IY3gzRUlMcWVXSFhGN2V3bE91dyIsInByb2ZpbGVfaWQiOiJwcm9fWHpGb2lhaDFNbHNDbVJqY3ViUXEiLCJ0ZW5hbnRfaWQiOiJwdWJsaWMifQ.UwdflL4JuswgoPSLDFEGkXg0IUHMdqiftn1HS5arGhc' \
--data ''
  • Response
[{"event_id":"evt_019503a21ce676f186def372c1678519","merchant_id":"merchant_1739520765","profile_id":"pro_XzFoiah1MlsCmRjcubQq","object_id":"pay_qF1JybZlZBLKU1m42nua","event_type":"payment_succeeded","event_class":"payments","is_delivery_successful":false,"initial_attempt_id":"evt_019503a21ce676f186def372c1678519","created":"2025-02-14T08:45:10.758Z"},{"event_id":"evt_0195039d99d47f519cb63e7752618825","merchant_id":"merchant_1739520765","profile_id":"pro_XzFoiah1MlsCmRjcubQq","object_id":"ref_dU8Rx4P5Mz25wtT7xIKS","event_type":"refund_succeeded","event_class":"refunds","is_delivery_successful":false,"initial_attempt_id":"evt_0195039d99d47f519cb63e7752618825","created":"2025-02-14T08:40:15.060Z"},{"event_id":"evt_0195039d6d6e79c1a407f83fe42ad994","merchant_id":"merchant_1739520765","profile_id":"pro_XzFoiah1MlsCmRjcubQq","object_id":"pay_uqIiFNnnpEOci2zPypY7","event_type":"payment_succeeded","event_class":"payments","is_delivery_successful":false,"initial_attempt_id":"evt_0195039d6d6e79c1a407f83fe42ad994","created":"2025-02-14T08:40:03.694Z"}]
  • List initial delivery attempts with constraints
curl --location 'http://localhost:8080/events/profile/list?limit=2&offset=1' \
--header 'Authorization: Bearer eyJBdXRob3JpemF0aW9uIjoicnJyIiwiYWxnIjoiSFMyNTYifQ.eyJ1c2VyX2lkIjoiZDk1NTcyN2ItNDQxYi1iNjVmLWE2NTA5ZWZiYjQ0YiIsIm1lcmNoYW50X2lkIjoibWVyY2hhbnRfMTczOTUyMDc2NSIsInJvbGVfaWQiOiJvcmdfYWRtaW4iLCJleHAiOjE3NDAxMzYxNTUsIm9yZ19pZCI6Im9yZ19IY3gzRUlMcWVXSFhGN2V3bE91dyIsInByb2ZpbGVfaWQiOiJwcm9fWHpGb2lhaDFNbHNDbVJqY3ViUXEiLCJ0ZW5hbnRfaWQiOiJwdWJsaWMifQ.UwdflL4JuswgoPSLDFEGkXg0IUHMdqiftn1HS5arGhc' \
--header 'Cookie: login_token=eyJBdXRob3JpemF0aW9uIjoicnJyIiwiYWxnIjoiSFMyNTYifQ.eyJ1c2VyX2lkIjoiZDk1NTcyN2ItNDQxYi1iNjVmLWE2NTA5ZWZiYjQ0YiIsIm1lcmNoYW50X2lkIjoibWVyY2hhbnRfMTczOTUyMDc2NSIsInJvbGVfaWQiOiJvcmdfYWRtaW4iLCJleHAiOjE3NDAxMzYxNTUsIm9yZ19pZCI6Im9yZ19IY3gzRUlMcWVXSFhGN2V3bE91dyIsInByb2ZpbGVfaWQiOiJwcm9fWHpGb2lhaDFNbHNDbVJqY3ViUXEiLCJ0ZW5hbnRfaWQiOiJwdWJsaWMifQ.UwdflL4JuswgoPSLDFEGkXg0IUHMdqiftn1HS5arGhc' \
--data ''
  • Response
[{"event_id":"evt_0195039d99d47f519cb63e7752618825","merchant_id":"merchant_1739520765","profile_id":"pro_XzFoiah1MlsCmRjcubQq","object_id":"ref_dU8Rx4P5Mz25wtT7xIKS","event_type":"refund_succeeded","event_class":"refunds","is_delivery_successful":false,"initial_attempt_id":"evt_0195039d99d47f519cb63e7752618825","created":"2025-02-14T08:40:15.060Z"},{"event_id":"evt_0195039d6d6e79c1a407f83fe42ad994","merchant_id":"merchant_1739520765","profile_id":"pro_XzFoiah1MlsCmRjcubQq","object_id":"pay_uqIiFNnnpEOci2zPypY7","event_type":"payment_succeeded","event_class":"payments","is_delivery_successful":false,"initial_attempt_id":"evt_0195039d6d6e79c1a407f83fe42ad994","created":"2025-02-14T08:40:03.694Z"}]

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

@Aishwariyaa-Anand Aishwariyaa-Anand requested review from a team as code owners February 20, 2025 11:14
Copy link

semanticdiff-com bot commented Feb 20, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/routes/app.rs  68% smaller
  crates/router/src/routes/webhook_events.rs  14% smaller
  crates/router/src/services/authorization/permissions.rs  12% smaller
  api-reference/openapi_spec.json  0% smaller
  crates/openapi/src/openapi.rs  0% smaller
  crates/openapi/src/routes/webhook_events.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 20, 2025
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 20, 2025
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant