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

feat(router): added new webhook URL to support merchant_connector_id #2006

Merged
merged 20 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7421eff
feat(router): added new webhook URL to support business_profile
sahkal Aug 23, 2023
2baf238
refactor(router): syned with main
sahkal Aug 25, 2023
991589b
fix(router): changed webhook route based on connector_id
sahkal Aug 25, 2023
1365cac
fix(router): fixed webhook endpoint to support business_profile for m…
sahkal Aug 28, 2023
385309d
refactor(router): removed unnecessary files
sahkal Aug 28, 2023
de7705a
refactor(router): syned with main
sahkal Aug 28, 2023
0d682fd
refactor(router) : added log for mca fetch failure
sahkal Aug 31, 2023
ab7b41f
Merge branch 'main' into webhook-support-for-business-profile
sahkal Aug 31, 2023
94220b9
Merge branch 'main' of https://github.com/juspay/hyperswitch into web…
sahkal Aug 31, 2023
eed6563
refactor(router): fixed cargo clippy issue
sahkal Aug 31, 2023
3b814d1
Merge branch 'webhook-support-for-business-profile' of https://github…
sahkal Aug 31, 2023
9cce06a
refactor(webhook): addressed pr comments
sahkal Sep 4, 2023
167a6c2
refactor(webhooks): resolved merge conflicts
sahkal Sep 4, 2023
51c8ae9
refactor(webhook): addressed pr comments and fixed fetching func for …
sahkal Sep 5, 2023
3c863b0
refactor(webhook): resolved merge conflicts
sahkal Sep 12, 2023
643b57a
Merge branch 'main' into webhook-support-for-business-profile
Narayanbhat166 Sep 12, 2023
a0ba724
chore: raise errors instead of ignoring them
Narayanbhat166 Sep 12, 2023
7d0bfe7
chore: rename variable
Narayanbhat166 Sep 12, 2023
7af1540
chore: rename variable
Narayanbhat166 Sep 12, 2023
2281089
chore: cargo clippy
Narayanbhat166 Sep 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ pub struct MerchantConnectorCreate {
}
}))]
pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,

