feat(router): adding generic tokenization endpoint (#7905)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Shivansh Mathur
2025-05-27 11:39:36 +05:30
committed by GitHub
parent c4a5e3ac16
commit 49a178ed20
60 changed files with 1450 additions and 38 deletions

View File

@ -157,6 +157,9 @@ Never share your secret api keys. Keep them guarded and secure.
// Routes for proxy
routes::proxy::proxy_core,
// Route for tokenization
routes::tokenization::create_token_vault_api,
),
components(schemas(
common_utils::types::MinorUnit,
@ -736,6 +739,8 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::proxy::ProxyResponse,
api_models::proxy::TokenType,
routes::payments::ForceSync,
api_models::tokenization::GenericTokenizationRequest,
api_models::tokenization::GenericTokenizationResponse,
)),
modifiers(&SecurityAddon)
)]

View File

@ -20,4 +20,5 @@ pub mod refunds;
pub mod relay;
pub mod revenue_recovery;
pub mod routing;
pub mod tokenization;
pub mod webhook_events;

View File

@ -0,0 +1,33 @@
use serde_json::json;
use utoipa::OpenApi;
#[cfg(feature = "v2")]
#[utoipa::path(
post,
path = "/v2/tokenize",
request_body(
content = GenericTokenizationRequest,
examples(("Create a token with customer_id" = (
value = json!({
"customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
"token_request": {
"payment_method_data": {
"card": {
"card_holder_name": "test name"
}
}
}
})
)))
),
responses(
(status = 200, description = "Token created successfully", body = GenericTokenizationResponse),
(status = 400, description = "Invalid request"),
(status = 401, description = "Unauthorized"),
(status = 500, description = "Internal server error")
),
tag = "Tokenization",
operation_id = "create_token_vault_api",
security(("ephemeral_key" = []),("api_key" = []))
)]
pub async fn create_token_vault_api() {}