Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(connector): Fix Paybox 3DS failing issue #7153

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: i32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this string

total_quantity: i32,
}
#[derive(Debug, Serialize, Eq, PartialEq)]
Expand Down Expand Up @@ -422,7 +422,8 @@ 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: common_enums::Country::from_alpha2(*address.get_country()?)
.to_numeric() as i32,
total_quantity: 1,
}))
} else {
Expand Down Expand Up @@ -601,20 +602,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
Loading