/// Identifier for the business profile, if not provided default will be chosen from merchant account
pub profile_id: Option<String>,
}
Expand Down
9 changes: 2 additions & 7 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::{
self,
errors::{self, CustomResult},
},
db::StorageInterface,
headers, logger, routes,
services::{
self,
Expand Down Expand Up @@ -1398,23 +1397,19 @@ impl api::IncomingWebhook for Adyen {

async fn verify_webhook_source(
&self,
db: &dyn StorageInterface,
request: &api::IncomingWebhookRequestDetails<'_>,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_label: &str,
key_store: &domain::MerchantKeyStore,
object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
let signature = self
.get_webhook_source_verification_signature(request)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
db,
merchant_account,
connector_label,
key_store,
object_reference_id,
merchant_connector_account,
)
.await
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Expand Down
9 changes: 2 additions & 7 deletions crates/router/src/connector/cashtocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
configs::settings::{self},
connector::{utils as connector_utils, utils as conn_utils},
core::errors::{self, CustomResult},
db::StorageInterface,
headers,
services::{
self,
Expand Down Expand Up @@ -331,23 +330,19 @@ impl api::IncomingWebhook for Cashtocode {

async fn verify_webhook_source(
&self,
db: &dyn StorageInterface,
request: &api::IncomingWebhookRequestDetails<'_>,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_label: &str,
key_store: &domain::MerchantKeyStore,
object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
let signature = self
.get_webhook_source_verification_signature(request)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
db,
merchant_account,
connector_label,
key_store,
object_reference_id,
merchant_connector_account,
)
.await
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Expand Down
14 changes: 5 additions & 9 deletions crates/router/src/connector/payme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use crate::{
errors::{self, CustomResult},
payments,
},
db, headers,
headers,
services::{self, request, ConnectorIntegration, ConnectorValidation},
types::{
self,
api::{self, ConnectorCommon, ConnectorCommonExt},
ErrorResponse, Response,
domain, ErrorResponse, Response,
},
utils::{self, BytesExt},
};
Expand Down Expand Up @@ -927,12 +927,10 @@ impl api::IncomingWebhook for Payme {

async fn verify_webhook_source(
&self,
db: &dyn db::StorageInterface,
request: &api::IncomingWebhookRequestDetails<'_>,
merchant_account: &types::domain::MerchantAccount,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_label: &str,
key_store: &types::domain::MerchantKeyStore,
object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
let algorithm = self
.get_webhook_source_verification_algorithm(request)
Expand All @@ -944,11 +942,9 @@ impl api::IncomingWebhook for Payme {

let connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
db,
merchant_account,
connector_label,
key_store,
object_reference_id,
merchant_connector_account,
)
.await
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Expand Down
5 changes: 1 addition & 4 deletions crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use crate::{
errors::{self, CustomResult},
payments,
},
db::StorageInterface,
headers,
services::{
self,
Expand Down Expand Up @@ -915,12 +914,10 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
impl api::IncomingWebhook for Paypal {
async fn verify_webhook_source(
&self,
_db: &dyn StorageInterface,
_request: &api::IncomingWebhookRequestDetails<'_>,
_merchant_account: &domain::MerchantAccount,
_merchant_connector_account: domain::MerchantConnectorAccount,
_connector_label: &str,
_key_store: &domain::MerchantKeyStore,
_object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
Ok(false) // Verify webhook source is not implemented for Paypal it requires additional apicall this function needs to be modified once we have a way to verify webhook source
}
Expand Down
9 changes: 2 additions & 7 deletions crates/router/src/connector/rapyd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{
connector::{utils as connector_utils, utils as conn_utils},
consts,
core::errors::{self, CustomResult},
db::StorageInterface,
headers, logger,
services::{
self,
Expand Down Expand Up @@ -762,23 +761,19 @@ impl api::IncomingWebhook for Rapyd {

async fn verify_webhook_source(
&self,
db: &dyn StorageInterface,
request: &api::IncomingWebhookRequestDetails<'_>,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_label: &str,
key_store: &domain::MerchantKeyStore,
object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
let signature = self
.get_webhook_source_verification_signature(request)
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
let connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
db,
merchant_account,
connector_label,
key_store,
object_reference_id,
merchant_connector_account,
)
.await
.change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?;
Expand Down
5 changes: 1 addition & 4 deletions crates/router/src/connector/stax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{
configs::settings,
consts,
core::errors::{self, CustomResult},
db::StorageInterface,
headers,
services::{
self,
Expand Down Expand Up @@ -773,12 +772,10 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
impl api::IncomingWebhook for Stax {
async fn verify_webhook_source(
&self,
_db: &dyn StorageInterface,
_request: &api::IncomingWebhookRequestDetails<'_>,
_merchant_account: &domain::MerchantAccount,
_merchant_connector_account: domain::MerchantConnectorAccount,
_connector_label: &str,
_key_store: &domain::MerchantKeyStore,
_object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
Ok(false)
}
Expand Down
9 changes: 2 additions & 7 deletions crates/router/src/connector/zen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{
errors::{self, CustomResult},
payments,
},
db::StorageInterface,
headers,
services::{
self,
Expand Down Expand Up @@ -563,23 +562,19 @@ impl api::IncomingWebhook for Zen {

async fn verify_webhook_source(
&self,
db: &dyn StorageInterface,
request: &api::IncomingWebhookRequestDetails<'_>,
merchant_account: &domain::MerchantAccount,
merchant_connector_account: domain::MerchantConnectorAccount,
connector_label: &str,
key_store: &domain::MerchantKeyStore,
object_reference_id: api_models::webhooks::ObjectReferenceId,
) -> CustomResult<bool, errors::ConnectorError> {
let algorithm = self.get_webhook_source_verification_algorithm(request)?;

let signature = self.get_webhook_source_verification_signature(request)?;
let mut connector_webhook_secrets = self
.get_webhook_source_verification_merchant_secret(
db,
merchant_account,
connector_label,
key_store,
object_reference_id,
merchant_connector_account,
)
.await?;
let mut message = self.get_webhook_source_verification_message(
Expand Down
Loading
Loading