feat(core): update card_details for an existing mandate (#3452)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Amisha Prabhat
2024-01-30 12:35:42 +05:30
committed by GitHub
parent c9d41e2169
commit 02074dfc23
22 changed files with 451 additions and 72 deletions

View File

@ -9,6 +9,13 @@ use error_stack::{IntoReport, ResultExt};
use masking::{PeekInterface, Secret};
use time::PrimitiveDateTime;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub struct MandateDetails {
pub update_mandate_id: Option<String>,
pub mandate_type: Option<MandateDataType>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum MandateDataType {
@ -16,6 +23,13 @@ pub enum MandateDataType {
MultiUse(Option<MandateAmountData>),
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[serde(untagged)]
pub enum MandateTypeDetails {
MandateType(MandateDataType),
MandateDetails(MandateDetails),
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct MandateAmountData {
pub amount: i64,
@ -29,6 +43,8 @@ pub struct MandateAmountData {
// information about creating mandates
#[derive(Default, Eq, PartialEq, Debug, Clone)]
pub struct MandateData {
/// A way to update the mandate's payment method details
pub update_mandate_id: Option<String>,
/// A concent from the customer to store the payment method
pub customer_acceptance: Option<CustomerAcceptance>,
/// A way to select the type of mandate used
@ -90,6 +106,7 @@ impl From<ApiMandateData> for MandateData {
Self {
customer_acceptance: value.customer_acceptance.map(|d| d.into()),
mandate_type: value.mandate_type.map(|d| d.into()),
update_mandate_id: value.update_mandate_id,
}
}
}