refactor(payment_intent_v2): payment intent fields refactoring (#5880)

Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Narayan Bhat
2024-09-20 16:50:53 +05:30
committed by GitHub
parent 00e913c75c
commit 5335f2d21c
48 changed files with 2478 additions and 1620 deletions

View File

@ -3213,3 +3213,39 @@ pub enum DeleteStatus {
Active,
Redacted,
}
/// Whether 3ds authentication is requested or not
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum External3dsAuthenticationRequest {
/// Request for 3ds authentication
Enable,
/// Skip 3ds authentication
Skip,
}
/// Whether payment link is requested to be enabled or not for this transaction
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum EnablePaymentLinkRequest {
/// Request for enabling payment link
Enable,
/// Skip enabling payment link
Skip,
}
/// Whether mit exemption is requested or not
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum MitExemptionRequest {
/// Request for applying MIT exemption
Apply,
/// Skip applying MIT exemption
Skip,
}
/// Whether customer is present / absent during the payment
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum PresenceOfCustomerDuringPayment {
/// Customer is present during the payment. This is the default value
Present,
/// Customer is absent during the payment
Absent,
}

View File

@ -1991,6 +1991,79 @@ mod custom_serde {
}
}
impl From<Option<bool>> for super::External3dsAuthenticationRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Enable,
_ => Self::Skip,
}
}
}
/// Get the boolean value of the `External3dsAuthenticationRequest`.
impl super::External3dsAuthenticationRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Enable => true,
Self::Skip => false,
}
}
}
impl super::EnablePaymentLinkRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Enable => true,
Self::Skip => false,
}
}
}
impl From<Option<bool>> for super::EnablePaymentLinkRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Enable,
_ => Self::Skip,
}
}
}
impl From<Option<bool>> for super::MitExemptionRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Apply,
_ => Self::Skip,
}
}
}
impl super::MitExemptionRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Apply => true,
Self::Skip => false,
}
}
}
impl From<Option<bool>> for super::PresenceOfCustomerDuringPayment {
fn from(value: Option<bool>) -> Self {
match value {
Some(false) => Self::Absent,
_ => Self::Present,
}
}
}
impl super::PresenceOfCustomerDuringPayment {
pub fn as_bool(&self) -> bool {
match self {
Self::Present => true,
Self::Absent => false,
}
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]