Skip to content

feat(router): adding generic tokenization endpoint #7905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 86 commits into from
May 27, 2025
Merged

Conversation

su-shivanshmathur
Copy link
Contributor

@su-shivanshmathur su-shivanshmathur commented Apr 25, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Create a new set of endpoints for giving tokenization as a service for generic usage, current motivation of the service is to be used in proxy payment service.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Create a token

curl --location 'http: //localhost:8080/v2/tokenize' \
--header 'x-profile-id: pro_neU1Qn8gnIich0LAaQXm' \
--header 'Authorization: publishable-key=PUBLISHABLE_KEY,client-secret=CLIENT_SECRET' \
--header 'Content-Type: application/json' \
--data '{
    "customer_id": customer_id,
    "token_request": {
        "payment_method_data": {
            "card": {
                "card_holder_name": "Narayan Bhat"
            }
        }
    }
}'

Response

{
    "id": "12345_tok_01966c6515157c3193db1c2502435ad5",
    "created_at": "2025-04-25 10:01:26.037519",
    "flag": "enabled"
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@su-shivanshmathur su-shivanshmathur self-assigned this Apr 25, 2025
@su-shivanshmathur su-shivanshmathur requested review from a team as code owners April 25, 2025 11:46
Copy link

semanticdiff-com bot commented Apr 25, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/db.rs  80% smaller
  crates/router/src/types/payment_methods.rs  78% smaller
  crates/diesel_models/src/enums.rs  41% smaller
  crates/hyperswitch_domain_models/src/payment_methods.rs  22% smaller
  crates/router/src/core/payment_methods.rs  1% smaller
  crates/common_enums/src/enums.rs  1% smaller
  api-reference-v2/api-reference/tokenization/tokenization--create.mdx Unsupported file format
  api-reference-v2/mint.json  0% smaller
  api-reference-v2/openapi_spec.json  0% smaller
  config/development.toml Unsupported file format
  crates/api_models/Cargo.toml Unsupported file format
  crates/api_models/src/events.rs  0% smaller
  crates/api_models/src/lib.rs  0% smaller
  crates/api_models/src/payment_methods.rs  0% smaller
  crates/api_models/src/tokenization.rs  0% smaller
  crates/common_types/Cargo.toml Unsupported file format
  crates/common_utils/Cargo.toml Unsupported file format
  crates/common_utils/src/consts.rs  0% smaller
  crates/common_utils/src/events.rs  0% smaller
  crates/common_utils/src/id_type.rs  0% smaller
  crates/common_utils/src/id_type/global_id.rs  0% smaller
  crates/common_utils/src/id_type/global_id/token.rs  0% smaller
  crates/common_utils/src/lib.rs  0% smaller
  crates/common_utils/src/tokenization.rs  0% smaller
  crates/diesel_models/Cargo.toml Unsupported file format
  crates/diesel_models/src/lib.rs  0% smaller
  crates/diesel_models/src/mod.rs  0% smaller
  crates/diesel_models/src/payment_methods_session.rs  0% smaller
  crates/diesel_models/src/query.rs  0% smaller
  crates/diesel_models/src/query/tokenization.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/diesel_models/src/tokenization.rs  0% smaller
  crates/diesel_models/src/types.rs  0% smaller
  crates/hyperswitch_domain_models/Cargo.toml Unsupported file format
  crates/hyperswitch_domain_models/src/lib.rs  0% smaller
  crates/hyperswitch_domain_models/src/tokenization.rs  0% smaller
  crates/masking/src/lib.rs  0% smaller
  crates/masking/src/secret.rs  0% smaller
  crates/openapi/Cargo.toml Unsupported file format
  crates/openapi/src/openapi_v2.rs  0% smaller
  crates/openapi/src/routes.rs  0% smaller
  crates/openapi/src/routes/tokenization.rs  0% smaller
  crates/router/Cargo.toml Unsupported file format
  crates/router/src/core.rs  0% smaller
  crates/router/src/core/payment_methods/transformers.rs  0% smaller
  crates/router/src/core/payment_methods/vault.rs  0% smaller
  crates/router/src/core/tokenization.rs  0% smaller
  crates/router/src/db/kafka_store.rs  0% smaller
  crates/router/src/lib.rs  0% smaller
  crates/router/src/routes.rs  0% smaller
  crates/router/src/routes/app.rs  0% smaller
  crates/router/src/routes/lock_utils.rs  0% smaller
  crates/router/src/routes/tokenization.rs  0% smaller
  crates/router_env/src/logger/types.rs  0% smaller
  crates/storage_impl/Cargo.toml Unsupported file format
  crates/storage_impl/src/lib.rs  0% smaller
  crates/storage_impl/src/mock_db.rs  0% smaller
  crates/storage_impl/src/tokenization.rs  0% smaller
  v2_migrations/2025-04-25-105138_tokenization_service_creation/down.sql Unsupported file format
  v2_migrations/2025-04-25-105138_tokenization_service_creation/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Apr 25, 2025
@su-shivanshmathur su-shivanshmathur linked an issue Apr 25, 2025 that may be closed by this pull request
2 tasks
@su-shivanshmathur su-shivanshmathur dismissed stale reviews from maverox and jarnura via a3baaf4 May 22, 2025 11:57
tsdk02
tsdk02 previously approved these changes May 22, 2025
maverox
maverox previously approved these changes May 22, 2025
@hyperswitch-bot hyperswitch-bot bot dismissed stale reviews from maverox and tsdk02 via cfc23d1 May 22, 2025 12:00
tsdk02
tsdk02 previously approved these changes May 22, 2025
prasunna09
prasunna09 previously approved these changes May 22, 2025

#[instrument(skip_all)]
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
pub async fn get_token_vault_core(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this name could be better.

ps: not able to get the functionality from the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can take up later when we'll use this for a handler fuction

jarnura
jarnura previously approved these changes May 22, 2025
@su-shivanshmathur su-shivanshmathur dismissed stale reviews from jarnura and prasunna09 via 332f7f1 May 22, 2025 17:14
use error_stack::ResultExt;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
use hyperswitch_domain_models;
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of having this on every import n method, this can be moved to parent level. core.rs in the same crate.

|state, auth: auth::AuthenticationData, request, _| async move {
tokenization::create_vault_token_core(
state,
&auth.merchant_account,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merchantContext has been introduced recently. we should use that ig

CC: @maverox

@likhinbopanna likhinbopanna added this pull request to the merge queue May 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 26, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue May 27, 2025
Merged via the queue into main with commit 49a178e May 27, 2025
14 of 20 checks passed
@likhinbopanna likhinbopanna deleted the feature/tokenize branch May 27, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Tokenization service
6 participants