feat(router): Handle incoming webhooks adyen#9372
Conversation
Changed Files
|
crates/router/src/utils.rs
Outdated
| let payment_intent = match payment_intent { | ||
| Ok(intent) => intent, | ||
| Err(_) => return Ok(None), // Payment resource doesn't exist -> NoEffect | ||
| }; |
There was a problem hiding this comment.
nit : you can use ok_or to convert Result to Option
There was a problem hiding this comment.
We cannot use ok_or here as it is already in result format.
crates/router/src/utils.rs
Outdated
|
|
||
| Ok(Some(mca)) | ||
| } | ||
| webhooks::ObjectReferenceId::MandateId(mandate_id_type) => { |
There was a problem hiding this comment.
Do we need to handle this?
crates/router/src/utils.rs
Outdated
|
|
||
| Ok(Some(mca)) | ||
| } | ||
| webhooks::ObjectReferenceId::ExternalAuthenticationID(auth_id_type) => { |
There was a problem hiding this comment.
Same here, do we need to handle this?
crates/router/src/utils.rs
Outdated
| pub async fn is_webhook_valid( | ||
| state: &SessionState, | ||
| object_reference_id: webhooks::ObjectReferenceId, | ||
| merchant_context: &domain::MerchantContext, | ||
| connector_name: &str, | ||
| ) -> CustomResult<bool, errors::ApiErrorResponse> { |
There was a problem hiding this comment.
Where is this being called?
There was a problem hiding this comment.
removing this
config/config.example.toml
Outdated
| connectors_with_webhook_source_verification_call = "paypal" # List of connectors which has additional source verification api-call | ||
|
|
||
| [webhook_ack_connectors] | ||
| connectors_with_webhook_ack = "adyen" # List of connectors which requires the acknowledgement for received webhook |
8f1a6bc to
7045dfe
Compare
|
Have a look at this function. |
| [webhook_source_verification_call] | ||
| connectors_with_webhook_source_verification_call = "paypal" # List of connectors which has additional source verification api-call | ||
|
|
||
| [webhook_ack_connectors] |
There was a problem hiding this comment.
This shouldn't be required, we already have fn should_acknowledge_webhook_for_resource_not_found_errors on Connector enum
crates/router/src/utils.rs
Outdated
| } | ||
|
|
||
| #[cfg(feature = "v1")] | ||
| pub async fn get_authentication_from_authentication_id_type( |
There was a problem hiding this comment.
Why do we need to duplicate all these functions?
There was a problem hiding this comment.
it is required because based on if we found the authentication details we are acknowledging the connector for webhook. i can use this inside existing find_mca_from_authentication_id_type so that no rewriting is required.
| match result { | ||
| Ok((_, webhook_tracker, _)) => return Ok(webhook_tracker), | ||
| Err(e) => return Err(e), | ||
| match Box::pin(helper_utils::get_mca_for_webhook_ack_connectors( |
There was a problem hiding this comment.
Why do we need different getter for the same flow? Can't we use same function and handle the 404s?
There was a problem hiding this comment.
Maybe we could modify the existing function to check for resource's profile_id and send back None in case it does not belong?
There was a problem hiding this comment.
This might need to change the existing flow of the function get_mca_from_object_reference_id.
It currently only fetch mca no validation logics like in get_mca_for_webhook_ack_connectors.
94852a0 to
5e9f1d3
Compare
5e9f1d3 to
01ea211
Compare
01ea211 to
d5e3d07
Compare
Type of Change
Description
Add acknowledgement in adyen for incoming webhooks by sending status 200.
Additional Changes
Motivation and Context
How did you test it?
We need to create two profiles having same adyen account, both the profiles should return 200 to webhooks even if it doesnt belongs to them.
here i made two profiles:
Making below payments API:
Response:
Refund:
Response:
Checklist
cargo +nightly fmt --allcargo clippy