From 03c71ea366041af060b385dc9d88d4b9eda4abea Mon Sep 17 00:00:00 2001 From: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:30:49 +0530 Subject: [PATCH 1/3] chore(env): remove unified_authentication_service base_url from integ, sandbox and production toml (#6865) --- config/deployments/env_specific.toml | 3 +++ config/deployments/integration_test.toml | 1 - config/deployments/production.toml | 1 - config/deployments/sandbox.toml | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml index 02d3fe66c09e..c470f364fe74 100644 --- a/config/deployments/env_specific.toml +++ b/config/deployments/env_specific.toml @@ -342,3 +342,6 @@ entity_logo_url = "https://example.com/logo.svg" # Logo URL of the entity to be foreground_color = "#000000" # Foreground color of email text primary_color = "#006DF9" # Primary color of email body background_color = "#FFFFFF" # Background color of email body + +[connectors.unified_authentication_service] #Unified Authentication Service Configuration +base_url = "http://localhost:8000" #base url to call unified authentication service diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index de8063b10294..fbf80ced5f17 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -107,7 +107,6 @@ thunes.base_url = "https://api.limonetikqualif.com/" trustpay.base_url = "https://test-tpgw.trustpay.eu/" trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/" tsys.base_url = "https://stagegw.transnox.com/" -unified_authentication_service.base_url = "http://localhost:8000" volt.base_url = "https://api.sandbox.volt.io/" wellsfargo.base_url = "https://apitest.cybersource.com/" wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/" diff --git a/config/deployments/production.toml b/config/deployments/production.toml index d4432b7021b9..a22b618bfa21 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -111,7 +111,6 @@ thunes.base_url = "https://api.limonetik.com/" trustpay.base_url = "https://tpgw.trustpay.eu/" trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/" tsys.base_url = "https://gateway.transit-pass.com/" -unified_authentication_service.base_url = "http://localhost:8000" volt.base_url = "https://api.volt.io/" wellsfargo.base_url = "https://api.cybersource.com/" wellsfargopayout.base_url = "https://api.wellsfargo.com/" diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index accf2f586afe..2defc5729cf2 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -111,7 +111,6 @@ thunes.base_url = "https://api.limonetikqualif.com/" trustpay.base_url = "https://test-tpgw.trustpay.eu/" trustpay.base_url_bank_redirects = "https://aapi.trustpay.eu/" tsys.base_url = "https://stagegw.transnox.com/" -unified_authentication_service.base_url = "http://localhost:8000" volt.base_url = "https://api.sandbox.volt.io/" wellsfargo.base_url = "https://apitest.cybersource.com/" wellsfargopayout.base_url = "https://api-sandbox.wellsfargo.com/" From db51ec43bc629dc20ceaa2bb57ede888d2d2fc2c Mon Sep 17 00:00:00 2001 From: Prajjwal Kumar Date: Wed, 18 Dec 2024 14:28:11 +0530 Subject: [PATCH 2/3] refactor(dynamic_routing): update the authentication for update config to include JWT type (#6785) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference/openapi_spec.json | 239 ++++++++++++++++++++++++++- crates/openapi/src/openapi.rs | 6 + crates/openapi/src/routes/routing.rs | 31 +++- crates/router/src/routes/routing.rs | 11 +- 4 files changed, 282 insertions(+), 5 deletions(-) diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index c31a8bd11ed6..33dd5d87a473 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -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" @@ -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": [ @@ -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.", @@ -10373,6 +10548,18 @@ } } }, + "DynamicRoutingConfigParams": { + "type": "string", + "enum": [ + "PaymentMethod", + "PaymentMethodType", + "AuthenticationType", + "Currency", + "Country", + "CardNetwork", + "CardBin" + ] + }, "DynamicRoutingFeatures": { "type": "string", "enum": [ @@ -24345,6 +24532,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": [ diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index db0db93109ba..65c76f8929f2 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -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, @@ -590,6 +592,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, diff --git a/crates/openapi/src/routes/routing.rs b/crates/openapi/src/routes/routing.rs index b0fcb75fa49b..6b968f80172e 100644 --- a/crates/openapi/src/routes/routing.rs +++ b/crates/openapi/src/routes/routing.rs @@ -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"), @@ -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"), diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs index 19b96a9dc843..76852bf12efe 100644 --- a/crates/router/src/routes/routing.rs +++ b/crates/router/src/routes/routing.rs @@ -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, @@ -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 From 4bc88a71903bbb06cc757569b4c20d2d63f9d245 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:22:05 +0000 Subject: [PATCH 3/3] chore(version): 2024.12.19.0 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb67d8929e3..48f61fc3f505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to HyperSwitch will be documented here. - - - +## 2024.12.19.0 + +### Refactors + +- **dynamic_routing:** Update the authentication for update config to include JWT type ([#6785](https://github.com/juspay/hyperswitch/pull/6785)) ([`db51ec4`](https://github.com/juspay/hyperswitch/commit/db51ec43bc629dc20ceaa2bb57ede888d2d2fc2c)) + +### Miscellaneous Tasks + +- **env:** Remove unified_authentication_service base_url from integ, sandbox and production toml ([#6865](https://github.com/juspay/hyperswitch/pull/6865)) ([`03c71ea`](https://github.com/juspay/hyperswitch/commit/03c71ea366041af060b385dc9d88d4b9eda4abea)) + +**Full Changelog:** [`2024.12.18.0...2024.12.19.0`](https://github.com/juspay/hyperswitch/compare/2024.12.18.0...2024.12.19.0) + +- - - + ## 2024.12.18.0 ### Features