feat(router): add payment method display name to feature matrix response (#7639)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2025-04-01 17:11:15 +05:30
committed by GitHub
parent 506a68a71f
commit e8afec2f51
7 changed files with 701 additions and 31 deletions

View File

@ -7874,14 +7874,17 @@
],
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "The name of the connector"
},
"display_name": {
"type": "string",
"description": "The display name of the connector",
"nullable": true
},
"description": {
"type": "string",
"description": "The description of the connector",
"nullable": true
},
"category": {
@ -7896,13 +7899,15 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/SupportedPaymentMethod"
}
},
"description": "The list of payment methods supported by the connector"
},
"supported_webhook_flows": {
"type": "array",
"items": {
"$ref": "#/components/schemas/EventClass"
},
"description": "The list of webhook flows supported by the connector",
"nullable": true
}
}
@ -8340,6 +8345,260 @@
"US"
]
},
"CountryAlpha3": {
"type": "string",
"enum": [
"AFG",
"ALA",
"ALB",
"DZA",
"ASM",
"AND",
"AGO",
"AIA",
"ATA",
"ATG",
"ARG",
"ARM",
"ABW",
"AUS",
"AUT",
"AZE",
"BHS",
"BHR",
"BGD",
"BRB",
"BLR",
"BEL",
"BLZ",
"BEN",
"BMU",
"BTN",
"BOL",
"BES",
"BIH",
"BWA",
"BVT",
"BRA",
"IOT",
"BRN",
"BGR",
"BFA",
"BDI",
"CPV",
"KHM",
"CMR",
"CAN",
"CYM",
"CAF",
"TCD",
"CHL",
"CHN",
"CXR",
"CCK",
"COL",
"COM",
"COG",
"COD",
"COK",
"CRI",
"CIV",
"HRV",
"CUB",
"CUW",
"CYP",
"CZE",
"DNK",
"DJI",
"DMA",
"DOM",
"ECU",
"EGY",
"SLV",
"GNQ",
"ERI",
"EST",
"ETH",
"FLK",
"FRO",
"FJI",
"FIN",
"FRA",
"GUF",
"PYF",
"ATF",
"GAB",
"GMB",
"GEO",
"DEU",
"GHA",
"GIB",
"GRC",
"GRL",
"GRD",
"GLP",
"GUM",
"GTM",
"GGY",
"GIN",
"GNB",
"GUY",
"HTI",
"HMD",
"VAT",
"HND",
"HKG",
"HUN",
"ISL",
"IND",
"IDN",
"IRN",
"IRQ",
"IRL",
"IMN",
"ISR",
"ITA",
"JAM",
"JPN",
"JEY",
"JOR",
"KAZ",
"KEN",
"KIR",
"PRK",
"KOR",
"KWT",
"KGZ",
"LAO",
"LVA",
"LBN",
"LSO",
"LBR",
"LBY",
"LIE",
"LTU",
"LUX",
"MAC",
"MKD",
"MDG",
"MWI",
"MYS",
"MDV",
"MLI",
"MLT",
"MHL",
"MTQ",
"MRT",
"MUS",
"MYT",
"MEX",
"FSM",
"MDA",
"MCO",
"MNG",
"MNE",
"MSR",
"MAR",
"MOZ",
"MMR",
"NAM",
"NRU",
"NPL",
"NLD",
"NCL",
"NZL",
"NIC",
"NER",
"NGA",
"NIU",
"NFK",
"MNP",
"NOR",
"OMN",
"PAK",
"PLW",
"PSE",
"PAN",
"PNG",
"PRY",
"PER",
"PHL",
"PCN",
"POL",
"PRT",
"PRI",
"QAT",
"REU",
"ROU",
"RUS",
"RWA",
"BLM",
"SHN",
"KNA",
"LCA",
"MAF",
"SPM",
"VCT",
"WSM",
"SMR",
"STP",
"SAU",
"SEN",
"SRB",
"SYC",
"SLE",
"SGP",
"SXM",
"SVK",
"SVN",
"SLB",
"SOM",
"ZAF",
"SGS",
"SSD",
"ESP",
"LKA",
"SDN",
"SUR",
"SJM",
"SWZ",
"SWE",
"CHE",
"SYR",
"TWN",
"TJK",
"TZA",
"THA",
"TLS",
"TGO",
"TKL",
"TON",
"TTO",
"TUN",
"TUR",
"TKM",
"TCA",
"TUV",
"UGA",
"UKR",
"ARE",
"GBR",
"USA",
"UMI",
"URY",
"UZB",
"VUT",
"VEN",
"VNM",
"VGB",
"VIR",
"WLF",
"ESH",
"YEM",
"ZMB",
"ZWE"
]
},
"CreateApiKeyRequest": {
"type": "object",
"description": "The request body for creating an API Key.",
@ -22068,6 +22327,7 @@
"required": [
"payment_method",
"payment_method_type",
"payment_method_type_display_name",
"mandates",
"refunds",
"supported_capture_methods"
@ -22079,6 +22339,10 @@
"payment_method_type": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"payment_method_type_display_name": {
"type": "string",
"description": "The display name of the payment method type"
},
"mandates": {
"$ref": "#/components/schemas/FeatureStatus"
},
@ -22089,13 +22353,15 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/CaptureMethod"
}
},
"description": "List of supported capture methods supported by the payment method type"
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
"$ref": "#/components/schemas/CountryAlpha3"
},
"description": "List of countries supported by the payment method type via the connector",
"uniqueItems": true,
"nullable": true
},
@ -22104,6 +22370,7 @@
"items": {
"$ref": "#/components/schemas/Currency"
},
"description": "List of currencies supported by the payment method type via the connector",
"uniqueItems": true,
"nullable": true
}

