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 CreateOneTimePaymentRequest {
    /// List of payment methods allowed during checkout.  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).
    #[serde(rename = "allowed_payment_method_types", skip_serializing_if = "Option::is_none")]
    pub allowed_payment_method_types: Option<Vec<models::PaymentMethodTypes>>,
    /// Billing address details for the payment
    #[serde(rename = "billing")]
    pub billing: Box<models::BillingAddress>,
    /// Fix the currency in which the end customer is billed. If Dodo Payments cannot support that currency for this transaction, it will not proceed
    #[serde(rename = "billing_currency", skip_serializing_if = "Option::is_none")]
    pub billing_currency: Option<models::Currency>,
    /// Customer information for the payment
    #[serde(rename = "customer")]
    pub customer: Box<models::CustomerRequest>,
    /// Discount Code to apply to the transaction
    #[serde(rename = "discount_code", skip_serializing_if = "Option::is_none")]
    pub discount_code: Option<String>,
    /// Override merchant default 3DS behaviour for this payment
    #[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>>,
    /// Whether to generate a payment link. Defaults to false if not specified.
    #[serde(rename = "payment_link", skip_serializing_if = "Option::is_none")]
    pub payment_link: Option<bool>,
    /// Optional payment method ID to use for this payment. If provided, customer_id must also be provided. The payment method will be validated for eligibility with the payment's currency.
    #[serde(rename = "payment_method_id", skip_serializing_if = "Option::is_none")]
    pub payment_method_id: Option<String>,
    /// List of products in the cart. Must contain at least 1 and at most 100 items.
    #[serde(rename = "product_cart")]
    pub product_cart: Vec<models::OneTimeProductCartItemReq>,
    /// If true, redirects the customer immediately after payment completion False by default
    #[serde(rename = "redirect_immediately", skip_serializing_if = "Option::is_none")]
    pub redirect_immediately: Option<bool>,
    /// Optional URL to redirect the customer after payment. Must be a valid URL if provided.
    #[serde(rename = "return_url", skip_serializing_if = "Option::is_none")]
    pub return_url: Option<String>,
    /// If true, returns a shortened payment link. 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>,
    /// Tax ID in case the payment is B2B. If tax id validation fails the payment creation will fail
    #[serde(rename = "tax_id", skip_serializing_if = "Option::is_none")]
    pub tax_id: Option<String>,
}

impl CreateOneTimePaymentRequest {
    pub fn new(billing: models::BillingAddress, customer: models::CustomerRequest, product_cart: Vec<models::OneTimeProductCartItemReq>) -> CreateOneTimePaymentRequest {
        CreateOneTimePaymentRequest {
            allowed_payment_method_types: None,
            billing: Box::new(billing),
            billing_currency: None,
            customer: Box::new(customer),
            discount_code: None,
            force_3ds: None,
            metadata: None,
            payment_link: None,
            payment_method_id: None,
            product_cart,
            redirect_immediately: None,
            return_url: None,
            short_link: None,
            show_saved_payment_methods: None,
            tax_id: None,
        }
    }
}