dodopayments_rust 2.2.2

Rust SDK for Dodo Payments API
Documentation
/*
 * public
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.87.0
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PaymentResponse {
    /// Billing address details for payments
    #[serde(rename = "billing")]
    pub billing: Box<models::BillingAddress>,
    /// brand id this payment belongs to
    #[serde(rename = "brand_id")]
    pub brand_id: String,
    /// Identifier of the business associated with the payment
    #[serde(rename = "business_id")]
    pub business_id: String,
    /// Cardholder name
    #[serde(rename = "card_holder_name", skip_serializing_if = "Option::is_none")]
    pub card_holder_name: Option<String>,
    /// ISO2 country code of the card
    #[serde(rename = "card_issuing_country", skip_serializing_if = "Option::is_none")]
    pub card_issuing_country: Option<models::CountryCodeAlpha2>,
    /// The last four digits of the card
    #[serde(rename = "card_last_four", skip_serializing_if = "Option::is_none")]
    pub card_last_four: Option<String>,
    /// Card network like VISA, MASTERCARD etc.
    #[serde(rename = "card_network", skip_serializing_if = "Option::is_none")]
    pub card_network: Option<String>,
    /// The type of card DEBIT or CREDIT
    #[serde(rename = "card_type", skip_serializing_if = "Option::is_none")]
    pub card_type: Option<String>,
    /// If payment is made using a checkout session, this field is set to the id of the session.
    #[serde(rename = "checkout_session_id", skip_serializing_if = "Option::is_none")]
    pub checkout_session_id: Option<String>,
    /// Timestamp when the payment was created
    #[serde(rename = "created_at")]
    pub created_at: String,
    /// Currency used for the payment
    #[serde(rename = "currency")]
    pub currency: models::Currency,
    /// Customer's responses to custom fields collected during checkout
    #[serde(rename = "custom_field_responses", skip_serializing_if = "Option::is_none")]
    pub custom_field_responses: Option<Vec<models::CustomFieldResponse>>,
    /// Details about the customer who made the payment
    #[serde(rename = "customer")]
    pub customer: Box<models::CustomerLimitedDetailsResponse>,
    /// brand id this payment belongs to
    #[serde(rename = "digital_products_delivered")]
    pub digital_products_delivered: bool,
    /// The discount id if discount is applied
    #[serde(rename = "discount_id", skip_serializing_if = "Option::is_none")]
    pub discount_id: Option<String>,
    /// List of disputes associated with this payment
    #[serde(rename = "disputes")]
    pub disputes: Vec<models::DisputeResponse>,
    /// An error code if the payment failed
    #[serde(rename = "error_code", skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// An error message if the payment failed
    #[serde(rename = "error_message", skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,
    /// Invoice ID for this payment. Uses India-specific invoice ID if available.
    #[serde(rename = "invoice_id", skip_serializing_if = "Option::is_none")]
    pub invoice_id: Option<String>,
    /// URL to download the invoice PDF for this payment.
    #[serde(rename = "invoice_url", skip_serializing_if = "Option::is_none")]
    pub invoice_url: Option<String>,
    /// Additional custom data associated with the payment
    #[serde(rename = "metadata")]
    pub metadata: std::collections::HashMap<String, String>,
    /// Unique identifier for the payment
    #[serde(rename = "payment_id")]
    pub payment_id: String,
    /// Checkout URL
    #[serde(rename = "payment_link", skip_serializing_if = "Option::is_none")]
    pub payment_link: Option<String>,
    /// Payment method used by customer (e.g. \"card\", \"bank_transfer\")
    #[serde(rename = "payment_method", skip_serializing_if = "Option::is_none")]
    pub payment_method: Option<String>,
    /// Specific type of payment method (e.g. \"visa\", \"mastercard\")
    #[serde(rename = "payment_method_type", skip_serializing_if = "Option::is_none")]
    pub payment_method_type: Option<String>,
    /// List of products purchased in a one-time payment
    #[serde(rename = "product_cart", skip_serializing_if = "Option::is_none")]
    pub product_cart: Option<Vec<models::OneTimeProductCartItemResponse>>,
    /// Summary of the refund status for this payment. None if no succeeded refunds exist.
    #[serde(rename = "refund_status", skip_serializing_if = "Option::is_none")]
    pub refund_status: Option<models::PaymentRefundStatus>,
    /// List of refunds issued for this payment
    #[serde(rename = "refunds")]
    pub refunds: Vec<models::RefundListItem>,
    /// The amount that will be credited to your Dodo balance after currency conversion and processing. Especially relevant for adaptive pricing where the customer's payment currency differs from your settlement currency.
    #[serde(rename = "settlement_amount")]
    pub settlement_amount: i32,
    /// The currency in which the settlement_amount will be credited to your Dodo balance. This may differ from the customer's payment currency in adaptive pricing scenarios.
    #[serde(rename = "settlement_currency")]
    pub settlement_currency: models::Currency,
    /// This represents the portion of settlement_amount that corresponds to taxes collected. Especially relevant for adaptive pricing where the tax component must be tracked separately in your Dodo balance.
    #[serde(rename = "settlement_tax", skip_serializing_if = "Option::is_none")]
    pub settlement_tax: Option<i32>,
    /// Current status of the payment intent
    #[serde(rename = "status", skip_serializing_if = "Option::is_none")]
    pub status: Option<models::IntentStatus>,
    /// Identifier of the subscription if payment is part of a subscription
    #[serde(rename = "subscription_id", skip_serializing_if = "Option::is_none")]
    pub subscription_id: Option<String>,
    /// Amount of tax collected in smallest currency unit (e.g. cents)
    #[serde(rename = "tax", skip_serializing_if = "Option::is_none")]
    pub tax: Option<i32>,
    /// Total amount charged to the customer including tax, in smallest currency unit (e.g. cents)
    #[serde(rename = "total_amount")]
    pub total_amount: i32,
    /// Timestamp when the payment was last updated
    #[serde(rename = "updated_at", skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<String>,
}

impl PaymentResponse {
    pub fn new(billing: models::BillingAddress, brand_id: String, business_id: String, created_at: String, currency: models::Currency, customer: models::CustomerLimitedDetailsResponse, digital_products_delivered: bool, disputes: Vec<models::DisputeResponse>, metadata: std::collections::HashMap<String, String>, payment_id: String, refunds: Vec<models::RefundListItem>, settlement_amount: i32, settlement_currency: models::Currency, total_amount: i32) -> PaymentResponse {
        PaymentResponse {
            billing: Box::new(billing),
            brand_id,
            business_id,
            card_holder_name: None,
            card_issuing_country: None,
            card_last_four: None,
            card_network: None,
            card_type: None,
            checkout_session_id: None,
            created_at,
            currency,
            custom_field_responses: None,
            customer: Box::new(customer),
            digital_products_delivered,
            discount_id: None,
            disputes,
            error_code: None,
            error_message: None,
            invoice_id: None,
            invoice_url: None,
            metadata,
            payment_id,
            payment_link: None,
            payment_method: None,
            payment_method_type: None,
            product_cart: None,
            refund_status: None,
            refunds,
            settlement_amount,
            settlement_currency,
            settlement_tax: None,
            status: None,
            subscription_id: None,
            tax: None,
            total_amount,
            updated_at: None,
        }
    }
}