View File

@ -9956,14 +9956,17 @@
],
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "The name of the connector"
},
"display_name": {
"type": "string",
"description": "The display name of the connector",
"nullable": true
},
"description": {
"type": "string",
"description": "The description of the connector",
"nullable": true
},
"category": {
@ -9978,13 +9981,15 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/SupportedPaymentMethod"
}
},
"description": "The list of payment methods supported by the connector"
},
"supported_webhook_flows": {
"type": "array",
"items": {
"$ref": "#/components/schemas/EventClass"
},
"description": "The list of webhook flows supported by the connector",
"nullable": true
}
}
@ -10451,6 +10456,260 @@
"US"
]
},
"CountryAlpha3": {
"type": "string",
"enum": [
"AFG",
"ALA",
"ALB",
"DZA",
"ASM",
"AND",
"AGO",
"AIA",
"ATA",
"ATG",
"ARG",
"ARM",
"ABW",
"AUS",
"AUT",
"AZE",
"BHS",
"BHR",
"BGD",
"BRB",
"BLR",
"BEL",
"BLZ",
"BEN",
"BMU",
"BTN",
"BOL",
"BES",
"BIH",
"BWA",
"BVT",
"BRA",
"IOT",
"BRN",
"BGR",
"BFA",
"BDI",
"CPV",
"KHM",
"CMR",
"CAN",
"CYM",
"CAF",
"TCD",
"CHL",
"CHN",
"CXR",
"CCK",
"COL",
"COM",
"COG",
"COD",
"COK",
"CRI",
"CIV",
"HRV",
"CUB",
"CUW",
"CYP",
"CZE",
"DNK",
"DJI",
"DMA",
"DOM",
"ECU",
"EGY",
"SLV",
"GNQ",
"ERI",
"EST",
"ETH",
"FLK",
"FRO",
"FJI",
"FIN",
"FRA",
"GUF",
"PYF",
"ATF",
"GAB",
"GMB",
"GEO",
"DEU",
"GHA",
"GIB",
"GRC",
"GRL",
"GRD",
"GLP",
"GUM",
"GTM",
"GGY",
"GIN",
"GNB",
"GUY",
"HTI",
"HMD",
"VAT",
"HND",
"HKG",
"HUN",
"ISL",
"IND",
"IDN",
"IRN",
"IRQ",
"IRL",
"IMN",
"ISR",
"ITA",
"JAM",
"JPN",
"JEY",
"JOR",
"KAZ",
"KEN",
"KIR",
"PRK",
"KOR",
"KWT",
"KGZ",
"LAO",
"LVA",
"LBN",
"LSO",
"LBR",
"LBY",
"LIE",
"LTU",
"LUX",
"MAC",
"MKD",
"MDG",
"MWI",
"MYS",
"MDV",
"MLI",
"MLT",
"MHL",
"MTQ",
"MRT",
"MUS",
"MYT",
"MEX",
"FSM",
"MDA",
"MCO",
"MNG",
"MNE",
"MSR",
"MAR",
"MOZ",
"MMR",
"NAM",
"NRU",
"NPL",
"NLD",
"NCL",
"NZL",
"NIC",
"NER",
"NGA",
"NIU",
"NFK",
"MNP",
"NOR",
"OMN",
"PAK",
"PLW",
"PSE",
"PAN",
"PNG",
"PRY",
"PER",
"PHL",
"PCN",
"POL",
"PRT",
"PRI",
"QAT",
"REU",
"ROU",
"RUS",
"RWA",
"BLM",
"SHN",
"KNA",
"LCA",
"MAF",
"SPM",
"VCT",
"WSM",
"SMR",
"STP",
"SAU",
"SEN",
"SRB",
"SYC",
"SLE",
"SGP",
"SXM",
"SVK",
"SVN",
"SLB",
"SOM",
"ZAF",
"SGS",
"SSD",
"ESP",
"LKA",
"SDN",
"SUR",
"SJM",
"SWZ",
"SWE",
"CHE",
"SYR",
"TWN",
"TJK",
"TZA",
"THA",
"TLS",
"TGO",
"TKL",
"TON",
"TTO",
"TUN",
"TUR",
"TKM",
"TCA",
"TUV",
"UGA",
"UKR",
"ARE",
"GBR",
"USA",
"UMI",
"URY",
"UZB",
"VUT",
"VEN",
"VNM",
"VGB",
"VIR",
"WLF",
"ESH",
"YEM",
"ZMB",
"ZWE"
]
},
"CreateApiKeyRequest": {
"type": "object",
"description": "The request body for creating an API Key.",
@ -26474,6 +26733,7 @@
"required": [
"payment_method",
"payment_method_type",
"payment_method_type_display_name",
"mandates",
"refunds",
"supported_capture_methods"
@ -26485,6 +26745,10 @@
"payment_method_type": {
"$ref": "#/components/schemas/PaymentMethodType"
},
"payment_method_type_display_name": {
"type": "string",
"description": "The display name of the payment method type"
},
"mandates": {
"$ref": "#/components/schemas/FeatureStatus"
},
@ -26495,13 +26759,15 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/CaptureMethod"
}
},
"description": "List of supported capture methods supported by the payment method type"
},
"supported_countries": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CountryAlpha2"
"$ref": "#/components/schemas/CountryAlpha3"
},
"description": "List of countries supported by the payment method type via the connector",
"uniqueItems": true,
"nullable": true
},
@ -26510,6 +26776,7 @@
"items": {
"$ref": "#/components/schemas/Currency"
},
"description": "List of currencies supported by the payment method type via the connector",
"uniqueItems": true,
"nullable": true
}

