From 02dee9c5811b83423a5cc7f90b203410b9e5c8a0 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:21:27 +0530 Subject: [PATCH] fix(openapi): correct schema references and semantics for v1 openApi spec (#8127) Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> --- api-reference/v1/openapi_spec_v1.json | 350 +++++++++++------- api-reference/v2/openapi_spec_v2.json | 8 +- crates/api_models/src/payments.rs | 29 +- .../src/connectors/payme/transformers.rs | 2 +- crates/openapi/src/openapi.rs | 9 +- crates/openapi/src/openapi_v2.rs | 1 + crates/openapi/src/routes/customers.rs | 2 + crates/openapi/src/routes/mandates.rs | 2 +- .../src/routes/merchant_connector_account.rs | 16 +- crates/openapi/src/routes/payment_link.rs | 4 +- crates/openapi/src/routes/payment_method.rs | 45 +-- crates/openapi/src/routes/payments.rs | 2 +- crates/openapi/src/routes/routing.rs | 2 +- .../src/core/payments/flows/session_flow.rs | 4 +- crates/router/src/routes/admin.rs | 95 ----- crates/router/src/routes/mandates.rs | 36 -- crates/router/src/routes/payment_link.rs | 35 -- crates/router/src/routes/payment_methods.rs | 41 -- crates/router/src/routes/refunds.rs | 105 ------ 19 files changed, 305 insertions(+), 483 deletions(-) diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json index 255db7ad06..9eac412150 100644 --- a/api-reference/v1/openapi_spec_v1.json +++ b/api-reference/v1/openapi_spec_v1.json @@ -1068,18 +1068,18 @@ "schema": { "type": "string" } + }, + { + "name": "client_secret", + "in": "query", + "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK", + "required": false, + "schema": { + "type": "string", + "nullable": true + } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RetrievePaymentLinkRequest" - } - } - }, - "required": true - }, "responses": { "200": { "description": "Gets details regarding payment link", @@ -1156,7 +1156,7 @@ ] } }, - "/{payment_id}/complete_authorize": { + "/payments/{payment_id}/complete_authorize": { "post": { "tags": [ "Payments" @@ -2053,7 +2053,7 @@ ] } }, - "/accounts/{account_id}/connectors": { + "/account/{account_id}/connectors": { "post": { "tags": [ "Merchant Connector Account" @@ -2186,7 +2186,7 @@ ] } }, - "/accounts/{account_id}/connectors/{connector_id}": { + "/account/{account_id}/connectors/{merchant_connector_id}": { "get": { "tags": [ "Merchant Connector Account" @@ -2205,13 +2205,12 @@ } }, { - "name": "connector_id", + "name": "merchant_connector_id", "in": "path", "description": "The unique identifier for the Merchant Connector", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -2257,13 +2256,12 @@ } }, { - "name": "connector_id", + "name": "merchant_connector_id", "in": "path", "description": "The unique identifier for the Merchant Connector", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -2338,13 +2336,12 @@ } }, { - "name": "connector_id", + "name": "merchant_connector_id", "in": "path", "description": "The unique identifier for the Merchant Connector", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -2616,7 +2613,7 @@ } }, "/customers/{customer_id}/mandates": { - "post": { + "get": { "tags": [ "Mandates" ], @@ -2855,6 +2852,32 @@ "summary": "Customers - List", "description": "Lists all the customers for a particular merchant id.", "operationId": "List all Customers for a Merchant", + "parameters": [ + { + "name": "offset", + "in": "query", + "description": "Offset for pagination", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "nullable": true, + "minimum": 0 + } + }, + { + "name": "limit", + "in": "query", + "description": "Limit for pagination", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "nullable": true, + "minimum": 0 + } + } + ], "responses": { "200": { "description": "Customers retrieved", @@ -2946,74 +2969,94 @@ "operationId": "List all Payment Methods for a Merchant", "parameters": [ { - "name": "account_id", - "in": "path", - "description": "The unique identifier for the merchant account", - "required": true, + "name": "client_secret", + "in": "query", + "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK", + "required": false, "schema": { - "type": "string" + "type": "string", + "nullable": true } }, { - "name": "accepted_country", + "name": "accepted_countries", "in": "query", "description": "The two-letter ISO currency code", - "required": true, + "required": false, "schema": { "type": "array", "items": { - "type": "string" - } + "$ref": "#/components/schemas/CountryAlpha2" + }, + "nullable": true } }, { - "name": "accepted_currency", - "in": "path", + "name": "accepted_currencies", + "in": "query", "description": "The three-letter ISO currency code", - "required": true, + "required": false, "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Currency" - } + }, + "nullable": true } }, { - "name": "minimum_amount", + "name": "amount", "in": "query", - "description": "The minimum amount accepted for processing by the particular payment method.", - "required": true, + "description": "The amount accepted for processing by the particular payment method.", + "required": false, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "nullable": true } }, { - "name": "maximum_amount", - "in": "query", - "description": "The maximum amount accepted for processing by the particular payment method.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "recurring_payment_enabled", + "name": "recurring_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for recurring payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true } }, { "name": "installment_payment_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for installment payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true + } + }, + { + "name": "limit", + "in": "query", + "description": "Indicates the limit of last used payment methods", + "required": false, + "schema": { + "type": "integer", + "format": "int64", + "nullable": true + } + }, + { + "name": "card_networks", + "in": "query", + "description": "Indicates whether the payment method is eligible for card netwotks", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CardNetwork" + }, + "nullable": true } } ], @@ -3064,65 +3107,94 @@ } }, { - "name": "accepted_country", + "name": "client_secret", "in": "query", - "description": "The two-letter ISO currency code", - "required": true, + "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK", + "required": false, "schema": { - "type": "array", - "items": { - "type": "string" - } + "type": "string", + "nullable": true } }, { - "name": "accepted_currency", - "in": "path", + "name": "accepted_countries", + "in": "query", + "description": "The two-letter ISO currency code", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "nullable": true + } + }, + { + "name": "accepted_currencies", + "in": "query", "description": "The three-letter ISO currency code", - "required": true, + "required": false, "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Currency" - } + }, + "nullable": true } }, { - "name": "minimum_amount", + "name": "amount", "in": "query", - "description": "The minimum amount accepted for processing by the particular payment method.", - "required": true, + "description": "The amount accepted for processing by the particular payment method.", + "required": false, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "nullable": true } }, { - "name": "maximum_amount", - "in": "query", - "description": "The maximum amount accepted for processing by the particular payment method.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "recurring_payment_enabled", + "name": "recurring_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for recurring payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true } }, { "name": "installment_payment_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for installment payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true + } + }, + { + "name": "limit", + "in": "query", + "description": "Indicates the limit of last used payment methods", + "required": false, + "schema": { + "type": "integer", + "format": "int64", + "nullable": true + } + }, + { + "name": "card_networks", + "in": "query", + "description": "Indicates whether the payment method is eligible for card netwotks", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CardNetwork" + }, + "nullable": true } } ], @@ -3161,83 +3233,94 @@ "operationId": "List Customer Payment Methods via Client Secret", "parameters": [ { - "name": "client-secret", - "in": "path", - "description": "A secret known only to your client and the authorization server. Used for client side authentication", - "required": true, + "name": "client_secret", + "in": "query", + "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK", + "required": false, "schema": { - "type": "string" + "type": "string", + "nullable": true } }, { - "name": "customer_id", - "in": "path", - "description": "The unique identifier for the customer account", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "accepted_country", + "name": "accepted_countries", "in": "query", "description": "The two-letter ISO currency code", - "required": true, + "required": false, "schema": { "type": "array", "items": { - "type": "string" - } + "$ref": "#/components/schemas/CountryAlpha2" + }, + "nullable": true } }, { - "name": "accepted_currency", - "in": "path", + "name": "accepted_currencies", + "in": "query", "description": "The three-letter ISO currency code", - "required": true, + "required": false, "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Currency" - } + }, + "nullable": true } }, { - "name": "minimum_amount", + "name": "amount", "in": "query", - "description": "The minimum amount accepted for processing by the particular payment method.", - "required": true, + "description": "The amount accepted for processing by the particular payment method.", + "required": false, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "nullable": true } }, { - "name": "maximum_amount", - "in": "query", - "description": "The maximum amount accepted for processing by the particular payment method.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "recurring_payment_enabled", + "name": "recurring_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for recurring payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true } }, { "name": "installment_payment_enabled", "in": "query", "description": "Indicates whether the payment method is eligible for installment payments", - "required": true, + "required": false, "schema": { - "type": "boolean" + "type": "boolean", + "nullable": true + } + }, + { + "name": "limit", + "in": "query", + "description": "Indicates the limit of last used payment methods", + "required": false, + "schema": { + "type": "integer", + "format": "int64", + "nullable": true + } + }, + { + "name": "card_networks", + "in": "query", + "description": "Indicates whether the payment method is eligible for card netwotks", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CardNetwork" + }, + "nullable": true } } ], @@ -4660,7 +4743,7 @@ ] } }, - "/account/:account_id/business_profile/:profile_id/dynamic_routing/contracts/toggle": { + "/account/{account_id}/business_profile/{profile_id}/dynamic_routing/contracts/toggle": { "post": { "tags": [ "Routing" @@ -7064,9 +7147,7 @@ "$ref": "#/components/schemas/NoThirdPartySdkSessionResponse" }, { - "type": "object", - "default": null, - "nullable": true + "$ref": "#/components/schemas/NullObject" } ] }, @@ -17697,6 +17778,10 @@ } } }, + "NullObject": { + "default": null, + "nullable": true + }, "NumberComparison": { "type": "object", "description": "Represents a number comparison for \"NumberComparisonArrayValue\"", @@ -30641,6 +30726,11 @@ "name": "api-key", "description": "Ephemeral keys provide temporary access to singular data, such as access to a single customer object for a short period of time." }, + "jwt_key": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + }, "publishable_key": { "type": "apiKey", "in": "header", diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json index 853b0c3c5b..b91ec81b08 100644 --- a/api-reference/v2/openapi_spec_v2.json +++ b/api-reference/v2/openapi_spec_v2.json @@ -4671,9 +4671,7 @@ "$ref": "#/components/schemas/NoThirdPartySdkSessionResponse" }, { - "type": "object", - "default": null, - "nullable": true + "$ref": "#/components/schemas/NullObject" } ] }, @@ -14703,6 +14701,10 @@ } } }, + "NullObject": { + "default": null, + "nullable": true + }, "NumberComparison": { "type": "object", "description": "Represents a number comparison for \"NumberComparisonArrayValue\"", diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 25e85c3f90..648df7b05a 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -7357,7 +7357,7 @@ pub enum ApplePaySessionResponse { /// This is the common response most of the times NoThirdPartySdk(NoThirdPartySdkSessionResponse), /// This is for the empty session response - NoSessionResponse, + NoSessionResponse(NullObject), } #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema, serde::Deserialize)] @@ -8953,3 +8953,30 @@ pub struct RecordAttemptErrorDetails { /// A string indicating how to proceed with an network error if payment gateway provide one. This is used to understand the network error code better. pub network_error_message: Option, } + +#[derive(Debug, Clone, Eq, PartialEq, ToSchema)] +pub struct NullObject; + +impl Serialize for NullObject { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_none() + } +} + +#[cfg(test)] +mod null_object_test { + use serde_json; + + use super::*; + + #[allow(clippy::unwrap_used)] + #[test] + fn test_null_object_serialization() { + let null_object = NullObject; + let serialized = serde_json::to_string(&null_object).unwrap(); + assert_eq!(serialized, "null"); + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/payme/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payme/transformers.rs index c587d2def5..7e58d9ed70 100644 --- a/crates/hyperswitch_connectors/src/connectors/payme/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/payme/transformers.rs @@ -572,7 +572,7 @@ impl ))) => Some(api_models::payments::SessionToken::ApplePay(Box::new( api_models::payments::ApplepaySessionTokenResponse { session_token_data: Some( - api_models::payments::ApplePaySessionResponse::NoSessionResponse, + api_models::payments::ApplePaySessionResponse::NoSessionResponse(api_models::payments::NullObject), ), payment_request_data: Some( api_models::payments::ApplePayPaymentRequest { diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 03b70f0b78..8ce212dd09 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -467,6 +467,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::PazeWalletData, api_models::payments::SessionToken, api_models::payments::ApplePaySessionResponse, + api_models::payments::NullObject, api_models::payments::ThirdPartySdkSessionResponse, api_models::payments::NoThirdPartySdkSessionResponse, api_models::payments::SecretInfoToInitiateSdk, @@ -798,7 +799,9 @@ struct SecurityAddon; impl utoipa::Modify for SecurityAddon { fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) { - use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme}; + use utoipa::openapi::security::{ + ApiKey, ApiKeyValue, HttpAuthScheme, HttpBuilder, SecurityScheme, + }; if let Some(components) = openapi.components.as_mut() { components.add_security_schemes_from_iter([ @@ -833,6 +836,10 @@ impl utoipa::Modify for SecurityAddon { to a single customer object for a short period of time." ))), ), + ( + "jwt_key", + SecurityScheme::Http(HttpBuilder::new().scheme(HttpAuthScheme::Bearer).bearer_format("JWT").build()) + ) ]); } } diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 43bf1159e7..d55d5829bd 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -346,6 +346,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::gsm::GsmDeleteResponse, api_models::gsm::GsmResponse, api_models::gsm::GsmDecision, + api_models::payments::NullObject, api_models::payments::AddressDetails, api_models::payments::BankDebitData, api_models::payments::AliPayQr, diff --git a/crates/openapi/src/routes/customers.rs b/crates/openapi/src/routes/customers.rs index f23b8b3495..b1451abc4d 100644 --- a/crates/openapi/src/routes/customers.rs +++ b/crates/openapi/src/routes/customers.rs @@ -95,6 +95,8 @@ pub async fn customers_delete() {} #[utoipa::path( get, path = "/customers/list", + params (("offset" = Option, Query, description = "Offset for pagination"), + ("limit" = Option, Query, description = "Limit for pagination")), responses( (status = 200, description = "Customers retrieved", body = Vec), (status = 400, description = "Invalid Data"), diff --git a/crates/openapi/src/routes/mandates.rs b/crates/openapi/src/routes/mandates.rs index b87affde8b..dc357f1fcb 100644 --- a/crates/openapi/src/routes/mandates.rs +++ b/crates/openapi/src/routes/mandates.rs @@ -64,7 +64,7 @@ pub async fn retrieve_mandates_list() {} /// /// Lists all the mandates for a particular customer id. #[utoipa::path( - post, + get, path = "/customers/{customer_id}/mandates", params( ("customer_id" = String, Path, description = "The unique identifier for the customer") diff --git a/crates/openapi/src/routes/merchant_connector_account.rs b/crates/openapi/src/routes/merchant_connector_account.rs index 9d64e15047..bd249bf242 100644 --- a/crates/openapi/src/routes/merchant_connector_account.rs +++ b/crates/openapi/src/routes/merchant_connector_account.rs @@ -4,7 +4,7 @@ #[cfg(feature = "v1")] #[utoipa::path( post, - path = "/accounts/{account_id}/connectors", + path = "/account/{account_id}/connectors", params( ("account_id" = String, Path, description = "The unique identifier for the merchant account") ), @@ -133,10 +133,10 @@ pub async fn connector_create() {} #[cfg(feature = "v1")] #[utoipa::path( get, - path = "/accounts/{account_id}/connectors/{connector_id}", + path = "/account/{account_id}/connectors/{merchant_connector_id}", params( ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") + ("merchant_connector_id" = String, Path, description = "The unique identifier for the Merchant Connector") ), responses( (status = 200, description = "Merchant Connector retrieved successfully", body = MerchantConnectorResponse), @@ -175,7 +175,7 @@ pub async fn connector_retrieve() {} /// List Merchant Connector Details for the merchant #[utoipa::path( get, - path = "/accounts/{account_id}/connectors", + path = "/account/{account_id}/connectors", params( ("account_id" = String, Path, description = "The unique identifier for the merchant account"), ), @@ -196,7 +196,7 @@ pub async fn connector_list() {} #[cfg(feature = "v1")] #[utoipa::path( post, - path = "/accounts/{account_id}/connectors/{connector_id}", + path = "/account/{account_id}/connectors/{merchant_connector_id}", request_body( content = MerchantConnectorUpdate, examples( @@ -225,7 +225,7 @@ pub async fn connector_list() {} ), params( ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") + ("merchant_connector_id" = String, Path, description = "The unique identifier for the Merchant Connector") ), responses( (status = 200, description = "Merchant Connector Updated", body = MerchantConnectorResponse), @@ -291,10 +291,10 @@ pub async fn connector_update() {} #[cfg(feature = "v1")] #[utoipa::path( delete, - path = "/accounts/{account_id}/connectors/{connector_id}", + path = "/account/{account_id}/connectors/{merchant_connector_id}", params( ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") + ("merchant_connector_id" = String, Path, description = "The unique identifier for the Merchant Connector") ), responses( (status = 200, description = "Merchant Connector Deleted", body = MerchantConnectorDeleteResponse), diff --git a/crates/openapi/src/routes/payment_link.rs b/crates/openapi/src/routes/payment_link.rs index 9b9cb3a4d5..7d5ac5247b 100644 --- a/crates/openapi/src/routes/payment_link.rs +++ b/crates/openapi/src/routes/payment_link.rs @@ -5,9 +5,9 @@ get, path = "/payment_link/{payment_link_id}", params( - ("payment_link_id" = String, Path, description = "The identifier for payment link") + ("payment_link_id" = String, Path, description = "The identifier for payment link"), + ("client_secret" = Option, Query, description = "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK"), ), - request_body=RetrievePaymentLinkRequest, responses( (status = 200, description = "Gets details regarding payment link", body = RetrievePaymentLinkResponse), (status = 404, description = "No payment link found") diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index 2e99106364..0cfcde2cb7 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -42,13 +42,14 @@ pub async fn create_payment_method_api() {} get, path = "/account/payment_methods", params ( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("accepted_country" = Vec, Query, description = "The two-letter ISO currency code"), - ("accepted_currency" = Vec, Path, description = "The three-letter ISO currency code"), - ("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."), - ("maximum_amount" = i64, Query, description = "The maximum amount accepted for processing by the particular payment method."), - ("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"), - ("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("client_secret" = Option, Query, description = "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK"), + ("accepted_countries" = Option>, Query, description = "The two-letter ISO currency code"), + ("accepted_currencies" = Option>, Query, description = "The three-letter ISO currency code"), + ("amount" = Option, Query, description = "The amount accepted for processing by the particular payment method."), + ("recurring_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for recurring payments"), + ("installment_payment_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("limit" = Option, Query, description = "Indicates the limit of last used payment methods"), + ("card_networks" = Option>, Query, description = "Indicates whether the payment method is eligible for card netwotks"), ), responses( (status = 200, description = "Payment Methods retrieved", body = PaymentMethodListResponse), @@ -69,12 +70,14 @@ pub async fn list_payment_method_api() {} path = "/customers/{customer_id}/payment_methods", params ( ("customer_id" = String, Path, description = "The unique identifier for the customer account"), - ("accepted_country" = Vec, Query, description = "The two-letter ISO currency code"), - ("accepted_currency" = Vec, Path, description = "The three-letter ISO currency code"), - ("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."), - ("maximum_amount" = i64, Query, description = "The maximum amount accepted for processing by the particular payment method."), - ("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"), - ("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("client_secret" = Option, Query, description = "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK"), + ("accepted_countries" = Option>, Query, description = "The two-letter ISO currency code"), + ("accepted_currencies" = Option>, Query, description = "The three-letter ISO currency code"), + ("amount" = Option, Query, description = "The amount accepted for processing by the particular payment method."), + ("recurring_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for recurring payments"), + ("installment_payment_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("limit" = Option, Query, description = "Indicates the limit of last used payment methods"), + ("card_networks" = Option>, Query, description = "Indicates whether the payment method is eligible for card netwotks"), ), responses( (status = 200, description = "Payment Methods retrieved", body = CustomerPaymentMethodsListResponse), @@ -95,14 +98,14 @@ pub async fn list_customer_payment_method_api() {} get, path = "/customers/payment_methods", params ( - ("client-secret" = String, Path, description = "A secret known only to your client and the authorization server. Used for client side authentication"), - ("customer_id" = String, Path, description = "The unique identifier for the customer account"), - ("accepted_country" = Vec, Query, description = "The two-letter ISO currency code"), - ("accepted_currency" = Vec, Path, description = "The three-letter ISO currency code"), - ("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."), - ("maximum_amount" = i64, Query, description = "The maximum amount accepted for processing by the particular payment method."), - ("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"), - ("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("client_secret" = Option, Query, description = "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK"), + ("accepted_countries" = Option>, Query, description = "The two-letter ISO currency code"), + ("accepted_currencies" = Option>, Query, description = "The three-letter ISO currency code"), + ("amount" = Option, Query, description = "The amount accepted for processing by the particular payment method."), + ("recurring_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for recurring payments"), + ("installment_payment_enabled" = Option, Query, description = "Indicates whether the payment method is eligible for installment payments"), + ("limit" = Option, Query, description = "Indicates the limit of last used payment methods"), + ("card_networks" = Option>, Query, description = "Indicates whether the payment method is eligible for card netwotks"), ), responses( (status = 200, description = "Payment Methods retrieved for customer tied to its respective client-secret passed in the param", body = CustomerPaymentMethodsListResponse), diff --git a/crates/openapi/src/routes/payments.rs b/crates/openapi/src/routes/payments.rs index 6160b68b44..66774a283b 100644 --- a/crates/openapi/src/routes/payments.rs +++ b/crates/openapi/src/routes/payments.rs @@ -757,7 +757,7 @@ pub fn payments_external_authentication() {} /// Payments - Complete Authorize #[utoipa::path( post, - path = "/{payment_id}/complete_authorize", + path = "/payments/{payment_id}/complete_authorize", request_body=PaymentsCompleteAuthorizeRequest, params( ("payment_id" =String, Path, description = "The identifier for payment") diff --git a/crates/openapi/src/routes/routing.rs b/crates/openapi/src/routes/routing.rs index c21669a993..f657915e6a 100644 --- a/crates/openapi/src/routes/routing.rs +++ b/crates/openapi/src/routes/routing.rs @@ -339,7 +339,7 @@ pub async fn toggle_elimination_routing() {} /// Create a Contract based dynamic routing algorithm #[utoipa::path( post, - path = "/account/:account_id/business_profile/:profile_id/dynamic_routing/contracts/toggle", + path = "/account/{account_id}/business_profile/{profile_id}/dynamic_routing/contracts/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/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs index 3c768a40b1..a805f455b4 100644 --- a/crates/router/src/core/payments/flows/session_flow.rs +++ b/crates/router/src/core/payments/flows/session_flow.rs @@ -269,7 +269,9 @@ async fn create_applepay_session_token( let delayed_response = is_session_response_delayed(state, connector); if delayed_response { let delayed_response_apple_pay_session = - Some(payment_types::ApplePaySessionResponse::NoSessionResponse); + Some(payment_types::ApplePaySessionResponse::NoSessionResponse( + api_models::payments::NullObject, + )); create_apple_pay_session_response( router_data, delayed_response_apple_pay_session, diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs index 9e9329ac54..d3ffb715b7 100644 --- a/crates/router/src/routes/admin.rs +++ b/crates/router/src/routes/admin.rs @@ -563,22 +563,6 @@ pub async fn connector_create( /// /// Retrieve Merchant Connector Details #[cfg(feature = "v1")] -#[utoipa::path( - get, - path = "/accounts/{account_id}/connectors/{connector_id}", - params( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") - ), - responses( - (status = 200, description = "Merchant Connector retrieved successfully", body = MerchantConnectorResponse), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "Retrieve a Merchant Connector", - security(("admin_api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsRetrieve))] pub async fn connector_retrieve( state: web::Data, @@ -701,21 +685,6 @@ pub async fn connector_list( /// Merchant Connector - List /// /// List Merchant Connector Details for the merchant -#[utoipa::path( - get, - path = "/accounts/{account_id}/connectors", - params( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ), - responses( - (status = 200, description = "Merchant Connector list retrieved successfully", body = Vec), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "List all Merchant Connectors Admin", - security(("admin_api_key" = [])) -)] #[cfg(feature = "v1")] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsList))] pub async fn connector_list( @@ -749,21 +718,6 @@ pub async fn connector_list( /// Merchant Connector - List /// /// List Merchant Connector Details for the merchant -#[utoipa::path( - get, - path = "/accounts/{account_id}/profile/connectors", - params( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ), - responses( - (status = 200, description = "Merchant Connector list retrieved successfully", body = Vec), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "List all Merchant Connectors for The given Profile", - security(("admin_api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsList))] pub async fn connector_list_profile( state: web::Data, @@ -802,23 +756,6 @@ pub async fn connector_list_profile( /// /// To update an existing Merchant Connector. Helpful in enabling / disabling different payment methods and other settings for the connector etc. #[cfg(feature = "v1")] -#[utoipa::path( - post, - path = "/accounts/{account_id}/connectors/{connector_id}", - request_body = MerchantConnectorUpdate, - params( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") - ), - responses( - (status = 200, description = "Merchant Connector Updated", body = MerchantConnectorResponse), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "Update a Merchant Connector", - security(("admin_api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsUpdate))] pub async fn connector_update( state: web::Data, @@ -863,22 +800,6 @@ pub async fn connector_update( /// /// To update an existing Merchant Connector. Helpful in enabling / disabling different payment methods and other settings for the connector etc. #[cfg(feature = "v2")] -#[utoipa::path( - post, - path = "/connector_accounts/{id}", - request_body = MerchantConnectorUpdate, - params( - ("id" = i32, Path, description = "The unique identifier for the Merchant Connector") - ), - responses( - (status = 200, description = "Merchant Connector Updated", body = MerchantConnectorResponse), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "Update a Merchant Connector", - security(("admin_api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsUpdate))] pub async fn connector_update( state: web::Data, @@ -913,22 +834,6 @@ pub async fn connector_update( /// /// Delete or Detach a Merchant Connector from Merchant Account #[cfg(feature = "v1")] -#[utoipa::path( - delete, - path = "/accounts/{account_id}/connectors/{connector_id}", - params( - ("account_id" = String, Path, description = "The unique identifier for the merchant account"), - ("connector_id" = i32, Path, description = "The unique identifier for the Merchant Connector") - ), - responses( - (status = 200, description = "Merchant Connector Deleted", body = MerchantConnectorDeleteResponse), - (status = 404, description = "Merchant Connector does not exist in records"), - (status = 401, description = "Unauthorized request") - ), - tag = "Merchant Connector Account", - operation_id = "Delete a Merchant Connector", - security(("admin_api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MerchantConnectorsDelete))] pub async fn connector_delete( state: web::Data, diff --git a/crates/router/src/routes/mandates.rs b/crates/router/src/routes/mandates.rs index 3169fce630..1d62f9d936 100644 --- a/crates/router/src/routes/mandates.rs +++ b/crates/router/src/routes/mandates.rs @@ -11,20 +11,6 @@ use crate::{ /// Mandates - Retrieve Mandate /// /// Retrieves a mandate created using the Payments/Create API -#[utoipa::path( - get, - path = "/mandates/{mandate_id}", - params( - ("mandate_id" = String, Path, description = "The identifier for mandate") - ), - responses( - (status = 200, description = "The mandate was retrieved successfully", body = MandateResponse), - (status = 404, description = "Mandate does not exist in our records") - ), - tag = "Mandates", - operation_id = "Retrieve a Mandate", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MandatesRetrieve))] // #[get("/{id}")] pub async fn get_mandate( @@ -87,28 +73,6 @@ pub async fn revoke_mandate( .await } /// Mandates - List Mandates -#[utoipa::path( - get, - path = "/mandates/list", - params( - ("limit" = Option, Query, description = "The maximum number of Mandate Objects to include in the response"), - ("mandate_status" = Option, Query, description = "The status of mandate"), - ("connector" = Option, Query, description = "The connector linked to mandate"), - ("created_time" = Option, Query, description = "The time at which mandate is created"), - ("created_time.lt" = Option, Query, description = "Time less than the mandate created time"), - ("created_time.gt" = Option, Query, description = "Time greater than the mandate created time"), - ("created_time.lte" = Option, Query, description = "Time less than or equals to the mandate created time"), - ("created_time.gte" = Option, Query, description = "Time greater than or equals to the mandate created time"), - ("offset" = Option, Query, description = "The number of Mandate Objects to skip when retrieving the list Mandates."), - ), - responses( - (status = 200, description = "The mandate list was retrieved successfully", body = Vec), - (status = 401, description = "Unauthorized request") - ), - tag = "Mandates", - operation_id = "List Mandates", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::MandatesList))] pub async fn retrieve_mandates_list( state: web::Data, diff --git a/crates/router/src/routes/payment_link.rs b/crates/router/src/routes/payment_link.rs index 26ead2845a..fc8cbd0043 100644 --- a/crates/router/src/routes/payment_link.rs +++ b/crates/router/src/routes/payment_link.rs @@ -11,21 +11,6 @@ use crate::{ /// Payments Link - Retrieve /// /// To retrieve the properties of a Payment Link. This may be used to get the status of a previously initiated payment or next action for an ongoing payment -#[utoipa::path( - get, - path = "/payment_link/{payment_link_id}", - params( - ("payment_link_id" = String, Path, description = "The identifier for payment link") - ), - request_body=RetrievePaymentLinkRequest, - responses( - (status = 200, description = "Gets details regarding payment link", body = RetrievePaymentLinkResponse), - (status = 404, description = "No payment link found") - ), - tag = "Payments", - operation_id = "Retrieve a Payment Link", - security(("api_key" = []), ("publishable_key" = [])) -)] #[instrument(skip(state, req), fields(flow = ?Flow::PaymentLinkRetrieve))] pub async fn payment_link_retrieve( state: web::Data, @@ -133,26 +118,6 @@ pub async fn initiate_secure_payment_link( /// Payment Link - List /// /// To list the payment links -#[utoipa::path( - get, - path = "/payment_link/list", - params( - ("limit" = Option, Query, description = "The maximum number of payment_link Objects to include in the response"), - ("connector" = Option, Query, description = "The connector linked to payment_link"), - ("created_time" = Option, Query, description = "The time at which payment_link is created"), - ("created_time.lt" = Option, Query, description = "Time less than the payment_link created time"), - ("created_time.gt" = Option, Query, description = "Time greater than the payment_link created time"), - ("created_time.lte" = Option, Query, description = "Time less than or equals to the payment_link created time"), - ("created_time.gte" = Option, Query, description = "Time greater than or equals to the payment_link created time"), - ), - responses( - (status = 200, description = "The payment link list was retrieved successfully"), - (status = 401, description = "Unauthorized request") - ), - tag = "Payment Link", - operation_id = "List all Payment links", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::PaymentLinkList))] pub async fn payments_link_list( state: web::Data, diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs index f094b89a16..20d0121ebd 100644 --- a/crates/router/src/routes/payment_methods.rs +++ b/crates/router/src/routes/payment_methods.rs @@ -469,26 +469,6 @@ pub async fn list_payment_method_api( /// List payment methods for a Customer /// /// To filter and list the applicable payment methods for a particular Customer ID -#[utoipa::path( - get, - path = "/customers/{customer_id}/payment_methods", - params ( - ("accepted_country" = Vec, Query, description = "The two-letter ISO currency code"), - ("accepted_currency" = Vec, Path, description = "The three-letter ISO currency code"), - ("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."), - ("maximum_amount" = i64, Query, description = "The maximum amount amount accepted for processing by the particular payment method."), - ("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"), - ("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"), - ), - responses( - (status = 200, description = "Payment Methods retrieved", body = CustomerPaymentMethodsListResponse), - (status = 400, description = "Invalid Data"), - (status = 404, description = "Payment Methods does not exist in records") - ), - tag = "Payment Methods", - operation_id = "List all Payment Methods for a Customer", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))] pub async fn list_customer_payment_method_api( state: web::Data, @@ -532,27 +512,6 @@ pub async fn list_customer_payment_method_api( /// List payment methods for a Customer /// /// To filter and list the applicable payment methods for a particular Customer ID -#[utoipa::path( - get, - path = "/customers/payment_methods", - params ( - ("client-secret" = String, Path, description = "A secret known only to your application and the authorization server"), - ("accepted_country" = Vec, Query, description = "The two-letter ISO currency code"), - ("accepted_currency" = Vec, Path, description = "The three-letter ISO currency code"), - ("minimum_amount" = i64, Query, description = "The minimum amount accepted for processing by the particular payment method."), - ("maximum_amount" = i64, Query, description = "The maximum amount amount accepted for processing by the particular payment method."), - ("recurring_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for recurring payments"), - ("installment_payment_enabled" = bool, Query, description = "Indicates whether the payment method is eligible for installment payments"), - ), - responses( - (status = 200, description = "Payment Methods retrieved for customer tied to its respective client-secret passed in the param", body = CustomerPaymentMethodsListResponse), - (status = 400, description = "Invalid Data"), - (status = 404, description = "Payment Methods does not exist in records") - ), - tag = "Payment Methods", - operation_id = "List all Payment Methods for a Customer", - security(("publishable_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::CustomerPaymentMethodsList))] pub async fn list_customer_payment_method_api_client( state: web::Data, diff --git a/crates/router/src/routes/refunds.rs b/crates/router/src/routes/refunds.rs index efc6fa2e93..7791dc330d 100644 --- a/crates/router/src/routes/refunds.rs +++ b/crates/router/src/routes/refunds.rs @@ -48,18 +48,6 @@ mod internal_payload_types { /// /// To create a refund against an already processed payment #[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))] -#[utoipa::path( - post, - path = "/refunds", - request_body=RefundRequest, - responses( - (status = 200, description = "Refund created", body = RefundResponse), - (status = 400, description = "Missing Mandatory fields") - ), - tag = "Refunds", - operation_id = "Create a Refund", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsCreate))] // #[post("")] pub async fn refunds_create( @@ -150,20 +138,6 @@ pub async fn refunds_create( /// Refunds - Retrieve (GET) /// /// To retrieve the properties of a Refund. This may be used to get the status of a previously initiated payment or next action for an ongoing payment -#[utoipa::path( - get, - path = "/refunds/{refund_id}", - params( - ("refund_id" = String, Path, description = "The identifier for refund") - ), - responses( - (status = 200, description = "Refund retrieved", body = RefundResponse), - (status = 404, description = "Refund does not exist in our records") - ), - tag = "Refunds", - operation_id = "Retrieve a Refund", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow))] // #[get("/{id}")] pub async fn refunds_retrieve( @@ -270,17 +244,6 @@ pub async fn refunds_retrieve( /// Refunds - Retrieve (POST) /// /// To retrieve the properties of a Refund. This may be used to get the status of a previously initiated payment or next action for an ongoing payment -#[utoipa::path( - get, - path = "/refunds/sync", - responses( - (status = 200, description = "Refund retrieved", body = RefundResponse), - (status = 404, description = "Refund does not exist in our records") - ), - tag = "Refunds", - operation_id = "Retrieve a Refund", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow))] // #[post("/sync")] pub async fn refunds_retrieve_with_body( @@ -325,21 +288,6 @@ pub async fn refunds_retrieve_with_body( /// Refunds - Update /// /// To update the properties of a Refund object. This may include attaching a reason for the refund or metadata fields -#[utoipa::path( - post, - path = "/refunds/{refund_id}", - params( - ("refund_id" = String, Path, description = "The identifier for refund") - ), - request_body=RefundUpdateRequest, - responses( - (status = 200, description = "Refund updated", body = RefundResponse), - (status = 400, description = "Missing Mandatory fields") - ), - tag = "Refunds", - operation_id = "Update a Refund", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsUpdate))] // #[post("/{id}")] pub async fn refunds_update( @@ -418,17 +366,6 @@ pub async fn refunds_metadata_update( /// Refunds - List /// /// To list the refunds associated with a payment_id or with the merchant, if payment_id is not provided -#[utoipa::path( - post, - path = "/refunds/list", - request_body=RefundListRequest, - responses( - (status = 200, description = "List of refunds", body = RefundListResponse), - ), - tag = "Refunds", - operation_id = "List all Refunds", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsList))] pub async fn refunds_list( state: web::Data, @@ -501,17 +438,6 @@ pub async fn refunds_list( /// Refunds - List at profile level /// /// To list the refunds associated with a payment_id or with the merchant, if payment_id is not provided -#[utoipa::path( - post, - path = "/refunds/profile/list", - request_body=RefundListRequest, - responses( - (status = 200, description = "List of refunds", body = RefundListResponse), - ), - tag = "Refunds", - operation_id = "List all Refunds", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsList))] pub async fn refunds_list_profile( state: web::Data, @@ -558,17 +484,6 @@ pub async fn refunds_list_profile( /// Refunds - Filter /// /// To list the refunds filters associated with list of connectors, currencies and payment statuses -#[utoipa::path( - post, - path = "/refunds/filter", - request_body=TimeRange, - responses( - (status = 200, description = "List of filters", body = RefundListMetaData), - ), - tag = "Refunds", - operation_id = "List all filters for Refunds", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsList))] pub async fn refunds_filter_list( state: web::Data, @@ -610,16 +525,6 @@ pub async fn refunds_filter_list( /// Refunds - Filter V2 /// /// To list the refunds filters associated with list of connectors, currencies and payment statuses -#[utoipa::path( - get, - path = "/refunds/v2/filter", - responses( - (status = 200, description = "List of static filters", body = RefundListFilters), - ), - tag = "Refunds", - operation_id = "List all filters for Refunds", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsFilters))] pub async fn get_refunds_filters(state: web::Data, req: HttpRequest) -> HttpResponse { let flow = Flow::RefundsFilters; @@ -657,16 +562,6 @@ pub async fn get_refunds_filters(state: web::Data, req: HttpRequest) - /// Refunds - Filter V2 at profile level /// /// To list the refunds filters associated with list of connectors, currencies and payment statuses -#[utoipa::path( - get, - path = "/refunds/v2/profile/filter", - responses( - (status = 200, description = "List of static filters", body = RefundListFilters), - ), - tag = "Refunds", - operation_id = "List all filters for Refunds", - security(("api_key" = [])) -)] #[instrument(skip_all, fields(flow = ?Flow::RefundsFilters))] pub async fn get_refunds_filters_profile( state: web::Data,