mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	feat(payment_methods): add support to pass apple pay recurring details to obtain apple pay merchant token (#6770)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		| @ -32,10 +32,16 @@ pub trait PayoutAttemptInterface {} | ||||
| pub trait PayoutsInterface {} | ||||
|  | ||||
| use api_models::payments::{ | ||||
|     ApplePayRecurringDetails as ApiApplePayRecurringDetails, | ||||
|     ApplePayRegularBillingDetails as ApiApplePayRegularBillingDetails, | ||||
|     FeatureMetadata as ApiFeatureMetadata, OrderDetailsWithAmount as ApiOrderDetailsWithAmount, | ||||
|     RecurringPaymentIntervalUnit as ApiRecurringPaymentIntervalUnit, | ||||
|     RedirectResponse as ApiRedirectResponse, | ||||
| }; | ||||
| use diesel_models::types::{FeatureMetadata, OrderDetailsWithAmount, RedirectResponse}; | ||||
| use diesel_models::types::{ | ||||
|     ApplePayRecurringDetails, ApplePayRegularBillingDetails, FeatureMetadata, | ||||
|     OrderDetailsWithAmount, RecurringPaymentIntervalUnit, RedirectResponse, | ||||
| }; | ||||
|  | ||||
| #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)] | ||||
| pub enum RemoteStorageObject<T: ForeignIDRef> { | ||||
| @ -75,10 +81,13 @@ impl ApiModelToDieselModelConvertor<ApiFeatureMetadata> for FeatureMetadata { | ||||
|         let ApiFeatureMetadata { | ||||
|             redirect_response, | ||||
|             search_tags, | ||||
|             apple_pay_recurring_details, | ||||
|         } = from; | ||||
|         Self { | ||||
|             redirect_response: redirect_response.map(RedirectResponse::convert_from), | ||||
|             search_tags, | ||||
|             apple_pay_recurring_details: apple_pay_recurring_details | ||||
|                 .map(ApplePayRecurringDetails::convert_from), | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -86,11 +95,14 @@ impl ApiModelToDieselModelConvertor<ApiFeatureMetadata> for FeatureMetadata { | ||||
|         let Self { | ||||
|             redirect_response, | ||||
|             search_tags, | ||||
|             apple_pay_recurring_details, | ||||
|         } = self; | ||||
|         ApiFeatureMetadata { | ||||
|             redirect_response: redirect_response | ||||
|                 .map(|redirect_response| redirect_response.convert_back()), | ||||
|             search_tags, | ||||
|             apple_pay_recurring_details: apple_pay_recurring_details | ||||
|                 .map(|value| value.convert_back()), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -119,6 +131,77 @@ impl ApiModelToDieselModelConvertor<ApiRedirectResponse> for RedirectResponse { | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl ApiModelToDieselModelConvertor<ApiRecurringPaymentIntervalUnit> | ||||
|     for RecurringPaymentIntervalUnit | ||||
| { | ||||
|     fn convert_from(from: ApiRecurringPaymentIntervalUnit) -> Self { | ||||
|         match from { | ||||
|             ApiRecurringPaymentIntervalUnit::Year => Self::Year, | ||||
|             ApiRecurringPaymentIntervalUnit::Month => Self::Month, | ||||
|             ApiRecurringPaymentIntervalUnit::Day => Self::Day, | ||||
|             ApiRecurringPaymentIntervalUnit::Hour => Self::Hour, | ||||
|             ApiRecurringPaymentIntervalUnit::Minute => Self::Minute, | ||||
|         } | ||||
|     } | ||||
|     fn convert_back(self) -> ApiRecurringPaymentIntervalUnit { | ||||
|         match self { | ||||
|             Self::Year => ApiRecurringPaymentIntervalUnit::Year, | ||||
|             Self::Month => ApiRecurringPaymentIntervalUnit::Month, | ||||
|             Self::Day => ApiRecurringPaymentIntervalUnit::Day, | ||||
|             Self::Hour => ApiRecurringPaymentIntervalUnit::Hour, | ||||
|             Self::Minute => ApiRecurringPaymentIntervalUnit::Minute, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl ApiModelToDieselModelConvertor<ApiApplePayRegularBillingDetails> | ||||
|     for ApplePayRegularBillingDetails | ||||
| { | ||||
|     fn convert_from(from: ApiApplePayRegularBillingDetails) -> Self { | ||||
|         Self { | ||||
|             label: from.label, | ||||
|             recurring_payment_start_date: from.recurring_payment_start_date, | ||||
|             recurring_payment_end_date: from.recurring_payment_end_date, | ||||
|             recurring_payment_interval_unit: from | ||||
|                 .recurring_payment_interval_unit | ||||
|                 .map(RecurringPaymentIntervalUnit::convert_from), | ||||
|             recurring_payment_interval_count: from.recurring_payment_interval_count, | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn convert_back(self) -> ApiApplePayRegularBillingDetails { | ||||
|         ApiApplePayRegularBillingDetails { | ||||
|             label: self.label, | ||||
|             recurring_payment_start_date: self.recurring_payment_start_date, | ||||
|             recurring_payment_end_date: self.recurring_payment_end_date, | ||||
|             recurring_payment_interval_unit: self | ||||
|                 .recurring_payment_interval_unit | ||||
|                 .map(|value| value.convert_back()), | ||||
|             recurring_payment_interval_count: self.recurring_payment_interval_count, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl ApiModelToDieselModelConvertor<ApiApplePayRecurringDetails> for ApplePayRecurringDetails { | ||||
|     fn convert_from(from: ApiApplePayRecurringDetails) -> Self { | ||||
|         Self { | ||||
|             payment_description: from.payment_description, | ||||
|             regular_billing: ApplePayRegularBillingDetails::convert_from(from.regular_billing), | ||||
|             billing_agreement: from.billing_agreement, | ||||
|             management_url: from.management_url, | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn convert_back(self) -> ApiApplePayRecurringDetails { | ||||
|         ApiApplePayRecurringDetails { | ||||
|             payment_description: self.payment_description, | ||||
|             regular_billing: self.regular_billing.convert_back(), | ||||
|             billing_agreement: self.billing_agreement, | ||||
|             management_url: self.management_url, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl ApiModelToDieselModelConvertor<ApiOrderDetailsWithAmount> for OrderDetailsWithAmount { | ||||
|     fn convert_from(from: ApiOrderDetailsWithAmount) -> Self { | ||||
|         let ApiOrderDetailsWithAmount { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shankar Singh C
					Shankar Singh C