mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	fix(router): make request_incremental_authorization optional in payment_intent (#3086)
				
					
				
			This commit is contained in:
		 Sai Harsha Vardhan
					Sai Harsha Vardhan
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							129b1e55bd
						
					
				
				
					commit
					f7da59d06a
				
			| @ -50,7 +50,7 @@ pub struct PaymentIntent { | ||||
|  | ||||
|     pub updated_by: String, | ||||
|     pub surcharge_applicable: Option<bool>, | ||||
|     pub request_incremental_authorization: storage_enums::RequestIncrementalAuthorization, | ||||
|     pub request_incremental_authorization: Option<storage_enums::RequestIncrementalAuthorization>, | ||||
|     pub incremental_authorization_allowed: Option<bool>, | ||||
|     pub authorization_count: Option<i32>, | ||||
| } | ||||
|  | ||||
| @ -107,7 +107,7 @@ pub struct PaymentIntentNew { | ||||
|  | ||||
|     pub updated_by: String, | ||||
|     pub surcharge_applicable: Option<bool>, | ||||
|     pub request_incremental_authorization: storage_enums::RequestIncrementalAuthorization, | ||||
|     pub request_incremental_authorization: Option<storage_enums::RequestIncrementalAuthorization>, | ||||
|     pub incremental_authorization_allowed: Option<bool>, | ||||
|     pub authorization_count: Option<i32>, | ||||
| } | ||||
|  | ||||
| @ -52,7 +52,7 @@ pub struct PaymentIntent { | ||||
|  | ||||
|     pub updated_by: String, | ||||
|     pub surcharge_applicable: Option<bool>, | ||||
|     pub request_incremental_authorization: RequestIncrementalAuthorization, | ||||
|     pub request_incremental_authorization: Option<RequestIncrementalAuthorization>, | ||||
|     pub incremental_authorization_allowed: Option<bool>, | ||||
|     pub authorization_count: Option<i32>, | ||||
| } | ||||
| @ -109,7 +109,7 @@ pub struct PaymentIntentNew { | ||||
|     pub payment_confirm_source: Option<storage_enums::PaymentSource>, | ||||
|     pub updated_by: String, | ||||
|     pub surcharge_applicable: Option<bool>, | ||||
|     pub request_incremental_authorization: RequestIncrementalAuthorization, | ||||
|     pub request_incremental_authorization: Option<RequestIncrementalAuthorization>, | ||||
|     pub incremental_authorization_allowed: Option<bool>, | ||||
|     pub authorization_count: Option<i32>, | ||||
| } | ||||
|  | ||||
| @ -703,7 +703,7 @@ diesel::table! { | ||||
|         #[max_length = 32] | ||||
|         updated_by -> Varchar, | ||||
|         surcharge_applicable -> Nullable<Bool>, | ||||
|         request_incremental_authorization -> RequestIncrementalAuthorization, | ||||
|         request_incremental_authorization -> Nullable<RequestIncrementalAuthorization>, | ||||
|         incremental_authorization_allowed -> Nullable<Bool>, | ||||
|         authorization_count -> Nullable<Int4>, | ||||
|     } | ||||
|  | ||||
| @ -2661,8 +2661,9 @@ mod tests { | ||||
|             payment_confirm_source: None, | ||||
|             surcharge_applicable: None, | ||||
|             updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(), | ||||
|             request_incremental_authorization: | ||||
|             request_incremental_authorization: Some( | ||||
|                 common_enums::RequestIncrementalAuthorization::default(), | ||||
|             ), | ||||
|             incremental_authorization_allowed: None, | ||||
|             authorization_count: None, | ||||
|         }; | ||||
| @ -2715,8 +2716,9 @@ mod tests { | ||||
|             payment_confirm_source: None, | ||||
|             surcharge_applicable: None, | ||||
|             updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(), | ||||
|             request_incremental_authorization: | ||||
|             request_incremental_authorization: Some( | ||||
|                 common_enums::RequestIncrementalAuthorization::default(), | ||||
|             ), | ||||
|             incremental_authorization_allowed: None, | ||||
|             authorization_count: None, | ||||
|         }; | ||||
| @ -2769,8 +2771,9 @@ mod tests { | ||||
|             payment_confirm_source: None, | ||||
|             surcharge_applicable: None, | ||||
|             updated_by: storage_enums::MerchantStorageScheme::PostgresOnly.to_string(), | ||||
|             request_incremental_authorization: | ||||
|             request_incremental_authorization: Some( | ||||
|                 common_enums::RequestIncrementalAuthorization::default(), | ||||
|             ), | ||||
|             incremental_authorization_allowed: None, | ||||
|             authorization_count: None, | ||||
|         }; | ||||
|  | ||||
| @ -1062,7 +1062,8 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz | ||||
|                 payment_data | ||||
|                     .payment_intent | ||||
|                     .request_incremental_authorization, | ||||
|                 RequestIncrementalAuthorization::True | RequestIncrementalAuthorization::Default | ||||
|                 Some(RequestIncrementalAuthorization::True) | ||||
|                     | Some(RequestIncrementalAuthorization::Default) | ||||
|             ), | ||||
|         }) | ||||
|     } | ||||
| @ -1350,7 +1351,8 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ | ||||
|                 payment_data | ||||
|                     .payment_intent | ||||
|                     .request_incremental_authorization, | ||||
|                 RequestIncrementalAuthorization::True | RequestIncrementalAuthorization::Default | ||||
|                 Some(RequestIncrementalAuthorization::True) | ||||
|                     | Some(RequestIncrementalAuthorization::Default) | ||||
|             ), | ||||
|         }) | ||||
|     } | ||||
|  | ||||
| @ -1066,8 +1066,8 @@ pub fn get_flow_name<F>() -> RouterResult<String> { | ||||
| pub fn get_request_incremental_authorization_value( | ||||
|     request_incremental_authorization: Option<bool>, | ||||
|     capture_method: Option<common_enums::CaptureMethod>, | ||||
| ) -> RouterResult<RequestIncrementalAuthorization> { | ||||
|     request_incremental_authorization | ||||
| ) -> RouterResult<Option<RequestIncrementalAuthorization>> { | ||||
|     Some(request_incremental_authorization | ||||
|         .map(|request_incremental_authorization| { | ||||
|             if request_incremental_authorization { | ||||
|                 if capture_method == Some(common_enums::CaptureMethod::Automatic) { | ||||
| @ -1078,14 +1078,16 @@ pub fn get_request_incremental_authorization_value( | ||||
|                 Ok(RequestIncrementalAuthorization::False) | ||||
|             } | ||||
|         }) | ||||
|         .unwrap_or(Ok(RequestIncrementalAuthorization::default())) | ||||
|         .unwrap_or(Ok(RequestIncrementalAuthorization::default()))).transpose() | ||||
| } | ||||
|  | ||||
| pub fn get_incremental_authorization_allowed_value( | ||||
|     incremental_authorization_allowed: Option<bool>, | ||||
|     request_incremental_authorization: RequestIncrementalAuthorization, | ||||
|     request_incremental_authorization: Option<RequestIncrementalAuthorization>, | ||||
| ) -> Option<bool> { | ||||
|     if request_incremental_authorization == common_enums::RequestIncrementalAuthorization::False { | ||||
|     if request_incremental_authorization | ||||
|         == Some(common_enums::RequestIncrementalAuthorization::False) | ||||
|     { | ||||
|         Some(false) | ||||
|     } else { | ||||
|         incremental_authorization_allowed | ||||
|  | ||||
| @ -0,0 +1,2 @@ | ||||
| -- This file should undo anything in `up.sql` | ||||
| ALTER TABLE payment_intent ALTER COLUMN request_incremental_authorization SET NOT NULL; | ||||
| @ -0,0 +1,2 @@ | ||||
| -- Your SQL goes here | ||||
| ALTER TABLE payment_intent ALTER COLUMN request_incremental_authorization DROP NOT NULL; | ||||
		Reference in New Issue
	
	Block a user