dodopayments_rust 2.2.1

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 CreateCheckoutSessionRequest {
    /// Customers will never see payment methods that are not in this list. However, adding a method here does not guarantee customers will see it. Availability still depends on other factors (e.g., customer location, merchant settings).  Disclaimar: Always provide 'credit' and 'debit' as a fallback. If all payment methods are unavailable, checkout session will fail.
    #[serde(rename = "allowed_payment_method_types", skip_serializing_if = "Option::is_none")]
    pub allowed_payment_method_types: Option<Vec<models::PaymentMethodTypes>>,
    /// Billing address information for the session
    #[serde(rename = "billing_address", skip_serializing_if = "Option::is_none")]
    pub billing_address: Option<Box<models::CheckoutSessionBillingAddress>>,
    /// This field is ingored if adaptive pricing is disabled
    #[serde(rename = "billing_currency", skip_serializing_if = "Option::is_none")]
    pub billing_currency: Option<models::Currency>,
    /// If confirm is true, all the details will be finalized. If required data is missing, an API error is thrown.
    #[serde(rename = "confirm", skip_serializing_if = "Option::is_none")]
    pub confirm: Option<bool>,
    /// Custom fields to collect from customer during checkout (max 5 fields)
    #[serde(rename = "custom_fields", skip_serializing_if = "Option::is_none")]
    pub custom_fields: Option<Vec<models::CustomField>>,
    /// Customer details for the session
    #[serde(rename = "customer", skip_serializing_if = "Option::is_none")]
    pub customer: Option<Box<models::CustomerRequest>>,
    /// Customization for the checkout session page
    #[serde(rename = "customization", skip_serializing_if = "Option::is_none")]
    pub customization: Option<Box<models::CheckoutSessionCustomization>>,
    #[serde(rename = "discount_code", skip_serializing_if = "Option::is_none")]
    pub discount_code: Option<String>,
    #[serde(rename = "feature_flags", skip_serializing_if = "Option::is_none")]
    pub feature_flags: Option<Box<models::CheckoutSessionFlags>>,
    /// Override merchant default 3DS behaviour for this session
    #[serde(rename = "force_3ds", skip_serializing_if = "Option::is_none")]
    pub force_3ds: Option<bool>,
    /// Additional metadata associated with the payment. Defaults to empty if not provided.
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// If true, only zipcode is required when confirm is true; other address fields remain optional
    #[serde(rename = "minimal_address", skip_serializing_if = "Option::is_none")]
    pub minimal_address: Option<bool>,
    /// Optional payment method ID to use for this checkout session. Only allowed when `confirm` is true. If provided, existing customer id must also be provided.
    #[serde(rename = "payment_method_id", skip_serializing_if = "Option::is_none")]
    pub payment_method_id: Option<String>,
    #[serde(rename = "product_cart")]
    pub product_cart: Vec<models::ProductItemReq>,
    /// Product collection ID for collection-based checkout flow
    #[serde(rename = "product_collection_id", skip_serializing_if = "Option::is_none")]
    pub product_collection_id: Option<String>,
    /// The url to redirect after payment failure or success.
    #[serde(rename = "return_url", skip_serializing_if = "Option::is_none")]
    pub return_url: Option<String>,
    /// If true, returns a shortened checkout URL. Defaults to false if not specified.
    #[serde(rename = "short_link", skip_serializing_if = "Option::is_none")]
    pub short_link: Option<bool>,
    /// Display saved payment methods of a returning customer False by default
    #[serde(rename = "show_saved_payment_methods", skip_serializing_if = "Option::is_none")]
    pub show_saved_payment_methods: Option<bool>,
    #[serde(rename = "subscription_data", skip_serializing_if = "Option::is_none")]
    pub subscription_data: Option<Box<models::SubscriptionData>>,
    /// Tax ID for the customer (e.g. VAT number). Requires billing_address with country.
    #[serde(rename = "tax_id", skip_serializing_if = "Option::is_none")]
    pub tax_id: Option<String>,
}

impl CreateCheckoutSessionRequest {
    pub fn new(product_cart: Vec<models::ProductItemReq>) -> CreateCheckoutSessionRequest {
        CreateCheckoutSessionRequest {
            allowed_payment_method_types: None,
            billing_address: None,
            billing_currency: None,
            confirm: None,
            custom_fields: None,
            customer: None,
            customization: None,
            discount_code: None,
            feature_flags: None,
            force_3ds: None,
            metadata: None,
            minimal_address: None,
            payment_method_id: None,
            product_cart,
            product_collection_id: None,
            return_url: None,
            short_link: None,
            show_saved_payment_methods: None,
            subscription_data: None,
            tax_id: None,
        }
    }
}