dodo_payments 0.1.1

This is Unoffical SDK of dodopayments.com
Documentation
use dodo_payments::{
    DodoPayments, client::DodoPaymentsConfigBuilder, operations::common::structs::*,
};
use std::env;

#[tokio::main]
async fn main() {
    let bearer_token = env::var("DODO_PAYMENTS_BEARER_TOKEN")
        .expect("DODO_PAYMENTS_BEARER_TOKEN must be set in env variables");
    let product_id = env::var("DODO_PAYMENTS_PRODUCT_ID")
        .expect("DODO_PAYMENTS_PRODUCT_ID must be set in env variables");
    let customer_id = env::var("DODO_PAYMENTS_CUSTOMER_ID")
        .expect("DODO_PAYMENTS_CUSTOMER_ID must be set in env variables");

    let client = DodoPayments::new(
        DodoPaymentsConfigBuilder::new()
            .bearer_token(&bearer_token)
            .environment("test_mode"),
    );

    let product_cart = vec![ProductItem {
        product_id: product_id.clone(),
        quantity: 1,
        amount: Some(100),
        addons: None,
    }];

    let customer = CustomerRequest::AttachExisting(AttachExistingCustomer { customer_id });

    let billing = BillingAddress {
        street: Some("123 Main St".to_string()),
        city: Some("Anytown".to_string()),
        state: Some("CA".to_string()),
        country: CountryCodeAlpha2::US,
        zipcode: Some("90210".to_string()),
    };

    let response = client
        .one_time_payments(product_cart, customer, billing)
        .send()
        .await;

    println!("Response: {:#?}", response);
}