mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	feat(payment_methods_v2): Payment methods v2 API models (#5564)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -17,7 +17,11 @@ use crate::{ | ||||
|     types::api::{customers as customer_types, payment_methods}, | ||||
| }; | ||||
|  | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "customer_v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| #[instrument(skip_all, fields(flow = ?Flow::CustomersCreate))] | ||||
| pub async fn customer_create( | ||||
|     state: web::Data<routes::AppState>, | ||||
| @ -59,7 +63,11 @@ pub async fn customer_create( | ||||
|     .await | ||||
| } | ||||
|  | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "customer_v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| #[instrument(skip_all, fields(flow = ?Flow::CustomersRetrieve))] | ||||
| pub async fn customer_retrieve( | ||||
|     state: web::Data<routes::AppState>, | ||||
| @ -93,7 +101,11 @@ pub async fn customer_retrieve( | ||||
|     .await | ||||
| } | ||||
|  | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "customer_v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| #[instrument(skip_all, fields(flow = ?Flow::CustomersUpdate))] | ||||
| pub async fn customer_update( | ||||
|     state: web::Data<routes::AppState>, | ||||
| @ -145,7 +157,11 @@ pub async fn customer_update( | ||||
|     .await | ||||
| } | ||||
|  | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "customer_v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| #[instrument(skip_all, fields(flow = ?Flow::CustomersDelete))] | ||||
| pub async fn customer_delete( | ||||
|     state: web::Data<routes::AppState>, | ||||
| @ -179,7 +195,11 @@ pub async fn customer_delete( | ||||
|     .await | ||||
| } | ||||
|  | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "customer_v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| #[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))] | ||||
| pub async fn list_customer_payment_method_api( | ||||
|     state: web::Data<routes::AppState>, | ||||
|  | ||||
| @ -1,6 +1,11 @@ | ||||
| use std::{convert::From, default::Default}; | ||||
|  | ||||
| use api_models::{payment_methods as api_types, payments}; | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| use api_models::payment_methods as api_types; | ||||
| use api_models::payments; | ||||
| #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "customer_v2")))] | ||||
| use common_utils::{crypto::Encryptable, date_time}; | ||||
| use common_utils::{ | ||||
| @ -209,6 +214,10 @@ pub struct CardDetails { | ||||
|     pub fingerprint: Option<masking::Secret<String>>, | ||||
| } | ||||
|  | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| impl From<api::CustomerPaymentMethodsListResponse> for CustomerPaymentMethodListResponse { | ||||
|     fn from(item: api::CustomerPaymentMethodsListResponse) -> Self { | ||||
|         let customer_payment_methods = item.customer_payment_methods; | ||||
| @ -223,27 +232,15 @@ impl From<api::CustomerPaymentMethodsListResponse> for CustomerPaymentMethodList | ||||
|     } | ||||
| } | ||||
|  | ||||
| // Check this in review | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| impl From<api_types::CustomerPaymentMethod> for PaymentMethodData { | ||||
|     fn from(item: api_types::CustomerPaymentMethod) -> Self { | ||||
|         #[cfg(all( | ||||
|             any(feature = "v1", feature = "v2"), | ||||
|             not(feature = "payment_methods_v2") | ||||
|         ))] | ||||
|         let card = item.card.map(From::from); | ||||
|         #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] | ||||
|         let card = match item.payment_method_data { | ||||
|             Some(api_types::PaymentMethodListData::Card(card)) => Some(CardDetails::from(card)), | ||||
|             _ => None, | ||||
|         }; | ||||
|         Self { | ||||
|             #[cfg(all( | ||||
|                 any(feature = "v1", feature = "v2"), | ||||
|                 not(feature = "payment_methods_v2") | ||||
|             ))] | ||||
|             id: Some(item.payment_token), | ||||
|             #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] | ||||
|             id: item.payment_token, | ||||
|             object: "payment_method", | ||||
|             card, | ||||
|             created: item.created, | ||||
| @ -251,6 +248,10 @@ impl From<api_types::CustomerPaymentMethod> for PaymentMethodData { | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[cfg(all( | ||||
|     any(feature = "v1", feature = "v2"), | ||||
|     not(feature = "payment_methods_v2") | ||||
| ))] | ||||
| impl From<api_types::CardDetailFromLocker> for CardDetails { | ||||
|     fn from(item: api_types::CardDetailFromLocker) -> Self { | ||||
|         Self { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sarthak Soni
					Sarthak Soni