mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-30 09:38:33 +08:00 
			
		
		
		
	refactor(compatibility): map connector to routing in payments request for backward compatibility (#1339)
Co-authored-by: Tinu Hareesswar <tinuhareesswarr@gmail.com>
This commit is contained in:
		 Abhishek Marrivagu
					Abhishek Marrivagu
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							23458bc427
						
					
				
				
					commit
					166688a590
				
			| @ -125,7 +125,7 @@ impl From<Shipping> for payments::Address { | ||||
| pub struct StripePaymentIntentRequest { | ||||
|     pub id: Option<String>, | ||||
|     pub amount: Option<i64>, //amount in cents, hence passed as integer | ||||
|     pub connector: Option<Vec<api_enums::Connector>>, | ||||
|     pub connector: Option<Vec<api_enums::RoutableConnectors>>, | ||||
|     pub currency: Option<String>, | ||||
|     #[serde(rename = "amount_to_capture")] | ||||
|     pub amount_capturable: Option<i64>, | ||||
| @ -169,10 +169,22 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest { | ||||
|             } | ||||
|             None => (None, None), | ||||
|         }; | ||||
|  | ||||
|         let routable_connector: Option<api_enums::RoutableConnectors> = | ||||
|             item.connector.and_then(|v| v.into_iter().next()); | ||||
|  | ||||
|         let routing = routable_connector | ||||
|             .map(crate::types::api::RoutingAlgorithm::Single) | ||||
|             .map(|r| { | ||||
|                 serde_json::to_value(r) | ||||
|                     .into_report() | ||||
|                     .change_context(errors::ApiErrorResponse::InternalServerError) | ||||
|                     .attach_printable("converting to routing failed") | ||||
|             }) | ||||
|             .transpose()?; | ||||
|         let request = Ok(Self { | ||||
|             payment_id: item.id.map(payments::PaymentIdType::PaymentIntentId), | ||||
|             amount: item.amount.map(|amount| amount.into()), | ||||
|             connector: item.connector, | ||||
|             currency: item | ||||
|                 .currency | ||||
|                 .as_ref() | ||||
| @ -215,6 +227,7 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest { | ||||
|             setup_future_usage: item.setup_future_usage, | ||||
|             mandate_id: item.mandate_id, | ||||
|             off_session: item.off_session, | ||||
|             routing, | ||||
|             ..Self::default() | ||||
|         }); | ||||
|         request | ||||
|  | ||||
		Reference in New Issue
	
	Block a user