mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			767 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			767 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| 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,
 | |
| ) -> bool {
 | |
|     let redis_key = format!("whconf_{}_{}", merchant_id, connector_id);
 | |
|     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)
 | |
| }
 | 
