mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 14:07:18 +08:00 
			
		
		
		
	refactor(openapi): move openapi to separate crate to decrease compile times (#3110)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sai Harsha Vardhan <56996463+sai-harsha-vardhan@users.noreply.github.com> Co-authored-by: Sahkal Poddar <sahkalplanet@gmail.com> Co-authored-by: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Co-authored-by: Sarthak Soni <76486416+Sarthak1799@users.noreply.github.com> Co-authored-by: shashank_attarde <shashank.attarde@juspay.in> Co-authored-by: Aprabhat19 <amishaprabhat@gmail.com> Co-authored-by: sai-harsha-vardhan <harsha111hero@gmail.com> Co-authored-by: Sahkal Poddar <sahkal.poddar@juspay.in> Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
		@ -16,21 +16,6 @@ use crate::{
 | 
			
		||||
    utils::Encode,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/// PaymentMethods - Create
 | 
			
		||||
///
 | 
			
		||||
/// To create a payment method against a customer object. In case of cards, this API could be used only by PCI compliant merchants
 | 
			
		||||
#[utoipa::path(
 | 
			
		||||
    post,
 | 
			
		||||
    path = "/payment_methods",
 | 
			
		||||
    request_body = PaymentMethodCreate,
 | 
			
		||||
    responses(
 | 
			
		||||
        (status = 200, description = "Payment Method Created", body = PaymentMethodResponse),
 | 
			
		||||
        (status = 400, description = "Invalid Data")
 | 
			
		||||
    ),
 | 
			
		||||
    tag = "Payment Methods",
 | 
			
		||||
    operation_id = "Create a Payment Method",
 | 
			
		||||
    security(("api_key" = []))
 | 
			
		||||
)]
 | 
			
		||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsCreate))]
 | 
			
		||||
pub async fn create_payment_method_api(
 | 
			
		||||
    state: web::Data<AppState>,
 | 
			
		||||
@ -57,30 +42,7 @@ pub async fn create_payment_method_api(
 | 
			
		||||
    ))
 | 
			
		||||
    .await
 | 
			
		||||
}
 | 
			
		||||
/// List payment methods for a Merchant
 | 
			
		||||
///
 | 
			
		||||
/// To filter and list the applicable payment methods for a particular Merchant ID
 | 
			
		||||
#[utoipa::path(
 | 
			
		||||
    get,
 | 
			
		||||
    path = "/account/payment_methods",
 | 
			
		||||
    params (
 | 
			
		||||
        ("account_id" = String, Path, description = "The unique identifier for the merchant account"),
 | 
			
		||||
        ("accepted_country" = Vec<String>, Query, description = "The two-letter ISO currency code"),
 | 
			
		||||
        ("accepted_currency" = Vec<Currency>, 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 = PaymentMethodListResponse),
 | 
			
		||||
        (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 Merchant",
 | 
			
		||||
    security(("api_key" = []), ("publishable_key" = []))
 | 
			
		||||
)]
 | 
			
		||||
 | 
			
		||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsList))]
 | 
			
		||||
pub async fn list_payment_method_api(
 | 
			
		||||
    state: web::Data<AppState>,
 | 
			
		||||
@ -214,23 +176,7 @@ pub async fn list_customer_payment_method_api_client(
 | 
			
		||||
    ))
 | 
			
		||||
    .await
 | 
			
		||||
}
 | 
			
		||||
/// Payment Method - Retrieve
 | 
			
		||||
///
 | 
			
		||||
/// To retrieve a payment method
 | 
			
		||||
#[utoipa::path(
 | 
			
		||||
    get,
 | 
			
		||||
    path = "/payment_methods/{method_id}",
 | 
			
		||||
    params (
 | 
			
		||||
        ("method_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 does not exist in records")
 | 
			
		||||
    ),
 | 
			
		||||
    tag = "Payment Methods",
 | 
			
		||||
    operation_id = "Retrieve a Payment method",
 | 
			
		||||
    security(("api_key" = []))
 | 
			
		||||
)]
 | 
			
		||||
 | 
			
		||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsRetrieve))]
 | 
			
		||||
pub async fn payment_method_retrieve_api(
 | 
			
		||||
    state: web::Data<AppState>,
 | 
			
		||||
@ -254,24 +200,7 @@ pub async fn payment_method_retrieve_api(
 | 
			
		||||
    ))
 | 
			
		||||
    .await
 | 
			
		||||
}
 | 
			
		||||
/// Payment Method - Update
 | 
			
		||||
///
 | 
			
		||||
/// To update an existing payment method attached to a customer object. This API is useful for use cases such as updating the card number for expired cards to prevent discontinuity in recurring payments
 | 
			
		||||
#[utoipa::path(
 | 
			
		||||
    post,
 | 
			
		||||
    path = "/payment_methods/{method_id}",
 | 
			
		||||
    params (
 | 
			
		||||
        ("method_id" = String, Path, description = "The unique identifier for the Payment Method"),
 | 
			
		||||
    ),
 | 
			
		||||
    request_body = PaymentMethodUpdate,
 | 
			
		||||
    responses(
 | 
			
		||||
        (status = 200, description = "Payment Method updated", body = PaymentMethodResponse),
 | 
			
		||||
        (status = 404, description = "Payment Method does not exist in records")
 | 
			
		||||
    ),
 | 
			
		||||
    tag = "Payment Methods",
 | 
			
		||||
    operation_id = "Update a Payment method",
 | 
			
		||||
    security(("api_key" = []))
 | 
			
		||||
)]
 | 
			
		||||
 | 
			
		||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsUpdate))]
 | 
			
		||||
pub async fn payment_method_update_api(
 | 
			
		||||
    state: web::Data<AppState>,
 | 
			
		||||
@ -301,23 +230,7 @@ pub async fn payment_method_update_api(
 | 
			
		||||
    ))
 | 
			
		||||
    .await
 | 
			
		||||
}
 | 
			
		||||
/// Payment Method - Delete
 | 
			
		||||
///
 | 
			
		||||
/// Delete payment method
 | 
			
		||||
#[utoipa::path(
 | 
			
		||||
    delete,
 | 
			
		||||
    path = "/payment_methods/{method_id}",
 | 
			
		||||
    params (
 | 
			
		||||
        ("method_id" = String, Path, description = "The unique identifier for the Payment Method"),
 | 
			
		||||
    ),
 | 
			
		||||
    responses(
 | 
			
		||||
        (status = 200, description = "Payment Method deleted", body = PaymentMethodDeleteResponse),
 | 
			
		||||
        (status = 404, description = "Payment Method does not exist in records")
 | 
			
		||||
    ),
 | 
			
		||||
    tag = "Payment Methods",
 | 
			
		||||
    operation_id = "Delete a Payment method",
 | 
			
		||||
    security(("api_key" = []))
 | 
			
		||||
)]
 | 
			
		||||
 | 
			
		||||
#[instrument(skip_all, fields(flow = ?Flow::PaymentMethodsDelete))]
 | 
			
		||||
pub async fn payment_method_delete_api(
 | 
			
		||||
    state: web::Data<AppState>,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user