feat(payment-methods): [Proxy] add saved card flow for proxy payments (#8964)

Co-authored-by: Prasunna Soppa <prasunna.soppa@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Prasunna Soppa <70575890+prasunna09@users.noreply.github.com>
This commit is contained in:
Sakil Mostak
2025-08-20 16:47:26 +05:30
committed by GitHub
parent a56d78a46a
commit 73dfa5e4fa
21 changed files with 861 additions and 29 deletions

View File

@ -497,6 +497,7 @@ pub enum PaymentMethodUpdateData {
#[serde(rename = "payment_method_data")]
pub enum PaymentMethodCreateData {
Card(CardDetail),
ProxyCard(ProxyCardDetails),
}
#[cfg(feature = "v1")]
@ -612,6 +613,57 @@ pub struct CardDetail {
pub card_cvc: Option<masking::Secret<String>>,
}
// This struct is for collecting Proxy Card Data
// All card related data present in this struct are tokenzied
// No strict type is present to accept tokenized data
#[cfg(feature = "v2")]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct ProxyCardDetails {
/// Tokenized Card Number
#[schema(value_type = String,example = "tok_sjfowhoejsldj")]
pub card_number: masking::Secret<String>,
/// Card Expiry Month
#[schema(value_type = String,example = "10")]
pub card_exp_month: masking::Secret<String>,
/// Card Expiry Year
#[schema(value_type = String,example = "25")]
pub card_exp_year: masking::Secret<String>,
/// First Six Digit of Card Number
pub bin_number: Option<String>,
///Last Four Digit of Card Number
pub last_four: Option<String>,
/// Issuer Bank for Card
pub card_issuer: Option<String>,
/// Card's Network
#[schema(value_type = Option<CardNetwork>)]
pub card_network: Option<common_enums::CardNetwork>,
/// Card Type
pub card_type: Option<String>,
/// Issuing Country of the Card
pub card_issuing_country: Option<String>,
/// Card Holder's Nick Name
#[schema(value_type = Option<String>,example = "John Doe")]
pub nick_name: Option<masking::Secret<String>>,
/// Card Holder Name
#[schema(value_type = String,example = "John Doe")]
pub card_holder_name: Option<masking::Secret<String>>,
/// The CVC number for the card
/// This is optional in case the card needs to be vaulted
#[schema(value_type = String, example = "242")]
pub card_cvc: Option<masking::Secret<String>>,
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct MigrateCardDetail {
@ -943,6 +995,12 @@ pub enum PaymentMethodsData {
WalletDetails(PaymentMethodDataWalletInfo),
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct ExternalVaultTokenData {
/// Tokenized reference for Card Number
pub tokenized_card_number: masking::Secret<String>,
}
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct CardDetailsPaymentMethod {
pub last4_digits: Option<String>,

View File

@ -2611,7 +2611,8 @@ pub struct ProxyPaymentMethodDataRequest {
#[serde(rename_all = "snake_case")]
pub enum ProxyPaymentMethodData {
#[schema(title = "ProxyCardData")]
VaultDataCard(ProxyCardData),
VaultDataCard(Box<ProxyCardData>),
VaultToken(VaultToken),
}
#[derive(Default, Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
@ -2655,6 +2656,25 @@ pub struct ProxyCardData {
/// The card holder's nick name
#[schema(value_type = Option<String>, example = "John Test")]
pub nick_name: Option<Secret<String>>,
/// The first six digit of the card number
#[schema(value_type = String, example = "424242")]
pub bin_number: Option<String>,
/// The last four digit of the card number
#[schema(value_type = String, example = "4242")]
pub last_four: Option<String>,
}
#[derive(Default, Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct VaultToken {
/// The tokenized CVC number for the card
#[schema(value_type = String, example = "242")]
pub card_cvc: Secret<String>,
/// The card holder's name
#[schema(value_type = String, example = "John Test")]
pub card_holder_name: Option<Secret<String>>,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema, Eq, PartialEq)]