mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	Testability ddd repository (#55)
This commit is contained in:
		| @ -1,21 +1,24 @@ | ||||
| use crate::{connection::RedisPool, types::api}; | ||||
| use crate::{ | ||||
|     db::{get_and_deserialize_key, StorageInterface}, | ||||
|     types::api, | ||||
| }; | ||||
|  | ||||
| fn default_webhook_config() -> api::MerchantWebhookConfig { | ||||
|     std::collections::HashSet::from([api::IncomingWebhookEvent::PaymentIntentSuccess]) | ||||
| } | ||||
|  | ||||
| pub async fn lookup_webhook_event( | ||||
|     db: &dyn StorageInterface, | ||||
|     connector_id: &str, | ||||
|     merchant_id: &str, | ||||
|     event: &api::IncomingWebhookEvent, | ||||
|     conn: RedisPool, | ||||
| ) -> bool { | ||||
|     let redis_key = format!("whconf_{}_{}", merchant_id, connector_id); | ||||
|     let webhook_config: api::MerchantWebhookConfig = conn | ||||
|         .get_and_deserialize_key(&redis_key, "MerchantWebhookConfig") | ||||
|         .await | ||||
|         .map(|h| &h | &default_webhook_config()) | ||||
|         .unwrap_or_else(|_| default_webhook_config()); | ||||
|     let webhook_config: api::MerchantWebhookConfig = | ||||
|         get_and_deserialize_key(db, &redis_key, "MerchantWebhookConfig") | ||||
|             .await | ||||
|             .map(|h| &h | &default_webhook_config()) | ||||
|             .unwrap_or_else(|_| default_webhook_config()); | ||||
|  | ||||
|     webhook_config.contains(event) | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 kos-for-juspay
					kos-for-juspay