feat(router): add payment method-specific features to connector feature list (#6963)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2025-01-21 13:33:09 +05:30
committed by GitHub
parent d35a922281
commit e35f7079e3
10 changed files with 229 additions and 93 deletions

View File

@ -6393,6 +6393,29 @@
} }
} }
}, },
"CardSpecificFeatures": {
"type": "object",
"required": [
"three_ds",
"non_three_ds",
"supported_card_networks"
],
"properties": {
"three_ds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"non_three_ds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"supported_card_networks": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CardNetwork"
},
"description": "List of supported card networks"
}
}
},
"CardToken": { "CardToken": {
"type": "object", "type": "object",
"required": [ "required": [
@ -14117,6 +14140,13 @@
} }
] ]
}, },
"PaymentMethodSpecificFeatures": {
"oneOf": [
{
"$ref": "#/components/schemas/CardSpecificFeatures"
}
]
},
"PaymentMethodStatus": { "PaymentMethodStatus": {
"type": "string", "type": "string",
"description": "Payment Method Status", "description": "Payment Method Status",
@ -20580,50 +20610,62 @@
"additionalProperties": false "additionalProperties": false
}, },
"SupportedPaymentMethod": { "SupportedPaymentMethod": {
"type": "object", "allOf": [
"required": [ {
"payment_method", "allOf": [
"payment_method_type", {
"mandates", "$ref": "#/components/schemas/PaymentMethodSpecificFeatures"
"refunds", }
"supported_capture_methods" ],
], "nullable": true
"properties": {
"payment_method": {
"$ref": "#/components/schemas/PaymentMethod"
}, },
"payment_method_type": { {
"$ref": "#/components/schemas/PaymentMethodType" "type": "object",
}, "required": [
"mandates": { "payment_method",
"$ref": "#/components/schemas/FeatureStatus" "payment_method_type",
}, "mandates",
"refunds": { "refunds",
"$ref": "#/components/schemas/FeatureStatus" "supported_capture_methods"
}, ],
"supported_capture_methods": { "properties": {
"type": "array", "payment_method": {
"items": { "$ref": "#/components/schemas/PaymentMethod"
"$ref": "#/components/schemas/CaptureMethod" },
"payment_method_type": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"mandates": {
"$ref": "#/components/schemas/FeatureStatus"
},
"refunds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"supported_capture_methods": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CaptureMethod"
}
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
},
"uniqueItems": true,
"nullable": true
},
"supported_currencies": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Currency"
},
"uniqueItems": true,
"nullable": true
}
} }
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
},
"uniqueItems": true,
"nullable": true
},
"supported_currencies": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Currency"
},
"uniqueItems": true,
"nullable": true
} }
} ]
}, },
"SurchargeCalculationOverride": { "SurchargeCalculationOverride": {
"type": "string", "type": "string",

View File

@ -9053,6 +9053,29 @@
} }
} }
}, },
"CardSpecificFeatures": {
"type": "object",
"required": [
"three_ds",
"non_three_ds",
"supported_card_networks"
],
"properties": {
"three_ds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"non_three_ds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"supported_card_networks": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CardNetwork"
},
"description": "List of supported card networks"
}
}
},
"CardToken": { "CardToken": {
"type": "object", "type": "object",
"required": [ "required": [
@ -17190,6 +17213,13 @@
} }
} }
}, },
"PaymentMethodSpecificFeatures": {
"oneOf": [
{
"$ref": "#/components/schemas/CardSpecificFeatures"
}
]
},
"PaymentMethodStatus": { "PaymentMethodStatus": {
"type": "string", "type": "string",
"description": "Payment Method Status", "description": "Payment Method Status",
@ -25176,50 +25206,62 @@
} }
}, },
"SupportedPaymentMethod": { "SupportedPaymentMethod": {
"type": "object", "allOf": [
"required": [ {
"payment_method", "allOf": [
"payment_method_type", {
"mandates", "$ref": "#/components/schemas/PaymentMethodSpecificFeatures"
"refunds", }
"supported_capture_methods" ],
], "nullable": true
"properties": {
"payment_method": {
"$ref": "#/components/schemas/PaymentMethod"
}, },
"payment_method_type": { {
"$ref": "#/components/schemas/PaymentMethodType" "type": "object",
}, "required": [
"mandates": { "payment_method",
"$ref": "#/components/schemas/FeatureStatus" "payment_method_type",
}, "mandates",
"refunds": { "refunds",
"$ref": "#/components/schemas/FeatureStatus" "supported_capture_methods"
}, ],
"supported_capture_methods": { "properties": {
"type": "array", "payment_method": {
"items": { "$ref": "#/components/schemas/PaymentMethod"
"$ref": "#/components/schemas/CaptureMethod" },
"payment_method_type": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"mandates": {
"$ref": "#/components/schemas/FeatureStatus"
},
"refunds": {
"$ref": "#/components/schemas/FeatureStatus"
},
"supported_capture_methods": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CaptureMethod"
}
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
},
"uniqueItems": true,
"nullable": true
},
"supported_currencies": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Currency"
},
"uniqueItems": true,
"nullable": true
}
} }
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
},
"uniqueItems": true,
"nullable": true
},
"supported_currencies": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Currency"
},
"uniqueItems": true,
"nullable": true
} }
} ]
}, },
"SurchargeDetailsResponse": { "SurchargeDetailsResponse": {
"type": "object", "type": "object",

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema; use utoipa::ToSchema;
use crate::enums::{ use crate::enums::{
CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, FeatureStatus, CaptureMethod, CardNetwork, Connector, CountryAlpha2, Currency, EventClass, FeatureStatus,
PaymentConnectorCategory, PaymentMethod, PaymentMethodType, PaymentConnectorCategory, PaymentMethod, PaymentMethodType,
}; };
@ -14,6 +14,23 @@ pub struct FeatureMatrixRequest {
pub connectors: Option<Vec<Connector>>, pub connectors: Option<Vec<Connector>>,
} }
#[derive(Debug, Clone, ToSchema, Serialize)]
pub struct CardSpecificFeatures {
/// Indicates whether three_ds card payments are supported.
pub three_ds: FeatureStatus,
/// Indicates whether non three_ds card payments are supported.
pub non_three_ds: FeatureStatus,
/// List of supported card networks
pub supported_card_networks: Vec<CardNetwork>,
}
#[derive(Debug, Clone, ToSchema, Serialize)]
#[serde(untagged)]
pub enum PaymentMethodSpecificFeatures {
/// Card specific features
Card(CardSpecificFeatures),
}
#[derive(Debug, ToSchema, Serialize)] #[derive(Debug, ToSchema, Serialize)]
pub struct SupportedPaymentMethod { pub struct SupportedPaymentMethod {
pub payment_method: PaymentMethod, pub payment_method: PaymentMethod,
@ -21,6 +38,8 @@ pub struct SupportedPaymentMethod {
pub mandates: FeatureStatus, pub mandates: FeatureStatus,
pub refunds: FeatureStatus, pub refunds: FeatureStatus,
pub supported_capture_methods: Vec<CaptureMethod>, pub supported_capture_methods: Vec<CaptureMethod>,
#[serde(flatten)]
pub payment_method_specific_features: Option<PaymentMethodSpecificFeatures>,
pub supported_countries: Option<HashSet<CountryAlpha2>>, pub supported_countries: Option<HashSet<CountryAlpha2>>,
pub supported_currencies: Option<HashSet<Currency>>, pub supported_currencies: Option<HashSet<Currency>>,
} }

View File

@ -825,6 +825,15 @@ lazy_static! {
enums::CaptureMethod::SequentialAutomatic, enums::CaptureMethod::SequentialAutomatic,
]; ];
let supported_card_network = vec![
common_enums::CardNetwork::Visa,
common_enums::CardNetwork::Mastercard,
common_enums::CardNetwork::AmericanExpress,
common_enums::CardNetwork::Discover,
common_enums::CardNetwork::JCB,
common_enums::CardNetwork::DinersClub,
];
let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); let mut bambora_supported_payment_methods = SupportedPaymentMethods::new();
bambora_supported_payment_methods.add( bambora_supported_payment_methods.add(
@ -834,15 +843,15 @@ lazy_static! {
mandates: common_enums::FeatureStatus::NotSupported, mandates: common_enums::FeatureStatus::NotSupported,
refunds: common_enums::FeatureStatus::Supported, refunds: common_enums::FeatureStatus::Supported,
supported_capture_methods: default_capture_methods.clone(), supported_capture_methods: default_capture_methods.clone(),
}, specific_features: Some(
); api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
bambora_supported_payment_methods.add( api_models::feature_matrix::CardSpecificFeatures {
enums::PaymentMethod::Card, three_ds: common_enums::FeatureStatus::Supported,
enums::PaymentMethodType::Debit, non_three_ds: common_enums::FeatureStatus::Supported,
PaymentMethodDetails { supported_card_networks: supported_card_network.clone(),
mandates: common_enums::FeatureStatus::NotSupported, }
refunds: common_enums::FeatureStatus::Supported, }),
supported_capture_methods: default_capture_methods.clone(), ),
}, },
); );

