Skip to content

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

Merged
likhinbopanna merged 6 commits intomainfrom
jwtauth-webhook-events
Mar 24, 2025
Merged

refactor(webhook): add jwt authenticated endpoint to list unique webhook events for a profile#7325
likhinbopanna merged 6 commits intomainfrom
jwtauth-webhook-events

Conversation

@Aishwariyaa-Anand
Copy link
Contributor

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
@semanticdiff-com
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-v2/openapi_spec.json  0% 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
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

Other than that, looks good to me!

@likhinbopanna likhinbopanna added this pull request to the merge queue Mar 24, 2025
Merged via the queue into main with commit 7010799 Mar 24, 2025
17 of 20 checks passed
@likhinbopanna likhinbopanna deleted the jwtauth-webhook-events branch March 24, 2025 12:00
pixincreate added a commit that referenced this pull request Mar 24, 2025
…lobalpay-fixes

* 'main' of github.com:juspay/hyperswitch:
  feat(connector): [Recurly] Add record back support for recurly [V2] (#7544)
  refactor(webhook): add jwt authenticated endpoint to list unique webhook events for a profile (#7325)
  feat(core): Add three_ds_requestor_app_url in business_profile (#7589)
  feat(refunds): Add refunds diesel model support in V2 API (#7503)
  fix(connector): [globalpay] address 5xx due to deserialization issue when `account_name` is not passed (#7540)
  chore: update production endpoint url for globalPay (#7588)
  feat(connector): [Stripebilling] add record back support for stripebilling (#7561)
  feat(router): Make payment_method_subtype optional in payment_attempt [V2] (#7568)
  fix(connector): RSync voided status mapping in AuthorizeDotNet (#7566)
  chore(version): 2025.03.24.0
  feat(connector): [Coingate] implement refunds  (#7513)
  feat(connectors): [Redsys] add Psync and Rsync support (#7586)
  refactor(connector): [BRAINTREE] Pass email in payment requests (#7591)
  feat(webhook): Return events list and total_count on list initial delivery attempt call (#7243)
  refactor(router): make error_type generic in domain_models inorder to avoid conversion of errors in storage_impl (#7537)
  feat(router): [V2] Return connector customer reference IDs in `CustomerResponse` (#7319)
  feat: core changes for extended authorization (#6766)
  feat(coingate): Add Payment webhooks (#7489)
  refactor(dynamic_routing): change insert operation to upsert for dynamic_routing_stats (#7398)
  feat(connectors): [Redsys] add 3D secure card payment support, including transaction capture, cancellation, and refunds (#7508)
pixincreate added a commit that referenced this pull request Mar 27, 2025
…e-status-check

* 'main' of github.com:juspay/hyperswitch: (74 commits)
  chore(version): 2025.03.26.0
  feat(connector): [Coingate] add wasm changes for coingate metadata (#7632)
  feat(connector): [TRUSTPAY]  implement Banktransfer PaymentMethod (#7575)
  feat(connector): [BANKOFAMERICA] Implement Samsung Pay (#6888)
  fix(connector):  add Nomupay in payout_connector_list for all environment (#7521)
  chore(version): 2025.03.25.0
  feat(connector): [Recurly] Add record back support for recurly [V2] (#7544)
  refactor(webhook): add jwt authenticated endpoint to list unique webhook events for a profile (#7325)
  feat(core): Add three_ds_requestor_app_url in business_profile (#7589)
  feat(refunds): Add refunds diesel model support in V2 API (#7503)
  fix(connector): [globalpay] address 5xx due to deserialization issue when `account_name` is not passed (#7540)
  chore: update production endpoint url for globalPay (#7588)
  feat(connector): [Stripebilling] add record back support for stripebilling (#7561)
  feat(router): Make payment_method_subtype optional in payment_attempt [V2] (#7568)
  fix(connector): RSync voided status mapping in AuthorizeDotNet (#7566)
  chore(version): 2025.03.24.0
  feat(connector): [Coingate] implement refunds  (#7513)
  feat(connectors): [Redsys] add Psync and Rsync support (#7586)
  refactor(connector): [BRAINTREE] Pass email in payment requests (#7591)
  feat(webhook): Return events list and total_count on list initial delivery attempt call (#7243)
  ...
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.

4 participants