Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
2a1384c
inital commit
su-shivanshmathur Apr 16, 2025
8a1ffef
updates
su-shivanshmathur Apr 17, 2025
59027b8
GlobalTokenId intoduce
su-shivanshmathur Apr 18, 2025
4076f3c
Changes
su-shivanshmathur Apr 18, 2025
b50f333
model changes
su-shivanshmathur Apr 18, 2025
967ab76
insert changes
su-shivanshmathur Apr 18, 2025
4cb5a50
Changes
su-shivanshmathur Apr 21, 2025
c3681e1
Working changes
su-shivanshmathur Apr 22, 2025
96d98c7
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur Apr 22, 2025
8485945
Working commits
su-shivanshmathur Apr 23, 2025
b4d4435
Sanity
su-shivanshmathur Apr 23, 2025
de7bc0f
Retrieve endpoint for tokenization
su-shivanshmathur Apr 25, 2025
d65dd5d
development.toml changes
su-shivanshmathur Apr 25, 2025
dcdc5d9
migrations
su-shivanshmathur Apr 25, 2025
978ca25
flag check
su-shivanshmathur Apr 25, 2025
6141225
chore: run formatter
hyperswitch-bot[bot] Apr 25, 2025
e8b4301
clippy errors
su-shivanshmathur Apr 25, 2025
8776570
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur Apr 25, 2025
7861564
Conflict resolve
su-shivanshmathur Apr 25, 2025
1d33d0c
chore: run formatter
hyperswitch-bot[bot] Apr 25, 2025
84ee28c
clippy changes
su-shivanshmathur Apr 28, 2025
3e9937a
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur Apr 28, 2025
f817c02
chore: run formatter
hyperswitch-bot[bot] Apr 28, 2025
428ac80
clippy error
su-shivanshmathur Apr 28, 2025
d3a6717
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur Apr 28, 2025
46460ed
chore: run formatter
hyperswitch-bot[bot] Apr 28, 2025
23eb33d
Changes
su-shivanshmathur Apr 28, 2025
219f9d7
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur Apr 28, 2025
096dbf7
Clippy changes
su-shivanshmathur Apr 28, 2025
27c74f2
chore: run formatter
hyperswitch-bot[bot] Apr 28, 2025
cbf61a2
schema changes
su-shivanshmathur Apr 28, 2025
2f11f33
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur Apr 28, 2025
a6bd4b2
changes in down.sql
su-shivanshmathur Apr 28, 2025
71442c8
storage_impl tokenization file removal
su-shivanshmathur Apr 28, 2025
0892344
chore: run formatter
hyperswitch-bot[bot] Apr 28, 2025
9926d7b
development.toml changes
su-shivanshmathur May 2, 2025
1ace00e
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 2, 2025
5ff31ee
Payment method session integration for tokenization service
su-shivanshmathur May 6, 2025
b53a889
chore: run formatter
hyperswitch-bot[bot] May 6, 2025
a3d7559
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 13, 2025
1625353
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 13, 2025
4b20cfe
Added client secret based auth
su-shivanshmathur May 14, 2025
448de98
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 14, 2025
14a26f0
chore: run formatter
hyperswitch-bot[bot] May 14, 2025
1fed101
masking data and adding storage_impl
su-shivanshmathur May 14, 2025
7e55476
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 14, 2025
a9993af
Comment resolution
su-shivanshmathur May 15, 2025
9ec9639
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 15, 2025
d48cb21
storage_imple usage inplace of db
su-shivanshmathur May 16, 2025
4d1ec7d
chore: run formatter
hyperswitch-bot[bot] May 16, 2025
2d2e0a2
JSON mask startegy introduce
su-shivanshmathur May 16, 2025
e459fbe
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 16, 2025
a1006d3
chore: run formatter
hyperswitch-bot[bot] May 16, 2025
a3c3915
adding unit test case
su-shivanshmathur May 16, 2025
6a617d0
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 16, 2025
749221b
chore: run formatter
hyperswitch-bot[bot] May 16, 2025
97b1904
test case changes
su-shivanshmathur May 16, 2025
b0501ca
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 16, 2025
9504270
chore: run formatter
hyperswitch-bot[bot] May 16, 2025
8255693
Comment and clippy changes
su-shivanshmathur May 18, 2025
006e520
clippy errors
su-shivanshmathur May 18, 2025
dc4b1ac
common imports
su-shivanshmathur May 18, 2025
27c652f
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 18, 2025
bd87f89
chore: run formatter
hyperswitch-bot[bot] May 18, 2025
fde7444
Comments
su-shivanshmathur May 18, 2025
b33d18d
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 18, 2025
3bb4e0b
openapi changes
su-shivanshmathur May 19, 2025
58a1d67
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 19, 2025
90b6050
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 20, 2025
1c56278
remove the api for get token
su-shivanshmathur May 21, 2025
2051cc4
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 21, 2025
8be1cfa
Format error
su-shivanshmathur May 21, 2025
5da9217
chore: run formatter
hyperswitch-bot[bot] May 21, 2025
89088e2
Removing unwanted imports and enums
su-shivanshmathur May 21, 2025
b6808b1
JsonMaskStrategy under serde feature flag
su-shivanshmathur May 22, 2025
810ae36
chore: run formatter
hyperswitch-bot[bot] May 22, 2025
a3baaf4
Comment changes and OpenApi spec changes
su-shivanshmathur May 22, 2025
54cf6d3
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 22, 2025
cfc23d1
chore: run formatter
hyperswitch-bot[bot] May 22, 2025
3daa21f
Merge branch 'main' of github.com:juspay/hyperswitch into feature/tok…
su-shivanshmathur May 22, 2025
ea3aee5
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 22, 2025
332f7f1
Comment resolution
su-shivanshmathur May 22, 2025
bf87db4
chore: run formatter
hyperswitch-bot[bot] May 22, 2025
3f5fd1b
OpenApi Changes
su-shivanshmathur May 22, 2025
874ea79
open-api changes
su-shivanshmathur May 22, 2025
daa0ea9
Merge branch 'feature/tokenize' of github.com:juspay/hyperswitch into…
su-shivanshmathur May 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
openapi: post /v2/tokenize
---
4 changes: 4 additions & 0 deletions api-reference-v2/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
{
"group": "Proxy",
"pages": ["api-reference/proxy/proxy"]
},
{
"group": "Tokenization",
"pages": ["api-reference/tokenization/tokenization--create"]
}
],
"footerSocials": {
Expand Down
123 changes: 123 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,67 @@
}
]
}
},
"/v2/tokenize": {
"post": {
"tags": [
"Tokenization"
],
"operationId": "create_token_vault_api",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GenericTokenizationRequest"
},
"examples": {
"Create a token with customer_id": {
"value": {
"customer_id": "12345_cus_0196d94b9c207333a297cbcf31f2e8c8",
"token_request": {
"payment_method_data": {
"card": {
"card_holder_name": "test name"
}
}
}
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Token created successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GenericTokenizationResponse"
}
}
}
},
"400": {
"description": "Invalid request"
},
"401": {
"description": "Unauthorized"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"ephemeral_key": []
},
{
"api_key": []
}
]
}
}
},
"components": {
Expand Down Expand Up @@ -11032,6 +11093,50 @@
}
}
},
"GenericTokenizationRequest": {
"type": "object",
"required": [
"customer_id",
"token_request"
],
"properties": {
"customer_id": {
"type": "string",
"description": "Customer ID for which the tokenization is requested",
"example": "12345_cus_01926c58bc6e77c09e809964e72af8c8"
},
"token_request": {
"type": "object",
"description": "Request for tokenization which contains the data to be tokenized"
}
}
},
"GenericTokenizationResponse": {
"type": "object",
"required": [
"id",
"created_at",
"flag"
],
"properties": {
"id": {
"type": "string",
"description": "Unique identifier returned by the tokenization service",
"example": "12345_tok_01926c58bc6e77c09e809964e72af8c8"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "Created time of the tokenization id",
"example": "2024-02-24T11:04:09.922Z"
},
"flag": {
"type": "string",
"description": "Status of the tokenization id created",
"example": "enabled"
}
}
},
"GiftCardAdditionalData": {
"oneOf": [
{
Expand Down Expand Up @@ -16595,6 +16700,10 @@
"example": 900,
"nullable": true,
"minimum": 0
},
"tokenization_data": {
"description": "Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data",
"nullable": true
}
}
},
Expand Down Expand Up @@ -16640,6 +16749,10 @@
],
"nullable": true
},
"tokenization_data": {
"description": "Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data",
"nullable": true
},
"expires_at": {
"type": "string",
"format": "date-time",
Expand Down Expand Up @@ -16678,6 +16791,12 @@
},
"description": "The payment method that was created using this payment method session",
"nullable": true
},
"associated_token_id": {
"type": "string",
"description": "The token-id created if there is tokenization_data present",
"example": "12345_tok_01926c58bc6e77c09e809964e72af8c8",
"nullable": true
}
}
},
Expand Down Expand Up @@ -16941,6 +17060,10 @@
}
],
"nullable": true
},
"tokenization_data": {
"description": "Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data",
"nullable": true
}
}
},
Expand Down
24 changes: 2 additions & 22 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,8 @@ redis_lock_timeout_in_seconds = 100
redis_ttl_in_seconds = 172800

