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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [REDSYS] add url safe base64 decoding support (#11024)
AkshayaFoiger6db63d4cca06
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rsindex 7700f4acbd..efbfdc572d 100644--- a/crates/hyperswitch_connectors/src/utils.rs+++ b/crates/hyperswitch_connectors/src/utils.rs@@ -38,7 +38,10 @@ use common_enums::{},};use common_utils::{- consts::{BASE64_ENGINE, BASE64_ENGINE_STD_NO_PAD},+ consts::{+ BASE64_ENGINE, BASE64_ENGINE_STD_NO_PAD, BASE64_ENGINE_URL_SAFE,+ BASE64_ENGINE_URL_SAFE_NO_PAD,+ },errors::{CustomResult, ParsingError, ReportSwitchExt},ext_traits::{OptionExt, StringExt, ValueExt},id_type,@@ -138,10 +141,22 @@ pub(crate) fn base64_decode(data: String) -> Result<Vec<u8>, Error> {.change_context(errors::ConnectorError::ResponseDeserializationFailed)}pub(crate) fn safe_base64_decode(data: String) -> Result<Vec<u8>, Error> {- [&BASE64_ENGINE, &BASE64_ENGINE_STD_NO_PAD]- .iter()- .find_map(|d| d.decode(&data).ok())- .ok_or(errors::ConnectorError::ResponseDeserializationFailed.into())+ let mut error_stack = Vec::new();+ [+ &BASE64_ENGINE,+ &BASE64_ENGINE_STD_NO_PAD,+ &BASE64_ENGINE_URL_SAFE,+ &BASE64_ENGINE_URL_SAFE_NO_PAD,+ ]+ .iter()+ .find_map(|engine| engine.decode(&data).map_err(|e| error_stack.push(e)).ok())+ .ok_or_else(|| {+ logger::error!(+ "Base64 decoding failed for all engines. Errors: {:?}",+ error_stack+ );+ report!(errors::ConnectorError::ResponseDeserializationFailed)+ })}pub(crate) fn to_currency_base_unit(