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

feat(sdk_config): added sdk config filter for get_sdk_config api (#14219)

Sahkal Poddar3fc54c13236c
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index e1e086db19..fa8abe6243 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -525,6 +525,8 @@ pub mod superposition {
pub const INCOMING_WEBHOOK_DISABLED_EVENTS: &str = "webhooks.incoming_webhook_disabled_events";
/// save wallet decrypted data in locker
pub const SAVE_WALLET_DECRYPTED_DATA: &str = "vaulting.save_wallet_decrypted_data";
+ /// checkout sdk configuration
+ pub const CHECKOUT_SDK: &str = "checkout_sdk";
/// Pre-FRM failure handling mode
pub const PRE_FRM_FAILURE_MODE: &str = "frm.pre_frm_failure_mode";
}
diff --git a/crates/router/src/core/superposition_sdk_config.rs b/crates/router/src/core/superposition_sdk_config.rs
index 1a79cc28b1..1bb2a873d9 100644
--- a/crates/router/src/core/superposition_sdk_config.rs
+++ b/crates/router/src/core/superposition_sdk_config.rs
@@ -10,7 +10,7 @@ use error_stack::ResultExt;
use serde_json::Map;
use crate::{
- consts::superposition::DYNAMIC_FIELDS,
+ consts::superposition::{CHECKOUT_SDK, DYNAMIC_FIELDS},
core::{
configs::dimension_state::Dimensions,
errors::{self, RouterResponse, StorageErrorExt},
@@ -304,7 +304,7 @@ pub async fn get_profile_superposition_sdk_config(
let raw_configs = state
.superposition_service
.get_cached_config(
- Some(vec![DYNAMIC_FIELDS.to_string()]),
+ Some(vec![DYNAMIC_FIELDS.to_string(), CHECKOUT_SDK.to_string()]),
Some(dimension_filter.clone()),
)
.await
@@ -403,7 +403,7 @@ pub async fn get_superposition_sdk_config(
let raw_configs = state
.superposition_service
.get_cached_config(
- Some(vec![DYNAMIC_FIELDS.to_string()]),
+ Some(vec![DYNAMIC_FIELDS.to_string(), CHECKOUT_SDK.to_string()]),
Some(dimension_filter.clone()),
)
.await
diff --git a/scripts/seed_superposition.sh b/scripts/seed_superposition.sh
index c863d554d4..548914bc4b 100755
--- a/scripts/seed_superposition.sh
+++ b/scripts/seed_superposition.sh
@@ -17,18 +17,53 @@ for dependency in curl jq; do
fi
done
+# The checked-in seed file has a couple of hand-authored values that aren't
+# valid TOML and trip up every parser:
+# 1. `"\null\"` is used as a placeholder default for nullable string
+# fields. The `\n` is parsed as a newline escape, leaving the string
+# unterminated.
+# 2. A handful of `_validation_regex_pattern` entries hold an email regex
+# as a double-quoted TOML string in which every literal `"` in the
+# regex was mistakenly encoded as `\\` instead of `\"` (e.g. `(".+")`
+# became `(\\.+\\)`), and that string also contains other backslash
+# sequences (`\s`, `\.`, `\-`, ...) that aren't valid TOML escapes at
+# all, so the fix switches those values to single-quoted TOML literal
+# strings instead (literal strings don't process escapes).
+# Sanitize both in memory rather than editing the seed file itself.
+sanitize_seed() {
+ sed \
+ -e 's/"\\null\\"/""/g' \
+ -e '/_validation_regex_pattern/ {
+s/@\\\\\]/@"]/g
+s/(\\\\\.+\\\\)/(".+")/g
+s/, value = "\(.*\)" }$/, value = '"'"'\1'"'"' }/
+}' \
+ "$SEED_FILE"
+}
+
toml_to_json() {
+ local sanitized
+ local output
+ local status
+
+ sanitized=$(sanitize_seed)
+
if command -v yq >/dev/null 2>&1; then
- yq -p toml -o json '.' "$SEED_FILE"
+ output=$(printf '%s\n' "$sanitized" | yq -p toml -o json '.' - 2>&1) && { printf '%s' "$output"; return 0; }
+ status=$?
elif command -v python3 >/dev/null 2>&1 \
&& python3 -c 'import tomllib' >/dev/null 2>&1; then
- python3 -c \
- 'import json, sys, tomllib; json.dump(tomllib.load(open(sys.argv[1], "rb")), sys.stdout)' \
- "$SEED_FILE"
+ output=$(printf '%s\n' "$sanitized" | python3 -c \
+ 'import json, sys, tomllib; json.dump(tomllib.load(sys.stdin.buffer), sys.stdout)' 2>&1) && { printf '%s' "$output"; return 0; }
+ status=$?
else
echo "Error: TOML parsing requires yq or Python 3.11+" >&2
exit 127
fi
+
+ echo "Error: '$SEED_FILE' is not valid TOML:" >&2
+ echo "$output" | tail -3 >&2
+ exit "$status"
}
show_progress() {