[jwekey]
vault_encryption_key = """
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwa6siKaSYqD1o4J3AbHq
Km8oVTvep7GoN/C45qY60C7DO72H1O7Ujt6ZsSiK83EyI0CaUg3ORPS3ayobFNmu
zR366ckK8GIf3BG7sVI6u/9751z4OvBHZMM9JFWa7Bx/RCPQ8aeM+iJoqf9auuQm
3NCTlfaZJif45pShswR+xuZTR/bqnsOSP/MFROI9ch0NE7KRogy0tvrZe21lP24i
Ro2LJJG+bYshxBddhxQf2ryJ85+/Trxdu16PunodGzCl6EMT3bvb4ZC41i15omqU
aXXV1Z1wYUhlsO0jyd1bVvjyuE/KE1TbBS0gfR/RkacODmmE2zEdZ0EyyiXwqkmc
oQIDAQAB
-----END PUBLIC KEY-----
"""
rust_locker_encryption_key = """
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwa6siKaSYqD1o4J3AbHq
Km8oVTvep7GoN/C45qY60C7DO72H1O7Ujt6ZsSiK83EyI0CaUg3ORPS3ayobFNmu
zR366ckK8GIf3BG7sVI6u/9751z4OvBHZMM9JFWa7Bx/RCPQ8aeM+iJoqf9auuQm
3NCTlfaZJif45pShswR+xuZTR/bqnsOSP/MFROI9ch0NE7KRogy0tvrZe21lP24i
Ro2LJJG+bYshxBddhxQf2ryJ85+/Trxdu16PunodGzCl6EMT3bvb4ZC41i15omqU
aXXV1Z1wYUhlsO0jyd1bVvjyuE/KE1TbBS0gfR/RkacODmmE2zEdZ0EyyiXwqkmc
oQIDAQAB
-----END PUBLIC KEY-----
"""
vault_encryption_key = ""
rust_locker_encryption_key = ""
Comment on lines +87 to +88
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we remove these keys? is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

