Skip to content

Commit

Permalink
Merge branch 'main' into Error-Code-handling-BOA-CC
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshayaFoiger committed Jan 5, 2024
2 parents ab40c8f + c8279b1 commit d51fc65
Show file tree
Hide file tree
Showing 87 changed files with 979 additions and 425 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.

13 changes: 7 additions & 6 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,10 @@ enabled = true # Switch to enable or disable PayPal onboarding
source = "logs" # The event sink to push events supports kafka or logs (stdout)

[events.kafka]
brokers = [] # Kafka broker urls for bootstrapping the client
intent_analytics_topic = "topic" # Kafka topic to be used for PaymentIntent events
attempt_analytics_topic = "topic" # Kafka topic to be used for PaymentAttempt events
refund_analytics_topic = "topic" # Kafka topic to be used for Refund events
api_logs_topic = "topic" # Kafka topic to be used for incoming api events
connector_logs_topic = "topic" # Kafka topic to be used for connector api events
brokers = [] # Kafka broker urls for bootstrapping the client
intent_analytics_topic = "topic" # Kafka topic to be used for PaymentIntent events
attempt_analytics_topic = "topic" # Kafka topic to be used for PaymentAttempt events
refund_analytics_topic = "topic" # Kafka topic to be used for Refund events
api_logs_topic = "topic" # Kafka topic to be used for incoming api events
connector_logs_topic = "topic" # Kafka topic to be used for connector api events
outgoing_webhook_logs_topic = "topic" # Kafka topic to be used for outgoing webhook events
1 change: 1 addition & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ attempt_analytics_topic = "hyperswitch-payment-attempt-events"
refund_analytics_topic = "hyperswitch-refund-events"
api_logs_topic = "hyperswitch-api-log-events"
connector_logs_topic = "hyperswitch-connector-api-events"
outgoing_webhook_logs_topic = "hyperswitch-outgoing-webhook-events"

[analytics]
source = "sqlx"
Expand Down
1 change: 1 addition & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ attempt_analytics_topic = "hyperswitch-payment-attempt-events"
refund_analytics_topic = "hyperswitch-refund-events"
api_logs_topic = "hyperswitch-api-log-events"
connector_logs_topic = "hyperswitch-connector-api-events"
outgoing_webhook_logs_topic = "hyperswitch-outgoing-webhook-events"

[analytics]
source = "sqlx"
Expand Down
109 changes: 109 additions & 0 deletions crates/analytics/docs/clickhouse/scripts/outgoing_webhook_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
CREATE TABLE
outgoing_webhook_events_queue (
`merchant_id` String,
`event_id` Nullable(String),
`event_type` LowCardinality(String),
`outgoing_webhook_event_type` LowCardinality(String),
`payment_id` Nullable(String),
`refund_id` Nullable(String),
`attempt_id` Nullable(String),
`dispute_id` Nullable(String),
`payment_method_id` Nullable(String),
`mandate_id` Nullable(String),
`content` Nullable(String),
`is_error` Bool,
`error` Nullable(String),
`created_at_timestamp` DateTime64(3)
) ENGINE = Kafka SETTINGS kafka_broker_list = 'kafka0:29092',
kafka_topic_list = 'hyperswitch-outgoing-webhook-events',
kafka_group_name = 'hyper-c1',
kafka_format = 'JSONEachRow',
kafka_handle_error_mode = 'stream';

CREATE TABLE
outgoing_webhook_events_cluster (
`merchant_id` String,
`event_id` String,
`event_type` LowCardinality(String),
`outgoing_webhook_event_type` LowCardinality(String),
`payment_id` Nullable(String),
`refund_id` Nullable(String),
`attempt_id` Nullable(String),
`dispute_id` Nullable(String),
`payment_method_id` Nullable(String),
`mandate_id` Nullable(String),
`content` Nullable(String),
`is_error` Bool,
`error` Nullable(String),
`created_at_timestamp` DateTime64(3),
`inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),
INDEX eventIndex event_type TYPE bloom_filter GRANULARITY 1,
INDEX webhookeventIndex outgoing_webhook_event_type TYPE bloom_filter GRANULARITY 1
) ENGINE = MergeTree PARTITION BY toStartOfDay(created_at_timestamp)
ORDER BY (
created_at_timestamp,
merchant_id,
event_id,
event_type,
outgoing_webhook_event_type
) TTL inserted_at + toIntervalMonth(6);

CREATE MATERIALIZED VIEW outgoing_webhook_events_mv TO outgoing_webhook_events_cluster (
`merchant_id` String,
`event_id` Nullable(String),
`event_type` LowCardinality(String),
`outgoing_webhook_event_type` LowCardinality(String),
`payment_id` Nullable(String),
`refund_id` Nullable(String),
`attempt_id` Nullable(String),
`dispute_id` Nullable(String),
`payment_method_id` Nullable(String),
`mandate_id` Nullable(String),
`content` Nullable(String),
`is_error` Bool,
`error` Nullable(String),
`created_at_timestamp` DateTime64(3),
`inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),
) AS
SELECT
merchant_id,
event_id,
event_type,
outgoing_webhook_event_type,
payment_id,
refund_id,
attempt_id,
dispute_id,
payment_method_id,
mandate_id,
content,
is_error,
error,
created_at_timestamp,
now() AS inserted_at
FROM
outgoing_webhook_events_queue
where length(_error) = 0;

CREATE MATERIALIZED VIEW outgoing_webhook_parse_errors (
`topic` String,
`partition` Int64,
`offset` Int64,
`raw` String,
`error` String
) ENGINE = MergeTree
ORDER BY (
topic, partition,
offset
) SETTINGS index_granularity = 8192 AS
SELECT
_topic AS topic,
_partition AS partition,
_offset AS
offset
,
_raw_message AS raw,
_error AS error
FROM
outgoing_webhook_events_queue
WHERE length(_error) > 0;
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
6 changes: 6 additions & 0 deletions crates/api_models/src/health_check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct RouterHealthCheckResponse {
pub database: String,
pub redis: String,
pub locker: String,
}
1 change: 1 addition & 0 deletions crates/api_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod errors;
pub mod events;
pub mod files;
pub mod gsm;
pub mod health_check;
pub mod locker_migration;
pub mod mandates;
pub mod organization;
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 @@ -85,7 +86,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
3 changes: 1 addition & 2 deletions crates/common_utils/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ impl RequestBuilder {
}

pub fn headers(mut self, headers: Vec<(String, Maskable<String>)>) -> Self {
let mut h = headers.into_iter().map(|(h, v)| (h, v));
self.headers.extend(&mut h);
self.headers.extend(headers);
self
}

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"] }
Loading

0 comments on commit d51fc65

Please sign in to comment.