View File

@ -978,6 +978,12 @@ lazy_static! {
enums::CaptureMethod::Manual, enums::CaptureMethod::Manual,
enums::CaptureMethod::SequentialAutomatic, enums::CaptureMethod::SequentialAutomatic,
]; ];
let supported_card_network = vec![
common_enums::CardNetwork::Visa,
common_enums::CardNetwork::Mastercard,
];
let mut deutschebank_supported_payment_methods = SupportedPaymentMethods::new(); let mut deutschebank_supported_payment_methods = SupportedPaymentMethods::new();
deutschebank_supported_payment_methods.add( deutschebank_supported_payment_methods.add(
@ -987,6 +993,7 @@ lazy_static! {
mandates: enums::FeatureStatus::Supported, mandates: enums::FeatureStatus::Supported,
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods: supported_capture_methods.clone(),
specific_features: None,
} }
); );
@ -997,6 +1004,15 @@ lazy_static! {
mandates: enums::FeatureStatus::NotSupported, mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods: supported_capture_methods.clone(),
specific_features: Some(
api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
api_models::feature_matrix::CardSpecificFeatures {
three_ds: common_enums::FeatureStatus::Supported,
non_three_ds: common_enums::FeatureStatus::NotSupported,
supported_card_networks: supported_card_network.clone(),
}
}),
),
} }
); );