vault_private_key = ""
tunnel_private_key = ""

Expand Down
3 changes: 2 additions & 1 deletion crates/api_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ olap = []
openapi = ["common_enums/openapi", "olap", "recon", "dummy_connector", "olap"]
recon = []
v1 = ["common_utils/v1"]
v2 = ["common_types/v2", "common_utils/v2", "customer_v2", "refunds_v2"]
v2 = ["common_types/v2", "common_utils/v2", "customer_v2", "refunds_v2", "tokenization_v2"]
customer_v2 = ["common_utils/customer_v2"]
payment_methods_v2 = ["common_utils/payment_methods_v2", "dep:reqwest"]
refunds_v2 = []
dynamic_routing = []
control_center_theme = ["dep:actix-web", "dep:actix-multipart"]
revenue_recovery = []
tokenization_v2 = ["common_utils/tokenization_v2"]

[dependencies]
actix-multipart = { version = "0.6.1", optional = true }
Expand Down
7 changes: 7 additions & 0 deletions crates/api_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use common_utils::{
};

use crate::customers::CustomerListRequest;
#[cfg(feature = "tokenization_v2")]
use crate::tokenization;
#[allow(unused_imports)]
use crate::{
admin::*,
Expand Down Expand Up @@ -228,3 +230,8 @@ impl ApiEventMetric for PaymentMethodSessionResponse {
})
}
}
#[cfg(feature = "tokenization_v2")]
impl ApiEventMetric for tokenization::GenericTokenizationRequest {}

#[cfg(feature = "tokenization_v2")]
impl ApiEventMetric for tokenization::GenericTokenizationResponse {}
2 changes: 2 additions & 0 deletions crates/api_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub mod refunds;
pub mod relay;
pub mod routing;
pub mod surcharge_decision_configs;
#[cfg(feature = "tokenization_v2")]
pub mod tokenization;
pub mod user;
pub mod user_role;
pub mod verifications;
Expand Down
16 changes: 16 additions & 0 deletions crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,10 @@ pub struct PaymentMethodSessionRequest {
/// If not provided, the session will expire in 15 minutes
#[schema(example = 900, default = 900)]
pub expires_in: Option<u32>,

/// Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data
#[schema(value_type = Option<serde_json::Value>)]
pub tokenization_data: Option<pii::SecretSerdeValue>,
}

