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
fix(core): [Network Token] Check Network Token Status Response Type Fix (#10354)
Sagnik Mitra46cd272c522c
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 7529ebd4ad..8ec05d2ea9 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -15805,11 +15805,6 @@"type": "object","required": ["status",- "token_expiry_month",- "token_expiry_year",- "card_last_four",- "token_last_four",- "card_expiry","payment_method_id","customer_id"],@@ -15819,23 +15814,33 @@},"token_expiry_month": {"type": "string",- "description": "The expiry month of the network token if active"+ "description": "The expiry month of the network token if active",+ "nullable": true},"token_expiry_year": {"type": "string",- "description": "The expiry year of the network token if active"+ "description": "The expiry year of the network token if active",+ "nullable": true},"card_last_four": {"type": "string",- "description": "The last four digits of the card"+ "description": "The last four digits of the card if active",+ "nullable": true},"token_last_four": {"type": "string",- "description": "The last four digits of the network token"+ "description": "The last four digits of the network token if active",+ "nullable": true+ },+ "card_expiry_month": {+ "type": "string",+ "description": "The expiry month of the card if active",+ "nullable": true},- "card_expiry": {+ "card_expiry_year": {"type": "string",- "description": "The expiry date of the card in MM/YY format"+ "description": "The expiry year of the card if active",+ "nullable": true},"payment_method_id": {"type": "string",@@ -26829,8 +26834,10 @@"type": "string","enum": ["ACTIVE",+ "INACTIVE","SUSPENDED",- "DEACTIVATED"+ "EXPIRED",+ "DELETED"]},"TokenType": {diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rsindex c9dfca3298..2b09009d1c 100644--- a/crates/api_models/src/enums.rs+++ b/crates/api_models/src/enums.rs@@ -525,8 +525,12 @@ impl From<PermissionScope> for ReconPermissionScope {pub enum TokenStatus {/// Indicates that the token is active and can be used for paymentsActive,+ /// Indicates that the token is inactive and can't be used for payments+ Inactive,/// Indicates that the token is suspended from network's end for some reason and can't be used for payments until it is re-activatedSuspended,- /// Indicates that the token is deactivated and further can't be used for payments- Deactivated,+ /// Indicates that the token is expired and can't be used for payments+ Expired,+ /// Indicates that the token is deleted and further can't be used for payments+ Deleted,}diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 9f3cf2c422..06fd914f8c 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -3381,21 +3381,26 @@ pub struct NetworkTokenStatusCheckSuccessResponse {pub status: api_enums::TokenStatus,/// The expiry month of the network token if active- #[schema(value_type = String)]- pub token_expiry_month: masking::Secret<String>,+ #[schema(value_type = Option<String>)]+ pub token_expiry_month: Option<masking::Secret<String>>,/// The expiry year of the network token if active- #[schema(value_type = String)]- pub token_expiry_year: masking::Secret<String>,+ #[schema(value_type = Option<String>)]+ pub token_expiry_year: Option<masking::Secret<String>>,++ /// The last four digits of the card if active+ pub card_last_four: Option<String>,- /// The last four digits of the card- pub card_last_four: String,+ /// The last four digits of the network token if active+ pub token_last_four: Option<String>,- /// The last four digits of the network token- pub token_last_four: String,+ /// The expiry month of the card if active+ #[schema(value_type = Option<String>)]+ pub card_expiry_month: Option<masking::Secret<String>>,- /// The expiry date of the card in MM/YY format- pub card_expiry: String,+ /// The expiry year of the card if active+ #[schema(value_type = Option<String>)]+ pub card_expiry_year: Option<masking::Secret<String>>,/// The payment method ID that was checked#[schema(value_type = String, example = "12345_pm_019959146f92737389eb6927ce1eb7dc")]diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex ca96fe5333..4573670ab7 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -3921,20 +3921,23 @@ pub async fn check_network_token_status(match network_tokenization::do_status_check_for_network_token(&state, &payment_method).await{Ok(network_token_details) => {- let status = match network_token_details.token_status {+ let status = match network_token_details.payload.token_status {pm_types::TokenStatus::Active => api_enums::TokenStatus::Active,pm_types::TokenStatus::Suspended => api_enums::TokenStatus::Suspended,- pm_types::TokenStatus::Deactivated => api_enums::TokenStatus::Deactivated,+ pm_types::TokenStatus::Inactive => api_enums::TokenStatus::Inactive,+ pm_types::TokenStatus::Expired => api_enums::TokenStatus::Expired,+ pm_types::TokenStatus::Deleted => api_enums::TokenStatus::Deleted,};payment_methods::NetworkTokenStatusCheckResponse::SuccessResponse(payment_methods::NetworkTokenStatusCheckSuccessResponse {status,- token_expiry_month: network_token_details.token_expiry_month,- token_expiry_year: network_token_details.token_expiry_year,- card_last_four: network_token_details.card_last_4,- card_expiry: network_token_details.card_expiry,- token_last_four: network_token_details.token_last_4,+ token_expiry_month: network_token_details.payload.token_expiry_month,+ token_expiry_year: network_token_details.payload.token_expiry_year,+ card_last_four: network_token_details.payload.card_last_four,+ card_expiry_month: network_token_details.payload.card_expiry_month,+ card_expiry_year: network_token_details.payload.card_expiry_year,+ token_last_four: network_token_details.payload.token_last_four,payment_method_id,customer_id: payment_method.customer_id,},diff --git a/crates/router/src/core/payment_methods/network_tokenization.rs b/crates/router/src/core/payment_methods/network_tokenization.rsindex 01df00d41d..f3bb20a657 100644--- a/crates/router/src/core/payment_methods/network_tokenization.rs+++ b/crates/router/src/core/payment_methods/network_tokenization.rs@@ -805,10 +805,10 @@ pub async fn check_token_status_with_tokenization_service(.parse_struct("Delete Network Tokenization Response").change_context(errors::NetworkTokenizationError::ResponseDeserializationFailed)?;- match check_token_status_response.token_status {+ match check_token_status_response.payload.token_status {pm_types::TokenStatus::Active => Ok((- Some(check_token_status_response.token_expiry_month),- Some(check_token_status_response.token_expiry_year),+ check_token_status_response.payload.token_expiry_month,+ check_token_status_response.payload.token_expiry_year,)),_ => Ok((None, None)),}diff --git a/crates/router/src/types/payment_methods.rs b/crates/router/src/types/payment_methods.rsindex 4f6865fadc..acdb17c07d 100644--- a/crates/router/src/types/payment_methods.rs+++ b/crates/router/src/types/payment_methods.rs@@ -338,6 +338,7 @@ pub struct CheckTokenStatus {#[cfg(feature = "v2")]#[derive(Debug, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]pub struct CheckTokenStatus {pub card_reference: String,pub customer_id: id_type::GlobalCustomerId,@@ -347,21 +348,28 @@ pub struct CheckTokenStatus {#[serde(rename_all = "UPPERCASE")]pub enum TokenStatus {Active,+ Inactive,Suspended,- Deactivated,+ Expired,+ Deleted,}#[derive(Debug, Deserialize)]#[serde(rename_all = "camelCase")]-pub struct CheckTokenStatusResponse {+pub struct CheckTokenStatusResponsePayload {pub token_status: TokenStatus,- pub token_expiry_month: Secret<String>,- pub token_expiry_year: Secret<String>,- pub card_last_4: String,- pub card_expiry: String,- pub token_last_4: String,+ pub token_expiry_month: Option<Secret<String>>,+ pub token_expiry_year: Option<Secret<String>>,+ pub card_last_four: Option<String>,+ pub card_expiry_month: Option<Secret<String>>,+ pub card_expiry_year: Option<Secret<String>>,+ pub token_last_four: Option<String>,}+#[derive(Debug, Deserialize)]+pub struct CheckTokenStatusResponse {+ pub payload: CheckTokenStatusResponsePayload,+}#[derive(Debug, Clone, Deserialize, Serialize)]pub struct NetworkTokenRequestorData {pub card_reference: String,