stripe_client.rs

 1#[cfg(test)]
 2mod fake_stripe_client;
 3mod real_stripe_client;
 4
 5use std::sync::Arc;
 6
 7use anyhow::Result;
 8use async_trait::async_trait;
 9
10#[cfg(test)]
11pub use fake_stripe_client::*;
12pub use real_stripe_client::*;
13
14#[derive(Debug, PartialEq, Eq, Hash, Clone)]
15pub struct StripeCustomerId(pub Arc<str>);
16
17#[derive(Debug, Clone)]
18pub struct StripeCustomer {
19    pub id: StripeCustomerId,
20    pub email: Option<String>,
21}
22
23#[derive(Debug)]
24pub struct CreateCustomerParams<'a> {
25    pub email: Option<&'a str>,
26}
27
28#[async_trait]
29pub trait StripeClient: Send + Sync {
30    async fn list_customers_by_email(&self, email: &str) -> Result<Vec<StripeCustomer>>;
31
32    async fn create_customer(&self, params: CreateCustomerParams<'_>) -> Result<StripeCustomer>;
33}