mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	feat(webhooks): store request and response payloads in events table (#4029)
				
					
				
			This commit is contained in:
		| @ -120,3 +120,27 @@ pub async fn construct_webhook_router_data<'a>( | ||||
|     }; | ||||
|     Ok(router_data) | ||||
| } | ||||
|  | ||||
| #[inline] | ||||
| pub(crate) fn get_idempotent_event_id( | ||||
|     primary_object_id: &str, | ||||
|     event_type: crate::types::storage::enums::EventType, | ||||
|     delivery_attempt: super::types::WebhookDeliveryAttempt, | ||||
| ) -> String { | ||||
|     use super::types::WebhookDeliveryAttempt; | ||||
|  | ||||
|     const EVENT_ID_SUFFIX_LENGTH: usize = 8; | ||||
|  | ||||
|     let common_prefix = format!("{primary_object_id}_{event_type}"); | ||||
|     match delivery_attempt { | ||||
|         WebhookDeliveryAttempt::InitialAttempt => common_prefix, | ||||
|         WebhookDeliveryAttempt::AutomaticRetry => { | ||||
|             common_utils::generate_id(EVENT_ID_SUFFIX_LENGTH, &common_prefix) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[inline] | ||||
| pub(crate) fn generate_event_id() -> String { | ||||
|     common_utils::generate_time_ordered_id("evt") | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sanchith Hegde
					Sanchith Hegde