Skip to content

Commit

Permalink
Merge branch 'main' into feat/block_paymentmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
prajjwalkumar17 authored Jan 5, 2024
2 parents e038a71 + 34318bc commit f39aebd
Show file tree
Hide file tree
Showing 45 changed files with 266 additions and 268 deletions.
11 changes: 6 additions & 5 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ rustflags = [
"-Funsafe_code",
"-Wclippy::as_conversions",
"-Wclippy::expect_used",
"-Wclippy::index_refutable_slice",
"-Wclippy::indexing_slicing",
"-Wclippy::match_on_vec_items",
"-Wclippy::missing_panics_doc",
"-Wclippy::panic_in_result_fn",
"-Wclippy::out_of_bounds_indexing",
"-Wclippy::panic",
"-Wclippy::panic_in_result_fn",
"-Wclippy::panicking_unwrap",
"-Wclippy::todo",
"-Wclippy::unimplemented",
Expand All @@ -23,10 +27,7 @@ rustflags = [


[build]
rustdocflags = [
"--cfg",
"uuid_unstable"
]
rustdocflags = ["--cfg", "uuid_unstable"]

[alias]
gen-pg = "generate --path ../../../../connector-template -n"
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 1.106.1 (2024-01-05)

### Bug Fixes

- **connector:** [iatapay] change refund amount ([#3244](https://github.com/juspay/hyperswitch/pull/3244)) ([`e79604b`](https://github.com/juspay/hyperswitch/commit/e79604bd4681a69802f3c3169dd94424e3688e42))

**Full Changelog:** [`v1.106.0...v1.106.1`](https://github.com/juspay/hyperswitch/compare/v1.106.0...v1.106.1)

- - -


## 1.106.0 (2024-01-04)

### Features
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,28 @@ pub mod payout_routing_algorithm {
where
A: de::MapAccess<'de>,
{
let mut output = serde_json::Value::Object(Map::new());
let mut output = Map::new();
let mut routing_data: String = "".to_string();
let mut routing_type: String = "".to_string();

while let Some(key) = map.next_key()? {
match key {
"type" => {
routing_type = map.next_value()?;
output["type"] = serde_json::Value::String(routing_type.to_owned());
output.insert(
"type".to_string(),
serde_json::Value::String(routing_type.to_owned()),
);
}
"data" => {
routing_data = map.next_value()?;
output["data"] = serde_json::Value::String(routing_data.to_owned());
output.insert(
"data".to_string(),
serde_json::Value::String(routing_data.to_owned()),
);
}
f => {
output[f] = map.next_value()?;
output.insert(f.to_string(), map.next_value()?);
}
}
}
Expand All @@ -392,7 +398,7 @@ pub mod payout_routing_algorithm {
}
u => Err(de::Error::custom(format!("Unknown routing algorithm {u}"))),
}?;
Ok(output)
Ok(serde_json::Value::Object(output))
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/cards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ time = "0.3.21"
# First party crates
common_utils = { version = "0.1.0", path = "../common_utils" }
masking = { version = "0.1.0", path = "../masking" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }

[dev-dependencies]
serde_json = "1.0.108"
8 changes: 7 additions & 1 deletion crates/cards/src/validate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{fmt, ops::Deref, str::FromStr};

use masking::{PeekInterface, Strategy, StrongSecret, WithType};
use router_env::logger;
use serde::{Deserialize, Deserializer, Serialize};
use thiserror::Error;

Expand Down Expand Up @@ -92,7 +93,12 @@ where
return WithType::fmt(val, f);
}

write!(f, "{}{}", &val_str[..6], "*".repeat(val_str.len() - 6))
if let Some(value) = val_str.get(..6) {
write!(f, "{}{}", value, "*".repeat(val_str.len() - 6))
} else {
logger::error!("Invalid card number {val_str}");
WithType::fmt(val, f)
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion crates/common_utils/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ impl DecodeMessage for GcmAes256 {
.change_context(errors::CryptoError::DecodingFailed)?;

let nonce_sequence = NonceSequence::from_bytes(
msg[..ring::aead::NONCE_LEN]
msg.get(..ring::aead::NONCE_LEN)
.ok_or(errors::CryptoError::DecodingFailed)
.into_report()
.attach_printable("Failed to read the nonce form the encrypted ciphertext")?
.try_into()
.into_report()
.change_context(errors::CryptoError::DecodingFailed)?,
Expand Down
53 changes: 36 additions & 17 deletions crates/common_utils/src/pii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use diesel::{
};
use error_stack::{IntoReport, ResultExt};
use masking::{ExposeInterface, Secret, Strategy, WithType};
#[cfg(feature = "logs")]
use router_env::logger;

use crate::{
crypto::Encryptable,
Expand Down Expand Up @@ -41,13 +43,14 @@ where
fn fmt(val: &T, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let val_str: &str = val.as_ref();

// masks everything but the last 4 digits
write!(
f,
"{}{}",
"*".repeat(val_str.len() - 4),
&val_str[val_str.len() - 4..]
)
if let Some(val_str) = val_str.get(val_str.len() - 4..) {
// masks everything but the last 4 digits
write!(f, "{}{}", "*".repeat(val_str.len() - 4), val_str)
} else {
#[cfg(feature = "logs")]
logger::error!("Invalid phone number: {val_str}");
WithType::fmt(val, f)
}
}
}

Expand Down Expand Up @@ -174,16 +177,26 @@ where
{
return WithType::fmt(val, f);
}
write!(
f,
"{}_{}_{}",
client_secret_segments[0],
client_secret_segments[1],
"*".repeat(
val_str.len()
- (client_secret_segments[0].len() + client_secret_segments[1].len() + 2)

if let Some((client_secret_segments_0, client_secret_segments_1)) = client_secret_segments
.first()
.zip(client_secret_segments.get(1))
{
write!(
f,
"{}_{}_{}",
client_secret_segments_0,
client_secret_segments_1,
"*".repeat(
val_str.len()
- (client_secret_segments_0.len() + client_secret_segments_1.len() + 2)
)
)
)
} else {
#[cfg(feature = "logs")]
logger::error!("Invalid client secret: {val_str}");
WithType::fmt(val, f)
}
}
}

Expand Down Expand Up @@ -325,7 +338,13 @@ where
}
}

write!(f, "{}.**.**.**", segments[0])
if let Some(segments) = segments.first() {
write!(f, "{}.**.**.**", segments)
} else {
#[cfg(feature = "logs")]
logger::error!("Invalid IP address: {val_str}");
WithType::fmt(val, f)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/connector_configs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ api_models = { version = "0.1.0", path = "../api_models", package = "api_models"
serde = { version = "1.0.193", features = ["derive"] }
serde_with = "3.4.0"
toml = "0.7.3"
utoipa = { version = "3.3.0", features = ["preserve_order"] }
utoipa = { version = "3.3.0", features = ["preserve_order"] }
48 changes: 21 additions & 27 deletions crates/connector_configs/src/response_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,34 +279,28 @@ impl ConnectorApiIntegrationPayload {

pub fn get_google_pay_metadata_response(response: Self) -> Option<GooglePayData> {
match response.metadata {
Some(meta_data) => match meta_data.google_pay {
Some(google_pay) => match google_pay {
GoogleApiModelData::Standard(standard_data) => {
if standard_data.allowed_payment_methods.is_empty() {
None
} else {
let data = Some(
standard_data.allowed_payment_methods[0]
.tokenization_specification
.parameters
.clone(),
);
match data {
Some(data) => Some(GooglePayData::Standard(GpayDashboardPayLoad {
gateway_merchant_id: data.gateway_merchant_id,
stripe_version: data.stripe_version,
stripe_publishable_key: data.stripe_publishable_key,
merchant_name: standard_data.merchant_info.merchant_name,
merchant_id: standard_data.merchant_info.merchant_id,
})),
None => None,
}
Some(meta_data) => {
match meta_data.google_pay {
Some(google_pay) => match google_pay {
GoogleApiModelData::Standard(standard_data) => {
let data = standard_data.allowed_payment_methods.first().map(
|allowed_pm| {
allowed_pm.tokenization_specification.parameters.clone()
},
)?;
Some(GooglePayData::Standard(GpayDashboardPayLoad {
gateway_merchant_id: data.gateway_merchant_id,
stripe_version: data.stripe_version,
stripe_publishable_key: data.stripe_publishable_key,
merchant_name: standard_data.merchant_info.merchant_name,
merchant_id: standard_data.merchant_info.merchant_id,
}))
}
}
GoogleApiModelData::Zen(data) => Some(GooglePayData::Zen(data)),
},
None => None,
},
GoogleApiModelData::Zen(data) => Some(GooglePayData::Zen(data)),
},
None => None,
}
}
None => None,
}
}
Expand Down
8 changes: 6 additions & 2 deletions crates/euclid/src/dssa/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,9 @@ mod tests {
.collect::<Vec<&dir::DirValue>>();
assert_eq!(
values,
expected_contexts[expected_idx]
expected_contexts
.get(expected_idx)
.expect("Error deriving contexts")
.iter()
.collect::<Vec<&dir::DirValue>>()
);
Expand All @@ -702,7 +704,9 @@ mod tests {
.collect::<Vec<&dir::DirValue>>();
assert_eq!(
values,
expected_contexts[expected_idx]
expected_contexts
.get(expected_idx)
.expect("Error deriving contexts")
.iter()
.collect::<Vec<&dir::DirValue>>()
);
Expand Down
5 changes: 4 additions & 1 deletion crates/euclid/src/frontend/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,10 @@ mod test {
};
let display_str = key.to_string();

assert_eq!(&json_str[1..json_str.len() - 1], display_str);
assert_eq!(
json_str.get(1..json_str.len() - 1).expect("Value metadata"),
display_str
);
key_names.insert(key, display_str);
}

Expand Down
5 changes: 4 additions & 1 deletion crates/euclid_macros/src/inner/knowledge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ impl GenContext {
.position(|v| *v == node_id)
.ok_or_else(|| "Error deciding cycle order".to_string())?;

let cycle_order = order[position..].to_vec();
let cycle_order = order
.get(position..)
.ok_or_else(|| "Error getting cycle order".to_string())?
.to_vec();
Ok(Some(cycle_order))
} else if visited.contains(&node_id) {
Ok(None)
Expand Down
7 changes: 6 additions & 1 deletion crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,12 @@ fn get_error_response(
})),
Some(authorizedotnet::TransactionResponse::AuthorizedotnetTransactionResponseError(_))
| None => {
let message = &response.messages.message[0].text;
let message = &response
.messages
.message
.first()
.ok_or(errors::ConnectorError::ResponseDeserializationFailed)?
.text;
Ok(types::ErrorResponse {
code: consts::NO_ERROR_CODE.to_string(),
message: message.to_string(),
Expand Down
Loading

0 comments on commit f39aebd

Please sign in to comment.