Repository: juspay/hyperswitch
File: crates/api_models/src/subscription.rs (Rust)

Code before:
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct PaymentResponseData {
    pub payment_id: PaymentId,
    pub status: IntentStatus,
    pub amount: MinorUnit,
    pub currency: Currency,
    pub profile_id: Option<ProfileId>,
    pub connector: Option<String>,
    /// Identifier for Payment Method
    #[schema(value_type = Option<String>, example = "pm_01926c58bc6e77c09e809964e72af8c8")]
    pub payment_method_id: Option<Secret<String>>,
    /// The url to which user must be redirected to after completion of the purchase
    #[schema(value_type = Option<String>)]
    pub return_url: Option<Url>,
    pub next_action: Option<NextActionData>,
    pub payment_experience: Option<PaymentExperience>,
    pub error_code: Option<String>,
    pub error_message: Option<String>,
    pub payment_method_type: Option<PaymentMethodType>,
    #[schema(value_type = Option<String>)]
    /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
    pub client_secret: Option<Secret<String>>,
    pub billing: Option<Address>,
    pub shipping: Option<Address>,
    pub payment_type: Option<PaymentType>,
    pub payment_token: Option<String>,
}

impl PaymentResponseData {
    pub fn get_billing_address(&self) -> Option<Address> {
        self.billing.clone()
    }
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct CreateMitPaymentRequestData {
    pub amount: MinorUnit,
    pub currency: Currency,
    pub confirm: bool,
    pub customer_id: Option<CustomerId>,
    pub recurring_details: Option<RecurringDetails>,
    pub off_session: Option<bool>,
    pub profile_id: Option<ProfileId>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ConfirmSubscriptionRequest {
    #[schema(value_type = Option<String>)]
    /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
    pub client_secret: Option<ClientSecret>,


Review comment (security):
```suggestion
    pub payment_token: Option<Secret<String>>,
```

Code after:
    pub off_session: Option<bool>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct PaymentResponseData {
    pub payment_id: PaymentId,
    pub status: IntentStatus,
    pub amount: MinorUnit,
    pub currency: Currency,
    pub profile_id: Option<ProfileId>,
    pub connector: Option<String>,
    /// Identifier for Payment Method
    #[schema(value_type = Option<String>, example = "pm_01926c58bc6e77c09e809964e72af8c8")]
    pub payment_method_id: Option<Secret<String>>,
    /// The url to which user must be redirected to after completion of the purchase
    #[schema(value_type = Option<String>)]
    pub return_url: Option<Url>,
    pub next_action: Option<NextActionData>,
    pub payment_experience: Option<PaymentExperience>,
    pub error_code: Option<String>,
    pub error_message: Option<String>,
    pub payment_method_type: Option<PaymentMethodType>,
    #[schema(value_type = Option<String>)]
    /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
    pub client_secret: Option<Secret<String>>,
    pub billing: Option<Address>,
    pub shipping: Option<Address>,
    pub payment_type: Option<PaymentType>,
    #[schema(value_type = Option<String>, example = "token_sxJdmpUnpNsJk5VWzcjl")]
    pub payment_token: Option<Secret<String>>,
}

impl PaymentResponseData {
    pub fn get_billing_address(&self) -> Option<Address> {
        self.billing.clone()
    }
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct CreateMitPaymentRequestData {
    pub amount: MinorUnit,
    pub currency: Currency,
    pub confirm: bool,
    pub customer_id: Option<CustomerId>,
    pub recurring_details: Option<RecurringDetails>,
    pub off_session: Option<bool>,
    pub profile_id: Option<ProfileId>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ConfirmSubscriptionRequest {