feat(payment_methods_v2): Update and Retrieve payment method APIs for v2 (#5939)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sarthak Soni
2024-09-26 18:45:18 +05:30
committed by GitHub
parent 8c128624f6
commit f096992218
10 changed files with 432 additions and 67 deletions

View File

@ -374,7 +374,7 @@ pub struct PaymentMethodUpdate {
#[serde(deny_unknown_fields)]
pub struct PaymentMethodUpdate {
/// payment method data to be passed
pub payment_method_data: Option<PaymentMethodUpdateData>,
pub payment_method_data: PaymentMethodUpdateData,
/// 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")]
@ -990,6 +990,27 @@ impl From<CardDetailsPaymentMethod> for CardDetailFromLocker {
}
}
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl From<CardDetail> for CardDetailFromLocker {
fn from(item: CardDetail) -> Self {
Self {
issuer_country: item.card_issuing_country,
last4_digits: Some(item.card_number.get_last4()),
card_number: Some(item.card_number),
expiry_month: Some(item.card_exp_month),
expiry_year: Some(item.card_exp_year),
card_holder_name: item.card_holder_name,
nick_name: item.nick_name,
card_isin: None,
card_issuer: item.card_issuer,
card_network: item.card_network,
card_type: item.card_type.map(|card| card.to_string()),
saved_to_locker: true,
card_fingerprint: None,
}
}
}
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))]
impl From<CardDetail> for CardDetailsPaymentMethod {
fn from(item: CardDetail) -> Self {