View File

@ -3,25 +3,24 @@ use std::collections::HashSet;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use crate::enums::{
CaptureMethod, CardNetwork, Connector, CountryAlpha2, Currency, EventClass, FeatureStatus,
PaymentConnectorCategory, PaymentMethod, PaymentMethodType,
};
#[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)]
pub struct FeatureMatrixRequest {
// List of connectors for which the feature matrix is requested
pub connectors: Option<Vec<Connector>>,
#[schema(value_type = Option<Vec<Connector>>)]
pub connectors: Option<Vec<common_enums::connector_enums::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 no_three_ds: FeatureStatus,
/// Indicates whether three_ds card payments are supported
#[schema(value_type = FeatureStatus)]
pub three_ds: common_enums::FeatureStatus,
/// Indicates whether non three_ds card payments are supported
#[schema(value_type = FeatureStatus)]
pub no_three_ds: common_enums::FeatureStatus,
/// List of supported card networks
pub supported_card_networks: Vec<CardNetwork>,
#[schema(value_type = Vec<CardNetwork>)]
pub supported_card_networks: Vec<common_enums::CardNetwork>,
}
#[derive(Debug, Clone, ToSchema, Serialize)]
@ -33,25 +32,50 @@ pub enum PaymentMethodSpecificFeatures {
#[derive(Debug, ToSchema, Serialize)]
pub struct SupportedPaymentMethod {
pub payment_method: PaymentMethod,
pub payment_method_type: PaymentMethodType,
pub mandates: FeatureStatus,
pub refunds: FeatureStatus,
pub supported_capture_methods: Vec<CaptureMethod>,
/// The payment method supported by the connector
#[schema(value_type = PaymentMethod)]
pub payment_method: common_enums::PaymentMethod,
/// The payment method type supported by the connector
#[schema(value_type = PaymentMethodType)]
pub payment_method_type: common_enums::PaymentMethodType,
/// The display name of the payment method type
pub payment_method_type_display_name: String,
/// Indicates whether the payment method supports mandates via the connector
#[schema(value_type = FeatureStatus)]
pub mandates: common_enums::FeatureStatus,
/// Indicates whether the payment method supports refunds via the connector
#[schema(value_type = FeatureStatus)]
pub refunds: common_enums::FeatureStatus,
/// List of supported capture methods supported by the payment method type
#[schema(value_type = Vec<CaptureMethod>)]
pub supported_capture_methods: Vec<common_enums::CaptureMethod>,
/// Information on the Payment method specific payment features
#[serde(flatten)]
pub payment_method_specific_features: Option<PaymentMethodSpecificFeatures>,
pub supported_countries: Option<HashSet<CountryAlpha2>>,
pub supported_currencies: Option<HashSet<Currency>>,
/// List of countries supported by the payment method type via the connector
#[schema(value_type = Option<HashSet<CountryAlpha3>>)]
pub supported_countries: Option<HashSet<common_enums::CountryAlpha3>>,
/// List of currencies supported by the payment method type via the connector
#[schema(value_type = Option<HashSet<Currency>>)]
pub supported_currencies: Option<HashSet<common_enums::Currency>>,
}
#[derive(Debug, ToSchema, Serialize)]
pub struct ConnectorFeatureMatrixResponse {
/// The name of the connector
pub name: String,
/// The display name of the connector
pub display_name: Option<String>,
/// The description of the connector
pub description: Option<String>,
pub category: Option<PaymentConnectorCategory>,
/// The category of the connector
#[schema(value_type = Option<PaymentConnectorCategory>, example = "payment_gateway")]
pub category: Option<common_enums::PaymentConnectorCategory>,
/// The list of payment methods supported by the connector
pub supported_payment_methods: Vec<SupportedPaymentMethod>,
pub supported_webhook_flows: Option<Vec<EventClass>>,
/// The list of webhook flows supported by the connector
#[schema(value_type = Option<Vec<EventClass>>)]
pub supported_webhook_flows: Option<Vec<common_enums::EventClass>>,
}
#[derive(Debug, Serialize, ToSchema)]

View File

@ -1842,6 +1842,110 @@ impl PaymentMethodType {
pub fn should_check_for_customer_saved_payment_method_type(self) -> bool {
matches!(self, Self::ApplePay | Self::GooglePay | Self::SamsungPay)
}
pub fn to_display_name(&self) -> String {
let display_name = match self {
Self::Ach => "ACH Direct Debit",
Self::Bacs => "BACS Direct Debit",
Self::Affirm => "Affirm",
Self::AfterpayClearpay => "Afterpay Clearpay",
Self::Alfamart => "Alfamart",
Self::AliPay => "Alipay",
Self::AliPayHk => "AlipayHK",
Self::Alma => "Alma",
Self::AmazonPay => "Amazon Pay",
Self::ApplePay => "Apple Pay",
Self::Atome => "Atome",
Self::BancontactCard => "Bancontact Card",
Self::Becs => "BECS Direct Debit",
Self::Benefit => "Benefit",
Self::Bizum => "Bizum",
Self::Blik => "BLIK",
Self::Boleto => "Boleto Bancário",
Self::BcaBankTransfer => "BCA Bank Transfer",
Self::BniVa => "BNI Virtual Account",
Self::BriVa => "BRI Virtual Account",
Self::CardRedirect => "Card Redirect",
Self::CimbVa => "CIMB Virtual Account",
Self::ClassicReward => "Classic Reward",
Self::Credit => "Credit Card",
Self::CryptoCurrency => "Crypto",
Self::Cashapp => "Cash App",
Self::Dana => "DANA",
Self::DanamonVa => "Danamon Virtual Account",
Self::Debit => "Debit Card",
Self::DuitNow => "DuitNow",
Self::Efecty => "Efecty",
Self::Eft => "EFT",
Self::Eps => "EPS",
Self::Fps => "FPS",
Self::Evoucher => "Evoucher",
Self::Giropay => "Giropay",
Self::Givex => "Givex",
Self::GooglePay => "Google Pay",
Self::GoPay => "GoPay",
Self::Gcash => "GCash",
Self::Ideal => "iDEAL",
Self::Interac => "Interac",
Self::Indomaret => "Indomaret",
Self::InstantBankTransfer => "Instant Bank Transfer",
Self::Klarna => "Klarna",
Self::KakaoPay => "KakaoPay",
Self::LocalBankRedirect => "Local Bank Redirect",
Self::MandiriVa => "Mandiri Virtual Account",
Self::Knet => "KNET",
Self::MbWay => "MB WAY",
Self::MobilePay => "MobilePay",
Self::Momo => "MoMo",
Self::MomoAtm => "MoMo ATM",
Self::Multibanco => "Multibanco",
Self::OnlineBankingThailand => "Online Banking Thailand",
Self::OnlineBankingCzechRepublic => "Online Banking Czech Republic",
Self::OnlineBankingFinland => "Online Banking Finland",
Self::OnlineBankingFpx => "Online Banking FPX",
Self::OnlineBankingPoland => "Online Banking Poland",
Self::OnlineBankingSlovakia => "Online Banking Slovakia",
Self::Oxxo => "OXXO",
Self::PagoEfectivo => "PagoEfectivo",
Self::PermataBankTransfer => "Permata Bank Transfer",
Self::OpenBankingUk => "Open Banking UK",
Self::PayBright => "PayBright",
Self::Paypal => "PayPal",
Self::Paze => "Paze",
Self::Pix => "Pix",
Self::PaySafeCard => "PaySafeCard",
Self::Przelewy24 => "Przelewy24",
Self::PromptPay => "PromptPay",
Self::Pse => "PSE",
Self::RedCompra => "RedCompra",
Self::RedPagos => "RedPagos",
Self::SamsungPay => "Samsung Pay",
Self::Sepa => "SEPA Direct Debit",
Self::SepaBankTransfer => "SEPA Bank Transfer",
Self::Sofort => "Sofort",
Self::Swish => "Swish",
Self::TouchNGo => "Touch 'n Go",
Self::Trustly => "Trustly",
Self::Twint => "TWINT",
Self::UpiCollect => "UPI Collect",
Self::UpiIntent => "UPI Intent",
Self::Vipps => "Vipps",
Self::VietQr => "VietQR",
Self::Venmo => "Venmo",
Self::Walley => "Walley",
Self::WeChatPay => "WeChat Pay",
Self::SevenEleven => "7-Eleven",
Self::Lawson => "Lawson",
Self::MiniStop => "Mini Stop",
Self::FamilyMart => "FamilyMart",
Self::Seicomart => "Seicomart",
Self::PayEasy => "PayEasy",
Self::LocalBankTransfer => "Local Bank Transfer",
Self::Mifinity => "MiFinity",
Self::OpenBankingPIS => "Open Banking PIS",
Self::DirectCarrierBilling => "Direct Carrier Billing",
};
display_name.to_string()
}
}
impl masking::SerializableSecret for PaymentMethodType {}
@ -2240,7 +2344,7 @@ pub enum RequestIncrementalAuthorization {
Default,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, strum::Display,)]
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug, Serialize, Deserialize, strum::Display, ToSchema,)]
#[rustfmt::skip]
pub enum CountryAlpha3 {
AFG, ALA, ALB, DZA, ASM, AND, AGO, AIA, ATA, ATG, ARG, ARM, ABW, AUS, AUT,

View File

@ -306,6 +306,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::DisputeStage,
api_models::enums::DisputeStatus,
api_models::enums::CountryAlpha2,
api_models::enums::CountryAlpha3,
api_models::enums::FieldType,
api_models::enums::FrmAction,
api_models::enums::FrmPreferredFlowTypes,

View File

@ -273,6 +273,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::DisputeStage,
api_models::enums::DisputeStatus,
api_models::enums::CountryAlpha2,
api_models::enums::CountryAlpha3,
api_models::enums::FieldType,
api_models::enums::FrmAction,
api_models::enums::FrmPreferredFlowTypes,

View File

@ -131,8 +131,13 @@ fn build_payment_method_wise_feature_details(
)
});
let supported_countries =
payment_method_type_config.and_then(|config| config.country.clone());
let supported_countries = payment_method_type_config.and_then(|config| {
config.country.clone().map(|set| {
set.into_iter()
.map(common_enums::CountryAlpha2::from_alpha2_to_alpha3)
.collect::<std::collections::HashSet<_>>()
})
});
let supported_currencies =
payment_method_type_config.and_then(|config| config.currency.clone());
@ -140,6 +145,7 @@ fn build_payment_method_wise_feature_details(
feature_matrix::SupportedPaymentMethod {
payment_method,
payment_method_type: *payment_method_type,
payment_method_type_display_name: payment_method_type.to_display_name(),
mandates: feature_metadata.mandates,
refunds: feature_metadata.refunds,
supported_capture_methods: feature_metadata.supported_capture_methods.clone(),