refactor(openapi): add openapi support for generating v2 api-reference (#5580)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2024-08-09 20:30:59 +05:30
committed by GitHub
parent 942e63d9cd
commit 92d76a361a
14 changed files with 17853 additions and 15 deletions

View File

@ -153,11 +153,11 @@ jobs:
files_changed="$(gh api --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --paginate https://api.github.com/repos/juspay/hyperswitch/pulls/${{ github.event.pull_request.number }}/files --jq '.[] | .filename')" files_changed="$(gh api --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --paginate https://api.github.com/repos/juspay/hyperswitch/pulls/${{ github.event.pull_request.number }}/files --jq '.[] | .filename')"
if echo "${files_changed}" | grep --quiet --extended-regexp '(^migrations/.*/(up|down)\.sql$|^crates/diesel_models/src/schema.rs$)' ; then if echo "${files_changed}" | grep --quiet --extended-regexp '(^(migrations|v2_migrations)/.*/(up|down)\.sql$|^crates/diesel_models/src/(schema|schema_v2).rs$)' ; then
migration_and_schema_changes='true' migration_and_schema_changes='true'
fi fi
if echo "${files_changed}" | grep --quiet --extended-regexp '^(api-reference/openapi_spec.json)$'; then if echo "${files_changed}" | grep --quiet --extended-regexp '^api-reference/(openapi_spec.json|openapi_spec_v2.json)$'; then
openapi_changes='true' openapi_changes='true'
fi fi

View File

@ -54,6 +54,10 @@ jobs:
shell: bash shell: bash
run: cargo run -p openapi run: cargo run -p openapi
- name: Generate the OpenAPI spec file for V2
shell: bash
run: cargo r -p openapi --no-default-features --features v2
- name: Install `swagger-cli` - name: Install `swagger-cli`
shell: bash shell: bash
run: npm install -g @apidevtools/swagger-cli run: npm install -g @apidevtools/swagger-cli
@ -62,15 +66,19 @@ jobs:
shell: bash shell: bash
run: swagger-cli validate ./api-reference/openapi_spec.json run: swagger-cli validate ./api-reference/openapi_spec.json
- name: Validate the JSON file for V2
shell: bash
run: swagger-cli validate ./api-reference/openapi_spec_v2.json
- name: Commit the JSON file if it is not up-to-date - name: Commit the JSON file if it is not up-to-date
# PR originated from same repository # PR originated from same repository
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }} if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
shell: bash shell: bash
run: | run: |
if ! git diff --quiet --exit-code -- api-reference/openapi_spec.json ; then if ! git diff --quiet --exit-code -- api-reference/openapi_spec.json api-reference/openapi_spec_v2.json ; then
git config --local user.name 'hyperswitch-bot[bot]' git config --local user.name 'hyperswitch-bot[bot]'
git config --local user.email '148525504+hyperswitch-bot[bot]@users.noreply.github.com' git config --local user.email '148525504+hyperswitch-bot[bot]@users.noreply.github.com'
git add api-reference/openapi_spec.json git add api-reference/openapi_spec.json api-reference/openapi_spec_v2.json
git commit --message 'docs(openapi): re-generate OpenAPI specification' git commit --message 'docs(openapi): re-generate OpenAPI specification'
git push git push
fi fi

View File

@ -0,0 +1,3 @@
---
openapi: post /connector_accounts
---

View File

@ -0,0 +1,3 @@
---
openapi: delete /connector_accounts/{id}
---

View File

@ -0,0 +1,3 @@
---
openapi: get /connector_accounts/{id}
---

View File

@ -0,0 +1,3 @@
---
openapi: post /connector_accounts/{id}
---

View File