#[cfg(feature = "v2")]
Expand All @@ -2877,6 +2881,10 @@ pub struct PaymentMethodsSessionUpdateRequest {
/// The network tokenization configuration if applicable
#[schema(value_type = Option<NetworkTokenization>)]
pub network_tokenization: Option<common_types::payment_methods::NetworkTokenization>,

/// Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data
#[schema(value_type = Option<serde_json::Value>)]
pub tokenization_data: Option<pii::SecretSerdeValue>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -2941,6 +2949,10 @@ pub struct PaymentMethodSessionResponse {
#[schema(value_type = Option<NetworkTokenization>)]
pub network_tokenization: Option<common_types::payment_methods::NetworkTokenization>,

/// Contains data to be passed on to tokenization service ( if present ) to create token_id for given JSON data
#[schema(value_type = Option<serde_json::Value>)]
pub tokenization_data: Option<pii::SecretSerdeValue>,

/// The iso timestamp when the session will expire
/// Trying to retrieve the session or any operations on the session after this time will result in an error
#[schema(value_type = PrimitiveDateTime, example = "2023-01-18T11:04:09.922Z")]
Expand All @@ -2966,6 +2978,10 @@ pub struct PaymentMethodSessionResponse {
/// The payment method that was created using this payment method session
#[schema(value_type = Option<Vec<String>>)]
pub associated_payment_methods: Option<Vec<id_type::GlobalPaymentMethodId>>,

/// The token-id created if there is tokenization_data present
#[schema(value_type = Option<String>, example = "12345_tok_01926c58bc6e77c09e809964e72af8c8")]
pub associated_token_id: Option<id_type::GlobalTokenId>,
}

#[cfg(feature = "v2")]
Expand Down
30 changes: 30 additions & 0 deletions crates/api_models/src/tokenization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use common_enums;
use common_utils::id_type::{GlobalCustomerId, GlobalTokenId};
use masking::Secret;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::{schema, ToSchema};

#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct GenericTokenizationResponse {
/// Unique identifier returned by the tokenization service
#[schema(value_type = String, example = "12345_tok_01926c58bc6e77c09e809964e72af8c8")]
pub id: GlobalTokenId,
/// Created time of the tokenization id
#[schema(value_type = PrimitiveDateTime,example = "2024-02-24T11:04:09.922Z")]
pub created_at: PrimitiveDateTime,
/// Status of the tokenization id created
#[schema(value_type = String,example = "enabled")]
pub flag: common_enums::TokenizationFlag,
}
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct GenericTokenizationRequest {
/// Customer ID for which the tokenization is requested
#[schema(value_type = String, example = "12345_cus_01926c58bc6e77c09e809964e72af8c8")]
pub customer_id: GlobalCustomerId,
/// Request for tokenization which contains the data to be tokenized
#[schema(value_type = Object,example = json!({ "city": "NY", "unit": "245" }))]
pub token_request: masking::Secret<serde_json::Value>,
}
24 changes: 23 additions & 1 deletion crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod diesel_exports {
DbRequestIncrementalAuthorization as RequestIncrementalAuthorization,
DbScaExemptionType as ScaExemptionType,
DbSuccessBasedRoutingConclusiveState as SuccessBasedRoutingConclusiveState,
DbWebhookDeliveryAttempt as WebhookDeliveryAttempt,
DbTokenizationFlag as TokenizationFlag, DbWebhookDeliveryAttempt as WebhookDeliveryAttempt,
};
}

Expand Down Expand Up @@ -8299,6 +8299,28 @@ pub enum CryptoPadding {
ZeroPadding,
}

#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumString,
ToSchema,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum TokenizationFlag {
/// Token is active and can be used for payments
Enabled,
/// Token is inactive and cannot be used for payments
Disabled,
}

/// The type of token data to fetch for get-token endpoint

#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
Expand Down
1 change: 1 addition & 0 deletions crates/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true
default = []
v1 = ["common_utils/v1"]
v2 = ["common_utils/v2"]
tokenization_v2 = ["common_utils/tokenization_v2"]

[dependencies]
diesel = "2.2.3"
Expand Down
1 change: 1 addition & 0 deletions crates/common_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ v2 = []
customer_v2 = []
payment_methods_v2 = []
crypto_openssl = ["dep:openssl"]
tokenization_v2 = []

[dependencies]
async-trait = { version = "0.1.79", optional = true }
Expand Down
4 changes: 4 additions & 0 deletions crates/common_utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ pub const DEFAULT_CARD_TESTING_GUARD_EXPIRY_IN_SECS: i32 = 3600;
/// SOAP 1.1 Envelope Namespace
pub const SOAP_ENV_NAMESPACE: &str = "http://schemas.xmlsoap.org/soap/envelope/";

#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
/// Length of generated tokens
pub const TOKEN_LENGTH: usize = 32;

/// The tag name used for identifying the host in metrics.
pub const METRICS_HOST_TAG_NAME: &str = "host";

Expand Down
Loading
Loading