mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
fix: redis deserialization issue in tokenization call (#878)
This commit is contained in:
committed by
GitHub
parent
cf902f19e5
commit
5e9d7d6b53
@ -319,7 +319,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize {
|
||||
metadata: Some(Metadata {
|
||||
order_details: None,
|
||||
data: masking::Secret::new("{}".into()),
|
||||
payload: Some(req.json_payload.unwrap_or("{}".into()).into()),
|
||||
payload: Some(req.json_payload.unwrap_or(serde_json::json!({})).into()),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
@ -597,13 +597,13 @@ async fn decide_payment_method_tokenize_action(
|
||||
payment_method: &storage::enums::PaymentMethod,
|
||||
pm_parent_token: Option<&String>,
|
||||
is_connector_tokenization_enabled: bool,
|
||||
) -> TokenizationAction {
|
||||
) -> RouterResult<TokenizationAction> {
|
||||
match pm_parent_token {
|
||||
None => {
|
||||
if is_connector_tokenization_enabled {
|
||||
TokenizationAction::TokenizeInConnectorAndRouter
|
||||
Ok(TokenizationAction::TokenizeInConnectorAndRouter)
|
||||
} else {
|
||||
TokenizationAction::TokenizeInRouter
|
||||
Ok(TokenizationAction::TokenizeInRouter)
|
||||
}
|
||||
}
|
||||
Some(token) => {
|
||||
@ -615,14 +615,19 @@ async fn decide_payment_method_tokenize_action(
|
||||
connector_name
|
||||
);
|
||||
|
||||
match redis_conn.get_key::<String>(&key).await {
|
||||
Ok(connector_token) => TokenizationAction::ConnectorToken(connector_token),
|
||||
Err(error) => {
|
||||
logger::debug!(connector_token_redis_error=?error);
|
||||
let connector_token_option = redis_conn
|
||||
.get_key::<Option<String>>(&key)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to fetch the token from redis")?;
|
||||
|
||||
match connector_token_option {
|
||||
Some(connector_token) => Ok(TokenizationAction::ConnectorToken(connector_token)),
|
||||
None => {
|
||||
if is_connector_tokenization_enabled {
|
||||
TokenizationAction::TokenizeInConnector
|
||||
Ok(TokenizationAction::TokenizeInConnector)
|
||||
} else {
|
||||
TokenizationAction::SkipConnectorTokenization
|
||||
Ok(TokenizationAction::TokenizeInRouter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -671,7 +676,7 @@ where
|
||||
payment_data.token.as_ref(),
|
||||
is_connector_tokenization_enabled,
|
||||
)
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
let connector_tokenization_action = match payment_method_action {
|
||||
TokenizationAction::TokenizeInRouter => {
|
||||
|
||||
@ -691,7 +691,14 @@ pub async fn make_pm_data<'a, F: Clone, R>(
|
||||
.to_owned()
|
||||
.get_required_value("payment_method")?,
|
||||
);
|
||||
redis_conn.get_key::<String>(&key).await.ok()
|
||||
|
||||
let hyperswitch_token_option = redis_conn
|
||||
.get_key::<Option<String>>(&key)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed to fetch the token from redis")?;
|
||||
|
||||
hyperswitch_token_option.or(Some(token))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -1307,10 +1314,10 @@ pub fn get_business_details(
|
||||
},
|
||||
)?;
|
||||
(
|
||||
business_country.unwrap_or(primary_business_details.country.to_owned()),
|
||||
business_country.unwrap_or_else(|| primary_business_details.country.to_owned()),
|
||||
business_label
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or(primary_business_details.business.to_owned()),
|
||||
.unwrap_or_else(|| primary_business_details.business.to_owned()),
|
||||
)
|
||||
} else {
|
||||
// If primary business details are not present or more than one
|
||||
|
||||
Reference in New Issue
Block a user