@ -0,0 +1,59 @@
{
"$schema": "https://mintlify.com/schema.json",
"name": "Hyperswitch",
"logo": {
"dark": "/logo/dark.svg",
"light": "/logo/light.svg"
},
"favicon": "/favicon.png",
"colors": {
"primary": "#006DF9",
"light": "#006DF9",
"dark": "#006DF9",
"background": {
"dark": "#242F48"
}
},
"tabs": [
{
"name": "API Reference",
"url": "api-reference"
},
{
"name": "Locker API Reference",
"url": "locker-api-reference"
}
],
"navigation": [
{
"group": "Get Started",
"pages": ["introduction"]
},
{
"group": "Essentials",
"pages": [
"essentials/webhooks",
"essentials/error_codes",
"essentials/rate_limit",
"essentials/go-live"
]
},
{
"group": "Merchant Connector Account",
"pages": [
"api-reference-v2/merchant-connector-account/merchant-connector--create",
"api-reference-v2/merchant-connector-account/merchant-connector--retrieve",
"api-reference-v2/merchant-connector-account/merchant-connector--update",
"api-reference-v2/merchant-connector-account/merchant-connector--delete"
]
}
],
"footerSocials": {
"github": "https://github.com/juspay/hyperswitch",
"linkedin": "https://www.linkedin.com/company/hyperswitch"
},
"openapi": ["openapi_spec_v2.json", "rust_locker_open_api_spec.yml"],
"api": {
"maintainOrder": true
}
}

View File

