From 52ed290608a953dd1fb550e05adf59c65aa8e5eb Mon Sep 17 00:00:00 2001 From: awasthi21 <107559116+awasthi21@users.noreply.github.com> Date: Wed, 5 Feb 2025 00:15:37 +0530 Subject: [PATCH] fix(connector): Fix Paybox 3DS failing issue (#7153) Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com> --- .../src/connectors/paybox/transformers.rs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs index effe6df28db..9d01036f660 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs @@ -148,7 +148,7 @@ pub struct ThreeDSPaymentsRequest { address1: Secret, zip_code: Secret, city: String, - country_code: api_models::enums::CountryAlpha2, + country_code: String, total_quantity: i32, } #[derive(Debug, Serialize, Eq, PartialEq)] @@ -422,7 +422,11 @@ impl TryFrom<&PayboxRouterData<&types::PaymentsAuthorizeRouterData>> for PayboxP address1: address.get_line1()?.clone(), zip_code: address.get_zip()?.clone(), city: address.get_city()?.clone(), - country_code: *address.get_country()?, + country_code: format!( + "{:03}", + common_enums::Country::from_alpha2(*address.get_country()?) + .to_numeric() + ), total_quantity: 1, })) } else { @@ -601,7 +605,7 @@ pub struct TransactionResponse { pub fn parse_url_encoded_to_struct( query_bytes: Bytes, ) -> CustomResult { - let (cow, _, _) = encoding_rs::ISO_8859_10.decode(&query_bytes); + let (cow, _, _) = encoding_rs::ISO_8859_15.decode(&query_bytes); serde_qs::from_str::(cow.as_ref()).change_context(errors::ConnectorError::ParsingFailed) } @@ -609,12 +613,13 @@ pub fn parse_paybox_response( query_bytes: Bytes, is_three_ds: bool, ) -> CustomResult { - let (cow, _, _) = encoding_rs::ISO_8859_10.decode(&query_bytes); - let response_str = cow.as_ref(); - - if response_str.starts_with("") && is_three_ds { + let (cow, _, _) = encoding_rs::ISO_8859_15.decode(&query_bytes); + let response_str = cow.as_ref().trim(); + if (response_str.starts_with("") || response_str.starts_with("")) + && is_three_ds + { let response = response_str.to_string(); - return Ok(if response.contains("Erreur") { + return Ok(if response.contains("Erreur 201") { PayboxResponse::Error(response) } else { PayboxResponse::ThreeDs(response.into())