use adk_core::Result;
use async_trait::async_trait;
use crate::domain::TransactionRecord;
use crate::kernel::commands::{
BeginInterventionCommand, CancelCheckoutCommand, CompleteCheckoutCommand,
ContinueInterventionCommand, CreateCheckoutCommand, DelegatePaymentCommand,
DelegatedPaymentResult, EvidenceLookup, ExecutePaymentCommand,
ListUnresolvedTransactionsRequest, OrderUpdateCommand, PaymentExecutionResult,
StoreEvidenceCommand, StoredEvidence, SyncPaymentOutcomeCommand, TransactionLookup,
UpdateCheckoutCommand,
};
#[async_trait]
pub trait MerchantCheckoutService: Send + Sync {
async fn create_checkout(&self, command: CreateCheckoutCommand) -> Result<TransactionRecord>;
async fn update_checkout(&self, command: UpdateCheckoutCommand) -> Result<TransactionRecord>;
async fn get_checkout(&self, lookup: TransactionLookup) -> Result<Option<TransactionRecord>>;
async fn complete_checkout(
&self,
command: CompleteCheckoutCommand,
) -> Result<TransactionRecord>;
async fn cancel_checkout(&self, command: CancelCheckoutCommand) -> Result<TransactionRecord>;
async fn apply_order_update(&self, command: OrderUpdateCommand) -> Result<TransactionRecord>;
}
#[async_trait]
pub trait PaymentExecutionService: Send + Sync {
async fn execute_payment(
&self,
command: ExecutePaymentCommand,
) -> Result<PaymentExecutionResult>;
async fn sync_payment_outcome(
&self,
command: SyncPaymentOutcomeCommand,
) -> Result<TransactionRecord>;
}
#[async_trait]
pub trait DelegatedPaymentService: Send + Sync {
async fn delegate_payment(
&self,
command: DelegatePaymentCommand,
) -> Result<DelegatedPaymentResult>;
}
#[async_trait]
pub trait InterventionService: Send + Sync {
async fn begin_intervention(
&self,
command: BeginInterventionCommand,
) -> Result<TransactionRecord>;
async fn continue_intervention(
&self,
command: ContinueInterventionCommand,
) -> Result<TransactionRecord>;
}
#[async_trait]
pub trait TransactionStore: Send + Sync {
async fn upsert(&self, record: TransactionRecord) -> Result<()>;
async fn get(&self, lookup: TransactionLookup) -> Result<Option<TransactionRecord>>;
async fn list_unresolved(
&self,
request: ListUnresolvedTransactionsRequest,
) -> Result<Vec<TransactionRecord>>;
}
#[async_trait]
pub trait EvidenceStore: Send + Sync {
async fn store(&self, command: StoreEvidenceCommand) -> Result<StoredEvidence>;
async fn load(&self, lookup: EvidenceLookup) -> Result<Option<StoredEvidence>>;
}