Skip to content

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

feat(core): Support skipping PSP tokenization in payment and mandate flows (#10074)

awasthi215910322f91b6
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 93d21e1502..69d2f97101 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -26731,6 +26731,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -27243,6 +27251,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -27903,6 +27919,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -28763,6 +28787,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
},
"additionalProperties": false
@@ -29449,6 +29481,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -30094,6 +30134,14 @@
}
],
"nullable": true
+ },
+ "tokenization": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Tokenization"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -36485,6 +36533,14 @@
"network_token"
]
},
+ "Tokenization": {
+ "type": "string",
+ "description": "The type of tokenization to use for the payment method",
+ "enum": [
+ "skip_psp",
+ "tokenize_at_psp"
+ ]
+ },
"TokenizeCardRequest": {
"type": "object",
"required": [
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index acdae459ff..5810c02628 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -26816,6 +26816,14 @@
"payment_method_id"
]
},
+ "Tokenization": {
+ "type": "string",
+ "description": "The type of tokenization to use for the payment method",
+ "enum": [
+ "skip_psp",
+ "tokenize_at_psp"
+ ]
+ },
"TokenizationType": {
"type": "string",
"description": "The type of tokenization to use for the payment method",
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index bb21eb9aee..1f919811ab 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -1385,6 +1385,10 @@ pub struct PaymentsRequest {
/// Billing descriptor information for the payment
#[schema(value_type = Option<BillingDescriptor>)]
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+
+ /// The tokenization preference for the payment method. This is used to control whether a PSP token is created or not.
+ #[schema(value_type = Option<Tokenization>, example = "tokenize_at_psp")]
+ pub tokenization: Option<enums::Tokenization>,
}
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]
@@ -7126,6 +7130,10 @@ pub struct PaymentsResponse {
/// Billing descriptor information for the payment
#[schema(value_type = Option<BillingDescriptor>)]
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+
+ /// The tokenization preference for the payment method. This is used to control whether a PSP token is created or not.
+ #[schema(value_type = Option<Tokenization>,example="skip_psp")]
+ pub tokenization: Option<enums::Tokenization>,
}
#[cfg(feature = "v2")]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index c24e9a3196..2a79e73f24 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -8423,6 +8423,30 @@ pub enum VaultSdk {
HyperswitchSdk,
}
+/// The type of tokenization to use for the payment method
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::EnumString,
+ ToSchema,
+)]
+#[router_derive::diesel_enum(storage_type = "text")]
+#[serde(rename_all = "snake_case")]
+#[strum(serialize_all = "snake_case")]
+pub enum Tokenization {
+ /// Skip PSP-level tokenization
+ SkipPsp,
+ /// Tokenize at PSP Level
+ TokenizeAtPsp,
+}
+
#[derive(
Clone,
Debug,
diff --git a/crates/diesel_models/src/payment_attempt.rs b/crates/diesel_models/src/payment_attempt.rs
index 5f6e8d4f5a..7f4f668a39 100644
--- a/crates/diesel_models/src/payment_attempt.rs
+++ b/crates/diesel_models/src/payment_attempt.rs
@@ -112,6 +112,7 @@ pub struct PaymentAttempt {
pub authorized_amount: Option<MinorUnit>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ pub tokenization: Option<common_enums::Tokenization>,
#[diesel(deserialize_as = RequiredFromNullable<storage_enums::PaymentMethod>)]
pub payment_method_type_v2: storage_enums::PaymentMethod,
pub connector_payment_id: Option<ConnectorTransactionId>,
@@ -236,6 +237,7 @@ pub struct PaymentAttempt {
pub authorized_amount: Option<MinorUnit>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[cfg(feature = "v1")]
@@ -382,6 +384,7 @@ pub struct PaymentAttemptNew {
pub authorized_amount: Option<MinorUnit>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[cfg(feature = "v1")]
@@ -470,6 +473,7 @@ pub struct PaymentAttemptNew {
pub authorized_amount: Option<MinorUnit>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[cfg(feature = "v1")]
@@ -544,6 +548,7 @@ pub enum PaymentAttemptUpdate {
shipping_cost: Option<MinorUnit>,
order_tax_amount: Option<MinorUnit>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ tokenization: Option<common_enums::Tokenization>,
card_discovery: Option<storage_enums::CardDiscovery>,
routing_approach: Option<storage_enums::RoutingApproach>,
connector_request_reference_id: Option<String>,
@@ -562,6 +567,7 @@ pub enum PaymentAttemptUpdate {
},
ConnectorMandateDetailUpdate {
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ tokenization: Option<common_enums::Tokenization>,
updated_by: String,
},
BlocklistUpdate {
@@ -599,6 +605,7 @@ pub enum PaymentAttemptUpdate {
capture_before: Option<PrimitiveDateTime>,
extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ tokenization: Option<common_enums::Tokenization>,
payment_method_data: Option<serde_json::Value>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
charges: Option<common_types::payments::ConnectorChargeResponseData>,
@@ -1015,6 +1022,7 @@ impl PaymentAttemptUpdateInternal {
request_extended_authorization: source.request_extended_authorization,
extended_authorization_applied: source.extended_authorization_applied,
extended_authorization_last_applied_at: source.extended_authorization_last_applied_at,
+ tokenization: source.tokenization,
capture_before: source.capture_before,
card_discovery: source.card_discovery,
charges: source.charges,
@@ -1100,6 +1108,7 @@ pub struct PaymentAttemptUpdateInternal {
pub capture_before: Option<PrimitiveDateTime>,
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
+ pub tokenization: Option<common_enums::Tokenization>,
pub shipping_cost: Option<MinorUnit>,
pub order_tax_amount: Option<MinorUnit>,
pub connector_mandate_detail: Option<ConnectorMandateReferenceId>,
@@ -1302,6 +1311,7 @@ impl PaymentAttemptUpdate {
capture_before,
extended_authorization_applied,
extended_authorization_last_applied_at,
+ tokenization,
card_discovery,
charges,
issuer_error_code,
@@ -1393,6 +1403,7 @@ impl PaymentAttemptUpdate {
request_extended_authorization: request_extended_authorization
.or(source.request_extended_authorization),
authorized_amount: authorized_amount.or(source.authorized_amount),
+ tokenization: tokenization.or(source.tokenization),
..source
}
}
@@ -2722,6 +2733,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
processor_transaction_data: None,
connector_mandate_detail: None,
@@ -2794,6 +2806,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -2843,6 +2856,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
shipping_cost,
order_tax_amount,
connector_mandate_detail,
+ tokenization,
card_discovery,
routing_approach,
connector_request_reference_id,
@@ -2903,6 +2917,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
extended_authorization_last_applied_at: None,
processor_transaction_data: None,
connector_mandate_detail,
+ tokenization,
card_discovery,
charges: None,
issuer_error_code: None,
@@ -2975,6 +2990,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
extended_authorization_last_applied_at: None,
processor_transaction_data: None,
connector_mandate_detail: None,
+ tokenization: None,
card_discovery: None,
charges: None,
issuer_error_code: None,
@@ -3048,6 +3064,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
extended_authorization_last_applied_at: None,
processor_transaction_data: None,
connector_mandate_detail: None,
+ tokenization: None,
card_discovery: None,
charges: None,
issuer_error_code: None,
@@ -3121,6 +3138,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
extended_authorization_last_applied_at: None,
processor_transaction_data: None,
connector_mandate_detail: None,
+ tokenization: None,
card_discovery: None,
charges: None,
issuer_error_code: None,
@@ -3137,6 +3155,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
},
PaymentAttemptUpdate::ConnectorMandateDetailUpdate {
connector_mandate_detail,
+ tokenization,
updated_by,
} => Self {
payment_method_id: None,
@@ -3154,6 +3173,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
error_message: None,
cancellation_reason: None,
mandate_id: None,
+ tokenization,
browser_info: None,
payment_token: None,
error_code: None,
@@ -3261,6 +3281,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -3299,6 +3320,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before,
extended_authorization_applied,
extended_authorization_last_applied_at,
+ tokenization,
payment_method_data,
connector_mandate_detail,
charges,
@@ -3356,6 +3378,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
external_three_ds_authentication_attempted: None,
authentication_connector: None,
authentication_id: None,
+ tokenization,
fingerprint_id: None,
payment_method_billing_address_id: None,
client_source: None,
@@ -3456,6 +3479,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
shipping_cost: None,
order_tax_amount: None,
connector_mandate_detail: None,
@@ -3523,6 +3547,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
processor_transaction_data: None,
connector_mandate_detail: None,
@@ -3602,6 +3627,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
processor_transaction_data: None,
connector_mandate_detail: None,
@@ -3687,6 +3713,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -3769,6 +3796,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
shipping_cost: None,
order_tax_amount: None,
connector_mandate_detail: None,
@@ -3843,6 +3871,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -3914,6 +3943,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
processor_transaction_data: None,
connector_mandate_detail: None,
@@ -3997,6 +4027,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -4068,6 +4099,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -4142,6 +4174,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -4226,6 +4259,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
order_tax_amount: None,
connector_mandate_detail: None,
card_discovery: None,
@@ -4298,6 +4332,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
capture_before: None,
extended_authorization_applied: None,
extended_authorization_last_applied_at: None,
+ tokenization: None,
processor_transaction_data: None,
connector_mandate_detail: None,
card_discovery: None,
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index 41dddd9917..8eaab84449 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -82,6 +82,7 @@ pub struct PaymentIntent {
pub enable_overcapture: Option<common_types::primitive_wrappers::EnableOvercaptureBool>,
pub mit_category: Option<storage_enums::MitCategory>,
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+ pub tokenization: Option<common_enums::Tokenization>,
pub merchant_reference_id: Option<common_utils::id_type::PaymentReferenceId>,
pub billing_address: Option<Encryption>,
pub shipping_address: Option<Encryption>,
@@ -188,6 +189,7 @@ pub struct PaymentIntent {
pub enable_overcapture: Option<common_types::primitive_wrappers::EnableOvercaptureBool>,
pub mit_category: Option<storage_enums::MitCategory>,
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, diesel::AsExpression, PartialEq)]
@@ -395,6 +397,7 @@ pub struct PaymentIntentNew {
pub duty_amount: Option<MinorUnit>,
pub order_date: Option<PrimitiveDateTime>,
pub mit_category: Option<storage_enums::MitCategory>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[cfg(feature = "v1")]
@@ -481,6 +484,7 @@ pub struct PaymentIntentNew {
pub enable_overcapture: Option<common_types::primitive_wrappers::EnableOvercaptureBool>,
pub mit_category: Option<storage_enums::MitCategory>,
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[cfg(feature = "v2")]
@@ -829,6 +833,7 @@ impl PaymentIntentUpdateInternal {
enable_overcapture: None,
mit_category: None,
billing_descriptor: source.billing_descriptor,
+ tokenization: None,
}
}
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index a67ca03423..79b9e8502f 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -1090,6 +1090,8 @@ diesel::table! {
is_stored_credential -> Nullable<Bool>,
authorized_amount -> Nullable<Int8>,
extended_authorization_last_applied_at -> Nullable<Timestamp>,
+ #[max_length = 64]
+ tokenization -> Nullable<Varchar>,
}
}
@@ -1197,6 +1199,8 @@ diesel::table! {
#[max_length = 64]
mit_category -> Nullable<Varchar>,
billing_descriptor -> Nullable<Jsonb>,
+ #[max_length = 64]
+ tokenization -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 9d642dbe8c..acdcf5ea5c 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -1032,6 +1032,8 @@ diesel::table! {
is_stored_credential -> Nullable<Bool>,
authorized_amount -> Nullable<Int8>,
extended_authorization_last_applied_at -> Nullable<Timestamp>,
+ #[max_length = 64]
+ tokenization -> Nullable<Varchar>,
payment_method_type_v2 -> Nullable<Varchar>,
#[max_length = 128]
connector_payment_id -> Nullable<Varchar>,
@@ -1132,6 +1134,8 @@ diesel::table! {
mit_category -> Nullable<Varchar>,
billing_descriptor -> Nullable<Jsonb>,
#[max_length = 64]
+ tokenization -> Nullable<Varchar>,
+ #[max_length = 64]
merchant_reference_id -> Nullable<Varchar>,
billing_address -> Nullable<Bytea>,
shipping_address -> Nullable<Bytea>,
diff --git a/crates/diesel_models/src/user/sample_data.rs b/crates/diesel_models/src/user/sample_data.rs
index b1e108ae41..3b28454798 100644
--- a/crates/diesel_models/src/user/sample_data.rs
+++ b/crates/diesel_models/src/user/sample_data.rs
@@ -211,6 +211,7 @@ pub struct PaymentAttemptBatchNew {
pub connector_mandate_detail: Option<ConnectorMandateReferenceId>,
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
+ pub tokenization: Option<common_enums::Tokenization>,
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
pub capture_before: Option<PrimitiveDateTime>,
pub card_discovery: Option<common_enums::CardDiscovery>,
@@ -315,6 +316,7 @@ impl PaymentAttemptBatchNew {
network_details: self.network_details,
is_stored_credential: self.is_stored_credential,
authorized_amount: self.authorized_amount,
+ tokenization: self.tokenization,
}
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
index 1c9ca14e3c..11bca71bbc 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
@@ -149,25 +149,44 @@ impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest {
};
let connector_merchant_config =
CybersourceConnectorMetadataObject::try_from(&item.connector_meta_data)?;
-
- let (action_list, action_token_types, authorization_options) = (
- Some(vec![CybersourceActionsList::TokenCreate]),
- Some(vec![
- CybersourceActionsTokenType::PaymentInstrument,
- CybersourceActionsTokenType::Customer,
- ]),
- Some(CybersourceAuthorizationOptions {
- initiator: Some(CybersourcePaymentInitiator {
- initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
- credential_stored_on_file: Some(true),
- stored_credential_used: None,
- }),
- merchant_initiated_transaction: None,
- ignore_avs_result: connector_merchant_config.disable_avs,
- ignore_cv_result: connector_merchant_config.disable_cvn,
- }),
+ let skip_psp_tokenization = matches!(
+ item.request.tokenization,
+ Some(common_enums::Tokenization::SkipPsp)
);
-
+ let (action_list, action_token_types, authorization_options) = if skip_psp_tokenization {
+ (
+ None,
+ None,
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(false),
+ stored_credential_used: None,
+ }),
+ merchant_initiated_transaction: None,
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
+ }),
+ )
+ } else {
+ (
+ Some(vec![CybersourceActionsList::TokenCreate]),
+ Some(vec![
+ CybersourceActionsTokenType::PaymentInstrument,
+ CybersourceActionsTokenType::Customer,
+ ]),
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(true),
+ stored_credential_used: None,
+ }),
+ merchant_initiated_transaction: None,
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
+ }),
+ )
+ };
let client_reference_information = ClientReferenceInformation {
code: Some(item.connector_request_reference_id.clone()),
};
@@ -816,23 +835,45 @@ impl
.clone()
.is_some_and(|mandate_details| mandate_details.customer_acceptance.is_some()))
{
- (
- Some(vec![CybersourceActionsList::TokenCreate]),
- Some(vec![
- CybersourceActionsTokenType::PaymentInstrument,
- CybersourceActionsTokenType::Customer,
- ]),
- Some(CybersourceAuthorizationOptions {
- initiator: Some(CybersourcePaymentInitiator {
- initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
- credential_stored_on_file: Some(true),
- stored_credential_used: None,
+ let skip_psp_tokenization = matches!(
+ item.router_data.request.tokenization,
+ Some(common_enums::Tokenization::SkipPsp)
+ );
+ if skip_psp_tokenization {
+ // COMPLETELY SKIP TOKENIZATION - don't send any tokenization fields
+ (
+ None,
+ None,
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(false),
+ stored_credential_used: None,
+ }),
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
+ merchant_initiated_transaction: None,
}),
- ignore_avs_result: connector_merchant_config.disable_avs,
- ignore_cv_result: connector_merchant_config.disable_cvn,
- merchant_initiated_transaction: None,
- }),
- )
+ )
+ } else {
+ (
+ Some(vec![CybersourceActionsList::TokenCreate]),
+ Some(vec![
+ CybersourceActionsTokenType::PaymentInstrument,
+ CybersourceActionsTokenType::Customer,
+ ]),
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(true),
+ stored_credential_used: None,
+ }),
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
+ merchant_initiated_transaction: None,
+ }),
+ )
+ }
} else if item.router_data.request.mandate_id.is_some() {
match item
.router_data
@@ -1136,23 +1177,44 @@ impl
if item.router_data.request.setup_future_usage == Some(FutureUsage::OffSession)
//TODO check for customer acceptance also
{
- (
- Some(vec![CybersourceActionsList::TokenCreate]),
- Some(vec![
- CybersourceActionsTokenType::PaymentInstrument,
- CybersourceActionsTokenType::Customer,
- ]),
- Some(CybersourceAuthorizationOptions {
- initiator: Some(CybersourcePaymentInitiator {
- initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
- credential_stored_on_file: Some(true),
- stored_credential_used: None,
+ let skip_psp_tokenization = matches!(
+ item.router_data.request.tokenization,
+ Some(common_enums::Tokenization::SkipPsp)
+ );
+ if skip_psp_tokenization {
+ (
+ None,
+ None,
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(false),
+ stored_credential_used: None,
+ }),
+ merchant_initiated_transaction: None,
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
}),
- merchant_initiated_transaction: None,
- ignore_avs_result: connector_merchant_config.disable_avs,
- ignore_cv_result: connector_merchant_config.disable_cvn,
- }),
- )
+ )
+ } else {
+ (
+ Some(vec![CybersourceActionsList::TokenCreate]),
+ Some(vec![
+ CybersourceActionsTokenType::PaymentInstrument,
+ CybersourceActionsTokenType::Customer,
+ ]),
+ Some(CybersourceAuthorizationOptions {
+ initiator: Some(CybersourcePaymentInitiator {
+ initiator_type: Some(CybersourcePaymentInitiatorTypes::Customer),
+ credential_stored_on_file: Some(true),
+ stored_credential_used: None,
+ }),
+ merchant_initiated_transaction: None,
+ ignore_avs_result: connector_merchant_config.disable_avs,
+ ignore_cv_result: connector_merchant_config.disable_cvn,
+ }),
+ )
+ }
} else {
(None, None, None)
};
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index d3693f3cd3..577142f1c2 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -7081,6 +7081,7 @@ pub(crate) fn convert_setup_mandate_router_data_to_authorize_router_data(
is_stored_credential: data.request.is_stored_credential,
mit_category: None,
billing_descriptor: data.request.billing_descriptor.clone(),
+ tokenization: None,
}
}
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index 8d01070bb3..c89109d649 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -132,6 +132,7 @@ pub struct PaymentIntent {
pub enable_overcapture: Option<EnableOvercaptureBool>,
pub mit_category: Option<common_enums::MitCategory>,
pub billing_descriptor: Option<BillingDescriptor>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
impl PaymentIntent {
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index d4bbbb27d8..ba4c8fe73b 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -1026,6 +1026,7 @@ pub struct PaymentAttempt {
pub profile_id: id_type::ProfileId,
pub organization_id: id_type::OrganizationId,
pub connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ pub tokenization: Option<common_enums::Tokenization>,
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
pub extended_authorization_last_applied_at: Option<PrimitiveDateTime>,
@@ -1256,6 +1257,18 @@ impl PaymentAttempt {
.ok()
.flatten()
}
+ pub fn get_tokenization_strategy(&self) -> Option<common_enums::Tokenization> {
+ match self.setup_future_usage_applied {
+ Some(common_enums::FutureUsage::OnSession) | None => None,
+ Some(common_enums::FutureUsage::OffSession) => Some(
+ self.connector_mandate_detail
+ .as_ref()
+ .and_then(|detail| detail.connector_mandate_id.as_ref())
+ .map(|_| common_enums::Tokenization::TokenizeAtPsp)
+ .unwrap_or(common_enums::Tokenization::SkipPsp),
+ ),
+ }
+ }
}
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -1333,6 +1346,7 @@ pub struct PaymentAttemptNew {
pub profile_id: id_type::ProfileId,
pub organization_id: id_type::OrganizationId,
pub connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ pub tokenization: Option<common_enums::Tokenization>,
pub request_extended_authorization: Option<RequestExtendedAuthorizationBool>,
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
pub capture_before: Option<PrimitiveDateTime>,
@@ -1417,6 +1431,7 @@ pub enum PaymentAttemptUpdate {
client_version: Option<String>,
customer_acceptance: Option<pii::SecretSerdeValue>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ tokenization: Option<common_enums::Tokenization>,
card_discovery: Option<common_enums::CardDiscovery>,
routing_approach: Option<storage_enums::RoutingApproach>,
connector_request_reference_id: Option<String>,
@@ -1442,6 +1457,7 @@ pub enum PaymentAttemptUpdate {
},
ConnectorMandateDetailUpdate {
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ tokenization: Option<common_enums::Tokenization>,
updated_by: String,
},
VoidUpdate {
@@ -1474,6 +1490,7 @@ pub enum PaymentAttemptUpdate {
extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
payment_method_data: Option<serde_json::Value>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
+ tokenization: Option<common_enums::Tokenization>,
charges: Option<common_types::payments::ConnectorChargeResponseData>,
setup_future_usage_applied: Option<storage_enums::FutureUsage>,
debit_routing_savings: Option<MinorUnit>,
@@ -1658,9 +1675,11 @@ impl PaymentAttemptUpdate {
},
Self::ConnectorMandateDetailUpdate {
connector_mandate_detail,
+ tokenization,
updated_by,
} => DieselPaymentAttemptUpdate::ConnectorMandateDetailUpdate {
connector_mandate_detail,
+ tokenization,
updated_by,
},
Self::PaymentMethodDetailsUpdate {
@@ -1699,6 +1718,7 @@ impl PaymentAttemptUpdate {
client_version,
customer_acceptance,
connector_mandate_detail,
+ tokenization,
card_discovery,
routing_approach,
connector_request_reference_id,
@@ -1738,6 +1758,7 @@ impl PaymentAttemptUpdate {
shipping_cost: net_amount.get_shipping_cost(),
order_tax_amount: net_amount.get_order_tax_amount(),
connector_mandate_detail,
+ tokenization,
card_discovery,
routing_approach: routing_approach.map(|approach| match approach {
// we need to make sure Other variant is not stored in DB, in the rare case
@@ -1785,6 +1806,7 @@ impl PaymentAttemptUpdate {
extended_authorization_last_applied_at,
payment_method_data,
connector_mandate_detail,
+ tokenization,
charges,
setup_future_usage_applied,
network_transaction_id,
@@ -1815,6 +1837,7 @@ impl PaymentAttemptUpdate {
extended_authorization_last_applied_at,
payment_method_data,
connector_mandate_detail,
+ tokenization,
charges,
setup_future_usage_applied,
network_transaction_id,
@@ -2189,6 +2212,7 @@ impl behaviour::Conversion for PaymentAttempt {
order_tax_amount: self.net_amount.get_order_tax_amount(),
shipping_cost: self.net_amount.get_shipping_cost(),
connector_mandate_detail: self.connector_mandate_detail,
+ tokenization: self.tokenization,
request_extended_authorization: self.request_extended_authorization,
extended_authorization_applied: self.extended_authorization_applied,
extended_authorization_last_applied_at: self.extended_authorization_last_applied_at,
@@ -2291,6 +2315,7 @@ impl behaviour::Conversion for PaymentAttempt {
profile_id: storage_model.profile_id,
organization_id: storage_model.organization_id,
connector_mandate_detail: storage_model.connector_mandate_detail,
+ tokenization: storage_model.tokenization,
request_extended_authorization: storage_model.request_extended_authorization,
extended_authorization_applied: storage_model.extended_authorization_applied,
extended_authorization_last_applied_at: storage_model
@@ -2396,6 +2421,7 @@ impl behaviour::Conversion for PaymentAttempt {
order_tax_amount: self.net_amount.get_order_tax_amount(),
shipping_cost: self.net_amount.get_shipping_cost(),
connector_mandate_detail: self.connector_mandate_detail,
+ tokenization: self.tokenization,
request_extended_authorization: self.request_extended_authorization,
extended_authorization_applied: self.extended_authorization_applied,
extended_authorization_last_applied_at: self.extended_authorization_last_applied_at,
@@ -2587,6 +2613,7 @@ impl behaviour::Conversion for PaymentAttempt {
attempts_group_id,
is_stored_credential: None,
authorized_amount,
+ tokenization: None,
})
}
@@ -2870,6 +2897,7 @@ impl behaviour::Conversion for PaymentAttempt {
created_by: created_by.map(|cb| cb.to_string()),
connector_request_reference_id,
network_details: None,
+ tokenization: None,
attempts_group_id,
is_stored_credential: None,
authorized_amount,
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 387d263cf1..c808560fb7 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -1983,6 +1983,7 @@ impl behaviour::Conversion for PaymentIntent {
enable_overcapture: None,
mit_category: None,
billing_descriptor: None,
+ tokenization: None,
})
}
async fn convert_back(
@@ -2240,6 +2241,7 @@ impl behaviour::Conversion for PaymentIntent {
duty_amount: None,
order_date: None,
enable_partial_authorization: self.enable_partial_authorization,
+ tokenization: None,
})
}
}
@@ -2325,6 +2327,7 @@ impl behaviour::Conversion for PaymentIntent {
enable_overcapture: self.enable_overcapture,
mit_category: self.mit_category,
billing_descriptor: self.billing_descriptor,
+ tokenization: self.tokenization,
})
}
@@ -2436,6 +2439,7 @@ impl behaviour::Conversion for PaymentIntent {
enable_overcapture: storage_model.enable_overcapture,
mit_category: storage_model.mit_category,
billing_descriptor: storage_model.billing_descriptor,
+ tokenization: storage_model.tokenization,
})
}
.await
@@ -2519,6 +2523,7 @@ impl behaviour::Conversion for PaymentIntent {
enable_overcapture: self.enable_overcapture,
mit_category: self.mit_category,
billing_descriptor: self.billing_descriptor,
+ tokenization: self.tokenization,
})
}
}
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index f6cb115a5e..d7b2419868 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -94,6 +94,7 @@ pub struct PaymentsAuthorizeData {
pub is_stored_credential: Option<bool>,
pub mit_category: Option<common_enums::MitCategory>,
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[derive(Debug, Clone, Serialize)]
@@ -821,6 +822,7 @@ pub struct CompleteAuthorizeData {
pub merchant_config_currency: Option<storage_enums::Currency>,
pub threeds_method_comp_ind: Option<api_models::payments::ThreeDsCompletionIndicator>,
pub is_stored_credential: Option<bool>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[derive(Debug, Clone, Serialize)]
@@ -1465,6 +1467,7 @@ pub struct SetupMandateRequestData {
pub is_stored_credential: Option<bool>,
pub billing_descriptor: Option<common_types::payments::BillingDescriptor>,
pub split_payments: Option<common_types::payments::SplitPaymentsRequest>,
+ pub tokenization: Option<common_enums::Tokenization>,
}
#[derive(Debug, Clone)]
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index db907cd2c8..f30d269aff 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -740,6 +740,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::EventClass,
api_models::enums::EventType,
api_models::enums::DecoupledAuthenticationType,
+ api_models::enums::Tokenization,
api_models::enums::AuthenticationStatus,
api_models::admin::MerchantAccountResponse,
api_models::admin::MerchantConnectorId,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index 74adf7cbb5..07652ca621 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -699,6 +699,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::EventClass,
api_models::enums::EventType,
api_models::enums::DecoupledAuthenticationType,
+ api_models::enums::Tokenization,
api_models::enums::AuthenticationStatus,
api_models::enums::UpdateActiveAttempt,
api_models::admin::MerchantAccountResponse,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index dc8a7ad415..9081e51454 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4108,6 +4108,7 @@ mod tests {
shipping_address_id: None,
billing_address_id: None,
mit_category: None,
+ tokenization: None,
statement_descriptor_name: None,
statement_descriptor_suffix: None,
created_at: common_utils::date_time::now(),
@@ -4258,6 +4259,7 @@ mod tests {
enable_partial_authorization: None,
enable_overcapture: None,
billing_descriptor: None,
+ tokenization: None,
};
let req_cs = Some("1".to_string());
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent,).is_err())
@@ -4278,6 +4280,7 @@ mod tests {
metadata: None,
connector_id: None,
mit_category: None,
+ tokenization: None,
shipping_address_id: None,
billing_address_id: None,
statement_descriptor_name: None,
@@ -4861,6 +4864,7 @@ impl AttemptType {
network_details: None,
is_stored_credential: old_payment_attempt.is_stored_credential,
authorized_amount: old_payment_attempt.authorized_amount,
+ tokenization: None,
}
}
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 758d63726f..43f9e24a83 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1982,7 +1982,10 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
payment_method_id: m_payment_method_id,
client_source,
client_version,
- customer_acceptance: payment_data.payment_attempt.customer_acceptance,
+ customer_acceptance: payment_data
+ .payment_attempt
+ .customer_acceptance
+ .clone(),
net_amount:
hyperswitch_domain_models::payments::payment_attempt::NetAmount::new(
payment_data.payment_attempt.net_amount.get_order_amount(),
@@ -1997,9 +2000,10 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
connector_mandate_detail: payment_data
.payment_attempt
- .connector_mandate_detail,
+ .connector_mandate_detail
+ .clone(),
card_discovery,
- routing_approach: payment_data.payment_attempt.routing_approach,
+ routing_approach: payment_data.payment_attempt.routing_approach.clone(),
connector_request_reference_id,
network_transaction_id: payment_data
.payment_attempt
@@ -2009,6 +2013,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for
request_extended_authorization: payment_data
.payment_attempt
.request_extended_authorization,
+ tokenization: payment_data.payment_attempt.get_tokenization_strategy(),
},
storage_scheme,
)
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index f7a4be399c..89126c93f5 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1430,6 +1430,7 @@ impl PaymentCreate {
network_details:None,
is_stored_credential,
authorized_amount: None,
+ tokenization:request.tokenization
},
additional_pm_data,
@@ -1676,6 +1677,7 @@ impl PaymentCreate {
enable_overcapture: request.enable_overcapture,
mit_category: request.mit_category,
billing_descriptor: request.billing_descriptor.clone(),
+ tokenization: request.tokenization,
})
}
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index ddf93d51c2..903b4f9519 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -1990,6 +1990,10 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
network_transaction_id: resp_network_transaction_id,
is_overcapture_enabled,
authorized_amount: router_data.authorized_amount,
+ tokenization: payment_data
+ .payment_attempt
+ .clone()
+ .get_tokenization_strategy(),
}),
),
};
diff --git a/crates/router/src/core/payments/retry.rs b/crates/router/src/core/payments/retry.rs
index 044afee01f..341daba0d5 100644
--- a/crates/router/src/core/payments/retry.rs
+++ b/crates/router/src/core/payments/retry.rs
@@ -550,6 +550,7 @@ where
.clone(),
is_overcapture_enabled: None,
authorized_amount: router_data.authorized_amount,
+ tokenization: None,
};
#[cfg(feature = "v1")]
@@ -754,6 +755,7 @@ pub fn make_new_payment_attempt(
network_details: Default::default(),
is_stored_credential: old_payment_attempt.is_stored_credential,
authorized_amount: old_payment_attempt.authorized_amount,
+ tokenization: Default::default(),
}
}
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index c183d02135..105bc9bd2c 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -453,6 +453,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
order_id: None,
locale: None,
mit_category: None,
+ tokenization: None,
payment_channel: None,
enable_partial_authorization: payment_data.payment_intent.enable_partial_authorization,
enable_overcapture: None,
@@ -1506,6 +1507,7 @@ pub async fn construct_payment_router_data_for_setup_mandate<'a>(
mandate_id: None,
setup_future_usage: Some(payment_data.payment_intent.setup_future_usage),
off_session: None,
+ tokenization: None,
setup_mandate_details: None,
router_return_url: Some(router_return_url.clone()),
webhook_url,
@@ -3897,6 +3899,7 @@ where
order_tax_amount,
connector_mandate_id,
mit_category: payment_intent.mit_category,
+ tokenization: payment_intent.tokenization,
shipping_cost: payment_intent.shipping_cost,
capture_before: payment_attempt.capture_before,
extended_authorization_applied: payment_attempt.extended_authorization_applied,
@@ -4221,6 +4224,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
shipping_cost: None,
card_discovery: pa.card_discovery,
mit_category: pi.mit_category,
+ tokenization:pi.tokenization,
force_3ds_challenge: pi.force_3ds_challenge,
force_3ds_challenge_trigger: pi.force_3ds_challenge_trigger,
whole_connector_response: None,
@@ -4565,6 +4569,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
connector_testing_data: None,
order_id: None,
mit_category: None,
+ tokenization: None,
locale: None,
payment_channel: None,
enable_partial_authorization: None,
@@ -4806,6 +4811,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
merchant_config_currency,
connector_testing_data,
mit_category: payment_data.payment_intent.mit_category,
+ tokenization: payment_data.payment_intent.tokenization,
order_id: None,
locale: Some(additional_data.state.locale.clone()),
payment_channel: payment_data.payment_intent.payment_channel,
@@ -5833,6 +5839,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::SetupMandateRequ
is_stored_credential: payment_data.payment_attempt.is_stored_credential,
billing_descriptor,
split_payments: payment_data.payment_intent.split_payments.clone(),
+ tokenization: payment_data.payment_intent.tokenization,
})
}
}
@@ -5983,6 +5990,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::CompleteAuthoriz
.as_ref()
.map(router_request_types::UcsAuthenticationData::foreign_try_from)
.transpose()?,
+ tokenization: payment_data.payment_intent.tokenization,
})
}
}
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index b61e85fd8f..bebdfc344d 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -2881,6 +2881,7 @@ async fn update_connector_mandate_details(
let attempt_update =
storage::PaymentAttemptUpdate::ConnectorMandateDetailUpdate {
connector_mandate_detail: Some(connector_mandate_reference_id),
+ tokenization: None, // We need to handle tokenization field update in webhooks as well
updated_by: merchant_context
.get_merchant_account()
.storage_scheme
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index 49b1869b36..c8724addf9 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -1410,6 +1410,7 @@ mod tests {
shipping_cost: None,
card_discovery: None,
mit_category: None,
+ tokenization: None,
force_3ds_challenge: None,
force_3ds_challenge_trigger: None,
issuer_error_code: None,
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index aeb71d9955..726961cd88 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -1319,6 +1319,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
is_stored_credential: data.request.is_stored_credential,
mit_category: None,
billing_descriptor: data.request.billing_descriptor.clone(),
+ tokenization: None,
}
}
}
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index 0177f19d63..7e2ad8189c 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -70,6 +70,7 @@ impl VerifyConnectorData {
is_stored_credential: None,
mit_category: None,
billing_descriptor: None,
+ tokenization: None,
}
}
diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs
index dbcbec6df6..66e5b60022 100644
--- a/crates/router/src/types/storage/payment_attempt.rs
+++ b/crates/router/src/types/storage/payment_attempt.rs
@@ -231,6 +231,7 @@ mod tests {
network_details: Default::default(),
is_stored_credential: None,
authorized_amount: Default::default(),
+ tokenization: Default::default(),
};
let store = state
@@ -328,6 +329,7 @@ mod tests {
network_details: Default::default(),
is_stored_credential: Default::default(),
authorized_amount: Default::default(),
+ tokenization: Default::default(),
};
let store = state
.stores
@@ -438,6 +440,7 @@ mod tests {
network_details: Default::default(),
is_stored_credential: Default::default(),
authorized_amount: Default::default(),
+ tokenization: Default::default(),
};
let store = state
.stores
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index 3265cd0db5..9d8e5d5384 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -300,6 +300,7 @@ pub async fn generate_sample_data(
enable_overcapture: None,
mit_category: None,
billing_descriptor: None,
+ tokenization: None,
};
let (connector_transaction_id, processor_transaction_data) =
ConnectorTransactionId::form_id_and_data(attempt_id.clone());
@@ -399,6 +400,7 @@ pub async fn generate_sample_data(
network_details: None,
is_stored_credential: None,
authorized_amount: None,
+ tokenization: None,
};
let refund = if refunds_count < number_of_refunds && !is_failed_payment {
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index c59a1fa500..0619da8727 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -1012,6 +1012,7 @@ impl Default for PaymentAuthorizeType {
is_stored_credential: None,
mit_category: None,
billing_descriptor: None,
+ tokenization: None,
};
Self(data)
}
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index faddc51c70..c261f5c124 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -443,6 +443,7 @@ async fn payments_create_core() {
expires_on: None,
fingerprint: None,
mit_category: None,
+ tokenization: None,
browser_info: None,
payment_method_id: None,
payment_method_status: None,
@@ -735,6 +736,7 @@ async fn payments_create_core_adyen_no_redirect() {
fingerprint: None,
browser_info: None,
mit_category: None,
+ tokenization: None,
payment_method_id: None,
payment_method_status: None,
updated: None,
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 82044a1839..2e6d81a207 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -215,6 +215,7 @@ async fn payments_create_core() {
order_tax_amount: None,
connector_mandate_id: None,
mit_category: None,
+ tokenization: None,
shipping_cost: None,
card_discovery: None,
force_3ds_challenge: None,
@@ -513,6 +514,7 @@ async fn payments_create_core_adyen_no_redirect() {
extended_authorization_last_applied_at: None,
order_tax_amount: None,
mit_category: None,
+ tokenization: None,
connector_mandate_id: None,
shipping_cost: None,
card_discovery: None,
diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs
index ffea612ebb..19137a5fa2 100644
--- a/crates/storage_impl/src/mock_db/payment_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs
@@ -245,6 +245,7 @@ impl PaymentAttemptInterface for MockDb {
network_details: payment_attempt.network_details,
is_stored_credential: payment_attempt.is_stored_credential,
authorized_amount: payment_attempt.authorized_amount,
+ tokenization: payment_attempt.tokenization,
};
payment_attempts.push(payment_attempt.clone());
Ok(payment_attempt)
diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs
index 456513e634..0b10a093b9 100644
--- a/crates/storage_impl/src/payments/payment_attempt.rs
+++ b/crates/storage_impl/src/payments/payment_attempt.rs
@@ -699,6 +699,7 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
network_details: payment_attempt.network_details.clone(),
is_stored_credential: payment_attempt.is_stored_credential,
authorized_amount: payment_attempt.authorized_amount,
+ tokenization: payment_attempt.tokenization,
};
let field = format!("pa_{}", created_attempt.attempt_id);
@@ -1913,6 +1914,7 @@ impl DataModelExt for PaymentAttempt {
network_details: self.network_details,
is_stored_credential: self.is_stored_credential,
authorized_amount: self.authorized_amount,
+ tokenization: self.tokenization,
}
}
@@ -2013,6 +2015,7 @@ impl DataModelExt for PaymentAttempt {
network_details: storage_model.network_details,
is_stored_credential: storage_model.is_stored_credential,
authorized_amount: storage_model.authorized_amount,
+ tokenization: storage_model.tokenization,
}
}
}
@@ -2109,6 +2112,7 @@ impl DataModelExt for PaymentAttemptNew {
network_details: self.network_details,
is_stored_credential: self.is_stored_credential,
authorized_amount: self.authorized_amount,
+ tokenization: self.tokenization,
}
}
@@ -2199,6 +2203,7 @@ impl DataModelExt for PaymentAttemptNew {
network_details: storage_model.network_details,
is_stored_credential: storage_model.is_stored_credential,
authorized_amount: storage_model.authorized_amount,
+ tokenization: storage_model.tokenization,
}
}
}
diff --git a/migrations/2025-11-12-043628_add_tokenization_payment_intent/down.sql b/migrations/2025-11-12-043628_add_tokenization_payment_intent/down.sql
new file mode 100644
index 0000000000..a103c8f042
--- /dev/null
+++ b/migrations/2025-11-12-043628_add_tokenization_payment_intent/down.sql
@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payment_intent
+DROP COLUMN IF EXISTS tokenization;
\ No newline at end of file
diff --git a/migrations/2025-11-12-043628_add_tokenization_payment_intent/up.sql b/migrations/2025-11-12-043628_add_tokenization_payment_intent/up.sql
new file mode 100644
index 0000000000..2eae2fc874
--- /dev/null
+++ b/migrations/2025-11-12-043628_add_tokenization_payment_intent/up.sql
@@ -0,0 +1,3 @@
+-- Add skip_psp_tokenization column to payment_intent table
+ALTER TABLE payment_intent
+ADD COLUMN IF NOT EXISTS tokenization VARCHAR(64);
\ No newline at end of file
diff --git a/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/down.sql b/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/down.sql
new file mode 100644
index 0000000000..9877da5eb9
--- /dev/null
+++ b/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/down.sql
@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payment_attempt
+DROP COLUMN IF EXISTS tokenization;
\ No newline at end of file
diff --git a/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/up.sql b/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/up.sql
new file mode 100644
index 0000000000..251299143f
--- /dev/null
+++ b/migrations/2025-11-12-075136_add_tokenization_field_in_payment_attempt/up.sql
@@ -0,0 +1,3 @@
+-- Add skip_psp_tokenization column to payment_intent table
+ALTER TABLE payment_attempt
+ADD COLUMN IF NOT EXISTS tokenization VARCHAR(64);
\ No newline at end of file