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

Open
wants to merge 35 commits into
base: main
Choose a base branch
from

Conversation

ShivanshMathurJuspay
Copy link
Contributor

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_b3wqqYY9ocG09WJxAUpy' \
--header 'Authorization: api-key=dev_zRu6GCOKMZcyEBDevpX7IJAfIT9J9VgWsJTH9Gi8rbtiNzlHjIh0BWAdtjCoAECV' \
--header 'Content-Type: application/json' \
--data-raw '{
    "customer_id": "12345_cus_01965d1e7a8e7de09f996cfd54f8dc82"
}'

Response

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

Retrieve API ( with reveal flag as true )

curl --location 'http://localhost:8080/v2/tokenize/12345_tok_01966c69995077f3a92bb7e1821dd34e?reveal=true' \
--header 'x-profile-id: pro_b3wqqYY9ocG09WJxAUpy' \
--header 'Authorization: api-key=dev_zRu6GCOKMZcyEBDevpX7IJAfIT9J9VgWsJTH9Gi8rbtiNzlHjIh0BWAdtjCoAECV'

Response

{
  "customer_id": "12345_cus_01965d1e7a8e7de09f996cfd54f8dc82"
}

Retrieve API ( with reveal flag as false or not given )

curl --location 'http://localhost:8080/v2/tokenize/12345_tok_01966c69995077f3a92bb7e1821dd34e' \
--header 'x-profile-id: pro_b3wqqYY9ocG09WJxAUpy' \
--header 'Authorization: api-key=dev_zRu6GCOKMZcyEBDevpX7IJAfIT9J9VgWsJTH9Gi8rbtiNzlHjIh0BWAdtjCoAECV'

Response

{
  "customer_id": "masked"
}

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

@ShivanshMathurJuspay ShivanshMathurJuspay self-assigned this Apr 25, 2025
@ShivanshMathurJuspay ShivanshMathurJuspay 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/hyperswitch_domain_models/src/payment_methods.rs  78% smaller
  crates/router/src/types/payment_methods.rs  78% smaller
  crates/diesel_models/src/enums.rs  8% smaller
  crates/router/src/db.rs  8% smaller
  crates/common_enums/src/enums.rs  1% 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/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/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/router/Cargo.toml Unsupported file format
  crates/router/src/core.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/db/tokenization.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
  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
@ShivanshMathurJuspay ShivanshMathurJuspay linked an issue Apr 25, 2025 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
1 participant