use crate::StripeConfig;
use std::sync::OnceLock;
static STRIPE_CLIENT: OnceLock<stripe::Client> = OnceLock::new();
static STRIPE_CONFIG: OnceLock<StripeConfig> = OnceLock::new();
pub struct Stripe;
impl Stripe {
pub fn init(config: StripeConfig) {
let client = stripe::Client::new(&config.api_key);
STRIPE_CLIENT.set(client).ok();
STRIPE_CONFIG.set(config).ok();
}
pub fn client() -> &'static stripe::Client {
STRIPE_CLIENT
.get()
.expect("Stripe::init() not called before Stripe::client()")
}
pub fn config() -> &'static StripeConfig {
STRIPE_CONFIG
.get()
.expect("Stripe::init() not called before Stripe::config()")
}
}