View File

@ -458,6 +458,7 @@ lazy_static! {
mandates: common_enums::FeatureStatus::NotSupported, mandates: common_enums::FeatureStatus::NotSupported,
refunds: common_enums::FeatureStatus::NotSupported, refunds: common_enums::FeatureStatus::NotSupported,
supported_capture_methods, supported_capture_methods,
specific_features: None,
}, },
); );

View File

@ -531,6 +531,8 @@ pub struct PaymentMethodDetails {
pub refunds: common_enums::FeatureStatus, pub refunds: common_enums::FeatureStatus,
/// List of supported capture methods /// List of supported capture methods
pub supported_capture_methods: Vec<common_enums::CaptureMethod>, pub supported_capture_methods: Vec<common_enums::CaptureMethod>,
/// Payment method specific features
pub specific_features: Option<api_models::feature_matrix::PaymentMethodSpecificFeatures>,
} }
/// list of payment method types and metadata related to them /// list of payment method types and metadata related to them

View File

@ -694,6 +694,8 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::feature_matrix::FeatureMatrixListResponse, api_models::feature_matrix::FeatureMatrixListResponse,
api_models::feature_matrix::FeatureMatrixRequest, api_models::feature_matrix::FeatureMatrixRequest,
api_models::feature_matrix::ConnectorFeatureMatrixResponse, api_models::feature_matrix::ConnectorFeatureMatrixResponse,
api_models::feature_matrix::PaymentMethodSpecificFeatures,
api_models::feature_matrix::CardSpecificFeatures,
api_models::feature_matrix::SupportedPaymentMethod, api_models::feature_matrix::SupportedPaymentMethod,
)), )),
modifiers(&SecurityAddon) modifiers(&SecurityAddon)

View File

@ -643,6 +643,8 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::feature_matrix::FeatureMatrixListResponse, api_models::feature_matrix::FeatureMatrixListResponse,
api_models::feature_matrix::FeatureMatrixRequest, api_models::feature_matrix::FeatureMatrixRequest,
api_models::feature_matrix::ConnectorFeatureMatrixResponse, api_models::feature_matrix::ConnectorFeatureMatrixResponse,
api_models::feature_matrix::PaymentMethodSpecificFeatures,
api_models::feature_matrix::CardSpecificFeatures,
api_models::feature_matrix::SupportedPaymentMethod, api_models::feature_matrix::SupportedPaymentMethod,
common_utils::types::BrowserInformation, common_utils::types::BrowserInformation,
api_models::payments::PaymentAmountDetailsResponse, api_models::payments::PaymentAmountDetailsResponse,

View File

@ -98,7 +98,7 @@ fn build_connector_feature_details(
.get_supported_webhook_flows() .get_supported_webhook_flows()
.map(|webhook_flows| webhook_flows.to_vec()); .map(|webhook_flows| webhook_flows.to_vec());
feature_matrix::ConnectorFeatureMatrixResponse { feature_matrix::ConnectorFeatureMatrixResponse {
name: connector_name, name: connector_name.to_uppercase(),
description: connector_about.map(|about| about.description.clone()), description: connector_about.map(|about| about.description.clone()),
category: connector_about.map(|about| about.connector_type), category: connector_about.map(|about| about.connector_type),
supported_webhook_flows, supported_webhook_flows,
@ -142,6 +142,7 @@ fn build_payment_method_wise_feature_details(
mandates: feature_metadata.mandates, mandates: feature_metadata.mandates,
refunds: feature_metadata.refunds, refunds: feature_metadata.refunds,
supported_capture_methods: feature_metadata.supported_capture_methods.clone(), supported_capture_methods: feature_metadata.supported_capture_methods.clone(),
payment_method_specific_features: feature_metadata.specific_features.clone(),
supported_countries, supported_countries,
supported_currencies, supported_currencies,
} }