refactor: Move CustomerAcceptance to common_types (#8299)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Anurag Thakur
2025-06-25 11:27:09 +05:30
committed by GitHub
parent 2298d487c7
commit 44d93e572f
35 changed files with 194 additions and 267 deletions

View File

@ -1,9 +1,10 @@
use common_types::payments as common_payments_types;
use masking::Secret;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use utoipa::ToSchema;
use crate::{enums as api_enums, payments};
use crate::enums as api_enums;
#[derive(Default, Debug, Deserialize, Serialize)]
pub struct MandateId {
@ -42,7 +43,7 @@ pub struct MandateResponse {
pub card: Option<MandateCardDetails>,
/// Details about the customers acceptance
#[schema(value_type = Option<CustomerAcceptance>)]
pub customer_acceptance: Option<payments::CustomerAcceptance>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
}
#[derive(Default, Debug, Deserialize, Serialize, ToSchema, Clone)]

View File

@ -10,6 +10,7 @@ use cards::CardNumber;
#[cfg(feature = "v2")]
use common_enums::enums::PaymentConnectorTransmission;
use common_enums::ProductType;
use common_types::payments as common_payments_types;
#[cfg(feature = "v1")]
use common_types::primitive_wrappers::{
ExtendedAuthorizationAppliedBool, RequestExtendedAuthorizationBool,
@ -1045,7 +1046,7 @@ pub struct PaymentsRequest {
/// This "CustomerAcceptance" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.
#[schema(value_type = Option<CustomerAcceptance>)]
pub customer_acceptance: Option<CustomerAcceptance>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
/// A unique identifier to link the payment to a mandate. To do Recurring payments after a mandate has been created, pass the mandate_id instead of payment_method_data
#[schema(max_length = 64, example = "mandate_iwer89rnjef349dni3")]
@ -1876,7 +1877,8 @@ pub struct MandateData {
/// A way to update the mandate's payment method details
pub update_mandate_id: Option<String>,
/// A consent from the customer to store the payment method
pub customer_acceptance: Option<CustomerAcceptance>,
#[schema(value_type = Option<CustomerAcceptance>)]
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
/// A way to select the type of mandate used
pub mandate_type: Option<MandateType>,
}
@ -1925,40 +1927,6 @@ impl Default for MandateType {
}
}
/// This "CustomerAcceptance" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.
#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct CustomerAcceptance {
/// Type of acceptance provided by the
#[schema(example = "online")]
pub acceptance_type: AcceptanceType,
/// Specifying when the customer acceptance was provided
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub accepted_at: Option<PrimitiveDateTime>,
/// Information required for online mandate generation
pub online: Option<OnlineMandate>,
}
#[derive(Default, Debug, serde::Deserialize, serde::Serialize, PartialEq, Eq, Clone, ToSchema)]
#[serde(rename_all = "lowercase")]
/// This is used to indicate if the mandate was accepted online or offline
pub enum AcceptanceType {
Online,
#[default]
Offline,
}
#[derive(Default, Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct OnlineMandate {
/// Ip address of the customer machine from which the mandate was created
#[schema(value_type = String, example = "123.32.25.123")]
pub ip_address: Option<Secret<String, pii::IpAddress>>,
/// The user-agent of the customer's browser
pub user_agent: String,
}
#[derive(Default, Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct Card {
/// The card number
@ -5379,7 +5347,7 @@ pub struct PaymentsConfirmIntentRequest {
/// This "CustomerAcceptance" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.
#[schema(value_type = Option<CustomerAcceptance>)]
pub customer_acceptance: Option<CustomerAcceptance>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
/// Additional details required by 3DS 2.0
#[schema(value_type = Option<BrowserInformation>)]
@ -5551,7 +5519,7 @@ pub struct PaymentsRequest {
/// This "CustomerAcceptance" object is passed during Payments-Confirm request, it enlists the type, time, and mode of acceptance properties related to an acceptance done by the customer. The customer_acceptance sub object is usually passed by the SDK or client.
#[schema(value_type = Option<CustomerAcceptance>)]
pub customer_acceptance: Option<CustomerAcceptance>,
pub customer_acceptance: Option<common_payments_types::CustomerAcceptance>,
/// Additional details required by 3DS 2.0
#[schema(value_type = Option<BrowserInformation>)]