use crate::payments::error::Error;
use async_trait::async_trait;
use pbbson::Model;

#[async_trait]
pub trait PaymentProcessor<B: ToString>: Sync + Send {
    // Creates a checkout session.
    async fn create_checkout_session(
        &self,
        account: Model,
        plan: Model,
        plan_metadata_field: &str,
        client_reference_id: Option<String>,
        success_url: Option<String>,
        cancel_url: Option<String>,
    ) -> Result<Model, Error>;

    // Ensure the given account is synced with the payment processor. For example, with Stripe
    // this means maintaining a Stripe Customer record for each account.
    async fn sync_account(&self, account: Model, accounts_bucket: B) -> Result<Model, Error>;

    // Ensure the given service plan is synced with the payment processor. For example, with
    // Stripe this means maintaining a Stripe Product record, and corresponding Stripe Price
    // records.
    async fn sync_plan(
        &self,
        plan: Model,
        plan_metadata_field: &str,
        services_bucket: B,
        plans_bucket: B,
    ) -> Result<Model, Error>;
}
