Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payment_methods): add v2 api for fetching token data (#7629)
Sakil Mostak2cefac5cb347
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex b6d6fb87e2..fa4bdbb8b2 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -13207,7 +13207,11 @@"nullable": true},"issuer_country": {- "type": "string",+ "allOf": [+ {+ "$ref": "#/components/schemas/CountryAlpha2"+ }+ ],"nullable": true},"network_token_expiry_month": {@@ -13251,6 +13255,82 @@}}},+ "NetworkTokenDetailsResponse": {+ "type": "object",+ "required": [+ "network_token",+ "network_token_exp_month",+ "network_token_exp_year"+ ],+ "properties": {+ "network_token": {+ "type": "string",+ "description": "Network token generated against the Card Number"+ },+ "network_token_exp_month": {+ "type": "string",+ "description": "Expiry month of the network token"+ },+ "network_token_exp_year": {+ "type": "string",+ "description": "Expiry year of the network token"+ },+ "cryptogram": {+ "type": "string",+ "description": "Cryptogram generated by the Network",+ "nullable": true+ },+ "card_issuer": {+ "type": "string",+ "description": "Issuer of the card",+ "nullable": true+ },+ "card_network": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CardNetwork"+ }+ ],+ "nullable": true+ },+ "card_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CardType"+ }+ ],+ "nullable": true+ },+ "card_issuing_country": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CountryAlpha2"+ }+ ],+ "nullable": true+ },+ "bank_code": {+ "type": "string",+ "description": "Bank code of the card",+ "nullable": true+ },+ "card_holder_name": {+ "type": "string",+ "description": "Name of the card holder",+ "nullable": true+ },+ "nick_name": {+ "type": "string",+ "description": "Nick name of the card holder",+ "nullable": true+ },+ "eci": {+ "type": "string",+ "description": "ECI indicator of the card",+ "nullable": true+ }+ }+ },"NetworkTokenResponse": {"type": "object","required": [@@ -22819,6 +22899,43 @@}}},+ "TokenDataResponse": {+ "type": "object",+ "required": [+ "payment_method_id",+ "token_type",+ "token_details"+ ],+ "properties": {+ "payment_method_id": {+ "type": "string",+ "description": "The unique identifier of the payment method.",+ "example": "12345_pm_01926c58bc6e77c09e809964e72af8c8"+ },+ "token_type": {+ "$ref": "#/components/schemas/TokenDataType"+ },+ "token_details": {+ "$ref": "#/components/schemas/TokenDetailsResponse"+ }+ }+ },+ "TokenDataType": {+ "type": "string",+ "description": "The type of token data to fetch for get-token endpoint",+ "enum": [+ "single_use_token",+ "multi_use_token",+ "network_token"+ ]+ },+ "TokenDetailsResponse": {+ "oneOf": [+ {+ "$ref": "#/components/schemas/NetworkTokenDetailsResponse"+ }+ ]+ },"TokenizationType": {"type": "string","description": "The type of tokenization to use for the payment method",diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex 36705fba44..e5f3cfbbe7 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -27314,6 +27314,15 @@}}},+ "TokenDataType": {+ "type": "string",+ "description": "The type of token data to fetch for get-token endpoint",+ "enum": [+ "single_use_token",+ "multi_use_token",+ "network_token"+ ]+ },"TokenizeCardRequest": {"type": "object","required": [diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 0f53776e64..df4074dc00 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -990,7 +990,8 @@ pub struct CardDetailsPaymentMethod {#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]pub struct NetworkTokenDetailsPaymentMethod {pub last4_digits: Option<String>,- pub issuer_country: Option<String>,+ #[schema(value_type = Option<CountryAlpha2>)]+ pub issuer_country: Option<common_enums::CountryAlpha2>,#[schema(value_type = Option<String>)]pub network_token_expiry_month: Option<masking::Secret<String>>,#[schema(value_type = Option<String>)]@@ -1922,6 +1923,90 @@ pub struct CustomerPaymentMethodsListResponse {pub customer_payment_methods: Vec<CustomerPaymentMethod>,}+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]+#[serde(deny_unknown_fields)]+pub struct GetTokenDataRequest {+ /// Indicates the type of token to be fetched+ pub token_type: api_enums::TokenDataType,+}++#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+impl common_utils::events::ApiEventMetric for GetTokenDataRequest {}++#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+#[derive(Debug, serde::Serialize, ToSchema)]+pub struct TokenDataResponse {+ /// The unique identifier of the payment method.+ #[schema(value_type = String, example = "12345_pm_01926c58bc6e77c09e809964e72af8c8")]+ pub payment_method_id: id_type::GlobalPaymentMethodId,++ /// token type of the payment method+ #[schema(value_type = TokenDataType)]+ pub token_type: api_enums::TokenDataType,++ /// token details of the payment method+ pub token_details: TokenDetailsResponse,+}++#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+impl common_utils::events::ApiEventMetric for TokenDataResponse {}++#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+#[derive(Debug, serde::Serialize, ToSchema)]+#[serde(untagged)]+pub enum TokenDetailsResponse {+ NetworkTokenDetails(NetworkTokenDetailsResponse),+}++#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+#[derive(Debug, serde::Serialize, ToSchema)]+pub struct NetworkTokenDetailsResponse {+ /// Network token generated against the Card Number+ #[schema(value_type = String)]+ pub network_token: cards::NetworkToken,++ /// Expiry month of the network token+ #[schema(value_type = String)]+ pub network_token_exp_month: masking::Secret<String>,++ /// Expiry year of the network token+ #[schema(value_type = String)]+ pub network_token_exp_year: masking::Secret<String>,++ /// Cryptogram generated by the Network+ #[schema(value_type = Option<String>)]+ pub cryptogram: Option<masking::Secret<String>>,++ /// Issuer of the card+ pub card_issuer: Option<String>,++ /// Card network of the token+ #[schema(value_type = Option<CardNetwork>)]+ pub card_network: Option<common_enums::CardNetwork>,++ /// Card type of the token+ pub card_type: Option<CardType>,++ /// Issuing country of the card+ #[schema(value_type = Option<CountryAlpha2>)]+ pub card_issuing_country: Option<common_enums::CountryAlpha2>,++ /// Bank code of the card+ pub bank_code: Option<String>,++ /// Name of the card holder+ #[schema(value_type = Option<String>)]+ pub card_holder_name: Option<masking::Secret<String>>,++ /// Nick name of the card holder+ #[schema(value_type = Option<String>)]+ pub nick_name: Option<masking::Secret<String>>,++ /// ECI indicator of the card+ pub eci: Option<String>,+}+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]#[derive(Debug, serde::Serialize, ToSchema)]pub struct TotalPaymentMethodCountResponse {diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex fc3ff05d86..89f375b51a 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -8167,3 +8167,16 @@ pub enum CryptoPadding {PKCS7,ZeroPadding,}++/// The type of token data to fetch for get-token endpoint++#[derive(Clone, Copy, Debug, serde::Deserialize, serde::Serialize, ToSchema)]+#[serde(rename_all = "snake_case")]+pub enum TokenDataType {+ /// Fetch single use token for the given payment method+ SingleUseToken,+ /// Fetch multi use token for the given payment method+ MultiUseToken,+ /// Fetch network token for the given payment method+ NetworkToken,+}diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex 2d386d0f00..9f62dbbe98 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -662,7 +662,7 @@ pub struct NetworkTokenData {pub card_issuer: Option<String>, //since network token is tied to card, so its issuer will be same as card issuerpub card_network: Option<common_enums::CardNetwork>,pub card_type: Option<payment_methods::CardType>,- pub card_issuing_country: Option<String>,+ pub card_issuing_country: Option<common_enums::CountryAlpha2>,pub bank_code: Option<String>,pub card_holder_name: Option<Secret<String>>,pub nick_name: Option<Secret<String>>,@@ -1878,7 +1878,7 @@ pub enum PaymentMethodsData {#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]pub struct NetworkTokenDetailsPaymentMethod {pub last4_digits: Option<String>,- pub issuer_country: Option<String>,+ pub issuer_country: Option<common_enums::CountryAlpha2>,pub network_token_expiry_month: Option<Secret<String>>,pub network_token_expiry_year: Option<Secret<String>>,pub nick_name: Option<Secret<String>>,@@ -1934,7 +1934,7 @@ impl From<payment_methods::CardDetail> for CardDetailsPaymentMethod {impl From<NetworkTokenDetails> for NetworkTokenDetailsPaymentMethod {fn from(item: NetworkTokenDetails) -> Self {Self {- issuer_country: item.card_issuing_country.map(|c| c.to_string()),+ issuer_country: item.card_issuing_country,last4_digits: Some(item.network_token.get_last4()),network_token_expiry_month: Some(item.network_token_exp_month),network_token_expiry_year: Some(item.network_token_exp_year),diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 6dc61d4bf4..79c4467f03 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -286,6 +286,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::ScaExemptionType,api_models::enums::PaymentMethod,api_models::enums::TriggeredBy,+ api_models::enums::TokenDataType,api_models::enums::PaymentMethodType,api_models::enums::ConnectorType,api_models::enums::PayoutConnectors,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex bb48871190..aafd626c7b 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -270,6 +270,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::enums::BankType,api_models::enums::BankHolderType,api_models::enums::CardNetwork,+ api_models::enums::TokenDataType,api_models::enums::DisputeStage,api_models::enums::DisputeStatus,api_models::enums::CountryAlpha2,@@ -543,6 +544,9 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payment_methods::PaymentMethodsSessionUpdateRequest,api_models::payment_methods::NetworkTokenResponse,api_models::payment_methods::NetworkTokenDetailsPaymentMethod,+ api_models::payment_methods::NetworkTokenDetailsResponse,+ api_models::payment_methods::TokenDataResponse,+ api_models::payment_methods::TokenDetailsResponse,api_models::payment_methods::TokenizeCardRequest,api_models::payment_methods::TokenizeDataRequest,api_models::payment_methods::TokenizePaymentMethodRequest,diff --git a/crates/payment_methods/Cargo.toml b/crates/payment_methods/Cargo.tomlindex db8fe23ba7..c4b0df3447 100644--- a/crates/payment_methods/Cargo.toml+++ b/crates/payment_methods/Cargo.toml@@ -22,7 +22,7 @@ hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces"workspace = true[features]-default = ["v1", "dummy_connector"]+default = ["dummy_connector"]v1 = ["hyperswitch_domain_models/v1", "storage_impl/v1", "common_utils/v1"]v2 = [ "payment_methods_v2"]payment_methods_v2 = [ "hyperswitch_domain_models/payment_methods_v2", "storage_impl/payment_methods_v2", "common_utils/payment_methods_v2"]diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 990071b37e..ab4379466e 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -50,11 +50,13 @@ use hyperswitch_domain_models::api::{GenericLinks, GenericLinksData};feature = "customer_v2"))]use hyperswitch_domain_models::mandates::CommonMandateReference;-#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]-use hyperswitch_domain_models::payment_method_data;use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent, VaultData,};+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+use hyperswitch_domain_models::{payment_method_data, payment_methods as domain_payment_methods};+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+use masking::ExposeOptionInterface;use masking::{PeekInterface, Secret};use router_env::{instrument, tracing};use time::Duration;@@ -1363,6 +1365,102 @@ pub async fn list_saved_payment_methods_for_customer())}+#[cfg(all(feature = "v2", feature = "olap"))]+#[instrument(skip_all)]+pub async fn get_token_data_for_payment_method(+ state: SessionState,+ merchant_account: domain::MerchantAccount,+ key_store: domain::MerchantKeyStore,+ profile: domain::Profile,+ request: payment_methods::GetTokenDataRequest,+ payment_method_id: id_type::GlobalPaymentMethodId,+) -> RouterResponse<api::TokenDataResponse> {+ let key_manager_state = &(&state).into();++ let db = &*state.store;++ let payment_method = db+ .find_payment_method(+ key_manager_state,+ &key_store,+ &payment_method_id,+ merchant_account.storage_scheme,+ )+ .await+ .to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;++ let token_data_response =+ generate_token_data_response(&state, request, profile, &payment_method).await?;++ Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(+ token_data_response,+ ))+}++#[cfg(all(feature = "v2", feature = "olap"))]+#[instrument(skip_all)]+pub async fn generate_token_data_response(+ state: &SessionState,+ request: payment_methods::GetTokenDataRequest,+ profile: domain::Profile,+ payment_method: &domain_payment_methods::PaymentMethod,+) -> RouterResult<api::TokenDataResponse> {+ let token_details = match request.token_type {+ common_enums::TokenDataType::NetworkToken => {+ let is_network_tokenization_enabled = profile.is_network_tokenization_enabled;+ if !is_network_tokenization_enabled {+ return Err(errors::ApiErrorResponse::UnprocessableEntity {+ message: "Network tokenization is not enabled for this profile".to_string(),+ }+ .into());+ }+ let network_token_requestor_ref_id = payment_method+ .network_token_requestor_reference_id+ .clone()+ .ok_or(errors::ApiErrorResponse::GenericNotFoundError {+ message: "NetworkTokenRequestorReferenceId is not present".to_string(),+ })?;++ let network_token = network_tokenization::get_token_from_tokenization_service(+ state,+ network_token_requestor_ref_id,+ payment_method,+ )+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("failed to fetch network token data from tokenization service")?;++ api::TokenDetailsResponse::NetworkTokenDetails(api::NetworkTokenDetailsResponse {+ network_token: network_token.network_token,+ network_token_exp_month: network_token.network_token_exp_month,+ network_token_exp_year: network_token.network_token_exp_year,+ cryptogram: network_token.cryptogram,+ card_issuer: network_token.card_issuer,+ card_network: network_token.card_network,+ card_type: network_token.card_type,+ card_issuing_country: network_token.card_issuing_country,+ bank_code: network_token.bank_code,+ card_holder_name: network_token.card_holder_name,+ nick_name: network_token.nick_name,+ eci: network_token.eci,+ })+ }+ common_enums::TokenDataType::SingleUseToken+ | common_enums::TokenDataType::MultiUseToken => {+ return Err(errors::ApiErrorResponse::UnprocessableEntity {+ message: "Token type not supported".to_string(),+ }+ .into());+ }+ };++ Ok(api::TokenDataResponse {+ payment_method_id: payment_method.id.clone(),+ token_type: request.token_type,+ token_details,+ })+}+#[cfg(all(feature = "v2", feature = "olap"))]#[instrument(skip_all)]pub async fn get_total_saved_payment_methods_for_merchant(diff --git a/crates/router/src/core/payment_methods/network_tokenization.rs b/crates/router/src/core/payment_methods/network_tokenization.rsindex 8aa371e7a7..3c3c7afd31 100644--- a/crates/router/src/core/payment_methods/network_tokenization.rs+++ b/crates/router/src/core/payment_methods/network_tokenization.rs@@ -1,5 +1,7 @@#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]use std::fmt::Debug;+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+use std::str::FromStr;use api_models::payment_methods as api_payment_methods;#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]@@ -19,7 +21,9 @@ use error_stack::ResultExt;#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]use error_stack::{report, ResultExt};#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]-use hyperswitch_domain_models::payment_method_data::NetworkTokenDetails;+use hyperswitch_domain_models::payment_method_data::{+ NetworkTokenDetails, NetworkTokenDetailsPaymentMethod,+};use josekit::jwe;use masking::{ExposeInterface, Mask, PeekInterface, Secret};@@ -575,6 +579,82 @@ pub async fn get_token_from_tokenization_service(Ok(network_token_data)}+#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]+pub async fn get_token_from_tokenization_service(+ state: &routes::SessionState,+ network_token_requestor_ref_id: String,+ pm_data: &domain::PaymentMethod,+) -> errors::RouterResult<domain::NetworkTokenData> {+ let token_response =+ if let Some(network_tokenization_service) = &state.conf.network_tokenization_service {+ record_operation_time(+ async {+ get_network_token(+ state,+ &pm_data.customer_id,+ network_token_requestor_ref_id,+ network_tokenization_service.get_inner(),+ )+ .await+ .inspect_err(+ |e| logger::error!(error=?e, "Error while fetching token from tokenization service")+ )+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Fetch network token failed")+ },+ &metrics::FETCH_NETWORK_TOKEN_TIME,+ &[],+ )+ .await+ } else {+ Err(errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured)+ .inspect_err(|err| {+ logger::error!(error=? err);+ })+ .change_context(errors::ApiErrorResponse::InternalServerError)+ }?;++ let token_decrypted = pm_data+ .network_token_payment_method_data+ .clone()+ .map(|value| value.into_inner())+ .and_then(|payment_method_data| match payment_method_data {+ hyperswitch_domain_models::payment_method_data::PaymentMethodsData::NetworkToken(+ token,+ ) => Some(token),+ _ => None,+ })+ .ok_or(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Failed to obtain decrypted token object from db")?;++ let network_token_data = domain::NetworkTokenData {+ network_token: token_response.authentication_details.token,+ cryptogram: Some(token_response.authentication_details.cryptogram),+ network_token_exp_month: token_decrypted+ .network_token_expiry_month+ .unwrap_or(token_response.token_details.exp_month),+ network_token_exp_year: token_decrypted+ .network_token_expiry_year+ .unwrap_or(token_response.token_details.exp_year),+ card_holder_name: token_decrypted.card_holder_name,+ nick_name: token_decrypted.nick_name.or(token_response.nickname),+ card_issuer: token_decrypted.card_issuer.or(token_response.issuer),+ card_network: Some(token_response.network),+ card_type: token_decrypted+ .card_type+ .or(token_response.card_type)+ .as_ref()+ .map(|c| api_payment_methods::CardType::from_str(c))+ .transpose()+ .ok()+ .flatten(),+ card_issuing_country: token_decrypted.issuer_country,+ bank_code: None,+ eci: token_response.eci,+ };+ Ok(network_token_data)+}+#[cfg(feature = "v1")]pub async fn do_status_check_for_network_token(state: &routes::SessionState,diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex f75fb9ad7f..842416e7c1 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -1252,6 +1252,10 @@ impl PaymentMethods {.service(web::resource("/update-saved-payment-method").route(web::put().to(payment_methods::payment_method_update_api)),+ )+ .service(+ web::resource("/get-token")+ .route(web::get().to(payment_methods::get_payment_method_token_data)),),);diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rsindex 760a4bc890..53d7e3075f 100644--- a/crates/router/src/routes/lock_utils.rs+++ b/crates/router/src/routes/lock_utils.rs@@ -112,6 +112,7 @@ impl From<Flow> for ApiIdentifier {| Flow::PaymentMethodsMigrate| Flow::PaymentMethodsList| Flow::CustomerPaymentMethodsList+ | Flow::GetPaymentMethodTokenData| Flow::PaymentMethodsRetrieve| Flow::PaymentMethodsUpdate| Flow::PaymentMethodsDeletediff --git a/crates/router/src/routes/payment_methods.rs b/crates/router/src/routes/payment_methods.rsindex e513d2c954..d473936f34 100644--- a/crates/router/src/routes/payment_methods.rs+++ b/crates/router/src/routes/payment_methods.rs@@ -676,6 +676,48 @@ pub async fn list_customer_payment_method_api(.await}+#[cfg(all(feature = "v2", feature = "olap"))]+#[instrument(skip_all, fields(flow = ?Flow::GetPaymentMethodTokenData))]+pub async fn get_payment_method_token_data(+ state: web::Data<AppState>,+ req: HttpRequest,+ path: web::Path<id_type::GlobalPaymentMethodId>,+ json_payload: web::Json<api_models::payment_methods::GetTokenDataRequest>,+) -> HttpResponse {+ let flow = Flow::GetPaymentMethodTokenData;+ let payment_method_id = path.into_inner();+ let payload = json_payload.into_inner();++ Box::pin(api::server_wrap(+ flow,+ state,+ &req,+ payload,+ |state, auth: auth::AuthenticationData, req, _| {+ payment_methods_routes::get_token_data_for_payment_method(+ state,+ auth.merchant_account,+ auth.key_store,+ auth.profile,+ req,+ payment_method_id.clone(),+ )+ },+ auth::auth_type(+ &auth::V2ApiKeyAuth {+ is_connected_allowed: false,+ is_platform_allowed: false,+ },+ &auth::JWTAuth {+ permission: Permission::MerchantCustomerRead,+ },+ req.headers(),+ ),+ api_locking::LockAction::NotApplicable,+ ))+ .await+}+#[cfg(all(feature = "v2", feature = "olap"))]#[instrument(skip_all, fields(flow = ?Flow::TotalPaymentMethodCount))]pub async fn get_total_payment_method_count(diff --git a/crates/router/src/types/api/payment_methods.rs b/crates/router/src/types/api/payment_methods.rsindex 9c5030a30a..09dd783e48 100644--- a/crates/router/src/types/api/payment_methods.rs+++ b/crates/router/src/types/api/payment_methods.rs@@ -4,13 +4,14 @@ pub use api_models::payment_methods::{CardNetworkTokenizeResponse, CardType, CustomerPaymentMethod,CustomerPaymentMethodsListResponse, DeleteTokenizeByTokenRequest, GetTokenizePayloadRequest,GetTokenizePayloadResponse, ListCountriesCurrenciesRequest, MigrateCardDetail,- NetworkTokenDetailsPaymentMethod, NetworkTokenResponse, PaymentMethodCollectLinkRenderRequest,- PaymentMethodCollectLinkRequest, PaymentMethodCreate, PaymentMethodCreateData,- PaymentMethodDeleteResponse, PaymentMethodId, PaymentMethodIntentConfirm,- PaymentMethodIntentCreate, PaymentMethodListData, PaymentMethodListRequest,- PaymentMethodListResponse, PaymentMethodMigrate, PaymentMethodMigrateResponse,- PaymentMethodResponse, PaymentMethodResponseData, PaymentMethodUpdate, PaymentMethodUpdateData,- PaymentMethodsData, TokenizePayloadEncrypted, TokenizePayloadRequest, TokenizedCardValue1,+ NetworkTokenDetailsPaymentMethod, NetworkTokenDetailsResponse, NetworkTokenResponse,+ PaymentMethodCollectLinkRenderRequest, PaymentMethodCollectLinkRequest, PaymentMethodCreate,+ PaymentMethodCreateData, PaymentMethodDeleteResponse, PaymentMethodId,+ PaymentMethodIntentConfirm, PaymentMethodIntentCreate, PaymentMethodListData,+ PaymentMethodListRequest, PaymentMethodListResponse, PaymentMethodMigrate,+ PaymentMethodMigrateResponse, PaymentMethodResponse, PaymentMethodResponseData,+ PaymentMethodUpdate, PaymentMethodUpdateData, PaymentMethodsData, TokenDataResponse,+ TokenDetailsResponse, TokenizePayloadEncrypted, TokenizePayloadRequest, TokenizedCardValue1,TokenizedCardValue2, TokenizedWalletValue1, TokenizedWalletValue2,TotalPaymentMethodCountResponse,};diff --git a/crates/router/src/types/payment_methods.rs b/crates/router/src/types/payment_methods.rsindex a47beaecad..4ce568e064 100644--- a/crates/router/src/types/payment_methods.rs+++ b/crates/router/src/types/payment_methods.rs@@ -270,12 +270,21 @@ pub struct GetCardToken {pub card_reference: String,pub customer_id: id_type::GlobalCustomerId,}++#[cfg(feature = "v1")]#[derive(Debug, Deserialize)]pub struct AuthenticationDetails {pub cryptogram: Secret<String>,pub token: CardNumber, //network token}+#[cfg(feature = "v2")]+#[derive(Debug, Deserialize)]+pub struct AuthenticationDetails {+ pub cryptogram: Secret<String>,+ pub token: NetworkToken, //network token+}+#[derive(Debug, Serialize, Deserialize)]pub struct TokenDetails {pub exp_month: Secret<String>,@@ -287,6 +296,10 @@ pub struct TokenResponse {pub authentication_details: AuthenticationDetails,pub network: api_enums::CardNetwork,pub token_details: TokenDetails,+ pub eci: Option<String>,+ pub card_type: Option<String>,+ pub issuer: Option<String>,+ pub nickname: Option<Secret<String>>,}#[cfg(all(diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rsindex 6a4ad4bcab..6d57291a60 100644--- a/crates/router_env/src/logger/types.rs+++ b/crates/router_env/src/logger/types.rs@@ -124,6 +124,8 @@ pub enum Flow {PaymentMethodSave,/// Customer payment methods list flow.CustomerPaymentMethodsList,+ /// Payment methods token data get flow.+ GetPaymentMethodTokenData,/// List Customers for a merchantCustomersList,/// Retrieve countries and currencies for connector and payment method