mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	enhance(storage_models): delete client secret when status is succeeded, failed, cancelled (#724)
This commit is contained in:
		| @ -1126,7 +1126,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for CancelRequest { | |||||||
|             Some(c) => Some( |             Some(c) => Some( | ||||||
|                 CancellationReason::from_str(c) |                 CancellationReason::from_str(c) | ||||||
|                     .into_report() |                     .into_report() | ||||||
|                     .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, |                     .change_context(errors::ConnectorError::RequestEncodingFailed)?, | ||||||
|             ), |             ), | ||||||
|             None => None, |             None => None, | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -178,7 +178,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|                 status: Some(status), |                 status: Some(status), | ||||||
|                 setup_future_usage, |                 setup_future_usage, | ||||||
|                 customer_id, |                 customer_id, | ||||||
|                 client_secret: make_client_secret_null_if_success(Some(status)), |                 client_secret: make_client_secret_null_based_on_status(status), | ||||||
|                 shipping_address_id, |                 shipping_address_id, | ||||||
|                 billing_address_id, |                 billing_address_id, | ||||||
|                 modified_at: Some(common_utils::date_time::now()), |                 modified_at: Some(common_utils::date_time::now()), | ||||||
| @ -199,7 +199,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|             } => Self { |             } => Self { | ||||||
|                 return_url, |                 return_url, | ||||||
|                 status, |                 status, | ||||||
|                 client_secret: make_client_secret_null_if_success(status), |                 client_secret: status.and_then(make_client_secret_null_based_on_status), | ||||||
|                 customer_id, |                 customer_id, | ||||||
|                 shipping_address_id, |                 shipping_address_id, | ||||||
|                 billing_address_id, |                 billing_address_id, | ||||||
| @ -209,6 +209,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|             PaymentIntentUpdate::PGStatusUpdate { status } => Self { |             PaymentIntentUpdate::PGStatusUpdate { status } => Self { | ||||||
|                 status: Some(status), |                 status: Some(status), | ||||||
|                 modified_at: Some(common_utils::date_time::now()), |                 modified_at: Some(common_utils::date_time::now()), | ||||||
|  |                 client_secret: make_client_secret_null_based_on_status(status), | ||||||
|                 ..Default::default() |                 ..Default::default() | ||||||
|             }, |             }, | ||||||
|             PaymentIntentUpdate::MerchantStatusUpdate { |             PaymentIntentUpdate::MerchantStatusUpdate { | ||||||
| @ -217,7 +218,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|                 billing_address_id, |                 billing_address_id, | ||||||
|             } => Self { |             } => Self { | ||||||
|                 status: Some(status), |                 status: Some(status), | ||||||
|                 client_secret: make_client_secret_null_if_success(Some(status)), |                 client_secret: make_client_secret_null_based_on_status(status), | ||||||
|                 shipping_address_id, |                 shipping_address_id, | ||||||
|                 billing_address_id, |                 billing_address_id, | ||||||
|                 modified_at: Some(common_utils::date_time::now()), |                 modified_at: Some(common_utils::date_time::now()), | ||||||
| @ -237,7 +238,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|                 amount_captured, |                 amount_captured, | ||||||
|                 // customer_id, |                 // customer_id, | ||||||
|                 return_url, |                 return_url, | ||||||
|                 client_secret: make_client_secret_null_if_success(Some(status)), |                 client_secret: make_client_secret_null_based_on_status(status), | ||||||
|                 modified_at: Some(common_utils::date_time::now()), |                 modified_at: Some(common_utils::date_time::now()), | ||||||
|                 ..Default::default() |                 ..Default::default() | ||||||
|             }, |             }, | ||||||
| @ -245,12 +246,17 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| fn make_client_secret_null_if_success( | fn make_client_secret_null_based_on_status( | ||||||
|     status: Option<storage_enums::IntentStatus>, |     status: storage_enums::IntentStatus, | ||||||
| ) -> Option<Option<String>> { | ) -> Option<Option<String>> { | ||||||
|     if status == Some(storage_enums::IntentStatus::Succeeded) { |     match status { | ||||||
|         Some(None) |         storage_enums::IntentStatus::Succeeded | ||||||
|     } else { |         | storage_enums::IntentStatus::Failed | ||||||
|         None |         | storage_enums::IntentStatus::Cancelled => Some(None), | ||||||
|  |         storage_enums::IntentStatus::Processing | ||||||
|  |         | storage_enums::IntentStatus::RequiresCustomerAction | ||||||
|  |         | storage_enums::IntentStatus::RequiresPaymentMethod | ||||||
|  |         | storage_enums::IntentStatus::RequiresConfirmation | ||||||
|  |         | storage_enums::IntentStatus::RequiresCapture => None, | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Abhishek
					Abhishek