pub struct StoreCredits { /* private fields */ }Expand description
Store credit operations for managing customer balances.
Implementations§
Source§impl StoreCredits
impl StoreCredits
Sourcepub fn is_supported(&self) -> bool
pub fn is_supported(&self) -> bool
Whether store credits are supported by the active backend.
Sourcepub fn create(&self, input: CreateStoreCredit) -> Result<StoreCredit>
pub fn create(&self, input: CreateStoreCredit) -> Result<StoreCredit>
Create a new store credit.
§Example
ⓘ
use stateset_embedded::{Commerce, CreateStoreCredit, CustomerId, StoreCreditReason};
use rust_decimal_macros::dec;
let commerce = Commerce::new("./store.db")?;
let credit = commerce.store_credits().create(CreateStoreCredit {
customer_id: CustomerId::new(),
initial_balance: dec!(50.00),
reason: StoreCreditReason::GoodwillCredit,
..Default::default()
})?;Sourcepub fn get(&self, id: StoreCreditId) -> Result<Option<StoreCredit>>
pub fn get(&self, id: StoreCreditId) -> Result<Option<StoreCredit>>
Get a store credit by ID.
Sourcepub fn list(&self, filter: StoreCreditFilter) -> Result<Vec<StoreCredit>>
pub fn list(&self, filter: StoreCreditFilter) -> Result<Vec<StoreCredit>>
List store credits with optional filtering.
Sourcepub fn adjust(
&self,
id: StoreCreditId,
input: AdjustStoreCredit,
) -> Result<StoreCredit>
pub fn adjust( &self, id: StoreCreditId, input: AdjustStoreCredit, ) -> Result<StoreCredit>
Adjust a store credit balance.
Can increase or decrease the balance with a reason for the adjustment.
Sourcepub fn apply(
&self,
id: StoreCreditId,
amount: Decimal,
reference_id: Option<String>,
) -> Result<StoreCreditTransaction>
pub fn apply( &self, id: StoreCreditId, amount: Decimal, reference_id: Option<String>, ) -> Result<StoreCreditTransaction>
Apply store credit to an order (debit).
Reduces the store credit balance by the specified amount.
Sourcepub fn get_transactions(
&self,
store_credit_id: StoreCreditId,
) -> Result<Vec<StoreCreditTransaction>>
pub fn get_transactions( &self, store_credit_id: StoreCreditId, ) -> Result<Vec<StoreCreditTransaction>>
Get transaction history for a store credit.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StoreCredits
impl !UnwindSafe for StoreCredits
impl Freeze for StoreCredits
impl Send for StoreCredits
impl Sync for StoreCredits
impl Unpin for StoreCredits
impl UnsafeUnpin for StoreCredits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more