Skip to content

Commit

Permalink
fix(connector): Fix Paybox 3DS failing issue (#7153)
Browse files Browse the repository at this point in the history
Co-authored-by: Gnanasundari24 <[email protected]>
  • Loading branch information
2 people authored and Narayanbhat166 committed Feb 6, 2025
1 parent 3e116b8 commit 52ed290
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub struct ThreeDSPaymentsRequest {
address1: Secret<String>,
zip_code: Secret<String>,
city: String,
country_code: api_models::enums::CountryAlpha2,
country_code: String,
total_quantity: i32,
}
#[derive(Debug, Serialize, Eq, PartialEq)]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -601,20 +605,21 @@ pub struct TransactionResponse {
pub fn parse_url_encoded_to_struct<T: DeserializeOwned>(
query_bytes: Bytes,
) -> CustomResult<T, errors::ConnectorError> {
let (cow, _, _) = encoding_rs::ISO_8859_10.decode(&query_bytes);
let (cow, _, _) = encoding_rs::ISO_8859_15.decode(&query_bytes);
serde_qs::from_str::<T>(cow.as_ref()).change_context(errors::ConnectorError::ParsingFailed)
}

pub fn parse_paybox_response(
query_bytes: Bytes,
is_three_ds: bool,
) -> CustomResult<PayboxResponse, errors::ConnectorError> {
let (cow, _, _) = encoding_rs::ISO_8859_10.decode(&query_bytes);
let response_str = cow.as_ref();

if response_str.starts_with("<html>") && 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("<html>") || response_str.starts_with("<!DOCTYPE html>"))
&& 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())
Expand Down

0 comments on commit 52ed290

Please sign in to comment.