mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +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:
@ -21,7 +21,7 @@ olap = ["data_models/olap", "storage_impl/olap", "scheduler/olap", "dep:analytic
|
||||
oltp = ["storage_impl/oltp"]
|
||||
kv_store = ["scheduler/kv_store"]
|
||||
accounts_cache = []
|
||||
openapi = ["olap", "oltp", "payouts"]
|
||||
openapi = ["olap", "oltp", "payouts", "dep:openapi"]
|
||||
vergen = ["router_env/vergen"]
|
||||
backwards_compatibility = ["api_models/backwards_compatibility"]
|
||||
business_profile_routing = ["api_models/business_profile_routing"]
|
||||
@ -96,7 +96,6 @@ tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread"] }
|
||||
unicode-segmentation = "1.10.1"
|
||||
url = { version = "2.4.0", features = ["serde"] }
|
||||
utoipa = { version = "3.3.0", features = ["preserve_order", "time"] }
|
||||
utoipa-swagger-ui = { version = "3.1.3", features = ["actix-web"] }
|
||||
uuid = { version = "1.3.3", features = ["serde", "v4"] }
|
||||
validator = "0.16.0"
|
||||
x509-parser = "0.15.0"
|
||||
@ -121,6 +120,7 @@ router_derive = { version = "0.1.0", path = "../router_derive" }
|
||||
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
|
||||
scheduler = { version = "0.1.0", path = "../scheduler", default-features = false }
|
||||
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
|
||||
openapi = { version = "0.1.0", path = "../openapi", optional = true }
|
||||
erased-serde = "0.3.31"
|
||||
quick-xml = { version = "0.31.0", features = ["serialize"] }
|
||||
rdkafka = "0.36.0"
|
||||
@ -139,6 +139,7 @@ time = { version = "0.3.21", features = ["macros"] }
|
||||
tokio = "1.35.1"
|
||||
wiremock = "0.5.18"
|
||||
|
||||
|
||||
# First party dev-dependencies
|
||||
test_utils = { version = "0.1.0", path = "../test_utils" }
|
||||
|
||||
|
||||
@ -9,24 +9,6 @@ async fn main() -> ApplicationResult<()> {
|
||||
// get commandline config before initializing config
|
||||
let cmd_line = <CmdLineConf as clap::Parser>::parse();
|
||||
|
||||
#[cfg(feature = "openapi")]
|
||||
{
|
||||
use router::configs::settings::Subcommand;
|
||||
if let Some(Subcommand::GenerateOpenapiSpec) = cmd_line.subcommand {
|
||||
let file_path = "openapi/openapi_spec.json";
|
||||
#[allow(clippy::expect_used)]
|
||||
std::fs::write(
|
||||
file_path,
|
||||
<router::openapi::ApiDoc as utoipa::OpenApi>::openapi()
|
||||
.to_pretty_json()
|
||||
.expect("Failed to serialize OpenAPI specification as JSON"),
|
||||
)
|
||||
.expect("Failed to write OpenAPI specification to file");
|
||||
println!("Successfully saved OpenAPI specification file at '{file_path}'");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::expect_used)]
|
||||
let conf = Settings::with_config_path(cmd_line.config_path)
|
||||
.expect("Unable to construct application configuration");
|
||||
|
||||
@ -12,6 +12,7 @@ pub mod cors;
|
||||
pub mod db;
|
||||
pub mod env;
|
||||
pub(crate) mod macros;
|
||||
|
||||
pub mod routes;
|
||||
pub mod workflows;
|
||||
|
||||
@ -19,7 +20,6 @@ pub mod workflows;
|
||||
pub mod analytics;
|
||||
pub mod events;
|
||||
pub mod middleware;
|
||||
pub mod openapi;
|
||||
pub mod services;
|
||||
pub mod types;
|
||||
pub mod utils;
|
||||
@ -93,15 +93,6 @@ pub fn mk_app(
|
||||
> {
|
||||
let mut server_app = get_application_builder(request_body_limit);
|
||||
|
||||
#[cfg(feature = "openapi")]
|
||||
{
|
||||
use utoipa::OpenApi;
|
||||
server_app = server_app.service(
|
||||
utoipa_swagger_ui::SwaggerUi::new("/docs/{_:.*}")
|
||||
.url("/docs/openapi.json", openapi::ApiDoc::openapi()),
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
{
|
||||
use routes::DummyConnector;
|
||||
|
||||
@ -1,533 +0,0 @@
|
||||
#[cfg(feature = "openapi")]
|
||||
#[derive(utoipa::OpenApi)]
|
||||
#[openapi(
|
||||
info(
|
||||
title = "Hyperswitch - API Documentation",
|
||||
contact(
|
||||
name = "Hyperswitch Support",
|
||||
url = "https://hyperswitch.io",
|
||||
email = "hyperswitch@juspay.in"
|
||||
),
|
||||
// terms_of_service = "https://www.juspay.io/terms",
|
||||
description = r#"
|
||||
## Get started
|
||||
|
||||
Hyperswitch provides a collection of APIs that enable you to process and manage payments.
|
||||
Our APIs accept and return JSON in the HTTP body, and return standard HTTP response codes.
|
||||
|
||||
You can consume the APIs directly using your favorite HTTP/REST library.
|
||||
|
||||
We have a testing environment referred to "sandbox", which you can setup to test API calls without
|
||||
affecting production data.
|
||||
Currently, our sandbox environment is live while our production environment is under development
|
||||
and will be available soon.
|
||||
You can sign up on our Dashboard to get API keys to access Hyperswitch API.
|
||||
|
||||
### Environment
|
||||
|
||||
Use the following base URLs when making requests to the APIs:
|
||||
|
||||
| Environment | Base URL |
|
||||
|---------------|------------------------------------|
|
||||
| Sandbox | <https://sandbox.hyperswitch.io> |
|
||||
| Production | <https://api.hyperswitch.io> |
|
||||
|
||||
## Authentication
|
||||
|
||||
When you sign up on our [dashboard](https://app.hyperswitch.io) and create a merchant
|
||||
account, you are given a secret key (also referred as api-key) and a publishable key.
|
||||
You may authenticate all API requests with Hyperswitch server by providing the appropriate key in
|
||||
the request Authorization header.
|
||||
|
||||
| Key | Description |
|
||||
|-----------------|-----------------------------------------------------------------------------------------------|
|
||||
| api-key | Private key. Used to authenticate all API requests from your merchant server |
|
||||
| publishable key | Unique identifier for your account. Used to authenticate API requests from your app's client |
|
||||
|
||||
Never share your secret api keys. Keep them guarded and secure.
|
||||
"#,
|
||||
),
|
||||
servers(
|
||||
(url = "https://sandbox.hyperswitch.io", description = "Sandbox Environment")
|
||||
),
|
||||
tags(
|
||||
(name = "Merchant Account", description = "Create and manage merchant accounts"),
|
||||
(name = "Merchant Connector Account", description = "Create and manage merchant connector accounts"),
|
||||
(name = "Payments", description = "Create and manage one-time payments, recurring payments and mandates"),
|
||||
(name = "Refunds", description = "Create and manage refunds for successful payments"),
|
||||
(name = "Mandates", description = "Manage mandates"),
|
||||
(name = "Customers", description = "Create and manage customers"),
|
||||
(name = "Payment Methods", description = "Create and manage payment methods of customers"),
|
||||
(name = "Disputes", description = "Manage disputes"),
|
||||
// (name = "API Key", description = "Create and manage API Keys"),
|
||||
(name = "Payouts", description = "Create and manage payouts"),
|
||||
(name = "payment link", description = "Create payment link"),
|
||||
),
|
||||
paths(
|
||||
crate::routes::refunds::refunds_create,
|
||||
crate::routes::refunds::refunds_retrieve,
|
||||
crate::routes::refunds::refunds_update,
|
||||
crate::routes::refunds::refunds_list,
|
||||
// Commenting this out as these are admin apis and not to be used by the merchant
|
||||
// crate::routes::admin::merchant_account_create,
|
||||
// crate::routes::admin::retrieve_merchant_account,
|
||||
// crate::routes::admin::update_merchant_account,
|
||||
// crate::routes::admin::delete_merchant_account,
|
||||
crate::routes::admin::payment_connector_create,
|
||||
crate::routes::admin::payment_connector_retrieve,
|
||||
crate::routes::admin::payment_connector_list,
|
||||
crate::routes::admin::payment_connector_update,
|
||||
crate::routes::admin::payment_connector_delete,
|
||||
crate::routes::mandates::get_mandate,
|
||||
crate::routes::mandates::revoke_mandate,
|
||||
crate::routes::payments::payments_create,
|
||||
// crate::routes::payments::payments_start,
|
||||
crate::routes::payments::payments_retrieve,
|
||||
crate::routes::payments::payments_update,
|
||||
crate::routes::payments::payments_confirm,
|
||||
crate::routes::payments::payments_capture,
|
||||
crate::routes::payments::payments_connector_session,
|
||||
// crate::routes::payments::payments_redirect_response,
|
||||
crate::routes::payments::payments_cancel,
|
||||
crate::routes::payments::payments_list,
|
||||
crate::routes::payment_methods::create_payment_method_api,
|
||||
crate::routes::payment_methods::list_payment_method_api,
|
||||
crate::routes::payment_methods::list_customer_payment_method_api,
|
||||
crate::routes::payment_methods::list_customer_payment_method_api_client,
|
||||
crate::routes::payment_methods::payment_method_retrieve_api,
|
||||
crate::routes::payment_methods::payment_method_update_api,
|
||||
crate::routes::payment_methods::payment_method_delete_api,
|
||||
crate::routes::customers::customers_create,
|
||||
crate::routes::customers::customers_retrieve,
|
||||
crate::routes::customers::customers_update,
|
||||
crate::routes::customers::customers_delete,
|
||||
crate::routes::customers::customers_list,
|
||||
// crate::routes::api_keys::api_key_create,
|
||||
// crate::routes::api_keys::api_key_retrieve,
|
||||
// crate::routes::api_keys::api_key_update,
|
||||
// crate::routes::api_keys::api_key_revoke,
|
||||
// crate::routes::api_keys::api_key_list,
|
||||
crate::routes::disputes::retrieve_disputes_list,
|
||||
crate::routes::disputes::retrieve_dispute,
|
||||
crate::routes::payouts::payouts_create,
|
||||
crate::routes::payouts::payouts_cancel,
|
||||
crate::routes::payouts::payouts_fulfill,
|
||||
crate::routes::payouts::payouts_retrieve,
|
||||
crate::routes::payouts::payouts_update,
|
||||
crate::routes::payment_link::payment_link_retrieve,
|
||||
crate::routes::gsm::create_gsm_rule,
|
||||
crate::routes::gsm::get_gsm_rule,
|
||||
crate::routes::gsm::update_gsm_rule,
|
||||
crate::routes::gsm::delete_gsm_rule,
|
||||
crate::routes::blocklist::add_entry_to_blocklist,
|
||||
crate::routes::blocklist::list_blocked_payment_methods,
|
||||
crate::routes::blocklist::remove_entry_from_blocklist
|
||||
),
|
||||
components(schemas(
|
||||
crate::types::api::refunds::RefundRequest,
|
||||
crate::types::api::refunds::RefundType,
|
||||
crate::types::api::refunds::RefundResponse,
|
||||
crate::types::api::refunds::RefundStatus,
|
||||
crate::types::api::refunds::RefundUpdateRequest,
|
||||
crate::types::api::admin::MerchantAccountCreate,
|
||||
crate::types::api::admin::MerchantAccountUpdate,
|
||||
crate::types::api::admin::MerchantAccountDeleteResponse,
|
||||
crate::types::api::admin::MerchantConnectorDeleteResponse,
|
||||
crate::types::api::admin::MerchantConnectorResponse,
|
||||
crate::types::api::customers::CustomerRequest,
|
||||
crate::types::api::customers::CustomerDeleteResponse,
|
||||
crate::types::api::payment_methods::PaymentMethodCreate,
|
||||
crate::types::api::payment_methods::PaymentMethodResponse,
|
||||
crate::types::api::payment_methods::PaymentMethodList,
|
||||
crate::types::api::payment_methods::CustomerPaymentMethod,
|
||||
crate::types::api::payment_methods::PaymentMethodListResponse,
|
||||
crate::types::api::payment_methods::CustomerPaymentMethodsListResponse,
|
||||
crate::types::api::payment_methods::PaymentMethodDeleteResponse,
|
||||
crate::types::api::payment_methods::PaymentMethodUpdate,
|
||||
crate::types::api::payment_methods::CardDetailFromLocker,
|
||||
crate::types::api::payment_methods::CardDetail,
|
||||
api_models::customers::CustomerResponse,
|
||||
api_models::admin::AcceptedCountries,
|
||||
api_models::admin::AcceptedCurrencies,
|
||||
api_models::enums::RoutingAlgorithm,
|
||||
api_models::enums::PaymentType,
|
||||
api_models::enums::PaymentMethod,
|
||||
api_models::enums::PaymentMethodType,
|
||||
api_models::enums::ConnectorType,
|
||||
api_models::enums::PayoutConnectors,
|
||||
api_models::enums::Currency,
|
||||
api_models::enums::IntentStatus,
|
||||
api_models::enums::CaptureMethod,
|
||||
api_models::enums::FutureUsage,
|
||||
api_models::enums::AuthenticationType,
|
||||
api_models::enums::Connector,
|
||||
api_models::enums::PaymentMethod,
|
||||
api_models::enums::PaymentMethodIssuerCode,
|
||||
api_models::enums::MandateStatus,
|
||||
api_models::enums::PaymentExperience,
|
||||
api_models::enums::BankNames,
|
||||
api_models::enums::CardNetwork,
|
||||
api_models::enums::DisputeStage,
|
||||
api_models::enums::DisputeStatus,
|
||||
api_models::enums::CountryAlpha2,
|
||||
api_models::enums::FieldType,
|
||||
api_models::enums::FrmAction,
|
||||
api_models::enums::FrmPreferredFlowTypes,
|
||||
api_models::enums::RetryAction,
|
||||
api_models::enums::AttemptStatus,
|
||||
api_models::enums::CaptureStatus,
|
||||
api_models::enums::ReconStatus,
|
||||
api_models::enums::ConnectorStatus,
|
||||
api_models::enums::AuthorizationStatus,
|
||||
api_models::admin::MerchantConnectorCreate,
|
||||
api_models::admin::MerchantConnectorUpdate,
|
||||
api_models::admin::PrimaryBusinessDetails,
|
||||
api_models::admin::FrmConfigs,
|
||||
api_models::admin::FrmPaymentMethod,
|
||||
api_models::admin::FrmPaymentMethodType,
|
||||
api_models::admin::PaymentMethodsEnabled,
|
||||
api_models::admin::MerchantConnectorDetailsWrap,
|
||||
api_models::admin::MerchantConnectorDetails,
|
||||
api_models::admin::MerchantConnectorWebhookDetails,
|
||||
api_models::admin::BusinessPaymentLinkConfig,
|
||||
api_models::admin::PaymentLinkConfigRequest,
|
||||
api_models::admin::PaymentLinkConfig,
|
||||
api_models::disputes::DisputeResponse,
|
||||
api_models::disputes::DisputeResponsePaymentsRetrieve,
|
||||
api_models::gsm::GsmCreateRequest,
|
||||
api_models::gsm::GsmRetrieveRequest,
|
||||
api_models::gsm::GsmUpdateRequest,
|
||||
api_models::gsm::GsmDeleteRequest,
|
||||
api_models::gsm::GsmDeleteResponse,
|
||||
api_models::gsm::GsmResponse,
|
||||
api_models::gsm::GsmDecision,
|
||||
api_models::payments::AddressDetails,
|
||||
api_models::payments::BankDebitData,
|
||||
api_models::payments::AliPayQr,
|
||||
api_models::payments::AliPayRedirection,
|
||||
api_models::payments::MomoRedirection,
|
||||
api_models::payments::TouchNGoRedirection,
|
||||
api_models::payments::GcashRedirection,
|
||||
api_models::payments::KakaoPayRedirection,
|
||||
api_models::payments::AliPayHkRedirection,
|
||||
api_models::payments::GoPayRedirection,
|
||||
api_models::payments::MbWayRedirection,
|
||||
api_models::payments::MobilePayRedirection,
|
||||
api_models::payments::WeChatPayRedirection,
|
||||
api_models::payments::WeChatPayQr,
|
||||
api_models::payments::BankDebitBilling,
|
||||
api_models::payments::CryptoData,
|
||||
api_models::payments::RewardData,
|
||||
api_models::payments::UpiData,
|
||||
api_models::payments::VoucherData,
|
||||
api_models::payments::BoletoVoucherData,
|
||||
api_models::payments::AlfamartVoucherData,
|
||||
api_models::payments::IndomaretVoucherData,
|
||||
api_models::payments::Address,
|
||||
api_models::payments::VoucherData,
|
||||
api_models::payments::JCSVoucherData,
|
||||
api_models::payments::AlfamartVoucherData,
|
||||
api_models::payments::IndomaretVoucherData,
|
||||
api_models::payments::BankRedirectData,
|
||||
api_models::payments::BankRedirectBilling,
|
||||
api_models::payments::BankRedirectBilling,
|
||||
api_models::payments::ConnectorMetadata,
|
||||
api_models::payments::FeatureMetadata,
|
||||
api_models::payments::ApplepayConnectorMetadataRequest,
|
||||
api_models::payments::SessionTokenInfo,
|
||||
api_models::payments::SwishQrData,
|
||||
api_models::payments::AirwallexData,
|
||||
api_models::payments::NoonData,
|
||||
api_models::payments::OrderDetails,
|
||||
api_models::payments::OrderDetailsWithAmount,
|
||||
api_models::payments::NextActionType,
|
||||
api_models::payments::WalletData,
|
||||
api_models::payments::NextActionData,
|
||||
api_models::payments::PayLaterData,
|
||||
api_models::payments::MandateData,
|
||||
api_models::payments::PhoneDetails,
|
||||
api_models::payments::PaymentMethodData,
|
||||
api_models::payments::MandateType,
|
||||
api_models::payments::AcceptanceType,
|
||||
api_models::payments::MandateAmountData,
|
||||
api_models::payments::OnlineMandate,
|
||||
api_models::payments::Card,
|
||||
api_models::payments::CardRedirectData,
|
||||
api_models::payments::CardToken,
|
||||
api_models::payments::CustomerAcceptance,
|
||||
api_models::payments::PaymentsRequest,
|
||||
api_models::payments::PaymentsCreateRequest,
|
||||
api_models::payments::PaymentsResponse,
|
||||
api_models::payments::PaymentsStartRequest,
|
||||
api_models::payments::PaymentRetrieveBody,
|
||||
api_models::payments::PaymentsRetrieveRequest,
|
||||
api_models::payments::PaymentIdType,
|
||||
api_models::payments::PaymentsCaptureRequest,
|
||||
api_models::payments::PaymentsSessionRequest,
|
||||
api_models::payments::PaymentsSessionResponse,
|
||||
api_models::payments::SessionToken,
|
||||
api_models::payments::ApplePaySessionResponse,
|
||||
api_models::payments::ThirdPartySdkSessionResponse,
|
||||
api_models::payments::NoThirdPartySdkSessionResponse,
|
||||
api_models::payments::SecretInfoToInitiateSdk,
|
||||
api_models::payments::ApplePayPaymentRequest,
|
||||
api_models::payments::AmountInfo,
|
||||
api_models::payments::ProductType,
|
||||
api_models::payments::GooglePayWalletData,
|
||||
api_models::payments::PayPalWalletData,
|
||||
api_models::payments::PaypalRedirection,
|
||||
api_models::payments::GpayMerchantInfo,
|
||||
api_models::payments::GpayAllowedPaymentMethods,
|
||||
api_models::payments::GpayAllowedMethodsParameters,
|
||||
api_models::payments::GpayTokenizationSpecification,
|
||||
api_models::payments::GpayTokenParameters,
|
||||
api_models::payments::GpayTransactionInfo,
|
||||
api_models::payments::GpaySessionTokenResponse,
|
||||
api_models::payments::GooglePayThirdPartySdkData,
|
||||
api_models::payments::KlarnaSessionTokenResponse,
|
||||
api_models::payments::PaypalSessionTokenResponse,
|
||||
api_models::payments::ApplepaySessionTokenResponse,
|
||||
api_models::payments::SdkNextAction,
|
||||
api_models::payments::NextActionCall,
|
||||
api_models::payments::SamsungPayWalletData,
|
||||
api_models::payments::WeChatPay,
|
||||
api_models::payments::GpayTokenizationData,
|
||||
api_models::payments::GooglePayPaymentMethodInfo,
|
||||
api_models::payments::ApplePayWalletData,
|
||||
api_models::payments::ApplepayPaymentMethod,
|
||||
api_models::payments::PaymentsCancelRequest,
|
||||
api_models::payments::PaymentListConstraints,
|
||||
api_models::payments::PaymentListResponse,
|
||||
api_models::payments::CashappQr,
|
||||
api_models::payments::BankTransferData,
|
||||
api_models::payments::BankTransferNextStepsData,
|
||||
api_models::payments::SepaAndBacsBillingDetails,
|
||||
api_models::payments::AchBillingDetails,
|
||||
api_models::payments::MultibancoBillingDetails,
|
||||
api_models::payments::DokuBillingDetails,
|
||||
api_models::payments::BankTransferInstructions,
|
||||
api_models::payments::ReceiverDetails,
|
||||
api_models::payments::AchTransfer,
|
||||
api_models::payments::MultibancoTransferInstructions,
|
||||
api_models::payments::DokuBankTransferInstructions,
|
||||
api_models::payments::ApplePayRedirectData,
|
||||
api_models::payments::ApplePayThirdPartySdkData,
|
||||
api_models::payments::GooglePayRedirectData,
|
||||
api_models::payments::GooglePayThirdPartySdk,
|
||||
api_models::payments::GooglePaySessionResponse,
|
||||
api_models::payments::SepaBankTransferInstructions,
|
||||
api_models::payments::BacsBankTransferInstructions,
|
||||
api_models::payments::RedirectResponse,
|
||||
api_models::payments::RequestSurchargeDetails,
|
||||
api_models::payments::PaymentAttemptResponse,
|
||||
api_models::payments::CaptureResponse,
|
||||
api_models::payments::IncrementalAuthorizationResponse,
|
||||
api_models::payments::PaymentCreatePaymentLinkConfig,
|
||||
api_models::payment_methods::RequiredFieldInfo,
|
||||
api_models::payment_methods::MaskedBankDetails,
|
||||
api_models::payment_methods::SurchargeDetailsResponse,
|
||||
api_models::payment_methods::SurchargeResponse,
|
||||
api_models::payment_methods::SurchargePercentage,
|
||||
api_models::payment_methods::RequestPaymentMethodTypes,
|
||||
api_models::refunds::RefundListRequest,
|
||||
api_models::refunds::RefundListResponse,
|
||||
api_models::payments::TimeRange,
|
||||
api_models::mandates::MandateRevokedResponse,
|
||||
api_models::mandates::MandateResponse,
|
||||
api_models::mandates::MandateCardDetails,
|
||||
api_models::ephemeral_key::EphemeralKeyCreateResponse,
|
||||
api_models::payments::CustomerDetails,
|
||||
api_models::payments::GiftCardData,
|
||||
api_models::payments::GiftCardDetails,
|
||||
api_models::payouts::PayoutCreateRequest,
|
||||
api_models::payments::Address,
|
||||
api_models::payouts::Card,
|
||||
api_models::payouts::AchBankTransfer,
|
||||
api_models::payouts::BacsBankTransfer,
|
||||
api_models::payouts::SepaBankTransfer,
|
||||
api_models::payouts::PayoutCreateResponse,
|
||||
api_models::payouts::PayoutRetrieveBody,
|
||||
api_models::payouts::PayoutRetrieveRequest,
|
||||
api_models::payouts::PayoutActionRequest,
|
||||
api_models::payouts::PayoutRequest,
|
||||
api_models::payouts::PayoutMethodData,
|
||||
api_models::payouts::Bank,
|
||||
api_models::enums::PayoutEntityType,
|
||||
api_models::enums::PayoutStatus,
|
||||
api_models::enums::PayoutType,
|
||||
api_models::payments::FrmMessage,
|
||||
api_models::webhooks::OutgoingWebhook,
|
||||
api_models::webhooks::OutgoingWebhookContent,
|
||||
api_models::enums::EventType,
|
||||
crate::types::api::admin::MerchantAccountResponse,
|
||||
crate::types::api::admin::MerchantConnectorId,
|
||||
crate::types::api::admin::MerchantDetails,
|
||||
crate::types::api::admin::WebhookDetails,
|
||||
crate::types::api::api_keys::ApiKeyExpiration,
|
||||
crate::types::api::api_keys::CreateApiKeyRequest,
|
||||
crate::types::api::api_keys::CreateApiKeyResponse,
|
||||
crate::types::api::api_keys::RetrieveApiKeyResponse,
|
||||
crate::types::api::api_keys::RevokeApiKeyResponse,
|
||||
crate::types::api::api_keys::UpdateApiKeyRequest,
|
||||
api_models::payments::RetrievePaymentLinkRequest,
|
||||
api_models::payments::PaymentLinkResponse,
|
||||
api_models::payments::RetrievePaymentLinkResponse,
|
||||
api_models::payments::PaymentLinkInitiateRequest,
|
||||
api_models::payments::PaymentLinkStatus,
|
||||
api_models::blocklist::BlocklistRequest,
|
||||
api_models::blocklist::BlocklistResponse,
|
||||
api_models::blocklist::ListBlocklistQuery,
|
||||
common_enums::enums::BlocklistDataKind
|
||||
)),
|
||||
modifiers(&SecurityAddon)
|
||||
)]
|
||||
pub struct ApiDoc;
|
||||
|
||||
struct SecurityAddon;
|
||||
|
||||
impl utoipa::Modify for SecurityAddon {
|
||||
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
|
||||
use utoipa::openapi::security::{ApiKey, ApiKeyValue, SecurityScheme};
|
||||
|
||||
if let Some(components) = openapi.components.as_mut() {
|
||||
components.add_security_schemes_from_iter([
|
||||
(
|
||||
"api_key",
|
||||
SecurityScheme::ApiKey(ApiKey::Header(ApiKeyValue::with_description(
|
||||
"api-key",
|
||||
"API keys are the most common method of authentication and can be obtained \
|
||||
from the HyperSwitch dashboard."
|
||||
))),
|
||||
),
|
||||
(
|
||||
"admin_api_key",
|
||||
SecurityScheme::ApiKey(ApiKey::Header(ApiKeyValue::with_description(
|
||||
"api-key",
|
||||
"Admin API keys allow you to perform some privileged actions such as \
|
||||
creating a merchant account and Merchant Connector account."
|
||||
))),
|
||||
),
|
||||
(
|
||||
"publishable_key",
|
||||
SecurityScheme::ApiKey(ApiKey::Header(ApiKeyValue::with_description(
|
||||
"api-key",
|
||||
"Publishable keys are a type of keys that can be public and have limited \
|
||||
scope of usage."
|
||||
))),
|
||||
),
|
||||
(
|
||||
"ephemeral_key",
|
||||
SecurityScheme::ApiKey(ApiKey::Header(ApiKeyValue::with_description(
|
||||
"api-key",
|
||||
"Ephemeral keys provide temporary access to singular data, such as access \
|
||||
to a single customer object for a short period of time."
|
||||
))),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod examples {
|
||||
/// Creating the payment with minimal fields
|
||||
pub const PAYMENTS_CREATE_MINIMUM_FIELDS: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
}"#;
|
||||
|
||||
/// Creating a manual capture payment
|
||||
pub const PAYMENTS_CREATE_WITH_MANUAL_CAPTURE: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"capture_method":"manual"
|
||||
}"#;
|
||||
|
||||
/// Creating a payment with billing and shipping address
|
||||
pub const PAYMENTS_CREATE_WITH_ADDRESS: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"customer": {
|
||||
"id" : "cus_abcdefgh"
|
||||
},
|
||||
"billing": {
|
||||
"address": {
|
||||
"line1": "1467",
|
||||
"line2": "Harrison Street",
|
||||
"line3": "Harrison Street",
|
||||
"city": "San Fransico",
|
||||
"state": "California",
|
||||
"zip": "94122",
|
||||
"country": "US",
|
||||
"first_name": "joseph",
|
||||
"last_name": "Doe"
|
||||
},
|
||||
"phone": {
|
||||
"number": "8056594427",
|
||||
"country_code": "+91"
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
|
||||
/// Creating a payment with customer details
|
||||
pub const PAYMENTS_CREATE_WITH_CUSTOMER_DATA: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"customer": {
|
||||
"id":"cus_abcdefgh",
|
||||
"name":"John Dough",
|
||||
"phone":"9999999999",
|
||||
"email":"john@example.com"
|
||||
}
|
||||
}"#;
|
||||
|
||||
/// 3DS force payment
|
||||
pub const PAYMENTS_CREATE_WITH_FORCED_3DS: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"authentication_type" : "three_ds"
|
||||
}"#;
|
||||
|
||||
/// A payment with other fields
|
||||
pub const PAYMENTS_CREATE: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"payment_id": "abcdefghijklmnopqrstuvwxyz",
|
||||
"customer": {
|
||||
"id":"cus_abcdefgh",
|
||||
"name":"John Dough",
|
||||
"phone":"9999999999",
|
||||
"email":"john@example.com"
|
||||
},
|
||||
"description": "Its my first payment request",
|
||||
"statement_descriptor_name": "joseph",
|
||||
"statement_descriptor_suffix": "JS",
|
||||
"metadata": {
|
||||
"udf1": "some-value",
|
||||
"udf2": "some-value"
|
||||
}
|
||||
}"#;
|
||||
|
||||
/// Creating the payment with order details
|
||||
pub const PAYMENTS_CREATE_WITH_ORDER_DETAILS: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"order_details": [
|
||||
{
|
||||
"product_name": "Apple iPhone 15",
|
||||
"quantity": 1,
|
||||
"amount" : 6540
|
||||
}
|
||||
]
|
||||
}"#;
|
||||
|
||||
/// Creating the payment with connector metadata for noon
|
||||
pub const PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY: &str = r#"{
|
||||
"amount": 6540,
|
||||
"currency": "USD",
|
||||
"connector_metadata": {
|
||||
"noon": {
|
||||
"order_category":"shoes"
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
}
|
||||
@ -458,7 +458,7 @@ impl Routing {
|
||||
)
|
||||
.service(
|
||||
web::resource("")
|
||||
.route(web::get().to(cloud_routing::routing_retrieve_dictionary))
|
||||
.route(web::get().to(cloud_routing::list_routing_configs))
|
||||
.route(web::post().to(cloud_routing::routing_create_config)),
|
||||
)
|
||||
.service(
|
||||
|
||||
@ -8,21 +8,6 @@ use crate::{
|
||||
types::api::customers,
|
||||
};
|
||||
|
||||
/// Create Customer
|
||||
///
|
||||
/// Create a customer object and store the customer details to be reused for future payments. Incase the customer already exists in the system, this API will respond with the customer details.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/customers",
|
||||
request_body = CustomerRequest,
|
||||
responses(
|
||||
(status = 200, description = "Customer Created", body = CustomerResponse),
|
||||
(status = 400, description = "Invalid data")
|
||||
),
|
||||
tag = "Customers",
|
||||
operation_id = "Create a Customer",
|
||||
security(("api_key" = []))
|
||||
)]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomersCreate))]
|
||||
pub async fn customers_create(
|
||||
state: web::Data<AppState>,
|
||||
@ -45,21 +30,7 @@ pub async fn customers_create(
|
||||
))
|
||||
.await
|
||||
}
|
||||
/// Retrieve Customer
|
||||
///
|
||||
/// Retrieve a customer's details.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/customers/{customer_id}",
|
||||
params (("customer_id" = String, Path, description = "The unique identifier for the Customer")),
|
||||
responses(
|
||||
(status = 200, description = "Customer Retrieved", body = CustomerResponse),
|
||||
(status = 404, description = "Customer was not found")
|
||||
),
|
||||
tag = "Customers",
|
||||
operation_id = "Retrieve a Customer",
|
||||
security(("api_key" = []), ("ephemeral_key" = []))
|
||||
)]
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomersRetrieve))]
|
||||
pub async fn customers_retrieve(
|
||||
state: web::Data<AppState>,
|
||||
@ -93,20 +64,6 @@ pub async fn customers_retrieve(
|
||||
.await
|
||||
}
|
||||
|
||||
/// List customers for a merchant
|
||||
///
|
||||
/// To filter and list the customers for a particular merchant id
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/customers/list",
|
||||
responses(
|
||||
(status = 200, description = "Customers retrieved", body = Vec<CustomerResponse>),
|
||||
(status = 400, description = "Invalid Data"),
|
||||
),
|
||||
tag = "Customers List",
|
||||
operation_id = "List all Customers for a Merchant",
|
||||
security(("api_key" = []))
|
||||
)]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomersList))]
|
||||
pub async fn customers_list(state: web::Data<AppState>, req: HttpRequest) -> HttpResponse {
|
||||
let flow = Flow::CustomersList;
|
||||
@ -127,22 +84,6 @@ pub async fn customers_list(state: web::Data<AppState>, req: HttpRequest) -> Htt
|
||||
.await
|
||||
}
|
||||
|
||||
/// Update Customer
|
||||
///
|
||||
/// Updates the customer's details in a customer object.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/customers/{customer_id}",
|
||||
request_body = CustomerRequest,
|
||||
params (("customer_id" = String, Path, description = "The unique identifier for the Customer")),
|
||||
responses(
|
||||
(status = 200, description = "Customer was Updated", body = CustomerResponse),
|
||||
(status = 404, description = "Customer was not found")
|
||||
),
|
||||
tag = "Customers",
|
||||
operation_id = "Update a Customer",
|
||||
security(("api_key" = []))
|
||||
)]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomersUpdate))]
|
||||
pub async fn customers_update(
|
||||
state: web::Data<AppState>,
|
||||
@ -168,21 +109,7 @@ pub async fn customers_update(
|
||||
))
|
||||
.await
|
||||
}
|
||||
/// Delete Customer
|
||||
///
|
||||
/// Delete a customer record.
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/customers/{customer_id}",
|
||||
params (("customer_id" = String, Path, description = "The unique identifier for the Customer")),
|
||||
responses(
|
||||
(status = 200, description = "Customer was Deleted", body = CustomerDeleteResponse),
|
||||
(status = 404, description = "Customer was not found")
|
||||
),
|
||||
tag = "Customers",
|
||||
operation_id = "Delete a Customer",
|
||||
security(("api_key" = []))
|
||||
)]
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::CustomersDelete))]
|
||||
pub async fn customers_delete(
|
||||
state: web::Data<AppState>,
|
||||
|
||||
@ -10,7 +10,7 @@ use crate::{
|
||||
|
||||
/// Mandates - Retrieve Mandate
|
||||
///
|
||||
/// Retrieve a mandate
|
||||
/// Retrieves a mandate created using the Payments/Create API
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/mandates/{mandate_id}",
|
||||
@ -49,12 +49,12 @@ pub async fn get_mandate(
|
||||
}
|
||||
/// Mandates - Revoke Mandate
|
||||
///
|
||||
/// Revoke a mandate
|
||||
/// Revokes a mandate created using the Payments/Create API
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/mandates/revoke/{mandate_id}",
|
||||
params(
|
||||
("mandate_id" = String, Path, description = "The identifier for mandate")
|
||||
("mandate_id" = String, Path, description = "The identifier for a mandate")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "The mandate was revoked successfully", body = MandateRevokedResponse),
|
||||
|
||||
@ -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>,
|
||||
|
||||
@ -17,12 +17,6 @@ use crate::{
|
||||
payments::{self, PaymentRedirectFlow},
|
||||
utils as core_utils,
|
||||
},
|
||||
// openapi::examples::{
|
||||
// PAYMENTS_CREATE, PAYMENTS_CREATE_MINIMUM_FIELDS, PAYMENTS_CREATE_WITH_ADDRESS,
|
||||
// PAYMENTS_CREATE_WITH_CUSTOMER_DATA, PAYMENTS_CREATE_WITH_FORCED_3DS,
|
||||
// PAYMENTS_CREATE_WITH_MANUAL_CAPTURE, PAYMENTS_CREATE_WITH_NOON_ORDER_CATETORY,
|
||||
// PAYMENTS_CREATE_WITH_ORDER_DETAILS,
|
||||
// },
|
||||
routes::lock_utils,
|
||||
services::{api, authentication as auth},
|
||||
types::{
|
||||
@ -1153,7 +1147,7 @@ where
|
||||
("payment_id" = String, Path, description = "The identifier for payment")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Payment authorized amount incremented"),
|
||||
(status = 200, description = "Payment authorized amount incremented", body = PaymentsResponse),
|
||||
(status = 400, description = "Missing mandatory fields")
|
||||
),
|
||||
tag = "Payments",
|
||||
|
||||
@ -113,7 +113,7 @@ pub async fn routing_retrieve_config(
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn routing_retrieve_dictionary(
|
||||
pub async fn list_routing_configs(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
#[cfg(feature = "business_profile_routing")] query: web::Query<RoutingRetrieveQuery>,
|
||||
|
||||
Reference in New Issue
Block a user