Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(payment_methods): remove storage_type from PaymentMethodSessionConfirmRequest and related logic (#11344)
Gaurav Rawat0e379acb370a
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 478807cb4e..48e2dfe22a 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -21464,14 +21464,6 @@"type": "string","description": "The return url to which the customer should be redirected to after adding the payment method","nullable": true- },- "storage_type": {- "allOf": [- {- "$ref": "#/components/schemas/StorageType"- }- ],- "nullable": true}}},@@ -21558,6 +21550,7 @@"id","expires_at","client_secret",+ "storage_type","keep_alive"],"properties": {@@ -21647,12 +21640,7 @@"nullable": true},"storage_type": {- "allOf": [- {- "$ref": "#/components/schemas/StorageType"- }- ],- "nullable": true+ "$ref": "#/components/schemas/StorageType"},"card_cvc_token_storage": {"allOf": [diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 05f3c8917f..709b79e419 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -3693,10 +3693,6 @@ pub struct PaymentMethodSessionConfirmRequest {/// The return url to which the customer should be redirected to after adding the payment method#[schema(value_type = Option<String>)]pub return_url: Option<common_utils::types::Url>,-- /// The storage type for the payment method- #[schema(value_type = Option<StorageType>)]- pub storage_type: Option<common_enums::StorageType>,}#[cfg(feature = "v2")]@@ -3757,8 +3753,8 @@ pub struct PaymentMethodSessionResponse {pub associated_token_id: Option<id_type::GlobalTokenId>,/// The storage type for the payment method- #[schema(value_type = Option<StorageType>)]- pub storage_type: Option<common_enums::StorageType>,+ #[schema(value_type = StorageType)]+ pub storage_type: common_enums::StorageType,/// Card CVC token storage details#[schema(value_type = Option<CardCVCTokenStorageDetails>)]diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 638a719330..08d0554428 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -4580,7 +4580,7 @@ pub async fn payment_methods_session_create(sdk_authorization,None,None,- Some(request.storage_type),+ request.storage_type,None,None,);@@ -4643,12 +4643,12 @@ pub async fn payment_methods_session_update(.attach_printable("Failed to update payment methods session in db")?;let response = transformers::generate_payment_method_session_response(- update_state_change,+ update_state_change.clone(),Secret::new("CLIENT_SECRET_REDACTED".to_string()),None, // sdk_authorization is not returned for non-create flowsNone, // TODO: send associated payments response based on the expandable paramNone,- None,+ update_state_change.storage_type,None,None,);@@ -4700,12 +4700,12 @@ pub async fn payment_methods_session_retrieve(.flatten();let response = transformers::generate_payment_method_session_response(- payment_method_session_domain_model,+ payment_method_session_domain_model.clone(),Secret::new("CLIENT_SECRET_REDACTED".to_string()),None, // sdk_authorization is not returned for non-create flowsNone, // TODO: send associated payments response based on the expandable paramNone,- None,+ payment_method_session_domain_model.storage_type,expiry.map(|time| {payment_methods::CardCVCTokenStorageDetails::generate_expiry_timestamp(time)}),@@ -4803,12 +4803,12 @@ pub async fn payment_methods_session_update_payment_method(.attach_printable("Failed to update saved payment method")?;let response = transformers::generate_payment_method_session_response(- updated_payment_method_session,+ updated_payment_method_session.clone(),Secret::new("CLIENT_SECRET_REDACTED".to_string()),None, // sdk_authorization is not returned for non-create flowsNone, // TODO: send associated payments response based on the expandable paramNone,- None,+ updated_payment_method_session.storage_type,update_response.card_cvc_token_storage,update_response.payment_method_data.clone(),);@@ -5003,10 +5003,7 @@ pub async fn payment_methods_session_confirm(}).or_else(|| payment_method_session_billing.clone());- let storage_type = get_storage_type_for_payment_method_create(- request.storage_type,- payment_method_session.storage_type,- )?;+ let storage_type = payment_method_session.storage_type;let create_payment_method_request = get_payment_method_create_request(request@@ -5142,7 +5139,7 @@ pub async fn payment_methods_session_confirm(None, // sdk_authorization is not returned for non-create flowspayments_response,(tokenization_response.flatten()),- Some(payment_method_response.storage_type),+ payment_method_response.storage_type,payment_method_response.card_cvc_token_storage,None,);@@ -5152,25 +5149,6 @@ pub async fn payment_methods_session_confirm())}-#[cfg(feature = "v2")]-pub fn get_storage_type_for_payment_method_create(- request_storage_type: Option<enums::StorageType>,- session_storage_type: enums::StorageType,-) -> RouterResult<enums::StorageType> {- match session_storage_type {- // If volatile return Volatile- enums::StorageType::Volatile => Ok(enums::StorageType::Volatile),-- // If persistent, validate that request_storage_type exists- enums::StorageType::Persistent => request_storage_type.ok_or(- errors::ApiErrorResponse::MissingRequiredField {- field_name: "storage_type",- }- .into(),- ),- }-}-#[cfg(feature = "v2")]impl pm_types::SavedPMLPaymentsInfo {pub async fn form_payments_info(diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex 6fbbd9b66f..10b343f0a6 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -1013,7 +1013,7 @@ pub fn generate_payment_method_session_response(sdk_authorization: Option<hyperswitch_domain_models::sdk_auth::SdkAuthorization>,associated_payment: Option<api_models::payments::PaymentsResponse>,tokenization_service_response: Option<api_models::tokenization::GenericTokenizationResponse>,- storage_type: Option<common_enums::StorageType>,+ storage_type: common_enums::StorageType,card_cvc_token_storage: Option<api_models::payment_methods::CardCVCTokenStorageDetails>,payment_method_data: Option<api_models::payment_methods::PaymentMethodResponseData>,) -> api_models::payment_methods::PaymentMethodSessionResponse {