mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
refactor(payment_methods): revamp payment methods update endpoint (#4305)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -76,7 +76,7 @@ pub struct PaymentMethodUpdate {
|
||||
"card_exp_month": "10",
|
||||
"card_exp_year": "25",
|
||||
"card_holder_name": "John Doe"}))]
|
||||
pub card: Option<CardDetail>,
|
||||
pub card: Option<CardDetailUpdate>,
|
||||
|
||||
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
|
||||
#[schema(value_type = Option<CardNetwork>,example = "Visa")]
|
||||
@ -95,6 +95,10 @@ pub struct PaymentMethodUpdate {
|
||||
/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
|
||||
#[schema(value_type = Option<Object>,example = json!({ "city": "NY", "unit": "245" }))]
|
||||
pub metadata: Option<pii::SecretSerdeValue>,
|
||||
|
||||
/// This is a 15 minute expiry token which shall be used from the client to authenticate and perform sessions from the SDK
|
||||
#[schema(max_length = 30, min_length = 30, example = "secret_k2uj3he2893eiu2d")]
|
||||
pub client_secret: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
@ -134,6 +138,54 @@ pub struct CardDetail {
|
||||
pub card_type: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct CardDetailUpdate {
|
||||
/// Card Expiry Month
|
||||
#[schema(value_type = String,example = "10")]
|
||||
pub card_exp_month: Option<masking::Secret<String>>,
|
||||
|
||||
/// Card Expiry Year
|
||||
#[schema(value_type = String,example = "25")]
|
||||
pub card_exp_year: Option<masking::Secret<String>>,
|
||||
|
||||
/// Card Holder Name
|
||||
#[schema(value_type = String,example = "John Doe")]
|
||||
pub card_holder_name: Option<masking::Secret<String>>,
|
||||
|
||||
/// Card Holder's Nick Name
|
||||
#[schema(value_type = Option<String>,example = "John Doe")]
|
||||
pub nick_name: Option<masking::Secret<String>>,
|
||||
}
|
||||
|
||||
impl CardDetailUpdate {
|
||||
pub fn apply(&self, card_data_from_locker: Card) -> CardDetail {
|
||||
CardDetail {
|
||||
card_number: card_data_from_locker.card_number,
|
||||
card_exp_month: self
|
||||
.card_exp_month
|
||||
.clone()
|
||||
.unwrap_or(card_data_from_locker.card_exp_month),
|
||||
card_exp_year: self
|
||||
.card_exp_year
|
||||
.clone()
|
||||
.unwrap_or(card_data_from_locker.card_exp_year),
|
||||
card_holder_name: self
|
||||
.card_holder_name
|
||||
.clone()
|
||||
.or(card_data_from_locker.name_on_card),
|
||||
nick_name: self
|
||||
.nick_name
|
||||
.clone()
|
||||
.or(card_data_from_locker.nick_name.map(masking::Secret::new)),
|
||||
card_issuing_country: None,
|
||||
card_network: None,
|
||||
card_issuer: None,
|
||||
card_type: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct PaymentMethodResponse {
|
||||
/// Unique identifier for a merchant
|
||||
@ -242,6 +294,17 @@ pub struct BankAccountConnectorDetails {
|
||||
pub enum BankAccountAccessCreds {
|
||||
AccessToken(masking::Secret<String>),
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone)]
|
||||
pub struct Card {
|
||||
pub card_number: CardNumber,
|
||||
pub name_on_card: Option<masking::Secret<String>>,
|
||||
pub card_exp_month: masking::Secret<String>,
|
||||
pub card_exp_year: masking::Secret<String>,
|
||||
pub card_brand: Option<String>,
|
||||
pub card_isin: Option<String>,
|
||||
pub nick_name: Option<String>,
|
||||
}
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
pub struct CardDetailFromLocker {
|
||||
pub scheme: Option<String>,
|
||||
|
||||
Reference in New Issue
Block a user