Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
122e13c
add initial migration files
prajjwalkumar17 Dec 2, 2024
8a8a720
add storage impl
prajjwalkumar17 Dec 2, 2024
ac3d83a
add diesel models
prajjwalkumar17 Dec 2, 2024
9e559cf
push the stats to db
prajjwalkumar17 Dec 3, 2024
61352c4
Merge branch 'main' of https://github.com/juspay/hyperswitch into ana…
prajjwalkumar17 Dec 3, 2024
d327364
chore: run formatter
hyperswitch-bot[bot] Dec 3, 2024
c029004
minor refactors
prajjwalkumar17 Dec 3, 2024
f7890e9
Merge branch 'analytics_sr' of https://github.com/juspay/hyperswitch …
prajjwalkumar17 Dec 3, 2024
9b15f3d
minor refactors
prajjwalkumar17 Dec 3, 2024
7407e2c
remove ToSchema
prajjwalkumar17 Dec 3, 2024
f0634f3
rerun just migrate_v2 locally
prajjwalkumar17 Dec 3, 2024
7a35aa0
rerun just migrate_v2 locally
prajjwalkumar17 Dec 3, 2024
62e564f
address comments
prajjwalkumar17 Dec 3, 2024
c959ba3
update Cargo.toml
prajjwalkumar17 Dec 3, 2024
3fa616a
fix migration consistency
prajjwalkumar17 Dec 3, 2024
1fd5588
fix clippy lints
prajjwalkumar17 Dec 3, 2024
c1a3786
chore: run formatter
hyperswitch-bot[bot] Dec 3, 2024
9c66a74
fix diesel migrations
prajjwalkumar17 Dec 3, 2024
06119a9
Merge branch 'analytics_sr' of github.com:juspay/hyperswitch into ana…
prajjwalkumar17 Dec 3, 2024
97882ab
address comments
prajjwalkumar17 Dec 4, 2024
33a9444
address comments
prajjwalkumar17 Dec 4, 2024
5c7270d
chore: run formatter
hyperswitch-bot[bot] Dec 4, 2024
5fff359
address comments
prajjwalkumar17 Dec 4, 2024
32582ff
address comments
prajjwalkumar17 Dec 4, 2024
f6346f1
chore: run formatter
hyperswitch-bot[bot] Dec 4, 2024
f82a012
address migration lints
prajjwalkumar17 Dec 4, 2024
06f712d
Merge branch 'analytics_sr' of https://github.com/juspay/hyperswitch …
prajjwalkumar17 Dec 4, 2024
2685da6
add payment_method enum
prajjwalkumar17 Dec 4, 2024
0b41afe
pull main
prajjwalkumar17 Dec 5, 2024
e7dc090
add attempt id in dynamic_routing_stats table
prajjwalkumar17 Dec 5, 2024
00da72b
add attempt id in dynamic_routing_stats table
prajjwalkumar17 Dec 5, 2024
a253cc4
add amount as a field
prajjwalkumar17 Dec 6, 2024
6e9e153
migration
prajjwalkumar17 Dec 6, 2024
8300564
refactor(dynamic_routing): update the authentication for update confi…
prajjwalkumar17 Dec 10, 2024
9f0c685
Merge branch 'main' into analytics_sr
prajjwalkumar17 Dec 10, 2024
e1a98bc
chore: run formatter
hyperswitch-bot[bot] Dec 10, 2024
e0dec1a
update post to patch
prajjwalkumar17 Dec 10, 2024
b2a6c84
Merge branch 'analytics_sr' of https://github.com/juspay/hyperswitch …
prajjwalkumar17 Dec 10, 2024
7794bd9
add the route in openapi_spec
prajjwalkumar17 Dec 12, 2024
3cd23f2
resolve conflicts
prajjwalkumar17 Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 238 additions & 1 deletion api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,91 @@
]
}
},
"/account/:account_id/business_profile/:profile_id/dynamic_routing/success_based/toggle": {
"/account/{account_id}/business_profile/{profile_id}/dynamic_routing/success_based/config/{algorithm_id}": {
"patch": {
"tags": [
"Routing"
],
"summary": "Routing - Update success based dynamic routing config for profile",
"description": "Update success based dynamic routing algorithm",
"operationId": "Update success based dynamic routing configs",
"parameters": [
{
"name": "account_id",
"in": "path",
"description": "Merchant id",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "profile_id",
"in": "path",
"description": "Profile id under which Dynamic routing needs to be toggled",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "algorithm_id",
"in": "path",
"description": "Success based routing algorithm id which was last activated to update the config",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DynamicRoutingFeatures"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Routing Algorithm updated",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RoutingDictionaryRecord"
}
}
}
},
"400": {
"description": "Update body is malformed"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Resource missing"
},
"422": {
"description": "Unprocessable request"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"api_key": []
},
{
"jwt_key": []
}
]
}
},
"/account/{account_id}/business_profile/{profile_id}/dynamic_routing/success_based/toggle": {
"post": {
"tags": [
"Routing"
Expand Down Expand Up @@ -3996,6 +4080,80 @@
]
}
},
"/account/{account_id}/business_profile/{profile_id}/dynamic_routing/elimination/toggle": {
"post": {
"tags": [
"Routing"
],
"summary": "Routing - Toggle elimination routing for profile",
"description": "Create a elimination based dynamic routing algorithm",
"operationId": "Toggle elimination routing algorithm",
"parameters": [
{
"name": "account_id",
"in": "path",
"description": "Merchant id",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "profile_id",
"in": "path",
"description": "Profile id under which Dynamic routing needs to be toggled",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "enable",
"in": "query",
"description": "Feature to enable for success based routing",
"required": true,
"schema": {
"$ref": "#/components/schemas/DynamicRoutingFeatures"
}
}
],
"responses": {
"200": {
"description": "Routing Algorithm created",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RoutingDictionaryRecord"
}
}
}
},
"400": {
"description": "Request body is malformed"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Resource missing"
},
"422": {
"description": "Unprocessable request"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"api_key": []
},
{
"jwt_key": []
}
]
}
},
"/blocklist": {
"delete": {
"tags": [
Expand Down Expand Up @@ -9551,6 +9709,23 @@
"ZWL"
]
},
"CurrentBlockThreshold": {
"type": "object",
"properties": {
"duration_in_mins": {
"type": "integer",
"format": "int64",
"nullable": true,
"minimum": 0
},
"max_total_count": {
"type": "integer",
"format": "int64",
"nullable": true,
"minimum": 0
}
}
},
"CustomerAcceptance": {
"type": "object",
"description": "This \"CustomerAcceptance\" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.",
Expand Down Expand Up @@ -10319,6 +10494,18 @@
}
}
},
"DynamicRoutingConfigParams": {
"type": "string",
"enum": [
"PaymentMethod",
"PaymentMethodType",
"AuthenticationType",
"Currency",
"Country",
"CardNetwork",
"CardBin"
]
},
"DynamicRoutingFeatures": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -24291,6 +24478,56 @@
},
"additionalProperties": false
},
"SuccessBasedRoutingConfig": {
"type": "object",
"properties": {
"params": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DynamicRoutingConfigParams"
},
"nullable": true
},
"config": {
"allOf": [
{
"$ref": "#/components/schemas/SuccessBasedRoutingConfigBody"
}
],
"nullable": true
}
}
},
"SuccessBasedRoutingConfigBody": {
"type": "object",
"properties": {
"min_aggregates_size": {
"type": "integer",
"format": "int32",
"nullable": true,
"minimum": 0
},
"default_success_rate": {
"type": "number",
"format": "double",
"nullable": true
},
"max_aggregates_size": {
"type": "integer",
"format": "int32",
"nullable": true,
"minimum": 0
},
"current_block_threshold": {
"allOf": [
{
"$ref": "#/components/schemas/CurrentBlockThreshold"
}
],
"nullable": true
}
}
},
"SurchargeDetailsResponse": {
"type": "object",
"required": [
Expand Down
6 changes: 6 additions & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ Never share your secret api keys. Keep them guarded and secure.
routes::routing::routing_retrieve_linked_config,
routes::routing::routing_retrieve_default_config_for_profiles,
routes::routing::routing_update_default_config_for_profile,
routes::routing::success_based_routing_update_configs,
routes::routing::toggle_success_based_routing,
routes::routing::toggle_elimination_routing,

// Routes for blocklist
routes::blocklist::remove_entry_from_blocklist,
Expand Down Expand Up @@ -589,6 +591,10 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::routing::RoutingKind,
api_models::routing::RoutableConnectorChoice,
api_models::routing::DynamicRoutingFeatures,
api_models::routing::SuccessBasedRoutingConfig,
api_models::routing::DynamicRoutingConfigParams,
api_models::routing::CurrentBlockThreshold,
api_models::routing::SuccessBasedRoutingConfigBody,
api_models::routing::LinkedRoutingConfigRetrieveResponse,
api_models::routing::RoutingRetrieveResponse,
api_models::routing::ProfileDefaultRoutingConfig,
Expand Down
31 changes: 29 additions & 2 deletions crates/openapi/src/routes/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub async fn routing_update_default_config_for_profile() {}
/// Create a success based dynamic routing algorithm
#[utoipa::path(
post,
path = "/account/:account_id/business_profile/:profile_id/dynamic_routing/success_based/toggle",
path = "/account/{account_id}/business_profile/{profile_id}/dynamic_routing/success_based/toggle",
params(
("account_id" = String, Path, description = "Merchant id"),
("profile_id" = String, Path, description = "Profile id under which Dynamic routing needs to be toggled"),
Expand All @@ -280,13 +280,40 @@ pub async fn routing_update_default_config_for_profile() {}
)]
pub async fn toggle_success_based_routing() {}

#[cfg(feature = "v1")]
/// Routing - Update success based dynamic routing config for profile
///
/// Update success based dynamic routing algorithm
#[utoipa::path(
patch,
path = "/account/{account_id}/business_profile/{profile_id}/dynamic_routing/success_based/config/{algorithm_id}",
params(
("account_id" = String, Path, description = "Merchant id"),
("profile_id" = String, Path, description = "Profile id under which Dynamic routing needs to be toggled"),
("algorithm_id" = String, Path, description = "Success based routing algorithm id which was last activated to update the config"),
),
request_body = DynamicRoutingFeatures,
responses(
(status = 200, description = "Routing Algorithm updated", body = RoutingDictionaryRecord),
(status = 400, description = "Update body is malformed"),
(status = 500, description = "Internal server error"),
(status = 404, description = "Resource missing"),
(status = 422, description = "Unprocessable request"),
(status = 403, description = "Forbidden"),
),
tag = "Routing",
operation_id = "Update success based dynamic routing configs",
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn success_based_routing_update_configs() {}

#[cfg(feature = "v1")]
/// Routing - Toggle elimination routing for profile
///
/// Create a elimination based dynamic routing algorithm
#[utoipa::path(
post,
path = "/account/:account_id/business_profile/:profile_id/dynamic_routing/elimination/toggle",
path = "/account/{account_id}/business_profile/{profile_id}/dynamic_routing/elimination/toggle",
params(
("account_id" = String, Path, description = "Merchant id"),
("profile_id" = String, Path, description = "Profile id under which Dynamic routing needs to be toggled"),
Expand Down
11 changes: 9 additions & 2 deletions crates/router/src/routes/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ pub async fn success_based_routing_update_configs(
flow,
state,
&req,
routing_payload_wrapper,
routing_payload_wrapper.clone(),
|state, _, wrapper: routing_types::SuccessBasedRoutingPayloadWrapper, _| async {
Box::pin(routing::success_based_routing_update_configs(
state,
Expand All @@ -1081,7 +1081,14 @@ pub async fn success_based_routing_update_configs(
))
.await
},
&auth::AdminApiAuth,
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth),
&auth::JWTAuthProfileFromRoute {
profile_id: routing_payload_wrapper.profile_id,
required_permission: Permission::ProfileRoutingWrite,
},
req.headers(),
),
api_locking::LockAction::NotApplicable,
))
.await
Expand Down
Loading