Skip to content

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

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

awasthi21a614c200498e
diff --git a/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs b/crates/hyperswitch_connectors/src/connectors/paybox/transformers.rs
index effe6df28d..9d01036f66 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<String>,
zip_code: Secret<String>,
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<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)
}
@@ -609,12 +613,13 @@ 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())