From 9ccfff7b694010af01075ba59ac1454f57be2002 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Thu, 7 Nov 2024 18:41:10 +0530 Subject: [PATCH 1/9] fix(openapi): Standardise API naming scheme for V2 --- .../api-reference/api-key/api-key--create.mdx | 2 +- .../api-reference/api-key/api-key--list.mdx | 2 +- .../api-key/api-key--retrieve.mdx | 2 +- .../api-reference/api-key/api-key--revoke.mdx | 2 +- .../api-reference/api-key/api-key--update.mdx | 2 +- .../merchant-connector--list.mdx | 2 +- .../connector-account--create.mdx | 2 +- .../connector-account--delete.mdx | 2 +- .../connector-account--retrieve.mdx | 2 +- .../connector-account--update.mdx | 2 +- .../business-profile--list.mdx | 2 +- .../merchant-account--create.mdx | 2 +- .../merchant-account--retrieve.mdx | 2 +- .../merchant-account--update.mdx | 2 +- .../merchant-account/profile--list.mdx | 2 +- .../organization--merchant-account--list.mdx | 2 +- .../profile/merchant-connector--list.mdx | 2 +- .../profile--activate-routing-algorithm.mdx | 2 +- .../profile--deactivate-routing-algorithm.mdx | 2 +- ...ile--retrieve-active-routing-algorithm.mdx | 2 +- ...eve-default-fallback-routing-algorithm.mdx | 2 +- ...ate-default-fallback-routing-algorithm.mdx | 2 +- .../api-reference/routing/routing--create.mdx | 2 +- .../routing/routing--retrieve.mdx | 2 +- api-reference-v2/openapi_spec.json | 50 +++++++++++-------- crates/api_models/src/organization.rs | 19 ++++++- crates/openapi/src/routes/api_keys.rs | 10 ++-- crates/openapi/src/routes/merchant_account.rs | 8 +-- .../src/routes/merchant_connector_account.rs | 8 +-- crates/openapi/src/routes/organization.rs | 2 +- crates/openapi/src/routes/profile.rs | 14 +++--- crates/openapi/src/routes/routing.rs | 4 +- crates/router/src/routes/app.rs | 30 +++++------ crates/router/src/types/api/admin.rs | 2 +- 34 files changed, 111 insertions(+), 84 deletions(-) diff --git a/api-reference-v2/api-reference/api-key/api-key--create.mdx b/api-reference-v2/api-reference/api-key/api-key--create.mdx index a92a8ea77fd..abc1dcda10f 100644 --- a/api-reference-v2/api-reference/api-key/api-key--create.mdx +++ b/api-reference-v2/api-reference/api-key/api-key--create.mdx @@ -1,3 +1,3 @@ --- -openapi: post /v2/api_keys +openapi: post /v2/api-keys --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/api-key/api-key--list.mdx b/api-reference-v2/api-reference/api-key/api-key--list.mdx index 5975e9bd6ca..fb84b35fbc7 100644 --- a/api-reference-v2/api-reference/api-key/api-key--list.mdx +++ b/api-reference-v2/api-reference/api-key/api-key--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/api_keys/list +openapi: get /v2/api-keys/list --- diff --git a/api-reference-v2/api-reference/api-key/api-key--retrieve.mdx b/api-reference-v2/api-reference/api-key/api-key--retrieve.mdx index ee7970122d4..72864363357 100644 --- a/api-reference-v2/api-reference/api-key/api-key--retrieve.mdx +++ b/api-reference-v2/api-reference/api-key/api-key--retrieve.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/api_keys/{id} +openapi: get /v2/api-keys/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/api-key/api-key--revoke.mdx b/api-reference-v2/api-reference/api-key/api-key--revoke.mdx index 9362743088b..b7ffd42e449 100644 --- a/api-reference-v2/api-reference/api-key/api-key--revoke.mdx +++ b/api-reference-v2/api-reference/api-key/api-key--revoke.mdx @@ -1,3 +1,3 @@ --- -openapi: delete /v2/api_keys/{id} +openapi: delete /v2/api-keys/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/api-key/api-key--update.mdx b/api-reference-v2/api-reference/api-key/api-key--update.mdx index c682cf1ee9e..2434e4981fc 100644 --- a/api-reference-v2/api-reference/api-key/api-key--update.mdx +++ b/api-reference-v2/api-reference/api-key/api-key--update.mdx @@ -1,3 +1,3 @@ --- -openapi: put /v2/api_keys/{id} +openapi: put /v2/api-keys/{id} --- diff --git a/api-reference-v2/api-reference/business-profile/merchant-connector--list.mdx b/api-reference-v2/api-reference/business-profile/merchant-connector--list.mdx index 6560f45e5fa..93c5a980c27 100644 --- a/api-reference-v2/api-reference/business-profile/merchant-connector--list.mdx +++ b/api-reference-v2/api-reference/business-profile/merchant-connector--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/profiles/{profile_id}/connector_accounts +openapi: get /v2/profiles/{profile_id}/connector-accounts --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/connector-account/connector-account--create.mdx b/api-reference-v2/api-reference/connector-account/connector-account--create.mdx index d8cac2bab39..d672d6fa34d 100644 --- a/api-reference-v2/api-reference/connector-account/connector-account--create.mdx +++ b/api-reference-v2/api-reference/connector-account/connector-account--create.mdx @@ -1,3 +1,3 @@ --- -openapi: post /v2/connector_accounts +openapi: post /v2/connector-accounts --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/connector-account/connector-account--delete.mdx b/api-reference-v2/api-reference/connector-account/connector-account--delete.mdx index 5c959648fff..15fdd664412 100644 --- a/api-reference-v2/api-reference/connector-account/connector-account--delete.mdx +++ b/api-reference-v2/api-reference/connector-account/connector-account--delete.mdx @@ -1,3 +1,3 @@ --- -openapi: delete /v2/connector_accounts/{id} +openapi: delete /v2/connector-accounts/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/connector-account/connector-account--retrieve.mdx b/api-reference-v2/api-reference/connector-account/connector-account--retrieve.mdx index 918de031276..dbd26b9b10b 100644 --- a/api-reference-v2/api-reference/connector-account/connector-account--retrieve.mdx +++ b/api-reference-v2/api-reference/connector-account/connector-account--retrieve.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/connector_accounts/{id} +openapi: get /v2/connector-accounts/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/connector-account/connector-account--update.mdx b/api-reference-v2/api-reference/connector-account/connector-account--update.mdx index 6ccd052fb9b..fe864d538f8 100644 --- a/api-reference-v2/api-reference/connector-account/connector-account--update.mdx +++ b/api-reference-v2/api-reference/connector-account/connector-account--update.mdx @@ -1,3 +1,3 @@ --- -openapi: put /v2/connector_accounts/{id} +openapi: put /v2/connector-accounts/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/merchant-account/business-profile--list.mdx b/api-reference-v2/api-reference/merchant-account/business-profile--list.mdx index 97deb0832cc..069bd602ddf 100644 --- a/api-reference-v2/api-reference/merchant-account/business-profile--list.mdx +++ b/api-reference-v2/api-reference/merchant-account/business-profile--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/merchant_accounts/{id}/profiles +openapi: get /v2/merchant-accounts/{id}/profiles --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/merchant-account/merchant-account--create.mdx b/api-reference-v2/api-reference/merchant-account/merchant-account--create.mdx index d870b811aae..38aed603f62 100644 --- a/api-reference-v2/api-reference/merchant-account/merchant-account--create.mdx +++ b/api-reference-v2/api-reference/merchant-account/merchant-account--create.mdx @@ -1,3 +1,3 @@ --- -openapi: post /v2/merchant_accounts +openapi: post /v2/merchant-accounts --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/merchant-account/merchant-account--retrieve.mdx b/api-reference-v2/api-reference/merchant-account/merchant-account--retrieve.mdx index d082565234e..3b744fb1406 100644 --- a/api-reference-v2/api-reference/merchant-account/merchant-account--retrieve.mdx +++ b/api-reference-v2/api-reference/merchant-account/merchant-account--retrieve.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/merchant_accounts/{id} +openapi: get /v2/merchant-accounts/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/merchant-account/merchant-account--update.mdx b/api-reference-v2/api-reference/merchant-account/merchant-account--update.mdx index 51f80ceea30..eb2e92d0652 100644 --- a/api-reference-v2/api-reference/merchant-account/merchant-account--update.mdx +++ b/api-reference-v2/api-reference/merchant-account/merchant-account--update.mdx @@ -1,3 +1,3 @@ --- -openapi: put /v2/merchant_accounts/{id} +openapi: put /v2/merchant-accounts/{id} --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/merchant-account/profile--list.mdx b/api-reference-v2/api-reference/merchant-account/profile--list.mdx index e14bc0d6ef3..f7a57875f65 100644 --- a/api-reference-v2/api-reference/merchant-account/profile--list.mdx +++ b/api-reference-v2/api-reference/merchant-account/profile--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/merchant_accounts/{account_id}/profiles +openapi: get /v2/merchant-accounts/{account_id}/profiles --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/organization/organization--merchant-account--list.mdx b/api-reference-v2/api-reference/organization/organization--merchant-account--list.mdx index 58d467dc572..9a03e8713d1 100644 --- a/api-reference-v2/api-reference/organization/organization--merchant-account--list.mdx +++ b/api-reference-v2/api-reference/organization/organization--merchant-account--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/organization/{id}/merchant_accounts +openapi: get /v2/organization/{id}/merchant-accounts --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/merchant-connector--list.mdx b/api-reference-v2/api-reference/profile/merchant-connector--list.mdx index 81f640436f4..55218be7c0b 100644 --- a/api-reference-v2/api-reference/profile/merchant-connector--list.mdx +++ b/api-reference-v2/api-reference/profile/merchant-connector--list.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/profiles/{id}/connector_accounts +openapi: get /v2/profiles/{id}/connector-accounts --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx index 7225f422e5a..ea9ee7596a0 100644 --- a/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--activate-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/activate_routing_algorithm +openapi: patch /v2/profiles/{id}/activate-routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx index 87aac8b9379..4d6b2d620c6 100644 --- a/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--deactivate-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/deactivate_routing_algorithm +openapi: patch /v2/profiles/{id}/deactivate-routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--retrieve-active-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--retrieve-active-routing-algorithm.mdx index 86d2d35d57c..143837676c2 100644 --- a/api-reference-v2/api-reference/profile/profile--retrieve-active-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--retrieve-active-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/profiles/{id}/routing_algorithm +openapi: get /v2/profiles/{id}/routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--retrieve-default-fallback-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--retrieve-default-fallback-routing-algorithm.mdx index 1bc383c278f..ebaad7c53ae 100644 --- a/api-reference-v2/api-reference/profile/profile--retrieve-default-fallback-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--retrieve-default-fallback-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/profiles/{id}/fallback_routing +openapi: get /v2/profiles/{id}/fallback-routing --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx b/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx index 76f4d4fa77f..b5df6a57ef8 100644 --- a/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx +++ b/api-reference-v2/api-reference/profile/profile--update-default-fallback-routing-algorithm.mdx @@ -1,3 +1,3 @@ --- -openapi: patch /v2/profiles/{id}/fallback_routing +openapi: patch /v2/profiles/{id}/fallback-routing --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/routing/routing--create.mdx b/api-reference-v2/api-reference/routing/routing--create.mdx index 65ef15008f2..438abd8e231 100644 --- a/api-reference-v2/api-reference/routing/routing--create.mdx +++ b/api-reference-v2/api-reference/routing/routing--create.mdx @@ -1,3 +1,3 @@ --- -openapi: post /v2/routing_algorithm +openapi: post /v2/routing-algorithm --- \ No newline at end of file diff --git a/api-reference-v2/api-reference/routing/routing--retrieve.mdx b/api-reference-v2/api-reference/routing/routing--retrieve.mdx index 776ff69e004..10db0200e18 100644 --- a/api-reference-v2/api-reference/routing/routing--retrieve.mdx +++ b/api-reference-v2/api-reference/routing/routing--retrieve.mdx @@ -1,3 +1,3 @@ --- -openapi: get /v2/routing_algorithm/{id} +openapi: get /v2/routing-algorithm/{id} --- \ No newline at end of file diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 0385aa55a20..762d1d5d340 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -164,7 +164,7 @@ ] } }, - "/v2/organization/{id}/merchant_accounts": { + "/v2/organization/{id}/merchant-accounts": { "get": { "tags": [ "Organization" @@ -208,7 +208,7 @@ ] } }, - "/v2/connector_accounts": { + "/v2/connector-accounts": { "post": { "tags": [ "Merchant Connector Account" @@ -285,7 +285,7 @@ ] } }, - "/v2/connector_accounts/{id}": { + "/v2/connector-accounts/{id}": { "get": { "tags": [ "Merchant Connector Account" @@ -445,7 +445,7 @@ ] } }, - "/v2/merchant_accounts": { + "/v2/merchant-accounts": { "post": { "tags": [ "Merchant Account" @@ -524,7 +524,7 @@ ] } }, - "/v2/merchant_accounts/{id}": { + "/v2/merchant-accounts/{id}": { "get": { "tags": [ "Merchant Account" @@ -630,7 +630,7 @@ ] } }, - "/v2/merchant_accounts/{id}/profiles": { + "/v2/merchant-accounts/{id}/profiles": { "get": { "tags": [ "Merchant Account" @@ -907,7 +907,7 @@ ] } }, - "/v2/profiles/{id}/connector_accounts": { + "/v2/profiles/{id}/connector-accounts": { "get": { "tags": [ "Business Profile" @@ -966,7 +966,7 @@ ] } }, - "/v2/profiles/{id}/activate_routing_algorithm": { + "/v2/profiles/{id}/activate-routing-algorithm": { "patch": { "tags": [ "Profile" @@ -1033,7 +1033,7 @@ ] } }, - "/v2/profiles/{id}/deactivate_routing_algorithm": { + "/v2/profiles/{id}/deactivate-routing-algorithm": { "patch": { "tags": [ "Profile" @@ -1086,7 +1086,7 @@ ] } }, - "/v2/profiles/{id}/fallback_routing": { + "/v2/profiles/{id}/fallback-routing": { "patch": { "tags": [ "Profile" @@ -1197,13 +1197,13 @@ ] } }, - "/v2/profiles/{id}/routing_algorithm": { + "/v2/profiles/{id}/routing-algorithm": { "get": { "tags": [ "Profile" ], "summary": "Profile - Retrieve Active Routing Algorithm", - "description": "Retrieve active routing algorithm under the profile", + "description": "_\nRetrieve active routing algorithm under the profile", "operationId": "Retrieve the active routing algorithm under the profile", "parameters": [ { @@ -1271,7 +1271,7 @@ ] } }, - "/v2/routing_algorithm": { + "/v2/routing-algorithm": { "post": { "tags": [ "Routing" @@ -1326,7 +1326,7 @@ ] } }, - "/v2/routing_algorithm/{id}": { + "/v2/routing-algorithm/{id}": { "get": { "tags": [ "Routing" @@ -1376,7 +1376,7 @@ ] } }, - "/v2/api_keys": { + "/v2/api-keys": { "post": { "tags": [ "API Key" @@ -1416,7 +1416,7 @@ ] } }, - "/v2/api_keys/{id}": { + "/v2/api-keys/{id}": { "get": { "tags": [ "API Key" @@ -1545,7 +1545,7 @@ ] } }, - "/v2/api_keys/list": { + "/v2/api-keys/list": { "get": { "tags": [ "API Key" @@ -11146,14 +11146,17 @@ ], "properties": { "organization_name": { - "type": "string" + "type": "string", + "description": "Name of the organization" }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true } }, @@ -11162,27 +11165,31 @@ "OrganizationResponse": { "type": "object", "required": [ - "organization_id", + "id", "modified_at", "created_at" ], "properties": { - "organization_id": { + "id": { "type": "string", + "description": "The unique identifier for the Organization", "example": "org_q98uSGAYbjEwqs0mJwnz", "maxLength": 64, "minLength": 1 }, "organization_name": { "type": "string", + "description": "Name of the Organization", "nullable": true }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true }, "modified_at": { @@ -11200,14 +11207,17 @@ "properties": { "organization_name": { "type": "string", + "description": "Name of the organization", "nullable": true }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true } }, diff --git a/crates/api_models/src/organization.rs b/crates/api_models/src/organization.rs index f95a1595116..2b8b1d95bca 100644 --- a/crates/api_models/src/organization.rs +++ b/crates/api_models/src/organization.rs @@ -22,9 +22,14 @@ pub struct OrganizationId { #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)] #[serde(deny_unknown_fields)] pub struct OrganizationCreateRequest { + /// Name of the organization pub organization_name: String, + + /// Details about the organization #[schema(value_type = Option)] pub organization_details: Option, + + /// Metadata is useful for storing additional, unstructured information on an object. #[schema(value_type = Option)] pub metadata: Option, } @@ -32,20 +37,32 @@ pub struct OrganizationCreateRequest { #[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)] #[serde(deny_unknown_fields)] pub struct OrganizationUpdateRequest { + /// Name of the organization pub organization_name: Option, + + /// Details about the organization #[schema(value_type = Option)] pub organization_details: Option, + + /// Metadata is useful for storing additional, unstructured information on an object. #[schema(value_type = Option)] pub metadata: Option, } #[derive(Debug, serde::Serialize, Clone, ToSchema)] pub struct OrganizationResponse { + /// The unique identifier for the Organization #[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")] - pub organization_id: id_type::OrganizationId, + pub id: id_type::OrganizationId, + + /// Name of the Organization pub organization_name: Option, + + /// Details about the organization #[schema(value_type = Option)] pub organization_details: Option, + + /// Metadata is useful for storing additional, unstructured information on an object. #[schema(value_type = Option)] pub metadata: Option, pub modified_at: time::PrimitiveDateTime, diff --git a/crates/openapi/src/routes/api_keys.rs b/crates/openapi/src/routes/api_keys.rs index cfc4c09ce46..964fa60fcf5 100644 --- a/crates/openapi/src/routes/api_keys.rs +++ b/crates/openapi/src/routes/api_keys.rs @@ -25,7 +25,7 @@ pub async fn api_key_create() {} /// displayed only once on creation, so ensure you store it securely. #[utoipa::path( post, - path = "/v2/api_keys", + path = "/v2/api-keys", request_body= CreateApiKeyRequest, responses( (status = 200, description = "API Key created", body = CreateApiKeyResponse), @@ -64,7 +64,7 @@ pub async fn api_key_retrieve() {} /// Retrieve information about the specified API Key. #[utoipa::path( get, - path = "/v2/api_keys/{id}", + path = "/v2/api-keys/{id}", params ( ("id" = String, Path, description = "The unique identifier for the API Key") ), @@ -106,7 +106,7 @@ pub async fn api_key_update() {} /// Update information for the specified API Key. #[utoipa::path( put, - path = "/v2/api_keys/{id}", + path = "/v2/api-keys/{id}", request_body = UpdateApiKeyRequest, params ( ("id" = String, Path, description = "The unique identifier for the API Key") @@ -150,7 +150,7 @@ pub async fn api_key_revoke() {} /// authenticating with our APIs. #[utoipa::path( delete, - path = "/v2/api_keys/{id}", + path = "/v2/api-keys/{id}", params ( ("id" = String, Path, description = "The unique identifier for the API Key") ), @@ -191,7 +191,7 @@ pub async fn api_key_list() {} /// List all the API Keys associated to a merchant account. #[utoipa::path( get, - path = "/v2/api_keys/list", + path = "/v2/api-keys/list", params( ("limit" = Option, Query, description = "The maximum number of API Keys to include in the response"), ("skip" = Option, Query, description = "The number of API Keys to skip when retrieving the list of API keys."), diff --git a/crates/openapi/src/routes/merchant_account.rs b/crates/openapi/src/routes/merchant_account.rs index 022a5e6c006..a3bf96ab897 100644 --- a/crates/openapi/src/routes/merchant_account.rs +++ b/crates/openapi/src/routes/merchant_account.rs @@ -50,7 +50,7 @@ pub async fn merchant_account_create() {} /// Before creating the merchant account, it is mandatory to create an organization. #[utoipa::path( post, - path = "/v2/merchant_accounts", + path = "/v2/merchant-accounts", params( ( "X-Organization-Id" = String, Header, @@ -128,7 +128,7 @@ pub async fn retrieve_merchant_account() {} /// Retrieve a *merchant* account details. #[utoipa::path( get, - path = "/v2/merchant_accounts/{id}", + path = "/v2/merchant-accounts/{id}", params (("id" = String, Path, description = "The unique identifier for the merchant account")), responses( (status = 200, description = "Merchant Account Retrieved", body = MerchantAccountResponse), @@ -190,7 +190,7 @@ pub async fn update_merchant_account() {} /// Updates details of an existing merchant account. Helpful in updating merchant details such as email, contact details, or other configuration details like webhook, routing algorithm etc #[utoipa::path( put, - path = "/v2/merchant_accounts/{id}", + path = "/v2/merchant-accounts/{id}", request_body ( content = MerchantAccountUpdate, examples( @@ -300,7 +300,7 @@ pub async fn payment_connector_list_profile() {} /// List profiles for an Merchant #[utoipa::path( get, - path = "/v2/merchant_accounts/{id}/profiles", + path = "/v2/merchant-accounts/{id}/profiles", params (("id" = String, Path, description = "The unique identifier for the Merchant")), responses( (status = 200, description = "profile list retrieved successfully", body = Vec), diff --git a/crates/openapi/src/routes/merchant_connector_account.rs b/crates/openapi/src/routes/merchant_connector_account.rs index 29092b5bba0..372f8688a26 100644 --- a/crates/openapi/src/routes/merchant_connector_account.rs +++ b/crates/openapi/src/routes/merchant_connector_account.rs @@ -67,7 +67,7 @@ pub async fn connector_create() {} #[cfg(feature = "v2")] #[utoipa::path( post, - path = "/v2/connector_accounts", + path = "/v2/connector-accounts", request_body( content = MerchantConnectorCreate, examples( @@ -152,7 +152,7 @@ pub async fn connector_retrieve() {} #[cfg(feature = "v2")] #[utoipa::path( get, - path = "/v2/connector_accounts/{id}", + path = "/v2/connector-accounts/{id}", params( ("id" = i32, Path, description = "The unique identifier for the Merchant Connector") ), @@ -241,7 +241,7 @@ pub async fn connector_update() {} #[cfg(feature = "v2")] #[utoipa::path( put, - path = "/v2/connector_accounts/{id}", + path = "/v2/connector-accounts/{id}", request_body( content = MerchantConnectorUpdate, examples( @@ -310,7 +310,7 @@ pub async fn connector_delete() {} #[cfg(feature = "v2")] #[utoipa::path( delete, - path = "/v2/connector_accounts/{id}", + path = "/v2/connector-accounts/{id}", params( ("id" = i32, Path, description = "The unique identifier for the Merchant Connector") ), diff --git a/crates/openapi/src/routes/organization.rs b/crates/openapi/src/routes/organization.rs index ce3199343cf..d677131d5db 100644 --- a/crates/openapi/src/routes/organization.rs +++ b/crates/openapi/src/routes/organization.rs @@ -150,7 +150,7 @@ pub async fn organization_update() {} /// List merchant accounts for an Organization #[utoipa::path( get, - path = "/v2/organization/{id}/merchant_accounts", + path = "/v2/organization/{id}/merchant-accounts", params (("id" = String, Path, description = "The unique identifier for the Organization")), responses( (status = 200, description = "Merchant Account list retrieved successfully", body = Vec), diff --git a/crates/openapi/src/routes/profile.rs b/crates/openapi/src/routes/profile.rs index d88568653a4..cc484aa3f95 100644 --- a/crates/openapi/src/routes/profile.rs +++ b/crates/openapi/src/routes/profile.rs @@ -210,7 +210,7 @@ pub async fn profile_update() {} /// Activates a routing algorithm under a profile #[utoipa::path( patch, - path = "/v2/profiles/{id}/activate_routing_algorithm", + path = "/v2/profiles/{id}/activate-routing-algorithm", request_body ( content = RoutingAlgorithmId, examples( ( "Activate a routing algorithm" = ( @@ -240,7 +240,7 @@ pub async fn routing_link_config() {} /// Deactivates a routing algorithm under a profile #[utoipa::path( patch, - path = "/v2/profiles/{id}/deactivate_routing_algorithm", + path = "/v2/profiles/{id}/deactivate-routing-algorithm", params( ("id" = String, Path, description = "The unique identifier for the profile"), ), @@ -263,7 +263,7 @@ pub async fn routing_unlink_config() {} /// Update the default fallback routing algorithm for the profile #[utoipa::path( patch, - path = "/v2/profiles/{id}/fallback_routing", + path = "/v2/profiles/{id}/fallback-routing", request_body = Vec, params( ("id" = String, Path, description = "The unique identifier for the profile"), @@ -307,11 +307,11 @@ pub async fn profile_retrieve() {} #[cfg(feature = "v2")] /// Profile - Retrieve Active Routing Algorithm -/// +///_ /// Retrieve active routing algorithm under the profile #[utoipa::path( get, - path = "/v2/profiles/{id}/routing_algorithm", + path = "/v2/profiles/{id}/routing-algorithm", params( ("id" = String, Path, description = "The unique identifier for the profile"), ("limit" = Option, Query, description = "The number of records of the algorithms to be returned"), @@ -334,7 +334,7 @@ pub async fn routing_retrieve_linked_config() {} /// Retrieve the default fallback routing algorithm for the profile #[utoipa::path( get, - path = "/v2/profiles/{id}/fallback_routing", + path = "/v2/profiles/{id}/fallback-routing", params( ("id" = String, Path, description = "The unique identifier for the profile"), ), @@ -353,7 +353,7 @@ pub async fn routing_retrieve_default_config() {} /// List Connector Accounts for the profile #[utoipa::path( get, - path = "/v2/profiles/{id}/connector_accounts", + path = "/v2/profiles/{id}/connector-accounts", params( ("id" = String, Path, description = "The unique identifier for the business profile"), ( diff --git a/crates/openapi/src/routes/routing.rs b/crates/openapi/src/routes/routing.rs index 67a22c2ca64..b144fd046ad 100644 --- a/crates/openapi/src/routes/routing.rs +++ b/crates/openapi/src/routes/routing.rs @@ -26,7 +26,7 @@ pub async fn routing_create_config() {} /// Create a routing algorithm #[utoipa::path( post, - path = "/v2/routing_algorithm", + path = "/v2/routing-algorithm", request_body = RoutingConfigRequest, responses( (status = 200, description = "Routing Algorithm created", body = RoutingDictionaryRecord), @@ -94,7 +94,7 @@ pub async fn routing_retrieve_config() {} #[utoipa::path( get, - path = "/v2/routing_algorithm/{id}", + path = "/v2/routing-algorithm/{id}", params( ("id" = String, Path, description = "The unique identifier for a routing algorithm"), ), diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index d747f96b9fb..fd359d9535b 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -693,7 +693,7 @@ pub struct Routing; #[cfg(all(feature = "olap", feature = "v2"))] impl Routing { pub fn server(state: AppState) -> Scope { - web::scope("/v2/routing_algorithm") + web::scope("/v2/routing-algorithm") .app_data(web::Data::new(state.clone())) .service( web::resource("").route(web::post().to(|state, req, payload| { @@ -958,7 +958,7 @@ impl Customers { #[cfg(all(feature = "oltp", feature = "v2", feature = "payment_methods_v2"))] { route = route.service( - web::resource("/{customer_id}/saved_payment_methods") + web::resource("/{customer_id}/saved-payment-methods") .route(web::get().to(list_customer_payment_method_api)), ); } @@ -1103,7 +1103,7 @@ impl Payouts { #[cfg(all(feature = "oltp", feature = "v2", feature = "payment_methods_v2",))] impl PaymentMethods { pub fn server(state: AppState) -> Scope { - let mut route = web::scope("/v2/payment_methods").app_data(web::Data::new(state)); + let mut route = web::scope("/v2/payment-methods").app_data(web::Data::new(state)); route = route .service(web::resource("").route(web::post().to(create_payment_method_api))) .service( @@ -1115,7 +1115,7 @@ impl PaymentMethods { .route(web::post().to(confirm_payment_method_intent_api)), ) .service( - web::resource("/{id}/update_saved_payment_method") + web::resource("/{id}/update-saved-payment-method") .route(web::patch().to(payment_method_update_api)), ) .service(web::resource("/{id}").route(web::get().to(payment_method_retrieve_api))) @@ -1257,7 +1257,7 @@ impl Organization { .route(web::put().to(admin::organization_update)), ) .service( - web::resource("/merchant_accounts") + web::resource("/merchant-accounts") .route(web::get().to(admin::merchant_account_list)), ), ) @@ -1269,7 +1269,7 @@ pub struct MerchantAccount; #[cfg(all(feature = "v2", feature = "olap"))] impl MerchantAccount { pub fn server(state: AppState) -> Scope { - web::scope("/v2/merchant_accounts") + web::scope("/v2/merchant-accounts") .app_data(web::Data::new(state)) .service(web::resource("").route(web::post().to(admin::merchant_account_create))) .service( @@ -1319,7 +1319,7 @@ pub struct MerchantConnectorAccount; #[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v2"))] impl MerchantConnectorAccount { pub fn server(state: AppState) -> Scope { - let mut route = web::scope("/v2/connector_accounts").app_data(web::Data::new(state)); + let mut route = web::scope("/v2/connector-accounts").app_data(web::Data::new(state)); #[cfg(feature = "olap")] { @@ -1493,7 +1493,7 @@ pub struct ApiKeys; #[cfg(all(feature = "olap", feature = "v2"))] impl ApiKeys { pub fn server(state: AppState) -> Scope { - web::scope("/v2/api_keys") + web::scope("/v2/api-keys") .app_data(web::Data::new(state)) .service(web::resource("").route(web::post().to(api_keys::api_key_create))) .service(web::resource("/list").route(web::get().to(api_keys::api_key_list))) @@ -1659,16 +1659,16 @@ impl Profile { .route(web::put().to(profiles::profile_update)), ) .service( - web::resource("/connector_accounts") + web::resource("/connector-accounts") .route(web::get().to(admin::connector_list)), ) .service( - web::resource("/fallback_routing") + web::resource("/fallback-routing") .route(web::get().to(routing::routing_retrieve_default_config)) .route(web::patch().to(routing::routing_update_default_config)), ) .service( - web::resource("/activate_routing_algorithm").route(web::patch().to( + web::resource("/activate-routing-algorithm").route(web::patch().to( |state, req, path, payload| { routing::routing_link_config( state, @@ -1681,7 +1681,7 @@ impl Profile { )), ) .service( - web::resource("/deactivate_routing_algorithm").route(web::patch().to( + web::resource("/deactivate-routing-algorithm").route(web::patch().to( |state, req, path| { routing::routing_unlink_config( state, @@ -1692,7 +1692,7 @@ impl Profile { }, )), ) - .service(web::resource("/routing_algorithm").route(web::get().to( + .service(web::resource("/routing-algorithm").route(web::get().to( |state, req, query_params, path| { routing::routing_retrieve_linked_config( state, @@ -1960,7 +1960,7 @@ impl User { ) .service(web::resource("/verify_email").route(web::post().to(user::verify_email))) .service( - web::resource("/v2/verify_email").route(web::post().to(user::verify_email)), + web::resource("/v2/verify-email").route(web::post().to(user::verify_email)), ) .service( web::resource("/verify_email_request") @@ -2014,7 +2014,7 @@ impl User { .route(web::post().to(user_role::accept_invitations_v2)), ) .service( - web::resource("/pre_auth").route( + web::resource("/pre-auth").route( web::post().to(user_role::accept_invitations_pre_auth), ), ), diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs index c81fc7ceb48..098c95fbe65 100644 --- a/crates/router/src/types/api/admin.rs +++ b/crates/router/src/types/api/admin.rs @@ -34,7 +34,7 @@ use crate::{ impl ForeignFrom for OrganizationResponse { fn foreign_from(org: diesel_models::organization::Organization) -> Self { Self { - organization_id: org.get_organization_id(), + id: org.get_organization_id(), organization_name: org.get_organization_name(), organization_details: org.organization_details, metadata: org.metadata, From ca279397018e4e7d496ee03bb25ab0425efae276 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Fri, 8 Nov 2024 15:07:23 +0530 Subject: [PATCH 2/9] Updated endpoints in cypress config --- cypress-tests-v2/cypress/support/commands.js | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/cypress-tests-v2/cypress/support/commands.js b/cypress-tests-v2/cypress/support/commands.js index eb4ca3423eb..b6955c542a7 100644 --- a/cypress-tests-v2/cypress/support/commands.js +++ b/cypress-tests-v2/cypress/support/commands.js @@ -64,10 +64,10 @@ Cypress.Commands.add( if (response.status === 200) { expect(response.body) - .to.have.property("organization_id") + .to.have.property("id") .and.to.include("org_") .and.to.be.a("string").and.not.be.empty; - globalState.set("organizationId", response.body.organization_id); + globalState.set("organizationId", response.body.id); cy.task("setGlobalState", globalState.data); expect(response.body).to.have.property("metadata").and.to.equal(null); } else { @@ -99,7 +99,7 @@ Cypress.Commands.add("organizationRetrieveCall", (globalState) => { if (response.status === 200) { expect(response.body) - .to.have.property("organization_id") + .to.have.property("id") .and.to.include("org_") .and.to.be.a("string").and.not.be.empty; expect(response.body.organization_name) @@ -107,7 +107,7 @@ Cypress.Commands.add("organizationRetrieveCall", (globalState) => { .and.to.be.a("string").and.not.be.empty; if (organization_id === undefined || organization_id === null) { - globalState.set("organizationId", response.body.organization_id); + globalState.set("organizationId", response.body.id); cy.task("setGlobalState", globalState.data); } } else { @@ -144,14 +144,14 @@ Cypress.Commands.add( if (response.status === 200) { expect(response.body) - .to.have.property("organization_id") + .to.have.property("id") .and.to.include("org_") .and.to.be.a("string").and.not.be.empty; expect(response.body).to.have.property("metadata").and.to.be.a("object") .and.not.be.empty; if (organization_id === undefined || organization_id === null) { - globalState.set("organizationId", response.body.organization_id); + globalState.set("organizationId", response.body.id); cy.task("setGlobalState", globalState.data); } } else { @@ -174,7 +174,7 @@ Cypress.Commands.add( const key_id_type = "publishable_key"; const key_id = validateEnv(base_url, key_id_type); const organization_id = globalState.get("organizationId"); - const url = `${base_url}/v2/merchant_accounts`; + const url = `${base_url}/v2/merchant-accounts`; const merchant_name = merchantAccountCreateBody.merchant_name .replaceAll(" ", "") @@ -223,7 +223,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => { const key_id_type = "publishable_key"; const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/merchant_accounts/${merchant_id}`; + const url = `${base_url}/v2/merchant-accounts/${merchant_id}`; cy.request({ method: "GET", @@ -265,7 +265,7 @@ Cypress.Commands.add( const key_id_type = "publishable_key"; const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/merchant_accounts/${merchant_id}`; + const url = `${base_url}/v2/merchant-accounts/${merchant_id}`; const merchant_name = merchantAccountUpdateBody.merchant_name; @@ -456,7 +456,7 @@ Cypress.Commands.add( const base_url = globalState.get("baseUrl"); const merchant_id = globalState.get("merchantId"); const profile_id = globalState.get("profileId"); - const url = `${base_url}/v2/connector_accounts`; + const url = `${base_url}/v2/connector-accounts`; const customHeaders = { "x-merchant-id": merchant_id, @@ -536,7 +536,7 @@ Cypress.Commands.add("mcaRetrieveCall", (globalState) => { const connector_name = globalState.get("connectorId"); const merchant_connector_id = globalState.get("merchantConnectorId"); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/connector_accounts/${merchant_connector_id}`; + const url = `${base_url}/v2/connector-accounts/${merchant_connector_id}`; const customHeaders = { "x-merchant-id": merchant_id, @@ -590,7 +590,7 @@ Cypress.Commands.add( const merchant_connector_id = globalState.get("merchantConnectorId"); const merchant_id = globalState.get("merchantId"); const profile_id = globalState.get("profileId"); - const url = `${base_url}/v2/connector_accounts/${merchant_connector_id}`; + const url = `${base_url}/v2/connector-accounts/${merchant_connector_id}`; const customHeaders = { "x-merchant-id": merchant_id, @@ -653,7 +653,7 @@ Cypress.Commands.add("apiKeyCreateCall", (apiKeyCreateBody, globalState) => { const key_id_type = "key_id"; const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/api_keys`; + const url = `${base_url}/v2/api-keys`; const customHeaders = { "x-merchant-id": merchant_id, @@ -703,7 +703,7 @@ Cypress.Commands.add("apiKeyRetrieveCall", (globalState) => { const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); const api_key_id = globalState.get("apiKeyId"); - const url = `${base_url}/v2/api_keys/${api_key_id}`; + const url = `${base_url}/v2/api-keys/${api_key_id}`; const customHeaders = { "x-merchant-id": merchant_id, @@ -750,7 +750,7 @@ Cypress.Commands.add("apiKeyUpdateCall", (apiKeyUpdateBody, globalState) => { const key_id_type = "key_id"; const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/api_keys/${api_key_id}`; + const url = `${base_url}/v2/api-keys/${api_key_id}`; const customHeaders = { "x-merchant-id": merchant_id, @@ -801,7 +801,7 @@ Cypress.Commands.add( const api_key = globalState.get("userInfoToken"); const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); - const url = `${base_url}/v2/routing_algorithm`; + const url = `${base_url}/v2/routing-algorithm`; // Update request body routingSetupBody.algorithm.data = payload.data; @@ -847,7 +847,7 @@ Cypress.Commands.add( const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); const routing_algorithm_id = globalState.get("routingAlgorithmId"); - const url = `${base_url}/v2/profiles/${profile_id}/activate_routing_algorithm`; + const url = `${base_url}/v2/profiles/${profile_id}/activate-routing-algorithm`; // Update request body routingActivationBody.routing_algorithm_id = routing_algorithm_id; @@ -885,7 +885,7 @@ Cypress.Commands.add("routingActivationRetrieveCall", (globalState) => { const profile_id = globalState.get("profileId"); const query_params = "limit=10"; const routing_algorithm_id = globalState.get("routingAlgorithmId"); - const url = `${base_url}/v2/profiles/${profile_id}/routing_algorithm?${query_params}`; + const url = `${base_url}/v2/profiles/${profile_id}/routing-algorithm?${query_params}`; cy.request({ method: "GET", @@ -922,7 +922,7 @@ Cypress.Commands.add("routingDeactivateCall", (globalState) => { const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); const routing_algorithm_id = globalState.get("routingAlgorithmId"); - const url = `${base_url}/v2/profiles/${profile_id}/deactivate_routing_algorithm`; + const url = `${base_url}/v2/profiles/${profile_id}/deactivate-routing-algorithm`; cy.request({ method: "PATCH", @@ -957,7 +957,7 @@ Cypress.Commands.add("routingRetrieveCall", (globalState) => { const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); const routing_algorithm_id = globalState.get("routingAlgorithmId"); - const url = `${base_url}/v2/routing_algorithm/${routing_algorithm_id}`; + const url = `${base_url}/v2/routing-algorithm/${routing_algorithm_id}`; cy.request({ method: "GET", @@ -996,7 +996,7 @@ Cypress.Commands.add( const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); const routing_algorithm_id = globalState.get("routingAlgorithmId"); - const url = `${base_url}/v2/profiles/${profile_id}/fallback_routing`; + const url = `${base_url}/v2/profiles/${profile_id}/fallback-routing`; // Update request body routingDefaultFallbackBody = payload; @@ -1029,7 +1029,7 @@ Cypress.Commands.add("routingFallbackRetrieveCall", (globalState) => { const api_key = globalState.get("userInfoToken"); const base_url = globalState.get("baseUrl"); const profile_id = globalState.get("profileId"); - const url = `${base_url}/v2/profiles/${profile_id}/fallback_routing`; + const url = `${base_url}/v2/profiles/${profile_id}/fallback-routing`; cy.request({ method: "GET", @@ -1166,7 +1166,7 @@ Cypress.Commands.add("merchantAccountsListCall", (globalState) => { const key_id_type = "publishable_key"; const key_id = validateEnv(base_url, key_id_type); const organization_id = globalState.get("organizationId"); - const url = `${base_url}/v2/organization/${organization_id}/merchant_accounts`; + const url = `${base_url}/v2/organization/${organization_id}/merchant-accounts`; cy.request({ method: "GET", @@ -1204,7 +1204,7 @@ Cypress.Commands.add("businessProfilesListCall", (globalState) => { const api_key = globalState.get("adminApiKey"); const base_url = globalState.get("baseUrl"); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/merchant_accounts/${merchant_id}/profiles`; + const url = `${base_url}/v2/merchant-accounts/${merchant_id}/profiles`; const customHeaders = { "x-merchant-id": merchant_id, @@ -1246,7 +1246,7 @@ Cypress.Commands.add("mcaListCall", (globalState, service_type) => { const base_url = globalState.get("baseUrl"); const merchant_id = globalState.get("merchantId"); const profile_id = globalState.get("profileId"); - const url = `${base_url}/v2/profiles/${profile_id}/connector_accounts`; + const url = `${base_url}/v2/profiles/${profile_id}/connector-accounts`; const customHeaders = { "x-merchant-id": merchant_id, @@ -1308,7 +1308,7 @@ Cypress.Commands.add("apiKeysListCall", (globalState) => { const key_id_type = "key_id"; const key_id = validateEnv(base_url, key_id_type); const merchant_id = globalState.get("merchantId"); - const url = `${base_url}/v2/api_keys/list`; + const url = `${base_url}/v2/api-keys/list`; const customHeaders = { "x-merchant-id": merchant_id, From d93416302671c3d0f61653371d14f820a00ed282 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Fri, 8 Nov 2024 17:42:08 +0530 Subject: [PATCH 3/9] Added OpenAPI spec for payment-methods v2 --- ...er-saved-payment-methods-for-a-payment.mdx | 3 + .../list-payment-methods-for-a-customer.mdx | 3 + .../payment-method--confirm-intent.mdx | 3 + .../payment-method--create-intent.mdx | 3 + .../payment-method--create.mdx | 3 + .../payment-method--delete.mdx | 3 + .../payment-method--retrieve.mdx | 3 + .../payment-method--update.mdx | 3 + api-reference-v2/mint.json | 23 +- api-reference-v2/openapi_spec.json | 770 +++++++++++++----- crates/api_models/src/payment_methods.rs | 5 +- crates/openapi/Cargo.toml | 2 +- crates/openapi/src/openapi_v2.rs | 18 + crates/openapi/src/routes/payment_method.rs | 191 +++++ crates/router/src/routes/app.rs | 6 +- crates/router/src/routes/payment_methods.rs | 47 -- 16 files changed, 835 insertions(+), 251 deletions(-) create mode 100644 api-reference-v2/api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/list-payment-methods-for-a-customer.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--confirm-intent.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--create-intent.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--create.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--delete.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--retrieve.mdx create mode 100644 api-reference-v2/api-reference/payment-methods/payment-method--update.mdx diff --git a/api-reference-v2/api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment.mdx b/api-reference-v2/api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment.mdx new file mode 100644 index 00000000000..7809830b820 --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment.mdx @@ -0,0 +1,3 @@ +--- +openapi: get /v2/payments/{id}/saved-payment-methods +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/list-payment-methods-for-a-customer.mdx b/api-reference-v2/api-reference/payment-methods/list-payment-methods-for-a-customer.mdx new file mode 100644 index 00000000000..ef5a27f9604 --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/list-payment-methods-for-a-customer.mdx @@ -0,0 +1,3 @@ +--- +openapi: get /v2/customers/{id}/saved-payment-methods +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--confirm-intent.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--confirm-intent.mdx new file mode 100644 index 00000000000..134374a7b6c --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--confirm-intent.mdx @@ -0,0 +1,3 @@ +--- +openapi: post /v2/payment-methods/{id}/confirm-intent +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--create-intent.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--create-intent.mdx new file mode 100644 index 00000000000..42cf716f2ab --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--create-intent.mdx @@ -0,0 +1,3 @@ +--- +openapi: post /v2/payment-methods/create-intent +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--create.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--create.mdx new file mode 100644 index 00000000000..1dce5179a94 --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--create.mdx @@ -0,0 +1,3 @@ +--- +openapi: post /v2/payment-methods +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--delete.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--delete.mdx new file mode 100644 index 00000000000..210bf843f97 --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--delete.mdx @@ -0,0 +1,3 @@ +--- +openapi: delete /v2/payment-methods/{id} +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--retrieve.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--retrieve.mdx new file mode 100644 index 00000000000..957d9760b3f --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--retrieve.mdx @@ -0,0 +1,3 @@ +--- +openapi: get /v2/payment-methods/{id} +--- \ No newline at end of file diff --git a/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx b/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx new file mode 100644 index 00000000000..0adee195a6f --- /dev/null +++ b/api-reference-v2/api-reference/payment-methods/payment-method--update.mdx @@ -0,0 +1,3 @@ +--- +openapi: patch /v2/payment-methods/{id}/update-saved-payment-method +--- \ No newline at end of file diff --git a/api-reference-v2/mint.json b/api-reference-v2/mint.json index c0723a63f3a..1cd612635c3 100644 --- a/api-reference-v2/mint.json +++ b/api-reference-v2/mint.json @@ -23,7 +23,9 @@ "navigation": [ { "group": "Get Started", - "pages": ["introduction"] + "pages": [ + "introduction" + ] }, { "group": "Essentials", @@ -43,6 +45,19 @@ "api-reference/payments/payments--get" ] }, + { + "group": "Payment Methods", + "pages": [ + "api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment", + "api-reference/payment-methods/list-payment-methods-for-a-customer", + "api-reference/payment-methods/payment-method--confirm-intent", + "api-reference/payment-methods/payment-method--create-intent", + "api-reference/payment-methods/payment-method--create", + "api-reference/payment-methods/payment-method--delete", + "api-reference/payment-methods/payment-method--retrieve", + "api-reference/payment-methods/payment-method--update" + ] + }, { "group": "Organization", "pages": [ @@ -119,8 +134,10 @@ "github": "https://github.com/juspay/hyperswitch", "linkedin": "https://www.linkedin.com/company/hyperswitch" }, - "openapi": ["openapi_spec.json"], + "openapi": [ + "openapi_spec.json" + ], "api": { "maintainOrder": true } -} +} \ No newline at end of file diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 762d1d5d340..7c737694552 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2017,6 +2017,332 @@ ] } }, + "/v2/payments/{id}/saved-payment-methods": { + "get": { + "tags": [ + "Payment Methods" + ], + "summary": "List payment methods for a Customer v2", + "description": "To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment", + "operationId": "List all Payment Methods for a Customer", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodListRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Methods retrieved for customer tied to its respective client-secret passed in the param", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + }, + "404": { + "description": "Payment Methods does not exist in records" + } + }, + "security": [ + { + "publishable_key": [] + } + ] + } + }, + "/v2/customers/{id}/saved-payment-methods": { + "get": { + "tags": [ + "Payment Methods" + ], + "summary": "List payment methods for a Customer v2", + "description": "To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context", + "operationId": "List all Payment Methods for a Customer", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodListRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Methods retrieved", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerPaymentMethodsListResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + }, + "404": { + "description": "Payment Methods does not exist in records" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/v2/payment-methods": { + "post": { + "tags": [ + "Payment Methods" + ], + "summary": "Create payment method v2", + "description": "TODO: Description Here", + "operationId": "Create Payment Method", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodCreate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Method Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/v2/payment-methods/create-intent": { + "post": { + "tags": [ + "Payment Methods" + ], + "summary": "Create payment method intent v2", + "description": "TODO: Description Here", + "operationId": "Create Payment Method Intent", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodIntentCreate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Method Intent Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/v2/payment-methods/{id}/confirm-intent": { + "post": { + "tags": [ + "Payment Methods" + ], + "summary": "Confirm payment method intent v2", + "description": "TODO: Description Here", + "operationId": "Confirm Payment Method Intent", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodIntentConfirm" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Method Intent Confirmed", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/v2/payment-methods/{id}/update-saved-payment-method": { + "patch": { + "tags": [ + "Payment Methods" + ], + "summary": "Update payment method v2", + "description": "TODO: Description Here", + "operationId": "Update Payment Method", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodUpdate" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Payment Method Update", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "400": { + "description": "Invalid Data" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/v2/payment-methods/{id}": { + "get": { + "tags": [ + "Payment Methods" + ], + "summary": "Retrieve payment method v2", + "description": "TODO: Description Here", + "operationId": "Retrieve Payment Method", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The unique identifier for the Payment Method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Payment Method Retrieved", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodResponse" + } + } + } + }, + "404": { + "description": "Payment Method Not Found" + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "delete": { + "tags": [ + "Payment Methods" + ], + "summary": "Delete payment method v2", + "description": "TODO: Description Here", + "operationId": "Delete Payment Method", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The unique identifier for the Payment Method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Payment Method Retrieved", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PaymentMethodDeleteResponse" + } + } + } + }, + "404": { + "description": "Payment Method Not Found" + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, "/v2/refunds": { "post": { "tags": [ @@ -5314,8 +5640,11 @@ "nullable": true }, "card_issuing_country": { - "type": "string", - "description": "Card Issuing Country", + "allOf": [ + { + "$ref": "#/components/schemas/CountryAlpha2" + } + ], "nullable": true }, "card_network": { @@ -5332,8 +5661,11 @@ "nullable": true }, "card_type": { - "type": "string", - "description": "Card Type", + "allOf": [ + { + "$ref": "#/components/schemas/CardType" + } + ], "nullable": true } }, @@ -5345,12 +5677,12 @@ "saved_to_locker" ], "properties": { - "scheme": { - "type": "string", - "nullable": true - }, "issuer_country": { - "type": "string", + "allOf": [ + { + "$ref": "#/components/schemas/CountryAlpha2" + } + ], "nullable": true }, "last4_digits": { @@ -5365,10 +5697,6 @@ "type": "string", "nullable": true }, - "card_token": { - "type": "string", - "nullable": true - }, "card_holder_name": { "type": "string", "nullable": true @@ -5409,21 +5737,9 @@ "CardDetailUpdate": { "type": "object", "required": [ - "card_exp_month", - "card_exp_year", "card_holder_name" ], "properties": { - "card_exp_month": { - "type": "string", - "description": "Card Expiry Month", - "example": "10" - }, - "card_exp_year": { - "type": "string", - "description": "Card Expiry Year", - "example": "25" - }, "card_holder_name": { "type": "string", "description": "Card Holder Name", @@ -5648,6 +5964,13 @@ } ] }, + "CardType": { + "type": "string", + "enum": [ + "credit", + "debit" + ] + }, "CashappQr": { "type": "object" }, @@ -6739,20 +7062,19 @@ "CustomerPaymentMethod": { "type": "object", "required": [ - "payment_token", "payment_method_id", "customer_id", "payment_method", "recurring_enabled", - "installment_payment_enabled", "requires_cvv", - "default_payment_method_set" + "is_default" ], "properties": { "payment_token": { "type": "string", "description": "Token for payment method in temporary card locker which gets refreshed often", - "example": "7ebf443f-a050-4067-84e5-e6f6d4800aef" + "example": "7ebf443f-a050-4067-84e5-e6f6d4800aef", + "nullable": true }, "payment_method_id": { "type": "string", @@ -6777,54 +7099,27 @@ ], "nullable": true }, - "payment_method_issuer": { - "type": "string", - "description": "The name of the bank/ provider issuing the payment method to the end user", - "example": "Citibank", - "nullable": true - }, - "payment_method_issuer_code": { - "allOf": [ - { - "$ref": "#/components/schemas/PaymentMethodIssuerCode" - } - ], - "nullable": true - }, "recurring_enabled": { "type": "boolean", "description": "Indicates whether the payment method is eligible for recurring payments", "example": true }, - "installment_payment_enabled": { - "type": "boolean", - "description": "Indicates whether the payment method is eligible for installment payments", - "example": true - }, - "payment_experience": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentExperience" - }, - "description": "Type of payment experience enabled with the connector", - "example": [ - "redirect_to_url" + "payment_method_data": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentMethodListData" + } ], "nullable": true }, - "card": { + "bank": { "allOf": [ { - "$ref": "#/components/schemas/CardDetailFromLocker" + "$ref": "#/components/schemas/MaskedBankDetails" } ], "nullable": true }, - "metadata": { - "type": "object", - "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.", - "nullable": true - }, "created": { "type": "string", "format": "date-time", @@ -6832,22 +7127,6 @@ "example": "2023-01-18T11:04:09.922Z", "nullable": true }, - "bank_transfer": { - "allOf": [ - { - "$ref": "#/components/schemas/Bank" - } - ], - "nullable": true - }, - "bank": { - "allOf": [ - { - "$ref": "#/components/schemas/MaskedBankDetails" - } - ], - "nullable": true - }, "surcharge_details": { "allOf": [ { @@ -6868,7 +7147,7 @@ "example": "2024-02-24T11:04:09.922Z", "nullable": true }, - "default_payment_method_set": { + "is_default": { "type": "boolean", "description": "Indicates if the payment method has been set to default or not", "example": true @@ -12260,41 +12539,17 @@ "PaymentMethodCreate": { "type": "object", "required": [ - "payment_method" + "payment_method", + "payment_method_type", + "customer_id", + "payment_method_data" ], "properties": { "payment_method": { "$ref": "#/components/schemas/PaymentMethod" }, "payment_method_type": { - "allOf": [ - { - "$ref": "#/components/schemas/PaymentMethodType" - } - ], - "nullable": true - }, - "payment_method_issuer": { - "type": "string", - "description": "The name of the bank/ provider issuing the payment method to the end user", - "example": "Citibank", - "nullable": true - }, - "payment_method_issuer_code": { - "allOf": [ - { - "$ref": "#/components/schemas/PaymentMethodIssuerCode" - } - ], - "nullable": true - }, - "card": { - "allOf": [ - { - "$ref": "#/components/schemas/CardDetail" - } - ], - "nullable": true + "$ref": "#/components/schemas/PaymentMethodType" }, "metadata": { "type": "object", @@ -12305,44 +12560,11 @@ "type": "string", "description": "The unique identifier of the customer.", "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44", - "nullable": true, "maxLength": 64, "minLength": 1 }, - "card_network": { - "type": "string", - "description": "The card network", - "example": "Visa", - "nullable": true - }, - "bank_transfer": { - "allOf": [ - { - "$ref": "#/components/schemas/Bank" - } - ], - "nullable": true - }, - "wallet": { - "allOf": [ - { - "$ref": "#/components/schemas/Wallet" - } - ], - "nullable": true - }, - "client_secret": { - "type": "string", - "description": "For Client based calls, SDK will use the client_secret\nin order to call /payment_methods\nClient secret will be generated whenever a new\npayment method is created", - "nullable": true - }, "payment_method_data": { - "allOf": [ - { - "$ref": "#/components/schemas/PaymentMethodCreateData" - } - ], - "nullable": true + "$ref": "#/components/schemas/PaymentMethodCreateData" }, "billing": { "allOf": [ @@ -12790,22 +13012,78 @@ "PaymentMethodDeleteResponse": { "type": "object", "required": [ - "payment_method_id", - "deleted" + "payment_method_id" ], "properties": { "payment_method_id": { "type": "string", "description": "The unique identifier of the Payment method", "example": "card_rGK4Vi5iSW70MY7J2mIg" - }, - "deleted": { - "type": "boolean", - "description": "Whether payment method was deleted or not", - "example": true } } }, + "PaymentMethodIntentConfirm": { + "type": "object", + "required": [ + "client_secret", + "payment_method_data", + "payment_method", + "payment_method_type" + ], + "properties": { + "client_secret": { + "type": "string", + "description": "For SDK based calls, client_secret would be required" + }, + "customer_id": { + "type": "string", + "description": "The unique identifier of the customer.", + "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44", + "nullable": true, + "maxLength": 64, + "minLength": 1 + }, + "payment_method_data": { + "$ref": "#/components/schemas/PaymentMethodCreateData" + }, + "payment_method": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethodType" + } + }, + "additionalProperties": false + }, + "PaymentMethodIntentCreate": { + "type": "object", + "required": [ + "customer_id" + ], + "properties": { + "metadata": { + "type": "object", + "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.", + "nullable": true + }, + "billing": { + "allOf": [ + { + "$ref": "#/components/schemas/Address" + } + ], + "nullable": true + }, + "customer_id": { + "type": "string", + "description": "The unique identifier of the customer.", + "example": "cus_y3oqhf46pyzuxjbcn2giaqnb44", + "maxLength": 64, + "minLength": 1 + } + }, + "additionalProperties": false + }, "PaymentMethodIssuerCode": { "type": "string", "enum": [ @@ -12843,6 +13121,104 @@ } } }, + "PaymentMethodListData": { + "oneOf": [ + { + "type": "object", + "required": [ + "card" + ], + "properties": { + "card": { + "$ref": "#/components/schemas/CardDetailFromLocker" + } + } + }, + { + "type": "object", + "required": [ + "bank" + ], + "properties": { + "bank": { + "$ref": "#/components/schemas/Bank" + } + } + } + ] + }, + "PaymentMethodListRequest": { + "type": "object", + "properties": { + "client_secret": { + "type": "string", + "description": "This is a 15 minute expiry token which shall be used from the client to authenticate and perform sessions from the SDK", + "example": "secret_k2uj3he2893eiu2d", + "nullable": true, + "maxLength": 30, + "minLength": 30 + }, + "accepted_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "description": "The two-letter ISO currency code", + "example": [ + "US", + "UK", + "IN" + ], + "nullable": true + }, + "amount": { + "allOf": [ + { + "$ref": "#/components/schemas/MinorUnit" + } + ], + "nullable": true + }, + "accepted_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "description": "The three-letter ISO currency code", + "example": [ + "USD", + "EUR" + ], + "nullable": true + }, + "recurring_enabled": { + "type": "boolean", + "description": "Indicates whether the payment method is eligible for recurring payments", + "example": true, + "nullable": true + }, + "card_networks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CardNetwork" + }, + "description": "Indicates whether the payment method is eligible for card netwotks", + "example": [ + "visa", + "mastercard" + ], + "nullable": true + }, + "limit": { + "type": "integer", + "format": "int64", + "description": "Indicates the limit of last used payment methods", + "example": 1, + "nullable": true + } + }, + "additionalProperties": false + }, "PaymentMethodListResponse": { "type": "object", "required": [ @@ -12923,17 +13299,16 @@ "PaymentMethodResponse": { "type": "object", "required": [ - "merchant_id", "payment_method_id", "payment_method", - "recurring_enabled", - "installment_payment_enabled" + "recurring_enabled" ], "properties": { "merchant_id": { "type": "string", "description": "Unique identifier for a merchant", - "example": "merchant_1671528864" + "example": "merchant_1671528864", + "nullable": true }, "customer_id": { "type": "string", @@ -12959,40 +13334,11 @@ ], "nullable": true }, - "card": { - "allOf": [ - { - "$ref": "#/components/schemas/CardDetailFromLocker" - } - ], - "nullable": true - }, "recurring_enabled": { "type": "boolean", "description": "Indicates whether the payment method is eligible for recurring payments", "example": true }, - "installment_payment_enabled": { - "type": "boolean", - "description": "Indicates whether the payment method is eligible for installment payments", - "example": true - }, - "payment_experience": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PaymentExperience" - }, - "description": "Type of payment experience enabled with the connector", - "example": [ - "redirect_to_url" - ], - "nullable": true - }, - "metadata": { - "type": "object", - "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.", - "nullable": true - }, "created": { "type": "string", "format": "date-time", @@ -13000,14 +13346,6 @@ "example": "2023-01-18T11:04:09.922Z", "nullable": true }, - "bank_transfer": { - "allOf": [ - { - "$ref": "#/components/schemas/Bank" - } - ], - "nullable": true - }, "last_used_at": { "type": "string", "format": "date-time", @@ -13018,9 +13356,32 @@ "type": "string", "description": "For Client based calls", "nullable": true + }, + "payment_method_data": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentMethodResponseData" + } + ], + "nullable": true } } }, + "PaymentMethodResponseData": { + "oneOf": [ + { + "type": "object", + "required": [ + "card" + ], + "properties": { + "card": { + "$ref": "#/components/schemas/CardDetailFromLocker" + } + } + } + ] + }, "PaymentMethodStatus": { "type": "string", "description": "Payment Method Status", @@ -13133,14 +13494,12 @@ }, "PaymentMethodUpdate": { "type": "object", + "required": [ + "payment_method_data" + ], "properties": { - "card": { - "allOf": [ - { - "$ref": "#/components/schemas/CardDetailUpdate" - } - ], - "nullable": true + "payment_method_data": { + "$ref": "#/components/schemas/PaymentMethodUpdateData" }, "client_secret": { "type": "string", @@ -13153,6 +13512,21 @@ }, "additionalProperties": false }, + "PaymentMethodUpdateData": { + "oneOf": [ + { + "type": "object", + "required": [ + "card" + ], + "properties": { + "card": { + "$ref": "#/components/schemas/CardDetailUpdate" + } + } + } + ] + }, "PaymentMethodsEnabled": { "type": "object", "description": "Details of all the payment methods enabled for the connector for the given merchant account", diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 0602f69d158..e8dda854463 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -489,6 +489,7 @@ pub struct CardDetail { pub nick_name: Option>, /// Card Issuing Country + #[schema(value_type = Option)] pub card_issuing_country: Option, /// Card's Network @@ -709,7 +710,7 @@ pub struct PaymentMethodResponse { #[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema, Clone)] pub struct PaymentMethodResponse { /// Unique identifier for a merchant - #[schema(example = "merchant_1671528864")] + #[schema(value_type = Option, example = "merchant_1671528864")] pub merchant_id: id_type::MerchantId, /// The unique identifier of the customer. @@ -852,6 +853,7 @@ pub struct CardDetailFromLocker { #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] pub struct CardDetailFromLocker { + #[schema(value_type = Option)] pub issuer_country: Option, pub last4_digits: Option, #[serde(skip)] @@ -1734,6 +1736,7 @@ pub struct CustomerPaymentMethod { pub enum PaymentMethodListData { Card(CardDetailFromLocker), #[cfg(feature = "payouts")] + #[schema(value_type = Bank)] Bank(payouts::Bank), } diff --git a/crates/openapi/Cargo.toml b/crates/openapi/Cargo.toml index 26707479b0d..930f9739e6e 100644 --- a/crates/openapi/Cargo.toml +++ b/crates/openapi/Cargo.toml @@ -16,7 +16,7 @@ common_utils = { version = "0.1.0", path = "../common_utils", features = ["logs" router_env = { version = "0.1.0", path = "../router_env" } [features] -v2 = ["api_models/v2", "api_models/customer_v2", "common_utils/v2"] +v2 = ["api_models/v2", "api_models/customer_v2", "common_utils/v2", "api_models/payment_methods_v2", "common_utils/payment_methods_v2"] v1 = ["api_models/v1", "common_utils/v1"] [lints] diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 7c09813ca6b..dd2406490ea 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -127,6 +127,17 @@ Never share your secret api keys. Keep them guarded and secure. routes::payments::payments_confirm_intent, routes::payments::payment_status, + //Routes for payment methods + routes::payment_method::list_customer_payment_method_for_payment, + routes::payment_method::list_customer_payment_method_api, + routes::payment_method::create_payment_method_api, + routes::payment_method::create_payment_method_intent_api, + routes::payment_method::confirm_payment_method_intent_api, + routes::payment_method::payment_method_update_api, + routes::payment_method::payment_method_retrieve_api, + routes::payment_method::payment_method_delete_api, + + //Routes for refunds routes::refunds::refunds_create, ), @@ -170,18 +181,25 @@ Never share your secret api keys. Keep them guarded and secure. api_models::customers::CustomerRequest, api_models::customers::CustomerDeleteResponse, api_models::payment_methods::PaymentMethodCreate, + api_models::payment_methods::PaymentMethodIntentCreate, + api_models::payment_methods::PaymentMethodIntentConfirm, api_models::payment_methods::PaymentMethodResponse, + api_models::payment_methods::PaymentMethodResponseData, api_models::payment_methods::PaymentMethodList, + api_models::payment_methods::PaymentMethodListData, api_models::payment_methods::CustomerPaymentMethod, + api_models::payment_methods::PaymentMethodListRequest, api_models::payment_methods::PaymentMethodListResponse, api_models::payment_methods::CustomerPaymentMethodsListResponse, api_models::payment_methods::PaymentMethodDeleteResponse, api_models::payment_methods::PaymentMethodUpdate, + api_models::payment_methods::PaymentMethodUpdateData, api_models::payment_methods::CustomerDefaultPaymentMethodResponse, api_models::payment_methods::CardDetailFromLocker, api_models::payment_methods::PaymentMethodCreateData, api_models::payment_methods::CardDetail, api_models::payment_methods::CardDetailUpdate, + api_models::payment_methods::CardType, api_models::payment_methods::RequestPaymentMethodTypes, api_models::poll::PollResponse, api_models::poll::PollStatus, diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index 3bc593aa5b2..dc27e5de8c3 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -31,6 +31,7 @@ operation_id = "Create a Payment Method", security(("api_key" = [])) )] +#[cfg(feature = "v1")] pub async fn create_payment_method_api() {} /// List payment methods for a Merchant @@ -84,6 +85,7 @@ pub async fn list_payment_method_api() {} operation_id = "List all Payment Methods for a Customer", security(("api_key" = [])) )] +#[cfg(feature = "v1")] pub async fn list_customer_payment_method_api() {} /// List customer saved payment methods for a Payment @@ -130,6 +132,7 @@ pub async fn list_customer_payment_method_api_client() {} operation_id = "Retrieve a Payment method", security(("api_key" = [])) )] +#[cfg(feature = "v1")] pub async fn payment_method_retrieve_api() {} /// Payment Method - Update @@ -151,6 +154,7 @@ pub async fn payment_method_retrieve_api() {} operation_id = "Update a Payment method", security(("api_key" = []), ("publishable_key" = [])) )] +#[cfg(feature = "v1")] pub async fn payment_method_update_api() {} /// Payment Method - Delete @@ -170,6 +174,7 @@ pub async fn payment_method_update_api() {} operation_id = "Delete a Payment method", security(("api_key" = [])) )] +#[cfg(feature = "v1")] pub async fn payment_method_delete_api() {} /// Payment Method - Set Default Payment Method for Customer @@ -192,3 +197,189 @@ pub async fn payment_method_delete_api() {} security(("ephemeral_key" = [])) )] pub async fn default_payment_method_set_api() {} + +/// List payment methods for a Customer v2 +/// +/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment +#[utoipa::path( + get, + path = "/v2/payments/{id}/saved-payment-methods", + request_body( + content = PaymentMethodListRequest, + // TODO: Add examples and add param for customer_id + ), + // 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" = [])) +)] +#[cfg(feature = "v2")] +pub async fn list_customer_payment_method_for_payment() {} + +/// List payment methods for a Customer v2 +/// +/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context +#[utoipa::path( + get, + path = "/v2/customers/{id}/saved-payment-methods", + request_body( + content = PaymentMethodListRequest, + // TODO: Add examples and add param for customer_id + ), + // 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" = [])) +)] +#[cfg(feature = "v2")] +pub async fn list_customer_payment_method_api() {} + +/// Create payment method v2 +/// +/// TODO: Description Here +#[utoipa::path( + post, + path = "/v2/payment-methods", + request_body( + content = PaymentMethodCreate, + // TODO: Add examples + ), + responses( + (status = 200, description = "Payment Method Created", body = PaymentMethodResponse), + (status = 400, description = "Invalid Data"), + ), + tag = "Payment Methods", + operation_id = "Create Payment Method", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn create_payment_method_api() {} + +/// Create payment method intent v2 +/// +/// TODO: Description Here +#[utoipa::path( + post, + path = "/v2/payment-methods/create-intent", + request_body( + content = PaymentMethodIntentCreate, + // TODO: Add examples + ), + responses( + (status = 200, description = "Payment Method Intent Created", body = PaymentMethodResponse), + (status = 400, description = "Invalid Data"), + ), + tag = "Payment Methods", + operation_id = "Create Payment Method Intent", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn create_payment_method_intent_api() {} + +/// Confirm payment method intent v2 +/// +/// TODO: Description Here +#[utoipa::path( + post, + path = "/v2/payment-methods/{id}/confirm-intent", + request_body( + content = PaymentMethodIntentConfirm, + // TODO: Add examples + ), + responses( + (status = 200, description = "Payment Method Intent Confirmed", body = PaymentMethodResponse), + (status = 400, description = "Invalid Data"), + ), + tag = "Payment Methods", + operation_id = "Confirm Payment Method Intent", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn confirm_payment_method_intent_api() {} + +/// Update payment method v2 +/// +/// TODO: Description Here +#[utoipa::path( + patch, + path = "/v2/payment-methods/{id}/update-saved-payment-method", + request_body( + content = PaymentMethodUpdate, + // TODO: Add examples + ), + responses( + (status = 200, description = "Payment Method Update", body = PaymentMethodResponse), + (status = 400, description = "Invalid Data"), + ), + tag = "Payment Methods", + operation_id = "Update Payment Method", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn payment_method_update_api() {} + + +/// Retrieve payment method v2 +/// +/// TODO: Description Here +#[utoipa::path( + get, + path = "/v2/payment-methods/{id}", + params ( + ("id" = String, Path, description = "The unique identifier for the Payment Method"), + ), + responses( + (status = 200, description = "Payment Method Retrieved", body = PaymentMethodResponse), + (status = 404, description = "Payment Method Not Found"), + ), + tag = "Payment Methods", + operation_id = "Retrieve Payment Method", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn payment_method_retrieve_api() {} + +/// Delete payment method v2 +/// +/// TODO: Description Here +#[utoipa::path( + delete, + path = "/v2/payment-methods/{id}", + params ( + ("id" = String, Path, description = "The unique identifier for the Payment Method"), + ), + responses( + (status = 200, description = "Payment Method Retrieved", body = PaymentMethodDeleteResponse), + (status = 404, description = "Payment Method Not Found"), + ), + tag = "Payment Methods", + operation_id = "Delete Payment Method", + security(("api_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn payment_method_delete_api() {} \ No newline at end of file diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index fd359d9535b..0d3e44e599e 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -539,7 +539,11 @@ impl Payments { .service(web::resource("").route(web::get().to(payments::payment_status))) .service( web::resource("/start_redirection") - .route(web::get().to(payments::payments_start_redirection)), + .route(web::get().to(payments::payments_start_redirection)) + .service( + web::resource("/saved-payment-methods") + .route(web::get().to(list_customer_payment_method_for_payment)), + ), ), ); diff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rs index 764e75df02a..d279907422d 100644 --- a/crates/router/src/routes/payment_methods.rs +++ b/crates/router/src/routes/payment_methods.rs @@ -508,30 +508,6 @@ pub async fn list_customer_payment_method_api( } #[cfg(all(feature = "v2", feature = "payment_methods_v2"))] -/// List payment methods for a Customer v2 -/// -/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment -#[utoipa::path( - get, - path = "v2/payments/{payment_id}/saved_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_for_payment( state: web::Data, @@ -575,29 +551,6 @@ pub async fn list_customer_payment_method_for_payment( feature = "payment_methods_v2", feature = "customer_v2" ))] -/// List payment methods for a Customer v2 -/// -/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context -#[utoipa::path( - get, - path = "v2/customers/{customer_id}/saved_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, From e6d5371bbb5467131245aeceb677fe438d6bacf1 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Fri, 8 Nov 2024 18:14:46 +0530 Subject: [PATCH 4/9] Keep id as organization_id for v1 --- api-reference/openapi_spec.json | 12 +++++++++++- crates/api_models/src/organization.rs | 21 +++++++++++++++++++++ crates/openapi/src/routes/payment_method.rs | 3 +-- crates/router/src/routes/app.rs | 10 +++++----- crates/router/src/types/api/admin.rs | 4 ++++ 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 733ba96237c..3bf96caa88e 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -14272,14 +14272,17 @@ ], "properties": { "organization_name": { - "type": "string" + "type": "string", + "description": "Name of the organization" }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true } }, @@ -14295,20 +14298,24 @@ "properties": { "organization_id": { "type": "string", + "description": "The unique identifier for the Organization", "example": "org_q98uSGAYbjEwqs0mJwnz", "maxLength": 64, "minLength": 1 }, "organization_name": { "type": "string", + "description": "Name of the Organization", "nullable": true }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true }, "modified_at": { @@ -14326,14 +14333,17 @@ "properties": { "organization_name": { "type": "string", + "description": "Name of the organization", "nullable": true }, "organization_details": { "type": "object", + "description": "Details about the organization", "nullable": true }, "metadata": { "type": "object", + "description": "Metadata is useful for storing additional, unstructured information on an object.", "nullable": true } }, diff --git a/crates/api_models/src/organization.rs b/crates/api_models/src/organization.rs index 2b8b1d95bca..c6bc3924d11 100644 --- a/crates/api_models/src/organization.rs +++ b/crates/api_models/src/organization.rs @@ -48,7 +48,28 @@ pub struct OrganizationUpdateRequest { #[schema(value_type = Option)] pub metadata: Option, } +#[cfg(feature = "v1")] +#[derive(Debug, serde::Serialize, Clone, ToSchema)] +pub struct OrganizationResponse { + /// The unique identifier for the Organization + #[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")] + pub organization_id: id_type::OrganizationId, + + /// Name of the Organization + pub organization_name: Option, + + /// Details about the organization + #[schema(value_type = Option)] + pub organization_details: Option, + + /// Metadata is useful for storing additional, unstructured information on an object. + #[schema(value_type = Option)] + pub metadata: Option, + pub modified_at: time::PrimitiveDateTime, + pub created_at: time::PrimitiveDateTime, +} +#[cfg(feature = "v2")] #[derive(Debug, serde::Serialize, Clone, ToSchema)] pub struct OrganizationResponse { /// The unique identifier for the Organization diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index dc27e5de8c3..1c085eacc3d 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -343,7 +343,6 @@ pub async fn confirm_payment_method_intent_api() {} #[cfg(feature = "v2")] pub async fn payment_method_update_api() {} - /// Retrieve payment method v2 /// /// TODO: Description Here @@ -382,4 +381,4 @@ pub async fn payment_method_retrieve_api() {} security(("api_key" = [])) )] #[cfg(feature = "v2")] -pub async fn payment_method_delete_api() {} \ No newline at end of file +pub async fn payment_method_delete_api() {} diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 0d3e44e599e..ffc48abee91 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -539,11 +539,11 @@ impl Payments { .service(web::resource("").route(web::get().to(payments::payment_status))) .service( web::resource("/start_redirection") - .route(web::get().to(payments::payments_start_redirection)) - .service( - web::resource("/saved-payment-methods") - .route(web::get().to(list_customer_payment_method_for_payment)), - ), + .route(web::get().to(payments::payments_start_redirection)), + ) + .service( + web::resource("/saved-payment-methods") + .route(web::get().to(list_customer_payment_method_for_payment)), ), ); diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rs index 098c95fbe65..85275a768df 100644 --- a/crates/router/src/types/api/admin.rs +++ b/crates/router/src/types/api/admin.rs @@ -34,7 +34,11 @@ use crate::{ impl ForeignFrom for OrganizationResponse { fn foreign_from(org: diesel_models::organization::Organization) -> Self { Self { + #[cfg(feature = "v2")] id: org.get_organization_id(), + + #[cfg(feature = "v1")] + organization_id: org.get_organization_id(), organization_name: org.get_organization_name(), organization_details: org.organization_details, metadata: org.metadata, From 9e2c9c10023d4b08a90b0d534e8b025315d287fe Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Wed, 13 Nov 2024 14:41:57 +0530 Subject: [PATCH 5/9] Added Payment Method API descriptions --- api-reference-v2/mint.json | 12 +- api-reference-v2/openapi_spec.json | 24 +-- crates/openapi/src/routes/payment_method.rs | 163 +++++++++----------- 3 files changed, 91 insertions(+), 108 deletions(-) diff --git a/api-reference-v2/mint.json b/api-reference-v2/mint.json index 1cd612635c3..aed89492443 100644 --- a/api-reference-v2/mint.json +++ b/api-reference-v2/mint.json @@ -48,14 +48,14 @@ { "group": "Payment Methods", "pages": [ - "api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment", - "api-reference/payment-methods/list-payment-methods-for-a-customer", - "api-reference/payment-methods/payment-method--confirm-intent", - "api-reference/payment-methods/payment-method--create-intent", "api-reference/payment-methods/payment-method--create", - "api-reference/payment-methods/payment-method--delete", "api-reference/payment-methods/payment-method--retrieve", - "api-reference/payment-methods/payment-method--update" + "api-reference/payment-methods/payment-method--update", + "api-reference/payment-methods/payment-method--delete", + "api-reference/payment-methods/payment-method--create-intent", + "api-reference/payment-methods/payment-method--confirm-intent", + "api-reference/payment-methods/list-customer-saved-payment-methods-for-a-payment", + "api-reference/payment-methods/list-payment-methods-for-a-customer" ] }, { diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 7c737694552..13137662253 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2022,7 +2022,7 @@ "tags": [ "Payment Methods" ], - "summary": "List payment methods for a Customer v2", + "summary": "List customer saved payment methods for a payment", "description": "To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment", "operationId": "List all Payment Methods for a Customer", "requestBody": { @@ -2065,7 +2065,7 @@ "tags": [ "Payment Methods" ], - "summary": "List payment methods for a Customer v2", + "summary": "List saved payment methods for a Customer", "description": "To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context", "operationId": "List all Payment Methods for a Customer", "requestBody": { @@ -2108,8 +2108,8 @@ "tags": [ "Payment Methods" ], - "summary": "Create payment method v2", - "description": "TODO: Description Here", + "summary": "Payment Method - Create", + "description": "Creates and stores a payment method against a customer. In case of cards, this API should be used only by PCI compliant merchants.", "operationId": "Create Payment Method", "requestBody": { "content": { @@ -2148,7 +2148,7 @@ "tags": [ "Payment Methods" ], - "summary": "Create payment method intent v2", + "summary": "Payment Method - Create Intent", "description": "TODO: Description Here", "operationId": "Create Payment Method Intent", "requestBody": { @@ -2188,7 +2188,7 @@ "tags": [ "Payment Methods" ], - "summary": "Confirm payment method intent v2", + "summary": "Payment Method - Confirm Intent", "description": "TODO: Description Here", "operationId": "Confirm Payment Method Intent", "requestBody": { @@ -2228,8 +2228,8 @@ "tags": [ "Payment Methods" ], - "summary": "Update payment method v2", - "description": "TODO: Description Here", + "summary": "Payment Method - Update", + "description": "Update an existing payment method of a customer. This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments.", "operationId": "Update Payment Method", "requestBody": { "content": { @@ -2268,8 +2268,8 @@ "tags": [ "Payment Methods" ], - "summary": "Retrieve payment method v2", - "description": "TODO: Description Here", + "summary": "Payment Method - Retrieve", + "description": "Retrieves a payment method of a customer.", "operationId": "Retrieve Payment Method", "parameters": [ { @@ -2307,8 +2307,8 @@ "tags": [ "Payment Methods" ], - "summary": "Delete payment method v2", - "description": "TODO: Description Here", + "summary": "Payment Method - Delete", + "description": "Deletes a payment method of a customer.", "operationId": "Delete Payment Method", "parameters": [ { diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index 1c085eacc3d..c3afd5ee609 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -198,70 +198,51 @@ pub async fn payment_method_delete_api() {} )] pub async fn default_payment_method_set_api() {} -/// List payment methods for a Customer v2 +/// Payment Method - Create Intent /// -/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment +/// TODO: Description Here #[utoipa::path( - get, - path = "/v2/payments/{id}/saved-payment-methods", + post, + path = "/v2/payment-methods/create-intent", request_body( - content = PaymentMethodListRequest, - // TODO: Add examples and add param for customer_id + content = PaymentMethodIntentCreate, + // TODO: Add examples ), - // 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 = 200, description = "Payment Method Intent Created", body = PaymentMethodResponse), (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" = [])) + operation_id = "Create Payment Method Intent", + security(("api_key" = [])) )] #[cfg(feature = "v2")] -pub async fn list_customer_payment_method_for_payment() {} +pub async fn create_payment_method_intent_api() {} -/// List payment methods for a Customer v2 +/// Payment Method - Confirm Intent /// -/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context +/// TODO: Description Here #[utoipa::path( - get, - path = "/v2/customers/{id}/saved-payment-methods", + post, + path = "/v2/payment-methods/{id}/confirm-intent", request_body( - content = PaymentMethodListRequest, - // TODO: Add examples and add param for customer_id + content = PaymentMethodIntentConfirm, + // TODO: Add examples ), - // 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 = 200, description = "Payment Method Intent Confirmed", body = PaymentMethodResponse), (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", + operation_id = "Confirm Payment Method Intent", security(("api_key" = [])) )] #[cfg(feature = "v2")] -pub async fn list_customer_payment_method_api() {} +pub async fn confirm_payment_method_intent_api() {} -/// Create payment method v2 +/// Payment Method - Create /// -/// TODO: Description Here +/// Creates and stores a payment method against a customer. In case of cards, this API should be used only by PCI compliant merchants. #[utoipa::path( post, path = "/v2/payment-methods", @@ -280,51 +261,29 @@ pub async fn list_customer_payment_method_api() {} #[cfg(feature = "v2")] pub async fn create_payment_method_api() {} -/// Create payment method intent v2 -/// -/// TODO: Description Here -#[utoipa::path( - post, - path = "/v2/payment-methods/create-intent", - request_body( - content = PaymentMethodIntentCreate, - // TODO: Add examples - ), - responses( - (status = 200, description = "Payment Method Intent Created", body = PaymentMethodResponse), - (status = 400, description = "Invalid Data"), - ), - tag = "Payment Methods", - operation_id = "Create Payment Method Intent", - security(("api_key" = [])) -)] -#[cfg(feature = "v2")] -pub async fn create_payment_method_intent_api() {} - -/// Confirm payment method intent v2 +/// Payment Method - Retrieve /// -/// TODO: Description Here +/// Retrieves a payment method of a customer. #[utoipa::path( - post, - path = "/v2/payment-methods/{id}/confirm-intent", - request_body( - content = PaymentMethodIntentConfirm, - // TODO: Add examples + get, + path = "/v2/payment-methods/{id}", + params ( + ("id" = String, Path, description = "The unique identifier for the Payment Method"), ), responses( - (status = 200, description = "Payment Method Intent Confirmed", body = PaymentMethodResponse), - (status = 400, description = "Invalid Data"), + (status = 200, description = "Payment Method Retrieved", body = PaymentMethodResponse), + (status = 404, description = "Payment Method Not Found"), ), tag = "Payment Methods", - operation_id = "Confirm Payment Method Intent", + operation_id = "Retrieve Payment Method", security(("api_key" = [])) )] #[cfg(feature = "v2")] -pub async fn confirm_payment_method_intent_api() {} +pub async fn payment_method_retrieve_api() {} -/// Update payment method v2 +/// Payment Method - Update /// -/// TODO: Description Here +/// Update an existing payment method of a customer. This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments. #[utoipa::path( patch, path = "/v2/payment-methods/{id}/update-saved-payment-method", @@ -343,42 +302,66 @@ pub async fn confirm_payment_method_intent_api() {} #[cfg(feature = "v2")] pub async fn payment_method_update_api() {} -/// Retrieve payment method v2 +/// Payment Method - Delete /// -/// TODO: Description Here +/// Deletes a payment method of a customer. #[utoipa::path( - get, + delete, path = "/v2/payment-methods/{id}", params ( ("id" = String, Path, description = "The unique identifier for the Payment Method"), ), responses( - (status = 200, description = "Payment Method Retrieved", body = PaymentMethodResponse), + (status = 200, description = "Payment Method Retrieved", body = PaymentMethodDeleteResponse), (status = 404, description = "Payment Method Not Found"), ), tag = "Payment Methods", - operation_id = "Retrieve Payment Method", + operation_id = "Delete Payment Method", security(("api_key" = [])) )] #[cfg(feature = "v2")] -pub async fn payment_method_retrieve_api() {} +pub async fn payment_method_delete_api() {} -/// Delete payment method v2 +/// List customer saved payment methods for a payment /// -/// TODO: Description Here +/// To filter and list the applicable payment methods for a particular Customer ID, is to be associated with a payment #[utoipa::path( - delete, - path = "/v2/payment-methods/{id}", - params ( - ("id" = String, Path, description = "The unique identifier for the Payment Method"), + get, + path = "/v2/payments/{id}/saved-payment-methods", + request_body( + content = PaymentMethodListRequest, + // TODO: Add examples and add param for customer_id ), responses( - (status = 200, description = "Payment Method Retrieved", body = PaymentMethodDeleteResponse), - (status = 404, description = "Payment Method Not Found"), + (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 = "Delete Payment Method", + operation_id = "List all Payment Methods for a Customer", + security(("publishable_key" = [])) +)] +#[cfg(feature = "v2")] +pub async fn list_customer_payment_method_for_payment() {} + +/// List saved payment methods for a Customer +/// +/// To filter and list the applicable payment methods for a particular Customer ID, to be used in a non-payments context +#[utoipa::path( + get, + path = "/v2/customers/{id}/saved-payment-methods", + request_body( + content = PaymentMethodListRequest, + // TODO: Add examples and add param for customer_id + ), + 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" = [])) )] #[cfg(feature = "v2")] -pub async fn payment_method_delete_api() {} +pub async fn list_customer_payment_method_api() {} From 6f0546242e8ced51c0f40406a329fef30e0cc137 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Thu, 14 Nov 2024 00:07:38 +0530 Subject: [PATCH 6/9] Address review comments --- .../api-reference/merchant-account/profile--list.mdx | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 api-reference-v2/api-reference/merchant-account/profile--list.mdx diff --git a/api-reference-v2/api-reference/merchant-account/profile--list.mdx b/api-reference-v2/api-reference/merchant-account/profile--list.mdx deleted file mode 100644 index f7a57875f65..00000000000 --- a/api-reference-v2/api-reference/merchant-account/profile--list.mdx +++ /dev/null @@ -1,3 +0,0 @@ ---- -openapi: get /v2/merchant-accounts/{account_id}/profiles ---- \ No newline at end of file From b68f99e4a52b876f47d878a73daa35b94e029a14 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Fri, 15 Nov 2024 13:09:33 +0530 Subject: [PATCH 7/9] Address review comments --- api-reference-v2/openapi_spec.json | 8 ++++---- crates/api_models/src/payment_methods.rs | 2 +- crates/openapi/src/routes/payment_method.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 13137662253..f158259bcb6 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2149,7 +2149,7 @@ "Payment Methods" ], "summary": "Payment Method - Create Intent", - "description": "TODO: Description Here", + "description": "Creates a payment method for customer with billing information and other metadata.", "operationId": "Create Payment Method Intent", "requestBody": { "content": { @@ -2189,7 +2189,7 @@ "Payment Methods" ], "summary": "Payment Method - Confirm Intent", - "description": "TODO: Description Here", + "description": "Update a payment method with customer's payment method related information.", "operationId": "Confirm Payment Method Intent", "requestBody": { "content": { @@ -13299,6 +13299,7 @@ "PaymentMethodResponse": { "type": "object", "required": [ + "merchant_id", "payment_method_id", "payment_method", "recurring_enabled" @@ -13307,8 +13308,7 @@ "merchant_id": { "type": "string", "description": "Unique identifier for a merchant", - "example": "merchant_1671528864", - "nullable": true + "example": "merchant_1671528864" }, "customer_id": { "type": "string", diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index e8dda854463..1b4b72fa033 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -710,7 +710,7 @@ pub struct PaymentMethodResponse { #[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema, Clone)] pub struct PaymentMethodResponse { /// Unique identifier for a merchant - #[schema(value_type = Option, example = "merchant_1671528864")] + #[schema(value_type = String, example = "merchant_1671528864")] pub merchant_id: id_type::MerchantId, /// The unique identifier of the customer. diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index c3afd5ee609..2780bf58097 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -200,7 +200,7 @@ pub async fn default_payment_method_set_api() {} /// Payment Method - Create Intent /// -/// TODO: Description Here +/// Creates a payment method for customer with billing information and other metadata. #[utoipa::path( post, path = "/v2/payment-methods/create-intent", @@ -221,7 +221,7 @@ pub async fn create_payment_method_intent_api() {} /// Payment Method - Confirm Intent /// -/// TODO: Description Here +/// Update a payment method with customer's payment method related information. #[utoipa::path( post, path = "/v2/payment-methods/{id}/confirm-intent", From 003b597fcd15afc7e292999e10e08858881a4844 Mon Sep 17 00:00:00 2001 From: Anurag Thakur Date: Thu, 28 Nov 2024 12:00:20 +0530 Subject: [PATCH 8/9] Address review comment --- crates/openapi/src/routes/payment_method.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/openapi/src/routes/payment_method.rs b/crates/openapi/src/routes/payment_method.rs index 2780bf58097..b38a2342678 100644 --- a/crates/openapi/src/routes/payment_method.rs +++ b/crates/openapi/src/routes/payment_method.rs @@ -283,7 +283,7 @@ pub async fn payment_method_retrieve_api() {} /// Payment Method - Update /// -/// Update an existing payment method of a customer. This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments. +/// Update an existing payment method of a customer. #[utoipa::path( patch, path = "/v2/payment-methods/{id}/update-saved-payment-method", From e7df6ecbcbf81b879f4c2b164d7ea80b6efa4a52 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 06:33:14 +0000 Subject: [PATCH 9/9] docs(openapi): re-generate OpenAPI specification --- api-reference-v2/openapi_spec.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index d90afc6a129..88ad74a7560 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -2229,7 +2229,7 @@ "Payment Methods" ], "summary": "Payment Method - Update", - "description": "Update an existing payment method of a customer. This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments.", + "description": "Update an existing payment method of a customer.", "operationId": "Update Payment Method", "requestBody": { "content": {