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(blocklist): introduce EligibilityPaymentMethodData for blocklist and eligibility checks (#11654)
Ayush Anand759c9e9736d1
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 08e83fc6f8..dadef177bc 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -14852,7 +14852,7 @@"corporatepurchasing","corporaterevolving","corporatet",- "corporatet_and_e",+ "corporate_t_and_e","corporation","credit","ctslandcard",@@ -14890,7 +14890,6 @@"globalpayment","gmcard","gold",- "gold_and_platinum","gold_personal","gold_platinum","gold_prem",@@ -14902,7 +14901,7 @@"governmentservicesloan","green","gsacard",- "gsacorporatet_and_e",+ "gsacorporate_t_and_e","gsapurchasing","hsanon_substantiated","icard",@@ -19026,6 +19025,321 @@}]},+ "EligibilityCard": {+ "type": "object",+ "description": "Card data for eligibility check — only card_number is required, no CVV needed",+ "required": [+ "card_number"+ ],+ "properties": {+ "card_number": {+ "type": "string",+ "description": "The card number",+ "example": "4242424242424242"+ },+ "card_exp_month": {+ "type": "string",+ "description": "The card's expiry month",+ "example": "24",+ "nullable": true+ },+ "card_exp_year": {+ "type": "string",+ "description": "The card's expiry year",+ "example": "24",+ "nullable": true+ },+ "card_cvc": {+ "type": "string",+ "description": "The card's CVC/CVV",+ "example": "123",+ "nullable": true+ },+ "card_holder_name": {+ "type": "string",+ "description": "The card holder's name",+ "example": "John Test",+ "nullable": true+ },+ "card_issuer": {+ "type": "string",+ "description": "The name of the issuer of card",+ "example": "chase",+ "nullable": true+ },+ "card_network": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CardNetwork"+ }+ ],+ "nullable": true+ },+ "card_type": {+ "type": "string",+ "example": "CREDIT",+ "nullable": true+ },+ "card_issuing_country": {+ "type": "string",+ "example": "INDIA",+ "nullable": true+ },+ "card_issuing_country_code": {+ "type": "string",+ "example": "IN",+ "nullable": true+ },+ "bank_code": {+ "type": "string",+ "example": "JP_AMEX",+ "nullable": true+ },+ "nick_name": {+ "type": "string",+ "description": "The card holder's nick name",+ "example": "John Test",+ "nullable": true+ }+ }+ },+ "EligibilityPaymentMethodData": {+ "oneOf": [+ {+ "type": "object",+ "title": "EligibilityCard",+ "required": [+ "card"+ ],+ "properties": {+ "card": {+ "$ref": "#/components/schemas/EligibilityCard"+ }+ }+ },+ {+ "type": "object",+ "title": "CardRedirect",+ "required": [+ "card_redirect"+ ],+ "properties": {+ "card_redirect": {+ "$ref": "#/components/schemas/CardRedirectData"+ }+ }+ },+ {+ "type": "object",+ "title": "Wallet",+ "required": [+ "wallet"+ ],+ "properties": {+ "wallet": {+ "$ref": "#/components/schemas/WalletData"+ }+ }+ },+ {+ "type": "object",+ "title": "PayLater",+ "required": [+ "pay_later"+ ],+ "properties": {+ "pay_later": {+ "$ref": "#/components/schemas/PayLaterData"+ }+ }+ },+ {+ "type": "object",+ "title": "BankRedirect",+ "required": [+ "bank_redirect"+ ],+ "properties": {+ "bank_redirect": {+ "$ref": "#/components/schemas/BankRedirectData"+ }+ }+ },+ {+ "type": "object",+ "title": "BankDebit",+ "required": [+ "bank_debit"+ ],+ "properties": {+ "bank_debit": {+ "$ref": "#/components/schemas/BankDebitData"+ }+ }+ },+ {+ "type": "object",+ "title": "BankTransfer",+ "required": [+ "bank_transfer"+ ],+ "properties": {+ "bank_transfer": {+ "$ref": "#/components/schemas/BankTransferData"+ }+ }+ },+ {+ "type": "object",+ "title": "RealTimePayment",+ "required": [+ "real_time_payment"+ ],+ "properties": {+ "real_time_payment": {+ "$ref": "#/components/schemas/RealTimePaymentData"+ }+ }+ },+ {+ "type": "object",+ "title": "Crypto",+ "required": [+ "crypto"+ ],+ "properties": {+ "crypto": {+ "$ref": "#/components/schemas/CryptoData"+ }+ }+ },+ {+ "type": "string",+ "title": "MandatePayment",+ "enum": [+ "mandate_payment"+ ]+ },+ {+ "type": "string",+ "title": "Reward",+ "enum": [+ "reward"+ ]+ },+ {+ "type": "object",+ "title": "Upi",+ "required": [+ "upi"+ ],+ "properties": {+ "upi": {+ "$ref": "#/components/schemas/UpiData"+ }+ }+ },+ {+ "type": "object",+ "title": "Voucher",+ "required": [+ "voucher"+ ],+ "properties": {+ "voucher": {+ "$ref": "#/components/schemas/VoucherData"+ }+ }+ },+ {+ "type": "object",+ "title": "GiftCard",+ "required": [+ "gift_card"+ ],+ "properties": {+ "gift_card": {+ "$ref": "#/components/schemas/GiftCardData"+ }+ }+ },+ {+ "type": "object",+ "title": "CardToken",+ "required": [+ "card_token"+ ],+ "properties": {+ "card_token": {+ "$ref": "#/components/schemas/CardToken"+ }+ }+ },+ {+ "type": "object",+ "title": "OpenBanking",+ "required": [+ "open_banking"+ ],+ "properties": {+ "open_banking": {+ "$ref": "#/components/schemas/OpenBankingData"+ }+ }+ },+ {+ "type": "object",+ "title": "MobilePayment",+ "required": [+ "mobile_payment"+ ],+ "properties": {+ "mobile_payment": {+ "$ref": "#/components/schemas/MobilePaymentData"+ }+ }+ },+ {+ "type": "object",+ "title": "NetworkToken",+ "required": [+ "network_token"+ ],+ "properties": {+ "network_token": {+ "$ref": "#/components/schemas/NetworkTokenData"+ }+ }+ }+ ],+ "description": "Payment method data for eligibility check"+ },+ "EligibilityPaymentMethodDataRequest": {+ "allOf": [+ {+ "allOf": [+ {+ "$ref": "#/components/schemas/EligibilityPaymentMethodData"+ }+ ],+ "nullable": true+ },+ {+ "type": "object",+ "properties": {+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ }+ }+ }+ ],+ "description": "Payment method data request for eligibility check"+ },"EligibilityResponseParams": {"oneOf": [{@@ -30929,7 +31243,7 @@"nullable": true},"payment_method_data": {- "$ref": "#/components/schemas/PaymentMethodDataRequest"+ "$ref": "#/components/schemas/EligibilityPaymentMethodDataRequest"},"browser_info": {"allOf": [diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 1f23a8c1ca..bf5e930c52 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -12238,13 +12238,190 @@ pub struct PaymentsEligibilityRequest {/// The payment method type to be used for the payment#[schema(value_type = Option<PaymentMethodType>)]pub payment_method_subtype: Option<api_enums::PaymentMethodType>,- /// The payment instrument data to be used for the payment- pub payment_method_data: PaymentMethodDataRequest,+ /// The payment instrument data for eligibility check+ #[serde(with = "eligibility_payment_method_data_serde")]+ pub payment_method_data: EligibilityPaymentMethodDataRequest,/// The browser information for the payment#[schema(value_type = Option<BrowserInformation>)]pub browser_info: Option<BrowserInformation>,}+/// Card data for eligibility check — only card_number is required, no CVV needed+#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema, Eq, PartialEq)]+pub struct EligibilityCard {+ /// The card number+ #[schema(value_type = String, example = "4242424242424242")]+ pub card_number: CardNumber,++ /// The card's expiry month+ #[schema(value_type = Option<String>, example = "24")]+ pub card_exp_month: Option<Secret<String>>,++ /// The card's expiry year+ #[schema(value_type = Option<String>, example = "24")]+ pub card_exp_year: Option<Secret<String>>,++ /// The card's CVC/CVV+ #[schema(value_type = Option<String>, example = "123")]+ pub card_cvc: Option<Secret<String>>,++ /// The card holder's name+ #[schema(value_type = Option<String>, example = "John Test")]+ pub card_holder_name: Option<Secret<String>>,++ /// The name of the issuer of card+ #[schema(example = "chase")]+ pub card_issuer: Option<String>,++ /// The card network for the card+ #[schema(value_type = Option<CardNetwork>, example = "Visa")]+ pub card_network: Option<api_enums::CardNetwork>,++ #[schema(example = "CREDIT")]+ pub card_type: Option<String>,++ #[schema(example = "INDIA")]+ pub card_issuing_country: Option<String>,++ #[schema(example = "IN")]+ pub card_issuing_country_code: Option<String>,++ #[schema(example = "JP_AMEX")]+ pub bank_code: Option<String>,++ /// The card holder's nick name+ #[schema(value_type = Option<String>, example = "John Test")]+ pub nick_name: Option<Secret<String>>,+}++/// Payment method data for eligibility check+#[derive(+ Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema, Eq, PartialEq, SmithyModel,+)]+#[serde(rename_all = "snake_case")]+#[smithy(namespace = "com.hyperswitch.smithy.types")]+pub enum EligibilityPaymentMethodData {+ #[schema(title = "EligibilityCard")]+ #[smithy(value_type = "EligibilityCard")]+ Card(EligibilityCard),+ #[schema(title = "CardRedirect")]+ #[smithy(value_type = "CardRedirectData")]+ CardRedirect(CardRedirectData),+ #[schema(title = "Wallet")]+ Wallet(WalletData),+ #[schema(title = "PayLater")]+ #[smithy(value_type = "PayLaterData")]+ PayLater(PayLaterData),+ #[schema(title = "BankRedirect")]+ #[smithy(value_type = "BankRedirectData")]+ BankRedirect(BankRedirectData),+ #[schema(title = "BankDebit")]+ #[smithy(value_type = "BankDebitData")]+ BankDebit(BankDebitData),+ #[schema(title = "BankTransfer")]+ #[smithy(value_type = "BankTransferData")]+ BankTransfer(Box<BankTransferData>),+ #[schema(title = "RealTimePayment")]+ #[smithy(value_type = "RealTimePaymentData")]+ RealTimePayment(Box<RealTimePaymentData>),+ #[schema(title = "Crypto")]+ #[smithy(value_type = "CryptoData")]+ Crypto(CryptoData),+ #[schema(title = "MandatePayment")]+ #[smithy(value_type = "smithy.api#Unit")]+ MandatePayment,+ #[schema(title = "Reward")]+ #[smithy(value_type = "smithy.api#Unit")]+ Reward,+ #[schema(title = "Upi")]+ #[smithy(value_type = "UpiData")]+ Upi(UpiData),+ #[schema(title = "Voucher")]+ #[smithy(value_type = "VoucherData")]+ Voucher(VoucherData),+ #[schema(title = "GiftCard")]+ #[smithy(value_type = "GiftCardData")]+ GiftCard(Box<GiftCardData>),+ #[schema(title = "CardToken")]+ #[smithy(value_type = "CardToken")]+ CardToken(CardToken),+ #[schema(title = "OpenBanking")]+ #[smithy(value_type = "OpenBankingData")]+ OpenBanking(OpenBankingData),+ #[schema(title = "MobilePayment")]+ #[smithy(value_type = "MobilePaymentData")]+ MobilePayment(MobilePaymentData),+ #[schema(title = "NetworkToken")]+ NetworkToken(NetworkTokenData),+}++/// Custom deserializer for EligibilityPaymentMethodDataRequest.+/// Required to catch deserialization errors: bare #[serde(flatten)] on+/// Option<ExternallyTaggedEnum> uses FlatMapDeserializer which swallows all+/// errors and returns None, hiding malformed card data. This mirrors the+/// approach used by payment_method_data_serde for PaymentMethodDataRequest.+#[cfg(feature = "v1")]+mod eligibility_payment_method_data_serde {+ use super::*;++ pub fn deserialize<'de, D>(+ deserializer: D,+ ) -> Result<EligibilityPaymentMethodDataRequest, D::Error>+ where+ D: Deserializer<'de>,+ {+ // Intermediate struct: flatten into raw serde_json::Value so errors are+ // preserved — FlatMapDeserializer only swallows errors on typed enums,+ // not on Value.+ #[derive(serde::Deserialize, Debug)]+ struct __Inner {+ billing: Option<Address>,+ #[serde(flatten)]+ payment_method_data: Option<serde_json::Value>,+ }++ let parsed = __Inner::deserialize(deserializer)?;++ let payment_method_data = if let Some(value) = parsed.payment_method_data {+ // Even when no payment method data is sent, flatten produces Some(Object {})+ if let serde_json::Value::Object(ref map) = value {+ if map.is_empty() {+ None+ } else {+ Some(+ serde_json::from_value::<EligibilityPaymentMethodData>(value)+ .map_err(|e| de::Error::custom(e.to_string()))?,+ )+ }+ } else {+ return Err(de::Error::custom("Expected a map for payment_method_data"));+ }+ } else {+ None+ };++ Ok(EligibilityPaymentMethodDataRequest {+ payment_method_data,+ billing: parsed.billing,+ })+ }+}++/// Payment method data request for eligibility check+#[derive(+ Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema, Eq, PartialEq, SmithyModel,+)]+#[smithy(namespace = "com.hyperswitch.smithy.types")]+pub struct EligibilityPaymentMethodDataRequest {+ #[serde(flatten)]+ #[smithy(value_type = "Option<EligibilityPaymentMethodData>")]+ pub payment_method_data: Option<EligibilityPaymentMethodData>,+ /// billing details for the payment method.+ /// This billing details will be passed to the processor as billing address.+ /// If not passed, then payment.billing will be considered+ pub billing: Option<Address>,+}+#[derive(Debug, serde::Serialize, Clone, ToSchema)]pub struct PaymentsEligibilityResponse {/// The identifier for the paymentdiff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex b44f11efc5..229e42511b 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -3291,7 +3291,7 @@ pub enum CardSubtype {Corporaterevolving,Corporatet,#[strum(serialize = "CORPORATET&E")]- CorporatetAndE,+ CorporateTAndE,Corporation,Credit,Ctslandcard,@@ -3345,8 +3345,6 @@ pub enum CardSubtype {Globalpayment,Gmcard,Gold,- #[strum(serialize = "GOLD&PLATINUM")]- GoldAndPlatinum,#[strum(serialize = "GOLD PERSONAL")]GoldPersonal,#[strum(serialize = "GOLD/PLATINUM")]@@ -3362,7 +3360,7 @@ pub enum CardSubtype {Green,Gsacard,#[strum(serialize = "GSACORPORATET&E")]- GsacorporatetAndE,+ GsacorporateTAndE,Gsapurchasing,#[strum(serialize = "HSANON-SUBSTANTIATED")]HsanonSubstantiated,diff --git a/crates/euclid_wasm/src/lib.rs b/crates/euclid_wasm/src/lib.rsindex 4fe00bf90d..cab1cd1393 100644--- a/crates/euclid_wasm/src/lib.rs+++ b/crates/euclid_wasm/src/lib.rs@@ -37,8 +37,9 @@ use api_models::payment_methods::CountryCodeWithName;#[cfg(feature = "payouts")]use common_enums::PayoutStatus;use common_enums::{- CountryAlpha2, DisputeStatus, EventClass, EventType, IntentStatus, MandateStatus,- MerchantCategoryCode, MerchantCategoryCodeWithName, RefundStatus, SubscriptionStatus,+ CardSubtype, CardType, CountryAlpha2, DisputeStatus, EventClass, EventType, IntentStatus,+ MandateStatus, MerchantCategoryCode, MerchantCategoryCodeWithName, RefundStatus,+ SubscriptionStatus,};use strum::IntoEnumIterator;@@ -524,6 +525,18 @@ pub fn get_payout_description_category() -> JsResult {Ok(serde_wasm_bindgen::to_value(&category)?)}+#[wasm_bindgen(js_name = getCardSubtypeValues)]+pub fn get_card_subtype_values() -> JsResult {+ let subtypes: Vec<CardSubtype> = CardSubtype::iter().collect();+ Ok(serde_wasm_bindgen::to_value(&subtypes)?)+}++#[wasm_bindgen(js_name = getCardTypeValues)]+pub fn get_card_type_values() -> JsResult {+ let types: Vec<CardType> = CardType::iter().collect();+ Ok(serde_wasm_bindgen::to_value(&types)?)+}+#[wasm_bindgen(js_name = getValidWebhookStatus)]pub fn get_valid_webhook_status(key: &str) -> JsResult {let event_class = EventClass::from_str(key)diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex cc17dc298f..416974faea 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -307,6 +307,53 @@ impl PaymentMethodData {}}+/// Card data for eligibility/blocklist checks — only card_number is required+#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]+pub struct EligibilityCard {+ pub card_number: cards::CardNumber,+ pub card_exp_month: Option<Secret<String>>,+ pub card_exp_year: Option<Secret<String>>,+ pub card_cvc: Option<Secret<String>>,+ pub card_issuer: Option<String>,+ pub card_network: Option<common_enums::CardNetwork>,+ pub card_type: Option<String>,+ pub card_issuing_country: Option<String>,+ pub card_issuing_country_code: Option<String>,+ pub bank_code: Option<String>,+ pub nick_name: Option<Secret<String>>,+ pub card_holder_name: Option<Secret<String>>,+ pub co_badged_card_data: Option<payment_methods::CoBadgedCardData>,+}++/// Payment method data for eligibility/blocklist checks — mirrors PaymentMethodData but uses EligibilityCard+#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]+pub enum EligibilityPaymentMethodData {+ Card(EligibilityCard),+ CardRedirect(CardRedirectData),+ Wallet(WalletData),+ PayLater(PayLaterData),+ BankRedirect(BankRedirectData),+ BankDebit(BankDebitData),+ BankTransfer(Box<BankTransferData>),+ Crypto(CryptoData),+ MandatePayment,+ Reward,+ RealTimePayment(Box<RealTimePaymentData>),+ Upi(UpiData),+ Voucher(VoucherData),+ GiftCard(Box<GiftCardData>),+ CardToken(CardToken),+ OpenBanking(OpenBankingData),+ NetworkToken(NetworkTokenData),+ MobilePayment(MobilePaymentData),+}++impl EligibilityPaymentMethodData {+ pub fn is_eligible_for_profile_config_blocklist(&self) -> bool {+ matches!(self, Self::Card(_))+ }+}+#[derive(PartialEq, Clone, Debug, Serialize, Deserialize, Default)]pub struct Card {pub card_number: cards::CardNumber,@@ -1732,6 +1779,183 @@ impl}}+impl From<CardWithOptionalCVC> for EligibilityCard {+ fn from(card: CardWithOptionalCVC) -> Self {+ Self {+ card_number: card.card_number,+ card_exp_month: Some(card.card_exp_month),+ card_exp_year: Some(card.card_exp_year),+ card_cvc: card.card_cvc,+ card_issuer: card.card_issuer,+ card_network: card.card_network,+ card_type: card.card_type,+ card_issuing_country: card.card_issuing_country,+ card_issuing_country_code: card.card_issuing_country_code,+ bank_code: card.bank_code,+ nick_name: card.nick_name,+ card_holder_name: card.card_holder_name,+ co_badged_card_data: card.co_badged_card_data,+ }+ }+}++impl From<Box<CardWithNetworkTokenDetails>> for EligibilityCard {+ fn from(card: Box<CardWithNetworkTokenDetails>) -> Self {+ Self::from(card.card_details)+ }+}++impl+ From<(+ api_models::payments::EligibilityCard,+ Option<payment_methods::CoBadgedCardData>,+ )> for EligibilityCard+{+ fn from(+ (eligibility_card, co_badged_card_data_optional): (+ api_models::payments::EligibilityCard,+ Option<payment_methods::CoBadgedCardData>,+ ),+ ) -> Self {+ let api_models::payments::EligibilityCard {+ card_number,+ card_exp_month,+ card_exp_year,+ card_cvc,+ card_holder_name,+ card_issuer,+ card_network,+ card_type,+ card_issuing_country,+ card_issuing_country_code,+ bank_code,+ nick_name,+ } = eligibility_card;++ Self {+ card_number,+ card_exp_month,+ card_exp_year,+ card_cvc,+ card_issuer,+ card_network,+ card_type,+ card_issuing_country,+ card_issuing_country_code,+ bank_code,+ nick_name,+ card_holder_name,+ co_badged_card_data: co_badged_card_data_optional,+ }+ }+}++impl From<api_models::payments::EligibilityPaymentMethodData> for EligibilityPaymentMethodData {+ fn from(value: api_models::payments::EligibilityPaymentMethodData) -> Self {+ match value {+ api_models::payments::EligibilityPaymentMethodData::Card(eligibility_card) => {+ Self::Card(EligibilityCard::from((eligibility_card, None)))+ }+ api_models::payments::EligibilityPaymentMethodData::CardRedirect(card_redirect) => {+ Self::CardRedirect(From::from(card_redirect))+ }+ api_models::payments::EligibilityPaymentMethodData::Wallet(wallet_data) => {+ Self::Wallet(From::from(wallet_data))+ }+ api_models::payments::EligibilityPaymentMethodData::PayLater(pay_later_data) => {+ Self::PayLater(From::from(pay_later_data))+ }+ api_models::payments::EligibilityPaymentMethodData::BankRedirect(+ bank_redirect_data,+ ) => Self::BankRedirect(From::from(bank_redirect_data)),+ api_models::payments::EligibilityPaymentMethodData::BankDebit(bank_debit_data) => {+ Self::BankDebit(From::from(bank_debit_data))+ }+ api_models::payments::EligibilityPaymentMethodData::BankTransfer(+ bank_transfer_data,+ ) => Self::BankTransfer(Box::new(From::from(*bank_transfer_data))),+ api_models::payments::EligibilityPaymentMethodData::RealTimePayment(+ real_time_payment_data,+ ) => Self::RealTimePayment(Box::new(From::from(*real_time_payment_data))),+ api_models::payments::EligibilityPaymentMethodData::Crypto(crypto_data) => {+ Self::Crypto(From::from(crypto_data))+ }+ api_models::payments::EligibilityPaymentMethodData::MandatePayment => {+ Self::MandatePayment+ }+ api_models::payments::EligibilityPaymentMethodData::Reward => Self::Reward,+ api_models::payments::EligibilityPaymentMethodData::Upi(upi_data) => {+ Self::Upi(From::from(upi_data))+ }+ api_models::payments::EligibilityPaymentMethodData::Voucher(voucher_data) => {+ Self::Voucher(From::from(voucher_data))+ }+ api_models::payments::EligibilityPaymentMethodData::GiftCard(gift_card_data) => {+ Self::GiftCard(Box::new(From::from(*gift_card_data)))+ }+ api_models::payments::EligibilityPaymentMethodData::CardToken(card_token) => {+ Self::CardToken(From::from(card_token))+ }+ api_models::payments::EligibilityPaymentMethodData::OpenBanking(open_banking_data) => {+ Self::OpenBanking(From::from(open_banking_data))+ }+ api_models::payments::EligibilityPaymentMethodData::MobilePayment(+ mobile_payment_data,+ ) => Self::MobilePayment(From::from(mobile_payment_data)),+ api_models::payments::EligibilityPaymentMethodData::NetworkToken(+ network_token_data,+ ) => Self::NetworkToken(From::from(network_token_data)),+ }+ }+}++impl From<PaymentMethodData> for EligibilityPaymentMethodData {+ fn from(value: PaymentMethodData) -> Self {+ match value {+ PaymentMethodData::Card(card) => Self::Card(EligibilityCard {+ card_number: card.card_number,+ card_exp_month: Some(card.card_exp_month),+ card_exp_year: Some(card.card_exp_year),+ card_cvc: Some(card.card_cvc),+ card_issuer: card.card_issuer,+ card_network: card.card_network,+ card_type: card.card_type,+ card_issuing_country: card.card_issuing_country,+ card_issuing_country_code: card.card_issuing_country_code,+ bank_code: card.bank_code,+ nick_name: card.nick_name,+ card_holder_name: card.card_holder_name,+ co_badged_card_data: card.co_badged_card_data,+ }),+ PaymentMethodData::CardRedirect(v) => Self::CardRedirect(v),+ PaymentMethodData::Wallet(v) => Self::Wallet(v),+ PaymentMethodData::PayLater(v) => Self::PayLater(v),+ PaymentMethodData::BankRedirect(v) => Self::BankRedirect(v),+ PaymentMethodData::BankDebit(v) => Self::BankDebit(v),+ PaymentMethodData::BankTransfer(v) => Self::BankTransfer(v),+ PaymentMethodData::Crypto(v) => Self::Crypto(v),+ PaymentMethodData::MandatePayment => Self::MandatePayment,+ PaymentMethodData::Reward => Self::Reward,+ PaymentMethodData::RealTimePayment(v) => Self::RealTimePayment(v),+ PaymentMethodData::Upi(v) => Self::Upi(v),+ PaymentMethodData::Voucher(v) => Self::Voucher(v),+ PaymentMethodData::GiftCard(v) => Self::GiftCard(v),+ PaymentMethodData::CardToken(v) => Self::CardToken(v),+ PaymentMethodData::OpenBanking(v) => Self::OpenBanking(v),+ PaymentMethodData::NetworkToken(v) => Self::NetworkToken(v),+ PaymentMethodData::MobilePayment(v) => Self::MobilePayment(v),+ PaymentMethodData::CardWithOptionalCVC(card) => Self::Card(card.into()),+ PaymentMethodData::CardWithNetworkTokenDetails(card) => Self::Card(card.into()),+ PaymentMethodData::CardDetailsForNetworkTransactionId(_)+ | PaymentMethodData::CardWithLimitedDetails(_)+ | PaymentMethodData::NetworkTokenDetailsForNetworkTransactionId(_)+ | PaymentMethodData::DecryptedWalletTokenDetailsForNetworkTransactionId(_) => {+ Self::MandatePayment+ }+ }+ }+}+#[cfg(feature = "v2")]implFrom<(diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 872ae84d00..89f1128f1d 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -593,6 +593,9 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::PaymentsConfirmRequest,api_models::payments::PaymentsResponse,api_models::payments::PaymentsCreateResponseOpenApi,+ api_models::payments::EligibilityCard,+ api_models::payments::EligibilityPaymentMethodData,+ api_models::payments::EligibilityPaymentMethodDataRequest,api_models::payments::PaymentsEligibilityRequest,api_models::payments::PaymentsEligibilityResponse,api_models::payments::PaymentsCreateResponseOpenApi,diff --git a/crates/router/src/core/blocklist/utils.rs b/crates/router/src/core/blocklist/utils.rsindex 8076db14f3..81b23de883 100644--- a/crates/router/src/core/blocklist/utils.rs+++ b/crates/router/src/core/blocklist/utils.rs@@ -309,7 +309,7 @@ async fn delete_card_bin_blocklist_entry(pub async fn should_payment_be_blocked(state: &SessionState,processor: &domain::Processor,- payment_method_data: &Option<domain::PaymentMethodData>,+ payment_method_data: &Option<domain::EligibilityPaymentMethodData>,business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {let db = &state.store;@@ -318,7 +318,7 @@ pub async fn should_payment_be_blocked(// Hashed Fingerprint to check whether or not this payment should be blocked.let card_number_fingerprint =- if let Some(domain::PaymentMethodData::Card(card)) = payment_method_data {+ if let Some(domain::EligibilityPaymentMethodData::Card(card)) = payment_method_data {generate_fingerprint(state,StrongSecret::new(card.card_number.get_card_no()),@@ -342,7 +342,9 @@ pub async fn should_payment_be_blocked(let card_bin_fingerprint = payment_method_data.as_ref().and_then(|pm_data| match pm_data {- domain::PaymentMethodData::Card(card) => Some(card.card_number.get_card_isin()),+ domain::EligibilityPaymentMethodData::Card(card) => {+ Some(card.card_number.get_card_isin())+ }_ => None,});@@ -351,7 +353,7 @@ pub async fn should_payment_be_blocked(payment_method_data.as_ref().and_then(|pm_data| match pm_data {- domain::PaymentMethodData::Card(card) => {+ domain::EligibilityPaymentMethodData::Card(card) => {Some(card.card_number.get_extended_card_bin())}_ => None,@@ -396,7 +398,11 @@ pub async fn should_payment_be_blocked(}}- if !should_payment_be_blocked {+ if !should_payment_be_blocked+ && payment_method_data+ .as_ref()+ .is_some_and(|pmd| pmd.is_eligible_for_profile_config_blocklist())+ {should_payment_be_blocked = should_payment_be_blocked_by_profile_config(state,payment_method_data,@@ -421,7 +427,10 @@ wherelet should_block = should_payment_be_blocked(state,processor,- &payment_data.payment_method_data,+ &payment_data+ .payment_method_data+ .clone()+ .map(domain::EligibilityPaymentMethodData::from),business_profile,).await?;@@ -482,7 +491,7 @@ wherepub async fn should_payment_be_blocked_by_profile_config(state: &SessionState,- payment_method_data: &Option<domain::PaymentMethodData>,+ payment_method_data: &Option<domain::EligibilityPaymentMethodData>,business_profile: &domain::Profile,) -> CustomResult<bool, errors::ApiErrorResponse> {let mut should_block = false;@@ -495,7 +504,9 @@ pub async fn should_payment_be_blocked_by_profile_config(let card_isin = payment_method_data.as_ref().and_then(|pm_data| match pm_data {- domain::PaymentMethodData::Card(card) => Some(card.card_number.get_card_isin()),+ domain::EligibilityPaymentMethodData::Card(card) => {+ Some(card.card_number.get_card_isin())+ }_ => None,});diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 1968423155..24b3ebe4ec 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -8345,7 +8345,7 @@ where#[cfg(feature = "v1")]#[derive(Clone)]pub struct PaymentEligibilityData {- pub payment_method_data: Option<domain::PaymentMethodData>,+ pub payment_method_data: Option<domain::EligibilityPaymentMethodData>,pub payment_intent: storage::PaymentIntent,pub browser_info: Option<pii::SecretSerdeValue>,}@@ -8361,7 +8361,7 @@ impl PaymentEligibilityData {.payment_method_data.payment_method_data.clone()- .map(domain::PaymentMethodData::from);+ .map(domain::EligibilityPaymentMethodData::from);let browser_info = payments_eligibility_request.browser_info.clone()@@ -11646,7 +11646,7 @@ impl EligibilityCheck for CardTestingCheck {business_profile: &domain::Profile,) -> CustomResult<CheckResult, errors::ApiErrorResponse> {match &payment_elgibility_data.payment_method_data {- Some(domain::PaymentMethodData::Card(card)) => {+ Some(domain::EligibilityPaymentMethodData::Card(card)) => {match card_testing_guard_utils::validate_card_testing_guard_checks(state,payment_elgibility_data