@ -1516,7 +1516,7 @@
}, },
"connector_label": "EU_adyen", "connector_label": "EU_adyen",
"connector_name": "adyen", "connector_name": "adyen",
"connector_type": "fiz_operations" "connector_type": "payment_processor"
} }
}, },
"Create a merchant connector account under a specific business profile": { "Create a merchant connector account under a specific business profile": {
@ -1527,7 +1527,7 @@
"key1": "{{adyen_merchant_account}}" "key1": "{{adyen_merchant_account}}"
}, },
"connector_name": "adyen", "connector_name": "adyen",
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"profile_id": "{{profile_id}}" "profile_id": "{{profile_id}}"
} }
}, },
@ -1539,7 +1539,7 @@
"key1": "{{adyen_merchant_account}}" "key1": "{{adyen_merchant_account}}"
}, },
"connector_name": "adyen", "connector_name": "adyen",
"connector_type": "fiz_operations" "connector_type": "payment_processor"
} }
} }
} }
@ -1704,7 +1704,7 @@
"examples": { "examples": {
"Enable card payment method": { "Enable card payment method": {
"value": { "value": {
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"payment_methods_enabled": [ "payment_methods_enabled": [
{ {
"payment_method": "card" "payment_method": "card"

File diff suppressed because it is too large Load Diff

View File

@ -539,7 +539,7 @@ pub struct MerchantAccountResponse {
#[derive(Clone, Debug, ToSchema, Serialize)] #[derive(Clone, Debug, ToSchema, Serialize)]
pub struct MerchantAccountResponse { pub struct MerchantAccountResponse {
/// The identifier for the Merchant Account /// The identifier for the Merchant Account
#[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44")] #[schema(max_length = 64, example = "y3oqhf46pyzuxjbcn2giaqnb44", value_type = String)]
pub id: id_type::MerchantId, pub id: id_type::MerchantId,
/// Name of the Merchant Account /// Name of the Merchant Account

View File

@ -17,5 +17,5 @@ router_env = { version = "0.1.0", path = "../router_env" }
[features] [features]
default = ["v1"] default = ["v1"]
v2 = ["api_models/v2"] v2 = ["api_models/v2", "api_models/customer_v2", "api_models/merchant_account_v2", "api_models/routing_v2", "api_models/merchant_connector_account_v2"]
v1 = ["api_models/v1"] v1 = ["api_models/v1"]

View File

@ -1,13 +1,23 @@
#[cfg(feature = "v1")]
mod openapi; mod openapi;
#[cfg(feature = "v2")]
mod openapi_v2;
mod routes; mod routes;
fn main() { fn main() {
#[cfg(feature = "v1")]
let relative_file_path = "api-reference/openapi_spec.json"; let relative_file_path = "api-reference/openapi_spec.json";
#[cfg(feature = "v2")]
let relative_file_path = "api-reference/openapi_spec_v2.json";
let mut file_path = router_env::workspace_path(); let mut file_path = router_env::workspace_path();
file_path.push(relative_file_path); file_path.push(relative_file_path);
#[cfg(feature = "v1")]
let openapi = <openapi::ApiDoc as utoipa::OpenApi>::openapi(); let openapi = <openapi::ApiDoc as utoipa::OpenApi>::openapi();
#[cfg(feature = "v2")]
let openapi = <openapi_v2::ApiDoc as utoipa::OpenApi>::openapi();
#[allow(clippy::expect_used)] #[allow(clippy::expect_used)]
std::fs::write( std::fs::write(

View File

@ -0,0 +1,506 @@
use crate::routes;
#[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 = "Business Profile", description = "Create and manage business profiles"),
(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"),
(name = "Routing", description = "Create and manage routing configurations"),
(name = "Event", description = "Manage events"),
),
// The paths will be displayed in the same order as they are registered here
paths(
// Routes for merchant connector account
routes::merchant_connector_account::connector_create,
routes::merchant_connector_account::connector_retrieve,
routes::merchant_connector_account::connector_update,
routes::merchant_connector_account::connector_delete,
),
components(schemas(
common_utils::types::MinorUnit,
common_utils::link_utils::GenericLinkUiConfig,
common_utils::link_utils::EnabledPaymentMethod,
api_models::refunds::RefundRequest,
api_models::refunds::RefundType,
api_models::refunds::RefundResponse,
api_models::refunds::RefundStatus,
api_models::refunds::RefundUpdateRequest,
api_models::organization::OrganizationRequest,
api_models::organization::OrganizationResponse,
api_models::admin::MerchantAccountCreate,
api_models::admin::MerchantAccountUpdate,
api_models::admin::MerchantAccountDeleteResponse,
api_models::admin::MerchantConnectorDeleteResponse,
api_models::admin::MerchantConnectorResponse,
api_models::admin::MerchantConnectorListResponse,
api_models::admin::AuthenticationConnectorDetails,
api_models::admin::ExtendedCardInfoConfig,
api_models::admin::BusinessGenericLinkConfig,
api_models::admin::BusinessCollectLinkConfig,
api_models::admin::BusinessPayoutLinkConfig,
api_models::customers::CustomerRequest,
api_models::customers::CustomerDeleteResponse,
api_models::payment_methods::PaymentMethodCreate,
api_models::payment_methods::PaymentMethodResponse,
api_models::payment_methods::PaymentMethodList,
api_models::payment_methods::CustomerPaymentMethod,
api_models::payment_methods::PaymentMethodListResponse,
api_models::payment_methods::CustomerPaymentMethodsListResponse,
api_models::payment_methods::PaymentMethodDeleteResponse,
api_models::payment_methods::PaymentMethodUpdate,
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::RequestPaymentMethodTypes,
api_models::poll::PollResponse,
api_models::poll::PollStatus,
api_models::customers::CustomerResponse,
api_models::admin::AcceptedCountries,
api_models::admin::AcceptedCurrencies,
api_models::enums::PaymentType,
api_models::enums::PaymentMethod,
api_models::enums::PaymentMethodType,
api_models::enums::ConnectorType,
api_models::enums::PayoutConnectors,
api_models::enums::AuthenticationConnectors,
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::enums::PaymentMethodStatus,
api_models::admin::MerchantConnectorCreate,
api_models::admin::AdditionalMerchantData,
api_models::admin::MerchantRecipientData,
api_models::admin::MerchantAccountData,
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::BusinessProfileCreate,
api_models::admin::BusinessProfileResponse,
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::UpiCollectData,
api_models::payments::UpiIntentData,
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::RealTimePaymentData,
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::PaymentProcessingDetailsAt,
api_models::payments::ApplepayInitiative,
api_models::payments::PaymentProcessingDetails,
api_models::payments::PaymentMethodDataResponseWithBilling,
api_models::payments::PaymentMethodDataResponse,
api_models::payments::CardResponse,
api_models::payments::PaylaterResponse,
api_models::payments::KlarnaSdkPaymentMethodResponse,
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::PaymentMethodDataRequest,
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::PaymentsUpdateRequest,
api_models::payments::PaymentsConfirmRequest,
api_models::payments::PaymentsResponse,
api_models::payments::PaymentsCreateResponseOpenApi,
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::ApplePayBillingContactFields,
api_models::payments::ApplePayShippingContactFields,
api_models::payments::ApplePayAddressParameters,
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::SdkNextActionData,
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::GpayShippingAddressParameters,
api_models::payments::GpayBillingAddressParameters,
api_models::payments::GpayBillingAddressFormat,
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::PaymentsIncrementalAuthorizationRequest,
api_models::payments::IncrementalAuthorizationResponse,
api_models::payments::PaymentsCompleteAuthorizeRequest,
api_models::payments::PaymentsExternalAuthenticationRequest,
api_models::payments::PaymentsExternalAuthenticationResponse,
api_models::payments::SdkInformation,
api_models::payments::DeviceChannel,
api_models::payments::ThreeDsCompletionIndicator,
api_models::payments::MifinityData,
api_models::enums::TransactionStatus,
api_models::payments::BrowserInformation,
api_models::payments::PaymentCreatePaymentLinkConfig,
api_models::payments::ThreeDsData,
api_models::payments::ThreeDsMethodData,
api_models::payments::PollConfigResponse,
api_models::payments::ExternalAuthenticationDetailsResponse,
api_models::payments::ExtendedCardInfo,
api_models::payment_methods::RequiredFieldInfo,
api_models::payment_methods::DefaultPaymentMethod,
api_models::payment_methods::MaskedBankDetails,
api_models::payment_methods::SurchargeDetailsResponse,
api_models::payment_methods::SurchargeResponse,
api_models::payment_methods::SurchargePercentage,
api_models::payment_methods::PaymentMethodCollectLinkRequest,
api_models::payment_methods::PaymentMethodCollectLinkResponse,
api_models::refunds::RefundListRequest,
api_models::refunds::RefundListResponse,
api_models::payments::TimeRange,
api_models::payments::AmountFilter,
api_models::mandates::MandateRevokedResponse,
api_models::mandates::MandateResponse,
api_models::mandates::MandateCardDetails,
api_models::mandates::RecurringDetails,
api_models::mandates::ProcessorPaymentToken,
api_models::ephemeral_key::EphemeralKeyCreateResponse,
api_models::payments::CustomerDetails,
api_models::payments::GiftCardData,
api_models::payments::GiftCardDetails,
api_models::payments::Address,
api_models::payouts::CardPayout,
api_models::payouts::Wallet,
api_models::payouts::Paypal,
api_models::payouts::Venmo,
api_models::payouts::AchBankTransfer,
api_models::payouts::BacsBankTransfer,
api_models::payouts::SepaBankTransfer,
api_models::payouts::PixBankTransfer,
api_models::payouts::PayoutRequest,
api_models::payouts::PayoutAttemptResponse,
api_models::payouts::PayoutActionRequest,
api_models::payouts::PayoutCreateRequest,
api_models::payouts::PayoutCreateResponse,
api_models::payouts::PayoutListConstraints,
api_models::payouts::PayoutListFilterConstraints,
api_models::payouts::PayoutListResponse,
api_models::payouts::PayoutRetrieveBody,
api_models::payouts::PayoutRetrieveRequest,
api_models::payouts::PayoutMethodData,
api_models::payouts::PayoutLinkResponse,
api_models::payouts::Bank,
api_models::payouts::PayoutCreatePayoutLinkConfig,
api_models::enums::PayoutEntityType,
api_models::enums::PayoutSendPriority,
api_models::enums::PayoutStatus,
api_models::enums::PayoutType,
api_models::enums::TransactionType,
api_models::payments::FrmMessage,
api_models::webhooks::OutgoingWebhook,
api_models::webhooks::OutgoingWebhookContent,
api_models::enums::EventClass,
api_models::enums::EventType,
api_models::enums::DecoupledAuthenticationType,
api_models::enums::AuthenticationStatus,
api_models::admin::MerchantAccountResponse,
api_models::admin::MerchantConnectorId,
api_models::admin::MerchantDetails,
api_models::admin::ToggleKVRequest,
api_models::admin::ToggleKVResponse,
api_models::admin::WebhookDetails,
api_models::api_keys::ApiKeyExpiration,
api_models::api_keys::CreateApiKeyRequest,
api_models::api_keys::CreateApiKeyResponse,
api_models::api_keys::RetrieveApiKeyResponse,
api_models::api_keys::RevokeApiKeyResponse,
api_models::api_keys::UpdateApiKeyRequest,
api_models::payments::RetrievePaymentLinkRequest,
api_models::payments::PaymentLinkResponse,
api_models::payments::RetrievePaymentLinkResponse,
api_models::payments::PaymentLinkInitiateRequest,
api_models::payouts::PayoutLinkInitiateRequest,
api_models::payments::ExtendedCardInfoResponse,
api_models::payments::GooglePayAssuranceDetails,
api_models::routing::RoutingConfigRequest,
api_models::routing::RoutingDictionaryRecord,
api_models::routing::RoutingKind,
api_models::routing::RoutableConnectorChoice,
api_models::routing::LinkedRoutingConfigRetrieveResponse,
api_models::routing::RoutingRetrieveResponse,
api_models::routing::ProfileDefaultRoutingConfig,
api_models::routing::MerchantRoutingAlgorithm,
api_models::routing::RoutingAlgorithmKind,
api_models::routing::RoutingDictionary,
api_models::routing::RoutingAlgorithm,
api_models::routing::StraightThroughAlgorithm,
api_models::routing::ConnectorVolumeSplit,
api_models::routing::ConnectorSelection,
api_models::routing::ast::RoutableChoiceKind,
api_models::enums::RoutableConnectors,
api_models::routing::ast::ProgramConnectorSelection,
api_models::routing::ast::RuleConnectorSelection,
api_models::routing::ast::IfStatement,
api_models::routing::ast::Comparison,
api_models::routing::ast::ComparisonType,
api_models::routing::ast::ValueType,
api_models::routing::ast::MetadataValue,
api_models::routing::ast::NumberComparison,
api_models::payment_methods::RequestPaymentMethodTypes,
api_models::payments::PaymentLinkStatus,
api_models::blocklist::BlocklistRequest,
api_models::blocklist::BlocklistResponse,
api_models::blocklist::ToggleBlocklistResponse,
api_models::blocklist::ListBlocklistQuery,
api_models::enums::BlocklistDataKind,
api_models::webhook_events::EventListItemResponse,
api_models::webhook_events::EventRetrieveResponse,
api_models::webhook_events::OutgoingWebhookRequestContent,
api_models::webhook_events::OutgoingWebhookResponseContent,
api_models::enums::WebhookDeliveryAttempt,
api_models::enums::PaymentChargeType,
api_models::enums::StripeChargeType,
api_models::payments::PaymentChargeRequest,
api_models::payments::PaymentChargeResponse,
api_models::refunds::ChargeRefunds,
api_models::payments::CustomerDetailsResponse,
api_models::payments::OpenBankingData,
api_models::payments::OpenBankingSessionToken,
)),
modifiers(&SecurityAddon)
)]
// Bypass clippy lint for not being constructed
#[allow(dead_code)]
pub(crate) 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",
"Use the API key created under your merchant account from the HyperSwitch dashboard. API key is used to authenticate API requests from your merchant server only. Don't expose this key on a website or embed it in a mobile application."
))),
),
(
"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."
))),
),
]);
}
}
}

View File

@ -1,6 +1,7 @@
/// Merchant Connector - Create /// Merchant Connector - Create
/// ///
/// Creates a new Merchant Connector for the merchant account. The connector could be a payment processor/facilitator/acquirer or a provider of specialized services like Fraud/Accounting etc. /// Creates a new Merchant Connector for the merchant account. The connector could be a payment processor/facilitator/acquirer or a provider of specialized services like Fraud/Accounting etc.
#[cfg(feature = "v1")]
#[utoipa::path( #[utoipa::path(
post, post,
path = "/accounts/{account_id}/connectors", path = "/accounts/{account_id}/connectors",
@ -10,7 +11,7 @@
( (
"Create a merchant connector account with minimal fields" = ( "Create a merchant connector account with minimal fields" = (
value = json!({ value = json!({
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"connector_name": "adyen", "connector_name": "adyen",
"connector_account_details": { "connector_account_details": {
"auth_type": "BodyKey", "auth_type": "BodyKey",
@ -23,7 +24,7 @@
( (
"Create a merchant connector account under a specific business profile" = ( "Create a merchant connector account under a specific business profile" = (
value = json!({ value = json!({
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"connector_name": "adyen", "connector_name": "adyen",
"connector_account_details": { "connector_account_details": {
"auth_type": "BodyKey", "auth_type": "BodyKey",
@ -37,7 +38,67 @@
( (
"Create a merchant account with custom connector label" = ( "Create a merchant account with custom connector label" = (
value = json!({ value = json!({
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"connector_name": "adyen",
"connector_label": "EU_adyen",
"connector_account_details": {
"auth_type": "BodyKey",
"api_key": "{{adyen-api-key}}",
"key1": "{{adyen_merchant_account}}"
}
})
)
),
)
),
responses(
(status = 200, description = "Merchant Connector Created", body = MerchantConnectorResponse),
(status = 400, description = "Missing Mandatory fields"),
),
tag = "Merchant Connector Account",
operation_id = "Create a Merchant Connector",
security(("admin_api_key" = []))
)]
pub async fn connector_create() {}
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/connector_accounts",
request_body(
content = MerchantConnectorCreate,
examples(
(
"Create a merchant connector account with minimal fields" = (
value = json!({
"connector_type": "payment_processor",
"connector_name": "adyen",
"connector_account_details": {
"auth_type": "BodyKey",
"api_key": "{{adyen-api-key}}",
"key1": "{{adyen_merchant_account}}"
}
})
)
),
(
"Create a merchant connector account under a specific business profile" = (
value = json!({
"connector_type": "payment_processor",
"connector_name": "adyen",
"connector_account_details": {
"auth_type": "BodyKey",
"api_key": "{{adyen-api-key}}",
"key1": "{{adyen_merchant_account}}"
},
"profile_id": "{{profile_id}}"
})
)
),
(
"Create a merchant account with custom connector label" = (
value = json!({
"connector_type": "payment_processor",
"connector_name": "adyen", "connector_name": "adyen",
"connector_label": "EU_adyen", "connector_label": "EU_adyen",
"connector_account_details": { "connector_account_details": {
@ -63,6 +124,7 @@ pub async fn connector_create() {}
/// Merchant Connector - Retrieve /// Merchant Connector - Retrieve
/// ///
/// Retrieves details of a Connector account /// Retrieves details of a Connector account
#[cfg(feature = "v1")]
#[utoipa::path( #[utoipa::path(
get, get,
path = "/accounts/{account_id}/connectors/{connector_id}", path = "/accounts/{account_id}/connectors/{connector_id}",
@ -81,6 +143,24 @@ pub async fn connector_create() {}
)] )]
pub async fn connector_retrieve() {} pub async fn connector_retrieve() {}
#[cfg(feature = "v2")]
#[utoipa::path(
get,
path = "/connector_accounts/{id}",
params(
("id" = i32, Path, description = "The unique identifier for the Merchant Connector")
),
responses(
(status = 200, description = "Merchant Connector retrieved successfully", body = MerchantConnectorResponse),
(status = 404, description = "Merchant Connector does not exist in records"),
(status = 401, description = "Unauthorized request")
),
tag = "Merchant Connector Account",
operation_id = "Retrieve a Merchant Connector",
security(("admin_api_key" = []))
)]
pub async fn connector_retrieve() {}
/// Merchant Connector - List /// Merchant Connector - List
/// ///
/// List Merchant Connector Details for the merchant /// List Merchant Connector Details for the merchant
@ -104,6 +184,7 @@ pub async fn payment_connector_list() {}
/// Merchant Connector - Update /// Merchant Connector - Update
/// ///
/// To update an existing Merchant Connector account. Helpful in enabling/disabling different payment methods and other settings for the connector /// To update an existing Merchant Connector account. Helpful in enabling/disabling different payment methods and other settings for the connector
#[cfg(feature = "v1")]
#[utoipa::path( #[utoipa::path(
post, post,
path = "/accounts/{account_id}/connectors/{connector_id}", path = "/accounts/{account_id}/connectors/{connector_id}",
@ -113,7 +194,7 @@ pub async fn payment_connector_list() {}
( (
"Enable card payment method" = ( "Enable card payment method" = (
value = json! ({ value = json! ({
"connector_type": "fiz_operations", "connector_type": "payment_processor",
"payment_methods_enabled": [ "payment_methods_enabled": [
{ {
"payment_method": "card" "payment_method": "card"
@ -148,9 +229,54 @@ pub async fn payment_connector_list() {}
)] )]
pub async fn connector_update() {} pub async fn connector_update() {}
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/connector_accounts/{id}",
request_body(
content = MerchantConnectorUpdate,
examples(
(
"Enable card payment method" = (
value = json! ({
"connector_type": "payment_processor",
"payment_methods_enabled": [
{
"payment_method": "card"
}
]
})
)
),
(
"Update webhook secret" = (
value = json! ({
"connector_webhook_details": {
"merchant_secret": "{{webhook_secret}}"
}
})
)
)
),
),
params(
("id" = i32, Path, description = "The unique identifier for the Merchant Connector")
),
responses(
(status = 200, description = "Merchant Connector Updated", body = MerchantConnectorResponse),
(status = 404, description = "Merchant Connector does not exist in records"),
(status = 401, description = "Unauthorized request")
),
tag = "Merchant Connector Account",
operation_id = "Update a Merchant Connector",
security(("admin_api_key" = []))
)]
pub async fn connector_update() {}
/// Merchant Connector - Delete /// Merchant Connector - Delete
/// ///
/// Delete or Detach a Merchant Connector from Merchant Account /// Delete or Detach a Merchant Connector from Merchant Account
#[cfg(feature = "v1")]
#[utoipa::path( #[utoipa::path(
delete, delete,
path = "/accounts/{account_id}/connectors/{connector_id}", path = "/accounts/{account_id}/connectors/{connector_id}",
@ -168,3 +294,21 @@ pub async fn connector_update() {}
security(("admin_api_key" = [])) security(("admin_api_key" = []))
)] )]
pub async fn connector_delete() {} pub async fn connector_delete() {}
#[cfg(feature = "v2")]
#[utoipa::path(
delete,
path = "/connector_accounts/{id}",
params(
("id" = i32, Path, description = "The unique identifier for the Merchant Connector")
),
responses(
(status = 200, description = "Merchant Connector Deleted", body = MerchantConnectorDeleteResponse),
(status = 404, description = "Merchant Connector does not exist in records"),
(status = 401, description = "Unauthorized request")
),
tag = "Merchant Connector Account",
operation_id = "Delete a Merchant Connector",
security(("admin_api_key" = []))
)]
pub async fn connector_delete() {}