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: introduce a framework to fetch configs from superposition (#9289)

Shaileshacc1568baab2
diff --git a/Cargo.lock b/Cargo.lock
index db4c2ac1cb..183c316a37 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -362,7 +362,7 @@ dependencies = [
"aws-config",
"aws-sdk-lambda",
"aws-smithy-types",
- "bigdecimal",
+ "bigdecimal 0.4.8",
"common_enums",
"common_utils",
"currency_conversion",
@@ -526,6 +526,48 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
+[[package]]
+name = "askama"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d4744ed2eef2645831b441d8f5459689ade2ab27c854488fbab1fbe94fce1a7"
+dependencies = [
+ "askama_derive",
+ "itoa",
+ "percent-encoding",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "askama_derive"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d661e0f57be36a5c14c48f78d09011e67e0cb618f269cca9f2fd8d15b68c46ac"
+dependencies = [
+ "askama_parser",
+ "basic-toml",
+ "memchr",
+ "proc-macro2",
+ "quote",
+ "rustc-hash 2.1.1",
+ "serde",
+ "serde_derive",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "askama_parser"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf315ce6524c857bb129ff794935cf6d42c82a6cff60526fe2a63593de4d0d4f"
+dependencies = [
+ "memchr",
+ "serde",
+ "serde_derive",
+ "winnow 0.7.10",
+]
+
[[package]]
name = "asn1-rs"
version = "0.6.2"
@@ -743,6 +785,30 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "aws-lc-rs"
+version = "1.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879b6c89592deb404ba4dc0ae6b58ffd1795c78991cbb5b8bc441c48a070440d"
+dependencies = [
+ "aws-lc-sys",
+ "zeroize",
+]
+
+[[package]]
+name = "aws-lc-sys"
+version = "0.32.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2b715a6010afb9e457ca2b7c9d2b9c344baa8baed7b38dc476034c171b32575"
+dependencies = [
+ "bindgen",
+ "cc",
+ "cmake",
+ "dunce",
+ "fs_extra",
+ "libloading",
+]
+
[[package]]
name = "aws-runtime"
version = "1.5.7"
@@ -1059,12 +1125,20 @@ dependencies = [
"aws-smithy-types",
"h2 0.4.8",
"http 0.2.12",
+ "http 1.3.1",
"http-body 0.4.6",
"hyper 0.14.32",
+ "hyper 1.6.0",
"hyper-rustls 0.24.2",
+ "hyper-rustls 0.27.6",
+ "hyper-util",
"pin-project-lite",
"rustls 0.21.12",
+ "rustls 0.23.27",
+ "rustls-native-certs 0.8.1",
+ "rustls-pki-types",
"tokio 1.45.1",
+ "tower 0.5.2",
"tracing",
]
@@ -1375,6 +1449,15 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
+[[package]]
+name = "basic-toml"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "bb8"
version = "0.8.6"
@@ -1387,6 +1470,18 @@ dependencies = [
"tokio 1.45.1",
]
+[[package]]
+name = "bigdecimal"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa"
+dependencies = [
+ "num-bigint",
+ "num-integer",
+ "num-traits",
+ "serde",
+]
+
[[package]]
name = "bigdecimal"
version = "0.4.8"
@@ -1410,6 +1505,26 @@ dependencies = [
"serde",
]
+[[package]]
+name = "bindgen"
+version = "0.72.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
+dependencies = [
+ "bitflags 2.9.0",
+ "cexpr",
+ "clang-sys",
+ "itertools 0.13.0",
+ "log",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash 2.1.1",
+ "shlex",
+ "syn 2.0.101",
+]
+
[[package]]
name = "bit-set"
version = "0.8.0"
@@ -1567,6 +1682,12 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "bytecount"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
+
[[package]]
name = "bytemuck"
version = "1.17.1"
@@ -1653,6 +1774,19 @@ dependencies = [
"serde",
]
+[[package]]
+name = "cargo_metadata"
+version = "0.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
+dependencies = [
+ "camino",
+ "cargo-platform",
+ "semver 1.0.26",
+ "serde",
+ "serde_json",
+]
+
[[package]]
name = "cargo_metadata"
version = "0.18.1"
@@ -1689,15 +1823,25 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
-version = "1.2.24"
+version = "1.2.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7"
+checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb"
dependencies = [
+ "find-msvc-tools",
"jobserver",
"libc",
"shlex",
]
+[[package]]
+name = "cexpr"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+dependencies = [
+ "nom 7.1.3",
+]
+
[[package]]
name = "cfb"
version = "0.7.3"
@@ -1801,6 +1945,17 @@ dependencies = [
"half",
]
+[[package]]
+name = "clang-sys"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
+dependencies = [
+ "glob",
+ "libc",
+ "libloading",
+]
+
[[package]]
name = "clap"
version = "4.5.38"
@@ -1850,6 +2005,15 @@ dependencies = [
"bitflags 1.3.2",
]
+[[package]]
+name = "cmake"
+version = "0.1.54"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "colorchoice"
version = "1.0.3"
@@ -2080,6 +2244,16 @@ dependencies = [
"libc",
]
+[[package]]
+name = "core-foundation"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
@@ -2731,6 +2905,12 @@ version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
+[[package]]
+name = "downcast"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1"
+
[[package]]
name = "drainer"
version = "0.1.0"
@@ -2773,6 +2953,12 @@ dependencies = [
"syn 2.0.101",
]
+[[package]]
+name = "dunce"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
+
[[package]]
name = "dyn-clone"
version = "1.0.19"
@@ -2939,6 +3125,15 @@ dependencies = [
"windows-sys 0.59.0",
]
+[[package]]
+name = "error-chain"
+version = "0.12.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
+dependencies = [
+ "version_check",
+]
+
[[package]]
name = "error-stack"
version = "0.4.1"
@@ -3081,6 +3276,7 @@ dependencies = [
"lettre",
"masking 0.1.0",
"once_cell",
+ "open-feature",
"prost",
"prost-types",
"quick-xml",
@@ -3090,6 +3286,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
+ "superposition_provider",
"thiserror 1.0.69",
"time",
"tokio 1.45.1",
@@ -3097,7 +3294,7 @@ dependencies = [
"tonic-build",
"tonic-reflection",
"tonic-types",
- "typed-builder",
+ "typed-builder 0.21.2",
"url",
"vaultrs",
]
@@ -3175,6 +3372,12 @@ version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3"
+
[[package]]
name = "fixedbitset"
version = "0.4.2"
@@ -3247,6 +3450,12 @@ dependencies = [
"percent-encoding",
]
+[[package]]
+name = "fragile"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619"
+
[[package]]
name = "fred"
version = "7.1.2"
@@ -3275,6 +3484,21 @@ dependencies = [
"urlencoding",
]
+[[package]]
+name = "fs-err"
+version = "2.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "fs_extra"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
+
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
@@ -3537,6 +3761,17 @@ dependencies = [
"walkdir",
]
+[[package]]
+name = "goblin"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47"
+dependencies = [
+ "log",
+ "plain",
+ "scroll",
+]
+
[[package]]
name = "graphviz-rust"
version = "0.6.6"
@@ -3973,7 +4208,7 @@ dependencies = [
"hyper 0.14.32",
"log",
"rustls 0.20.9",
- "rustls-native-certs",
+ "rustls-native-certs 0.6.3",
"tokio 1.45.1",
"tokio-rustls 0.23.4",
]
@@ -3989,7 +4224,7 @@ dependencies = [
"hyper 0.14.32",
"log",
"rustls 0.21.12",
- "rustls-native-certs",
+ "rustls-native-certs 0.6.3",
"tokio 1.45.1",
"tokio-rustls 0.24.1",
]
@@ -4004,6 +4239,7 @@ dependencies = [
"hyper 1.6.0",
"hyper-util",
"rustls 0.23.27",
+ "rustls-native-certs 0.8.1",
"rustls-pki-types",
"tokio 1.45.1",
"tokio-rustls 0.26.2",
@@ -4747,6 +4983,16 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "libloading"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
+dependencies = [
+ "cfg-if 1.0.0",
+ "windows-targets 0.52.6",
+]
+
[[package]]
name = "libm"
version = "0.2.11"
@@ -4850,6 +5096,10 @@ name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
+dependencies = [
+ "serde",
+ "value-bag",
+]
[[package]]
name = "lru"
@@ -5072,6 +5322,21 @@ dependencies = [
"unicase",
]
+[[package]]
+name = "mini-moka"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c325dfab65f261f386debee8b0969da215b3fa0037e74c8a1234db7ba986d803"
+dependencies = [
+ "crossbeam-channel",
+ "crossbeam-utils 0.8.21",
+ "dashmap",
+ "skeptic",
+ "smallvec 1.15.0",
+ "tagptr",
+ "triomphe",
+]
+
[[package]]
name = "minimal-lexical"
version = "0.2.1"
@@ -5151,6 +5416,32 @@ dependencies = [
"ws2_32-sys",
]
+[[package]]
+name = "mockall"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2"
+dependencies = [
+ "cfg-if 1.0.0",
+ "downcast",
+ "fragile",
+ "mockall_derive",
+ "predicates",
+ "predicates-tree",
+]
+
+[[package]]
+name = "mockall_derive"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898"
+dependencies = [
+ "cfg-if 1.0.0",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
[[package]]
name = "moka"
version = "0.12.7"
@@ -5208,7 +5499,7 @@ dependencies = [
"openssl-probe",
"openssl-sys",
"schannel",
- "security-framework",
+ "security-framework 2.11.1",
"security-framework-sys",
"tempfile",
]
@@ -5450,6 +5741,21 @@ version = "11.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
+[[package]]
+name = "open-feature"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f1ef07989b00b697d9e597e66509e2b0e7a1c889d8925fffe5408703215d72b"
+dependencies = [
+ "async-trait",
+ "lazy_static",
+ "log",
+ "mockall",
+ "time",
+ "tokio 1.45.1",
+ "typed-builder 0.22.0",
+]
+
[[package]]
name = "openapi"
version = "0.1.0"
@@ -6074,6 +6380,12 @@ version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+[[package]]
+name = "plain"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
+
[[package]]
name = "plotters"
version = "0.3.6"
@@ -6164,6 +6476,32 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
+[[package]]
+name = "predicates"
+version = "3.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573"
+dependencies = [
+ "anstyle",
+ "predicates-core",
+]
+
+[[package]]
+name = "predicates-core"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa"
+
+[[package]]
+name = "predicates-tree"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c"
+dependencies = [
+ "predicates-core",
+ "termtree",
+]
+
[[package]]
name = "prettyplease"
version = "0.2.20"
@@ -6336,6 +6674,17 @@ dependencies = [
"syn 1.0.109",
]
+[[package]]
+name = "pulldown-cmark"
+version = "0.9.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
+dependencies = [
+ "bitflags 2.9.0",
+ "memchr",
+ "unicase",
+]
+
[[package]]
name = "qrcode"
version = "0.14.1"
@@ -7321,6 +7670,7 @@ version = "0.23.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321"
dependencies = [
+ "aws-lc-rs",
"once_cell",
"ring 0.17.14",
"rustls-pki-types",
@@ -7338,16 +7688,28 @@ dependencies = [
"openssl-probe",
"rustls-pemfile 1.0.4",
"schannel",
- "security-framework",
+ "security-framework 2.11.1",
]
[[package]]
-name = "rustls-pemfile"
-version = "1.0.4"
+name = "rustls-native-certs"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
+checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3"
dependencies = [
- "base64 0.21.7",
+ "openssl-probe",
+ "rustls-pki-types",
+ "schannel",
+ "security-framework 3.5.1",
+]
+
+[[package]]
+name = "rustls-pemfile"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
+dependencies = [
+ "base64 0.21.7",
]
[[package]]
@@ -7396,6 +7758,7 @@ version = "0.103.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435"
dependencies = [
+ "aws-lc-rs",
"ring 0.17.14",
"rustls-pki-types",
"untrusted 0.9.0",
@@ -7501,6 +7864,26 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+[[package]]
+name = "scroll"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6"
+dependencies = [
+ "scroll_derive",
+]
+
+[[package]]
+name = "scroll_derive"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
[[package]]
name = "sct"
version = "0.7.1"
@@ -7617,7 +8000,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
"bitflags 2.9.0",
- "core-foundation",
+ "core-foundation 0.9.4",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
+]
+
+[[package]]
+name = "security-framework"
+version = "3.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef"
+dependencies = [
+ "bitflags 2.9.0",
+ "core-foundation 0.10.1",
"core-foundation-sys",
"libc",
"security-framework-sys",
@@ -7625,9 +8021,9 @@ dependencies = [
[[package]]
name = "security-framework-sys"
-version = "2.14.0"
+version = "2.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32"
+checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0"
dependencies = [
"core-foundation-sys",
"libc",
@@ -7709,6 +8105,15 @@ dependencies = [
"syn 2.0.101",
]
+[[package]]
+name = "serde_fmt"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "serde_json"
version = "1.0.140"
@@ -7980,6 +8385,21 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
+[[package]]
+name = "skeptic"
+version = "0.13.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8"
+dependencies = [
+ "bytecount",
+ "cargo_metadata 0.14.2",
+ "error-chain",
+ "glob",
+ "pulldown-cmark",
+ "tempfile",
+ "walkdir",
+]
+
[[package]]
name = "slab"
version = "0.4.9"
@@ -8017,6 +8437,12 @@ dependencies = [
"serde",
]
+[[package]]
+name = "smawk"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
+
[[package]]
name = "smithy"
version = "0.1.0"
@@ -8121,7 +8547,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6"
dependencies = [
"base64 0.22.1",
- "bigdecimal",
+ "bigdecimal 0.4.8",
"bytes 1.10.1",
"crc",
"crossbeam-queue 0.3.12",
@@ -8197,7 +8623,7 @@ checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
dependencies = [
"atoi",
"base64 0.22.1",
- "bigdecimal",
+ "bigdecimal 0.4.8",
"bitflags 2.9.0",
"byteorder",
"bytes 1.10.1",
@@ -8241,7 +8667,7 @@ checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
dependencies = [
"atoi",
"base64 0.22.1",
- "bigdecimal",
+ "bigdecimal 0.4.8",
"bitflags 2.9.0",
"byteorder",
"crc",
@@ -8460,6 +8886,183 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+[[package]]
+name = "superposition_core"
+version = "0.88.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0ea3804ca840e2329ee43d27f4bfb27b6fb4abf4f5441e33abe2aded2244387"
+dependencies = [
+ "actix-web",
+ "anyhow",
+ "cfg-if 1.0.0",
+ "chrono",
+ "derive_more 0.99.19",
+ "itertools 0.10.5",
+ "log",
+ "mini-moka",
+ "once_cell",
+ "rand 0.9.1",
+ "reqwest 0.11.27",
+ "serde",
+ "serde_json",
+ "strum 0.25.0",
+ "strum_macros 0.25.3",
+ "superposition_types",
+ "thiserror 1.0.69",
+ "tokio 1.45.1",
+ "uniffi",
+]
+
+[[package]]
+name = "superposition_derives"
+version = "0.88.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99060e97964918193b87fe387baf5ff5a5b3b48de05ffd2bd9b9e022f960762a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "superposition_provider"
+version = "0.88.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8023fbfd3195a1c66d1f69367eb11c984e9b4dc5e2147a1de68a32172e401e50"
+dependencies = [
+ "async-trait",
+ "aws-smithy-types",
+ "chrono",
+ "log",
+ "open-feature",
+ "reqwest 0.11.27",
+ "serde",
+ "serde_json",
+ "superposition_core",
+ "superposition_sdk",
+ "superposition_types",
+ "thiserror 1.0.69",
+ "tokio 1.45.1",
+ "uuid",
+]
+
+[[package]]
+name = "superposition_sdk"
+version = "0.88.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b37344622f87b506e1afb21ba81b435814e95b3ff092a2dea40706d3db36eae"
+dependencies = [
+ "aws-smithy-async",
+ "aws-smithy-http 0.62.1",
+ "aws-smithy-json 0.61.3",
+ "aws-smithy-runtime",
+ "aws-smithy-runtime-api",
+ "aws-smithy-types",
+ "bytes 1.10.1",
+ "fastrand",
+ "http 0.2.12",
+ "tracing",
+]
+
+[[package]]
+name = "superposition_types"
+version = "0.88.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "165524147049a9332077d163658759d477bef9985ae20c3e4a142c9d4c7a3873"
+dependencies = [
+ "bigdecimal 0.3.1",
+ "chrono",
+ "derive_more 0.99.19",
+ "log",
+ "regex",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "strum 0.25.0",
+ "strum_macros 0.25.3",
+ "superposition_derives",
+ "uniffi",
+ "uuid",
+]
+
+[[package]]
+name = "sval"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d94c4464e595f0284970fd9c7e9013804d035d4a61ab74b113242c874c05814d"
+
+[[package]]
+name = "sval_buffer"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0f46e34b20a39e6a2bf02b926983149b3af6609fd1ee8a6e63f6f340f3e2164"
+dependencies = [
+ "sval",
+ "sval_ref",
+]
+
+[[package]]
+name = "sval_dynamic"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03d0970e53c92ab5381d3b2db1828da8af945954d4234225f6dd9c3afbcef3f5"
+dependencies = [
+ "sval",
+]
+
+[[package]]
+name = "sval_fmt"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43e5e6e1613e1e7fc2e1a9fdd709622e54c122ceb067a60d170d75efd491a839"
+dependencies = [
+ "itoa",
+ "ryu",
+ "sval",
+]
+
+[[package]]
+name = "sval_json"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aec382f7bfa6e367b23c9611f129b94eb7daaf3d8fae45a8d0a0211eb4d4c8e6"
+dependencies = [
+ "itoa",
+ "ryu",
+ "sval",
+]
+
+[[package]]
+name = "sval_nested"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3049d0f99ce6297f8f7d9953b35a0103b7584d8f638de40e64edb7105fa578ae"
+dependencies = [
+ "sval",
+ "sval_buffer",
+ "sval_ref",
+]
+
+[[package]]
+name = "sval_ref"
+version = "2.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f88913e77506085c0a8bf6912bb6558591a960faf5317df6c1d9b227224ca6e1"
+dependencies = [
+ "sval",
+]
+
+[[package]]
+name = "sval_serde"
+version = "2.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "172dd4aa8cb3b45c8ac8f3b4111d644cd26938b0643ede8f93070812b87fb339"
+dependencies = [
+ "serde",
+ "sval",
+ "sval_nested",
+]
+
[[package]]
name = "syn"
version = "1.0.109"
@@ -8539,7 +9142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
dependencies = [
"bitflags 1.3.2",
- "core-foundation",
+ "core-foundation 0.9.4",
"system-configuration-sys 0.5.0",
]
@@ -8550,7 +9153,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 2.9.0",
- "core-foundation",
+ "core-foundation 0.9.4",
"system-configuration-sys 0.6.0",
]
@@ -8632,6 +9235,12 @@ dependencies = [
"unic-segment",
]
+[[package]]
+name = "termtree"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
+
[[package]]
name = "test-case"
version = "3.3.1"
@@ -8688,6 +9297,15 @@ dependencies = [
"toml 0.8.22",
]
+[[package]]
+name = "textwrap"
+version = "0.16.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
+dependencies = [
+ "smawk",
+]
+
[[package]]
name = "thirtyfour"
version = "0.31.0"
@@ -9544,7 +10162,16 @@ version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fef81aec2ca29576f9f6ae8755108640d0a86dd3161b2e8bca6cfa554e98f77d"
dependencies = [
- "typed-builder-macro",
+ "typed-builder-macro 0.21.2",
+]
+
+[[package]]
+name = "typed-builder"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "398a3a3c918c96de527dc11e6e846cd549d4508030b8a33e1da12789c856b81a"
+dependencies = [
+ "typed-builder-macro 0.22.0",
]
[[package]]
@@ -9558,6 +10185,17 @@ dependencies = [
"syn 2.0.101",
]
+[[package]]
+name = "typed-builder-macro"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e48cea23f68d1f78eb7bc092881b6bb88d3d6b5b7e6234f6f9c911da1ffb221"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
[[package]]
name = "typeid"
version = "1.0.2"
@@ -9749,6 +10387,127 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402bb19d8e03f1d1a7450e2bd613980869438e0666331be3e073089124aa1adc"
+[[package]]
+name = "uniffi"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6d968cb62160c11f2573e6be724ef8b1b18a277aededd17033f8a912d73e2b4"
+dependencies = [
+ "anyhow",
+ "camino",
+ "cargo_metadata 0.19.2",
+ "clap",
+ "uniffi_bindgen",
+ "uniffi_core",
+ "uniffi_macros",
+ "uniffi_pipeline",
+]
+
+[[package]]
+name = "uniffi_bindgen"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6b39ef1acbe1467d5d210f274fae344cb6f8766339330cb4c9688752899bf6b"
+dependencies = [
+ "anyhow",
+ "askama",
+ "camino",
+ "cargo_metadata 0.19.2",
+ "fs-err",
+ "glob",
+ "goblin",
+ "heck 0.5.0",
+ "indexmap 2.9.0",
+ "once_cell",
+ "serde",
+ "tempfile",
+ "textwrap",
+ "toml 0.5.11",
+ "uniffi_internal_macros",
+ "uniffi_meta",
+ "uniffi_pipeline",
+ "uniffi_udl",
+]
+
+[[package]]
+name = "uniffi_core"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2d990b553d6b9a7ee9c3ae71134674739913d52350b56152b0e613595bb5a6f"
+dependencies = [
+ "anyhow",
+ "bytes 1.10.1",
+ "once_cell",
+ "static_assertions",
+]
+
+[[package]]
+name = "uniffi_internal_macros"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "04f4f224becf14885c10e6e400b95cc4d1985738140cb194ccc2044563f8a56b"
+dependencies = [
+ "anyhow",
+ "indexmap 2.9.0",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.101",
+]
+
+[[package]]
+name = "uniffi_macros"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b481d385af334871d70904e6a5f129be7cd38c18fcf8dd8fd1f646b426a56d58"
+dependencies = [
+ "camino",
+ "fs-err",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "syn 2.0.101",
+ "toml 0.5.11",
+ "uniffi_meta",
+]
+
+[[package]]
+name = "uniffi_meta"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "10f817868a3b171bb7bf259e882138d104deafde65684689b4694c846d322491"
+dependencies = [
+ "anyhow",
+ "siphasher 0.3.11",
+ "uniffi_internal_macros",
+ "uniffi_pipeline",
+]
+
+[[package]]
+name = "uniffi_pipeline"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4b147e133ad7824e32426b90bc41fda584363563f2ba747f590eca1fd6fd14e6"
+dependencies = [
+ "anyhow",
+ "heck 0.5.0",
+ "indexmap 2.9.0",
+ "tempfile",
+ "uniffi_internal_macros",
+]
+
+[[package]]
+name = "uniffi_udl"
+version = "0.29.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caed654fb73da5abbc7a7e9c741532284532ba4762d6fe5071372df22a41730a"
+dependencies = [
+ "anyhow",
+ "textwrap",
+ "uniffi_meta",
+ "weedle2",
+]
+
[[package]]
name = "untrusted"
version = "0.7.1"
@@ -9847,6 +10606,7 @@ checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
dependencies = [
"getrandom 0.3.3",
"js-sys",
+ "serde",
"wasm-bindgen",
]
@@ -9871,6 +10631,42 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
+[[package]]
+name = "value-bag"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5"
+dependencies = [
+ "value-bag-serde1",
+ "value-bag-sval2",
+]
+
+[[package]]
+name = "value-bag-serde1"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35540706617d373b118d550d41f5dfe0b78a0c195dc13c6815e92e2638432306"
+dependencies = [
+ "erased-serde 0.4.6",
+ "serde",
+ "serde_fmt",
+]
+
+[[package]]
+name = "value-bag-sval2"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fe7e140a2658cc16f7ee7a86e413e803fc8f9b5127adc8755c19f9fefa63a52"
+dependencies = [
+ "sval",
+ "sval_buffer",
+ "sval_dynamic",
+ "sval_fmt",
+ "sval_json",
+ "sval_ref",
+ "sval_serde",
+]
+
[[package]]
name = "vaultrs"
version = "0.7.4"
@@ -10145,6 +10941,15 @@ dependencies = [
"rustls-pki-types",
]
+[[package]]
+name = "weedle2"
+version = "5.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e"
+dependencies = [
+ "nom 7.1.3",
+]
+
[[package]]
name = "whoami"
version = "1.5.2"
diff --git a/config/config.example.toml b/config/config.example.toml
index 967f76556c..c4eabbb369 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -1292,3 +1292,12 @@ internal_api_key = "test_internal_api_key" # API key for internal merchant id an
[internal_services] # Internal services base urls and configs
payments_base_url = "http://localhost:8080"
+
+[superposition]
+enabled = false # Enable or disable Superposition integration (default: false)
+endpoint = "http://superposition:8080" # Superposition service endpoint URL
+token = "your_superposition_token" # Superposition token
+org_id = "your_org_id" # Organization ID in Superposition
+workspace_id = "your_workspace_id" # Workspace ID in Superposition
+polling_interval = 15 # Polling interval in seconds for configuration updates
+request_timeout = 60 # Request timeout in seconds for Superposition API calls (optional, default: none)
diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml
index b852340144..c3e0618166 100644
--- a/config/deployments/env_specific.toml
+++ b/config/deployments/env_specific.toml
@@ -98,7 +98,7 @@ consolidated_events_topic = "topic" # Kafka topic to be used for Consolidat
authentication_analytics_topic = "topic" # Kafka topic to be used for Authentication events
fraud_check_analytics_topic = "topic" # Kafka topic to be used for Fraud Check events
routing_logs_topic = "topic" # Kafka topic to be used for Routing events
-revenue_recovery_topic = "topic" # Kafka topic to be used for Revenue Recovery Events
+revenue_recovery_topic = "topic" # Kafka topic to be used for Revenue Recovery Events
# File storage configuration
[file_storage]
@@ -393,9 +393,9 @@ ucs_psync_disabled_connectors = "cashtocode" # Comma-separated list of connec
[revenue_recovery]
# monitoring threshold - 120 days
-monitoring_threshold_in_seconds = 10368000
+monitoring_threshold_in_seconds = 10368000
retry_algorithm_type = "cascading"
-redis_ttl_in_seconds=3888000
+redis_ttl_in_seconds=3888000
# Card specific configuration for Revenue Recovery
[revenue_recovery.card_config.amex]
@@ -416,7 +416,7 @@ max_retry_count_for_thirty_day = 20
[revenue_recovery.recovery_timestamp] # Timestamp configuration for Revenue Recovery
initial_timestamp_in_seconds = 3600 # number of seconds added to start time for Decider service of Revenue Recovery
-job_schedule_buffer_time_in_seconds = 3600 # time in seconds to be added in schedule time as a buffer
+job_schedule_buffer_time_in_seconds = 3600 # time in seconds to be added in schedule time as a buffer
reopen_workflow_buffer_time_in_seconds = 3600 # time in seconds to be added in scheduling for calculate workflow
max_random_schedule_delay_in_seconds = 300 # max random delay in seconds to schedule the payment for Revenue Recovery
redis_ttl_buffer_in_seconds=300 # buffer time in seconds to be added to redis ttl for Revenue Recovery
@@ -430,4 +430,13 @@ encryption_key = "" # Key to encrypt and decrypt chat
proxy_connector_http_status_code = false # If enabled, the http status code of the connector will be proxied in the response
[internal_services] # Internal services base urls and configs
-payments_base_url = "http://localhost:8080"
\ No newline at end of file
+payments_base_url = "http://localhost:8080"
+
+[superposition]
+enabled = false # Enable or disable Superposition integration (default: false)
+endpoint = "http://superposition:8080" # Superposition service endpoint URL
+token = "your_superposition_token" # Superposition token
+org_id = "your_org_id" # Organization ID in Superposition
+workspace_id = "your_workspace_id" # Workspace ID in Superposition
+polling_interval = 15 # Polling interval in seconds for configuration updates
+# request_timeout = # Request timeout in seconds for Superposition API calls (optional, default: none)
diff --git a/config/development.toml b/config/development.toml
index 47bdec051b..472bba83f2 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -1407,3 +1407,12 @@ internal_api_key = "test_internal_api_key"
[internal_services]
payments_base_url = "http://localhost:8080"
+
+[superposition]
+enabled = false # Enable Superposition integration
+endpoint = "http://localhost:8081" # Superposition service endpoint
+token = "123456" # Superposition token
+org_id = "localorg" # Organization ID in Superposition
+workspace_id = "dev" # Workspace ID in Superposition
+polling_interval = 15 # Polling interval in seconds for configuration updates
+# request_timeout = # Request timeout in seconds for Superposition API calls (optional, default: none)
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 999f7e67df..989944b60c 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -1300,3 +1300,12 @@ internal_api_key = "test_internal_api_key" # API key for internal merchant id an
[internal_services] # Internal services base urls and configs
payments_base_url = "http://localhost:8080"
+
+[superposition]
+enabled = false # Enable Superposition for dynamic configuration management
+endpoint = "http://superposition:8080" # Superposition service endpoint
+token = "123456" # Superposition token
+org_id = "localorg" # Organization ID in Superposition
+workspace_id = "dev" # Workspace ID in Superposition
+polling_interval = 15 # Polling interval in seconds for configuration updates
+# request_timeout = # Request timeout in seconds for Superposition API calls (optional, default: none)
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 288b9d9141..db4b01cc0d 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -12,6 +12,7 @@ aws_kms = ["dep:aws-config", "dep:aws-sdk-kms"]
email = ["dep:aws-config"]
aws_s3 = ["dep:aws-config", "dep:aws-sdk-s3"]
hashicorp-vault = ["dep:vaultrs"]
+superposition = ["dep:open-feature", "dep:superposition_provider"]
v1 = ["hyperswitch_interfaces/v1", "common_utils/v1"]
v2 = ["hyperswitch_interfaces/v2", "common_utils/v2"]
revenue_recovery = [
@@ -69,6 +70,8 @@ http = "0.2.12"
url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "f719688943adf7bc17bb93dcb43f27485c17a96e", package = "rust-grpc-client" }
+open-feature = { version = "0.2.5", optional = true }
+superposition_provider = { version = "0.88.1", optional = true }
# First party crates
diff --git a/crates/external_services/src/lib.rs b/crates/external_services/src/lib.rs
index 23f0a59718..8b318d0235 100644
--- a/crates/external_services/src/lib.rs
+++ b/crates/external_services/src/lib.rs
@@ -2,32 +2,25 @@
#![warn(missing_docs, missing_debug_implementations)]
-#[cfg(feature = "email")]
-pub mod email;
-
#[cfg(feature = "aws_kms")]
pub mod aws_kms;
-
+/// crm module
+pub mod crm;
+#[cfg(feature = "email")]
+pub mod email;
pub mod file_storage;
-#[cfg(feature = "hashicorp-vault")]
-pub mod hashicorp_vault;
-
-pub mod no_encryption;
-
/// Building grpc clients to communicate with the server
pub mod grpc_client;
-
+#[cfg(feature = "hashicorp-vault")]
+pub mod hashicorp_vault;
/// http_client module
pub mod http_client;
-
/// hubspot_proxy module
pub mod hubspot_proxy;
-
pub mod managers;
-
-/// crm module
-pub mod crm;
-
+pub mod no_encryption;
+#[cfg(feature = "superposition")]
+pub mod superposition;
/// deserializers module_path
pub mod utils;
diff --git a/crates/external_services/src/superposition.rs b/crates/external_services/src/superposition.rs
new file mode 100644
index 0000000000..06b18142eb
--- /dev/null
+++ b/crates/external_services/src/superposition.rs
@@ -0,0 +1,186 @@
+//! Superposition client for dynamic configuration management
+
+/// Type definitions for Superposition integration
+pub mod types;
+
+use std::collections::HashMap;
+
+use common_utils::errors::CustomResult;
+use error_stack::report;
+use masking::ExposeInterface;
+
+pub use self::types::{ConfigContext, SuperpositionClientConfig, SuperpositionError};
+
+fn convert_open_feature_value(value: open_feature::Value) -> Result<serde_json::Value, String> {
+ match value {
+ open_feature::Value::String(s) => Ok(serde_json::Value::String(s)),
+ open_feature::Value::Bool(b) => Ok(serde_json::Value::Bool(b)),
+ open_feature::Value::Int(n) => Ok(serde_json::Value::Number(serde_json::Number::from(n))),
+ open_feature::Value::Float(f) => serde_json::Number::from_f64(f)
+ .map(serde_json::Value::Number)
+ .ok_or_else(|| format!("Invalid number: {f}")),
+ open_feature::Value::Struct(sv) => Ok(types::JsonValue::try_from(sv)?.into_inner()),
+ open_feature::Value::Array(values) => Ok(serde_json::Value::Array(
+ values
+ .into_iter()
+ .map(convert_open_feature_value)
+ .collect::<Result<Vec<_>, _>>()?,
+ )),
+ }
+}
+
+/// Superposition client wrapper
+// Debug trait cannot be derived because open_feature::Client doesn't implement Debug
+#[allow(missing_debug_implementations)]
+pub struct SuperpositionClient {
+ client: open_feature::Client,
+}
+
+impl SuperpositionClient {
+ /// Create a new Superposition client
+ pub async fn new(config: SuperpositionClientConfig) -> CustomResult<Self, SuperpositionError> {
+ let provider_options = superposition_provider::SuperpositionProviderOptions {
+ endpoint: config.endpoint.clone(),
+ token: config.token.expose(),
+ org_id: config.org_id.clone(),
+ workspace_id: config.workspace_id.clone(),
+ fallback_config: None,
+ evaluation_cache: None,
+ refresh_strategy: superposition_provider::RefreshStrategy::Polling(
+ superposition_provider::PollingStrategy {
+ interval: config.polling_interval,
+ timeout: config.request_timeout,
+ },
+ ),
+ experimentation_options: None,
+ };
+
+ // Create provider and set up OpenFeature
+ let provider = superposition_provider::SuperpositionProvider::new(provider_options);
+
+ // Initialize OpenFeature API and set provider
+ let mut api = open_feature::OpenFeature::singleton_mut().await;
+ api.set_provider(provider).await;
+
+ // Create client
+ let client = api.create_client();
+
+ router_env::logger::info!("Superposition client initialized successfully");
+
+ Ok(Self { client })
+ }
+
+ /// Build evaluation context for Superposition requests
+ fn build_evaluation_context(
+ &self,
+ context: Option<&ConfigContext>,
+ ) -> open_feature::EvaluationContext {
+ open_feature::EvaluationContext {
+ custom_fields: context.map_or(HashMap::new(), |ctx| {
+ ctx.values
+ .iter()
+ .map(|(k, v)| {
+ (
+ k.clone(),
+ open_feature::EvaluationContextFieldValue::String(v.clone()),
+ )
+ })
+ .collect()
+ }),
+ targeting_key: None,
+ }
+ }
+
+ /// Get a boolean configuration value from Superposition
+ pub async fn get_bool_value(
+ &self,
+ key: &str,
+ context: Option<&ConfigContext>,
+ ) -> CustomResult<bool, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context);
+
+ self.client
+ .get_bool_value(key, Some(&evaluation_context), None)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ClientError(format!(
+ "Failed to get bool value for key '{key}': {e:?}"
+ )))
+ })
+ }
+
+ /// Get a string configuration value from Superposition
+ pub async fn get_string_value(
+ &self,
+ key: &str,
+ context: Option<&ConfigContext>,
+ ) -> CustomResult<String, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context);
+
+ self.client
+ .get_string_value(key, Some(&evaluation_context), None)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ClientError(format!(
+ "Failed to get string value for key '{key}': {e:?}"
+ )))
+ })
+ }
+
+ /// Get an integer configuration value from Superposition
+ pub async fn get_int_value(
+ &self,
+ key: &str,
+ context: Option<&ConfigContext>,
+ ) -> CustomResult<i64, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context);
+
+ self.client
+ .get_int_value(key, Some(&evaluation_context), None)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ClientError(format!(
+ "Failed to get int value for key '{key}': {e:?}"
+ )))
+ })
+ }
+
+ /// Get a float configuration value from Superposition
+ pub async fn get_float_value(
+ &self,
+ key: &str,
+ context: Option<&ConfigContext>,
+ ) -> CustomResult<f64, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context);
+
+ self.client
+ .get_float_value(key, Some(&evaluation_context), None)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ClientError(format!(
+ "Failed to get float value for key '{key}': {e:?}"
+ )))
+ })
+ }
+
+ /// Get an object configuration value from Superposition
+ pub async fn get_object_value(
+ &self,
+ key: &str,
+ context: Option<&ConfigContext>,
+ ) -> CustomResult<serde_json::Value, SuperpositionError> {
+ let evaluation_context = self.build_evaluation_context(context);
+
+ let json_result = self
+ .client
+ .get_struct_value::<types::JsonValue>(key, Some(&evaluation_context), None)
+ .await
+ .map_err(|e| {
+ report!(SuperpositionError::ClientError(format!(
+ "Failed to get object value for key '{key}': {e:?}"
+ )))
+ })?;
+
+ Ok(json_result.into_inner())
+ }
+}
diff --git a/crates/external_services/src/superposition/types.rs b/crates/external_services/src/superposition/types.rs
new file mode 100644
index 0000000000..59f8a3a04c
--- /dev/null
+++ b/crates/external_services/src/superposition/types.rs
@@ -0,0 +1,179 @@
+//! Type definitions for Superposition integration
+
+use std::collections::HashMap;
+
+use common_utils::{errors::CustomResult, fp_utils::when};
+use masking::{ExposeInterface, Secret};
+
+/// Wrapper type for JSON values from Superposition
+#[derive(Debug, Clone)]
+pub struct JsonValue(serde_json::Value);
+
+impl JsonValue {
+ /// Consume the wrapper and return the inner JSON value
+ pub(super) fn into_inner(self) -> serde_json::Value {
+ self.0
+ }
+}
+
+impl TryFrom<open_feature::StructValue> for JsonValue {
+ type Error = String;
+
+ fn try_from(sv: open_feature::StructValue) -> Result<Self, Self::Error> {
+ let capacity = sv.fields.len();
+ sv.fields
+ .into_iter()
+ .try_fold(
+ serde_json::Map::with_capacity(capacity),
+ |mut map, (k, v)| {
+ let value = super::convert_open_feature_value(v)?;
+ map.insert(k, value);
+ Ok(map)
+ },
+ )
+ .map(|map| Self(serde_json::Value::Object(map)))
+ }
+}
+
+/// Configuration for Superposition integration
+#[derive(Debug, Clone, serde::Deserialize)]
+#[serde(default)]
+pub struct SuperpositionClientConfig {
+ /// Whether Superposition is enabled
+ pub enabled: bool,
+ /// Superposition API endpoint
+ pub endpoint: String,
+ /// Authentication token for Superposition
+ pub token: Secret<String>,
+ /// Organization ID in Superposition
+ pub org_id: String,
+ /// Workspace ID in Superposition
+ pub workspace_id: String,
+ /// Polling interval in seconds for configuration updates
+ pub polling_interval: u64,
+ /// Request timeout in seconds for Superposition API calls (None = no timeout)
+ pub request_timeout: Option<u64>,
+}
+
+impl Default for SuperpositionClientConfig {
+ fn default() -> Self {
+ Self {
+ enabled: false,
+ endpoint: String::new(),
+ token: Secret::new(String::new()),
+ org_id: String::new(),
+ workspace_id: String::new(),
+ polling_interval: 15,
+ request_timeout: None,
+ }
+ }
+}
+
+/// Errors that can occur when using Superposition
+#[derive(Debug, thiserror::Error)]
+pub enum SuperpositionError {
+ /// Error initializing the Superposition client
+ #[error("Failed to initialize Superposition client: {0}")]
+ ClientInitError(String),
+ /// Error from the Superposition client
+ #[error("Superposition client error: {0}")]
+ ClientError(String),
+ /// Invalid configuration provided
+ #[error("Invalid configuration: {0}")]
+ InvalidConfiguration(String),
+}
+
+/// Context for configuration requests
+#[derive(Debug, Clone, Default)]
+pub struct ConfigContext {
+ /// Key-value pairs for configuration context
+ pub(super) values: HashMap<String, String>,
+}
+
+impl SuperpositionClientConfig {
+ /// Validate the Superposition configuration
+ pub fn validate(&self) -> Result<(), SuperpositionError> {
+ if !self.enabled {
+ return Ok(());
+ }
+
+ when(self.endpoint.is_empty(), || {
+ Err(SuperpositionError::InvalidConfiguration(
+ "Superposition endpoint cannot be empty".to_string(),
+ ))
+ })?;
+
+ when(url::Url::parse(&self.endpoint).is_err(), || {
+ Err(SuperpositionError::InvalidConfiguration(
+ "Superposition endpoint must be a valid URL".to_string(),
+ ))
+ })?;
+
+ when(self.token.clone().expose().is_empty(), || {
+ Err(SuperpositionError::InvalidConfiguration(
+ "Superposition token cannot be empty".to_string(),
+ ))
+ })?;
+
+ when(self.org_id.is_empty(), || {
+ Err(SuperpositionError::InvalidConfiguration(
+ "Superposition org_id cannot be empty".to_string(),
+ ))
+ })?;
+
+ when(self.workspace_id.is_empty(), || {
+ Err(SuperpositionError::InvalidConfiguration(
+ "Superposition workspace_id cannot be empty".to_string(),
+ ))
+ })?;
+
+ Ok(())
+ }
+}
+
+impl ConfigContext {
+ /// Create a new empty context
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// Add a key-value pair to the context. Replaces existing value if key exists.
+ pub fn with(mut self, key: &str, value: &str) -> Self {
+ self.values.insert(key.to_string(), value.to_string());
+ self
+ }
+}
+
+#[cfg(feature = "superposition")]
+#[async_trait::async_trait]
+impl hyperswitch_interfaces::secrets_interface::secret_handler::SecretsHandler
+ for SuperpositionClientConfig
+{
+ async fn convert_to_raw_secret(
+ value: hyperswitch_interfaces::secrets_interface::secret_state::SecretStateContainer<
+ Self,
+ hyperswitch_interfaces::secrets_interface::secret_state::SecuredSecret,
+ >,
+ secret_management_client: &dyn hyperswitch_interfaces::secrets_interface::SecretManagementInterface,
+ ) -> CustomResult<
+ hyperswitch_interfaces::secrets_interface::secret_state::SecretStateContainer<
+ Self,
+ hyperswitch_interfaces::secrets_interface::secret_state::RawSecret,
+ >,
+ hyperswitch_interfaces::secrets_interface::SecretsManagementError,
+ > {
+ let superposition_config = value.get_inner();
+ let token = if superposition_config.enabled {
+ secret_management_client
+ .get_secret(superposition_config.token.clone())
+ .await?
+ } else {
+ superposition_config.token.clone()
+ };
+
+ Ok(value.transition_state(|superposition_config| Self {
+ token,
+ ..superposition_config
+ }))
+ }
+}
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 9c52f1d709..b3486257ef 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -10,7 +10,7 @@ license.workspace = true
[features]
default = ["common_default", "v1"]
-common_default = ["kv_store", "stripe", "oltp", "olap", "accounts_cache", "dummy_connector", "payouts", "payout_retry", "retry", "frm", "tls", "partial-auth", "km_forward_x_request_id"]
+common_default = ["kv_store", "stripe", "oltp", "olap", "accounts_cache", "dummy_connector", "payouts", "payout_retry", "retry", "frm", "tls", "partial-auth", "km_forward_x_request_id", "external_services/superposition"]
olap = ["hyperswitch_domain_models/olap", "storage_impl/olap", "scheduler/olap", "api_models/olap", "dep:analytics"]
tls = ["actix-web/rustls-0_22"]
email = ["external_services/email", "scheduler/email", "olap"]
diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rs
index 7aef8d7446..37b551081c 100644
--- a/crates/router/src/configs/secrets_transformers.rs
+++ b/crates/router/src/configs/secrets_transformers.rs
@@ -478,6 +478,15 @@ pub(crate) async fn fetch_raw_secrets(
.await
.expect("Failed to decrypt chat configs");
+ #[allow(clippy::expect_used)]
+ let superposition =
+ external_services::superposition::SuperpositionClientConfig::convert_to_raw_secret(
+ conf.superposition,
+ secret_management_client,
+ )
+ .await
+ .expect("Failed to decrypt superposition config");
+
Settings {
server: conf.server,
chat,
@@ -581,5 +590,6 @@ pub(crate) async fn fetch_raw_secrets(
enhancement: conf.enhancement,
proxy_status_mapping: conf.proxy_status_mapping,
internal_services: conf.internal_services,
+ superposition,
}
}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 2dd028cf72..28b21cc7e0 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -20,6 +20,7 @@ use external_services::{
encryption_management::EncryptionManagementConfig,
secrets_management::SecretsManagementConfig,
},
+ superposition::SuperpositionClientConfig,
};
pub use hyperswitch_interfaces::configs::Connectors;
use hyperswitch_interfaces::{
@@ -168,6 +169,7 @@ pub struct Settings<S: SecretState> {
pub infra_values: Option<HashMap<String, String>>,
#[serde(default)]
pub enhancement: Option<HashMap<String, String>>,
+ pub superposition: SecretStateContainer<SuperpositionClientConfig, S>,
pub proxy_status_mapping: ProxyStatusMapping,
pub internal_services: InternalServicesConfig,
}
@@ -1147,6 +1149,11 @@ impl Settings<SecuredSecret> {
.transpose()
.map_err(|err| ApplicationError::InvalidConfigurationValueError(err.to_string()))?;
+ self.superposition
+ .get_inner()
+ .validate()
+ .map_err(|err| ApplicationError::InvalidConfigurationValueError(err.to_string()))?;
+
Ok(())
}
}
diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs
index f121a83361..ca57eee0a9 100644
--- a/crates/router/src/consts.rs
+++ b/crates/router/src/consts.rs
@@ -339,6 +339,12 @@ pub const UCS_AUTH_CURRENCY_AUTH_KEY: &str = "currency-auth-key";
/// Form field name for challenge request during creq submission
pub const CREQ_CHALLENGE_REQUEST_KEY: &str = "creq";
+/// Superposition configuration keys
+pub mod superposition {
+ /// CVV requirement configuration key
+ pub const REQUIRES_CVV: &str = "requires_cvv";
+}
+
#[cfg(test)]
mod tests {
#![allow(clippy::expect_used)]
diff --git a/crates/router/src/core.rs b/crates/router/src/core.rs
index cef4e6f900..e180c1a9af 100644
--- a/crates/router/src/core.rs
+++ b/crates/router/src/core.rs
@@ -9,6 +9,7 @@ pub mod blocklist;
pub mod cache;
pub mod card_testing_guard;
pub mod cards_info;
+pub mod chat;
pub mod conditional_config;
pub mod configs;
#[cfg(feature = "olap")]
@@ -17,6 +18,8 @@ pub mod connector_validation;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod currency;
pub mod customers;
+#[cfg(feature = "v1")]
+pub mod debit_routing;
pub mod disputes;
pub mod encryption;
pub mod errors;
@@ -41,20 +44,28 @@ pub mod payout_link;
pub mod payouts;
pub mod pm_auth;
pub mod poll;
+pub mod profile_acquirer;
+#[cfg(feature = "v2")]
+pub mod proxy;
#[cfg(feature = "recon")]
pub mod recon;
#[cfg(feature = "v1")]
pub mod refunds;
#[cfg(feature = "v2")]
pub mod refunds_v2;
-
-#[cfg(feature = "v1")]
-pub mod debit_routing;
+pub mod relay;
+#[cfg(feature = "v2")]
+pub mod revenue_recovery;
+#[cfg(feature = "v2")]
+pub mod revenue_recovery_data_backfill;
pub mod routing;
#[cfg(feature = "v1")]
pub mod subscription;
pub mod surcharge_decision_config;
pub mod three_ds_decision_rule;
+pub mod tokenization;
+pub mod unified_authentication_service;
+pub mod unified_connector_service;
#[cfg(feature = "olap")]
pub mod user;
#[cfg(feature = "olap")]
@@ -65,18 +76,3 @@ pub mod verification;
#[cfg(feature = "olap")]
pub mod verify_connector;
pub mod webhooks;
-
-pub mod profile_acquirer;
-pub mod unified_authentication_service;
-pub mod unified_connector_service;
-
-#[cfg(feature = "v2")]
-pub mod proxy;
-pub mod relay;
-#[cfg(feature = "v2")]
-pub mod revenue_recovery;
-
-pub mod chat;
-#[cfg(feature = "v2")]
-pub mod revenue_recovery_data_backfill;
-pub mod tokenization;
diff --git a/crates/router/src/core/configs.rs b/crates/router/src/core/configs.rs
index be8dfc8382..247ce98b00 100644
--- a/crates/router/src/core/configs.rs
+++ b/crates/router/src/core/configs.rs
@@ -1,4 +1,6 @@
+use common_utils::errors::CustomResult;
use error_stack::ResultExt;
+use external_services::superposition::ConfigContext;
use crate::{
core::errors::{self, utils::StorageErrorExt, RouterResponse},
@@ -50,3 +52,235 @@ pub async fn config_delete(state: SessionState, key: String) -> RouterResponse<a
.to_not_found_response(errors::ApiErrorResponse::ConfigNotFound)?;
Ok(ApplicationResponse::Json(config.foreign_into()))
}
+
+/// Get a boolean configuration value with superposition and database fallback
+pub async fn get_config_bool(
+ state: &SessionState,
+ superposition_key: &str,
+ db_key: &str,
+ context: Option<ConfigContext>,
+ default_value: bool,
+) -> CustomResult<bool, errors::StorageError> {
+ // Try superposition first if available
+ let superposition_result = if let Some(ref superposition_client) = state.superposition_service {
+ match superposition_client
+ .get_bool_value(superposition_key, context.as_ref())
+ .await
+ {
+ Ok(value) => Some(value),
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to retrieve config from superposition, falling back to database: {:?}",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
+
+ // Use superposition result or fall back to database
+ let result = if let Some(value) = superposition_result {
+ Ok(value)
+ } else {
+ let config = state
+ .store
+ .find_config_by_key_unwrap_or(db_key, Some(default_value.to_string()))
+ .await?;
+
+ config
+ .config
+ .parse::<bool>()
+ .change_context(errors::StorageError::DeserializationFailed)
+ };
+
+ result
+}
+
+/// Get a string configuration value with superposition and database fallback
+pub async fn get_config_string(
+ state: &SessionState,
+ superposition_key: &str,
+ db_key: &str,
+ context: Option<ConfigContext>,
+ default_value: String,
+) -> CustomResult<String, errors::StorageError> {
+ // Try superposition first if available
+ let superposition_result = if let Some(ref superposition_client) = state.superposition_service {
+ match superposition_client
+ .get_string_value(superposition_key, context.as_ref())
+ .await
+ {
+ Ok(value) => Some(value),
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to retrieve config from superposition, falling back to database: {:?}",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
+
+ // Use superposition result or fall back to database
+ let result = if let Some(value) = superposition_result {
+ Ok(value)
+ } else {
+ let config = state
+ .store
+ .find_config_by_key_unwrap_or(db_key, Some(default_value))
+ .await?;
+
+ Ok(config.config)
+ };
+
+ result
+}
+
+/// Get an integer configuration value with superposition and database fallback
+pub async fn get_config_int(
+ state: &SessionState,
+ superposition_key: &str,
+ db_key: &str,
+ context: Option<ConfigContext>,
+ default_value: i64,
+) -> CustomResult<i64, errors::StorageError> {
+ // Try superposition first if available
+ let superposition_result = if let Some(ref superposition_client) = state.superposition_service {
+ match superposition_client
+ .get_int_value(superposition_key, context.as_ref())
+ .await
+ {
+ Ok(value) => Some(value),
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to retrieve config from superposition, falling back to database: {:?}",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
+
+ // Use superposition result or fall back to database
+ let result = if let Some(value) = superposition_result {
+ Ok(value)
+ } else {
+ let config = state
+ .store
+ .find_config_by_key_unwrap_or(db_key, Some(default_value.to_string()))
+ .await?;
+
+ config
+ .config
+ .parse::<i64>()
+ .change_context(errors::StorageError::DeserializationFailed)
+ };
+
+ result
+}
+
+/// Get a float configuration value with superposition and database fallback
+pub async fn get_config_float(
+ state: &SessionState,
+ superposition_key: &str,
+ db_key: &str,
+ context: Option<ConfigContext>,
+ default_value: f64,
+) -> CustomResult<f64, errors::StorageError> {
+ // Try superposition first if available
+ let superposition_result = if let Some(ref superposition_client) = state.superposition_service {
+ match superposition_client
+ .get_float_value(superposition_key, context.as_ref())
+ .await
+ {
+ Ok(value) => Some(value),
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to retrieve config from superposition, falling back to database: {:?}",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
+
+ // Use superposition result or fall back to database
+ let result = if let Some(value) = superposition_result {
+ Ok(value)
+ } else {
+ let config = state
+ .store
+ .find_config_by_key_unwrap_or(db_key, Some(default_value.to_string()))
+ .await?;
+
+ config
+ .config
+ .parse::<f64>()
+ .change_context(errors::StorageError::DeserializationFailed)
+ };
+
+ result
+}
+
+/// Get an object configuration value with superposition and database fallback
+pub async fn get_config_object<T>(
+ state: &SessionState,
+ superposition_key: &str,
+ db_key: &str,
+ context: Option<ConfigContext>,
+ default_value: T,
+) -> CustomResult<T, errors::StorageError>
+where
+ T: serde::de::DeserializeOwned + serde::Serialize,
+{
+ // Try superposition first if available
+ let superposition_result = if let Some(ref superposition_client) = state.superposition_service {
+ match superposition_client
+ .get_object_value(superposition_key, context.as_ref())
+ .await
+ {
+ Ok(json_value) => Some(
+ serde_json::from_value::<T>(json_value)
+ .change_context(errors::StorageError::DeserializationFailed),
+ ),
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to retrieve config from superposition, falling back to database: {:?}",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
+
+ // Use superposition result or fall back to database
+ let result = if let Some(superposition_result) = superposition_result {
+ superposition_result
+ } else {
+ let config = state
+ .store
+ .find_config_by_key_unwrap_or(
+ db_key,
+ Some(
+ serde_json::to_string(&default_value)
+ .change_context(errors::StorageError::SerializationFailed)?,
+ ),
+ )
+ .await?;
+
+ serde_json::from_str::<T>(&config.config)
+ .change_context(errors::StorageError::DeserializationFailed)
+ };
+
+ result
+}
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 8941dea672..3348cd2a8c 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -77,6 +77,7 @@ use crate::{
configs::settings,
consts as router_consts,
core::{
+ configs,
errors::{self, StorageErrorExt},
payment_methods::{network_tokenization, transformers as payment_methods, vault},
payments::{
@@ -4133,19 +4134,27 @@ pub async fn list_customer_payment_method(
.await
.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;
- let is_requires_cvv = db
- .find_config_by_key_unwrap_or(
- &merchant_context
- .get_merchant_account()
- .get_id()
- .get_requires_cvv_key(),
- Some("true".to_string()),
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to fetch requires_cvv config")?;
-
- let requires_cvv = is_requires_cvv.config != "false";
+ let requires_cvv = configs::get_config_bool(
+ state,
+ router_consts::superposition::REQUIRES_CVV, // superposition key
+ &merchant_context
+ .get_merchant_account()
+ .get_id()
+ .get_requires_cvv_key(), // database key
+ Some(
+ external_services::superposition::ConfigContext::new().with(
+ "merchant_id",
+ merchant_context
+ .get_merchant_account()
+ .get_id()
+ .get_string_repr(),
+ ),
+ ), // context
+ true, // default value
+ )
+ .await
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to fetch requires_cvv config")?;
let resp = db
.find_payment_method_by_customer_id_merchant_id_status(
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 7fdf59c271..3a46c1a976 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -18,6 +18,7 @@ use external_services::grpc_client::revenue_recovery::GrpcRecoveryHeaders;
use external_services::{
file_storage::FileStorageInterface,
grpc_client::{GrpcClients, GrpcHeaders, GrpcHeadersUcs, GrpcHeadersUcsBuilderInitial},
+ superposition::SuperpositionClient,
};
use hyperswitch_interfaces::{
crm::CrmInterface,
@@ -137,6 +138,7 @@ pub struct SessionState {
pub crm_client: Arc<dyn CrmInterface>,
pub infra_components: Option<serde_json::Value>,
pub enhancement: Option<HashMap<String, String>>,
+ pub superposition_service: Option<Arc<SuperpositionClient>>,
}
impl scheduler::SchedulerSessionState for SessionState {
fn get_db(&self) -> Box<dyn SchedulerInterface> {
@@ -261,6 +263,7 @@ pub struct AppState {
pub crm_client: Arc<dyn CrmInterface>,
pub infra_components: Option<serde_json::Value>,
pub enhancement: Option<HashMap<String, String>>,
+ pub superposition_service: Option<Arc<SuperpositionClient>>,
}
impl scheduler::SchedulerAppState for AppState {
fn get_tenants(&self) -> Vec<id_type::TenantId> {
@@ -427,6 +430,23 @@ impl AppState {
let grpc_client = conf.grpc_client.get_grpc_client_interface().await;
let infra_component_values = Self::process_env_mappings(conf.infra_values.clone());
let enhancement = conf.enhancement.clone();
+ let superposition_service = if conf.superposition.get_inner().enabled {
+ match SuperpositionClient::new(conf.superposition.get_inner().clone()).await {
+ Ok(client) => {
+ router_env::logger::info!("Superposition client initialized successfully");
+ Some(Arc::new(client))
+ }
+ Err(err) => {
+ router_env::logger::warn!(
+ "Failed to initialize superposition client: {:?}. Continuing without superposition support.",
+ err
+ );
+ None
+ }
+ }
+ } else {
+ None
+ };
Self {
flow_name: String::from("default"),
stores,
@@ -449,6 +469,7 @@ impl AppState {
crm_client,
infra_components: infra_component_values,
enhancement,
+ superposition_service,
}
})
.await
@@ -545,6 +566,7 @@ impl AppState {
crm_client: self.crm_client.clone(),
infra_components: self.infra_components.clone(),
enhancement: self.enhancement.clone(),
+ superposition_service: self.superposition_service.clone(),
})
}
diff --git a/docker-compose-development.yml b/docker-compose-development.yml
index 6bdda27c9e..ab5f616a4f 100644
--- a/docker-compose-development.yml
+++ b/docker-compose-development.yml
@@ -64,6 +64,17 @@ services:
# format -> postgresql://DB_USER:DB_PASSWORD@HOST:PORT/DATABASE_NAME
- DATABASE_URL=postgresql://db_user:db_pass@pg:5432/hyperswitch_db
+ superposition:
+ image: ghcr.io/juspay/superposition-demo:latest
+ ports:
+ - "8081:8080"
+ networks:
+ - router_net
+ environment:
+ - API_HOSTNAME=http://localhost:8081
+ profiles:
+ - superposition
+
### Application services
hyperswitch-server:
build: