pub struct Transaction { /* private fields */ }Expand description
Domain Entity: Transaction
Represents a payment transaction for article access in the paywall system. Transactions are immutable once confirmed - any changes create new events.
Domain Rules:
- Transaction must have a valid blockchain signature
- Amount must be positive and match article price
- Reader wallet must be valid
- Only pending transactions can be confirmed or failed
- Only confirmed transactions can be refunded or disputed
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(
tenant_id: TenantId,
article_id: ArticleId,
creator_id: CreatorId,
reader_wallet: WalletAddress,
amount: Money,
platform_fee_percentage: u64,
blockchain: Blockchain,
tx_signature: String,
) -> Result<Self>
pub fn new( tenant_id: TenantId, article_id: ArticleId, creator_id: CreatorId, reader_wallet: WalletAddress, amount: Money, platform_fee_percentage: u64, blockchain: Blockchain, tx_signature: String, ) -> Result<Self>
Create a new pending transaction
Sourcepub fn reconstruct(
id: TransactionId,
tenant_id: TenantId,
article_id: ArticleId,
creator_id: CreatorId,
reader_wallet: WalletAddress,
amount: Money,
platform_fee: Money,
creator_amount: Money,
blockchain: Blockchain,
tx_signature: String,
status: TransactionStatus,
created_at: DateTime<Utc>,
confirmed_at: Option<DateTime<Utc>>,
refunded_at: Option<DateTime<Utc>>,
metadata: Value,
) -> Self
pub fn reconstruct( id: TransactionId, tenant_id: TenantId, article_id: ArticleId, creator_id: CreatorId, reader_wallet: WalletAddress, amount: Money, platform_fee: Money, creator_amount: Money, blockchain: Blockchain, tx_signature: String, status: TransactionStatus, created_at: DateTime<Utc>, confirmed_at: Option<DateTime<Utc>>, refunded_at: Option<DateTime<Utc>>, metadata: Value, ) -> Self
Reconstruct transaction from storage (bypasses validation)
pub fn id(&self) -> &TransactionId
pub fn tenant_id(&self) -> &TenantId
pub fn article_id(&self) -> &ArticleId
pub fn creator_id(&self) -> &CreatorId
pub fn reader_wallet(&self) -> &WalletAddress
pub fn amount(&self) -> &Money
pub fn amount_cents(&self) -> u64
pub fn platform_fee(&self) -> &Money
pub fn platform_fee_cents(&self) -> u64
pub fn creator_amount(&self) -> &Money
pub fn creator_amount_cents(&self) -> u64
pub fn blockchain(&self) -> Blockchain
pub fn tx_signature(&self) -> &str
pub fn status(&self) -> TransactionStatus
pub fn created_at(&self) -> DateTime<Utc>
pub fn confirmed_at(&self) -> Option<DateTime<Utc>>
pub fn refunded_at(&self) -> Option<DateTime<Utc>>
pub fn metadata(&self) -> &Value
Sourcepub fn is_confirmed(&self) -> bool
pub fn is_confirmed(&self) -> bool
Check if transaction is confirmed
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Check if transaction is pending
Sourcepub fn grants_access(&self) -> bool
pub fn grants_access(&self) -> bool
Check if transaction can grant access (confirmed and not refunded)
Sourcepub fn resolve_dispute(&mut self, resolution: &str) -> Result<()>
pub fn resolve_dispute(&mut self, resolution: &str) -> Result<()>
Resolve a dispute (back to confirmed)
Sourcepub fn explorer_url(&self) -> String
pub fn explorer_url(&self) -> String
Get explorer URL for the transaction
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&Transaction> for TransactionDto
impl From<&Transaction> for TransactionDto
Source§fn from(tx: &Transaction) -> Self
fn from(tx: &Transaction) -> Self
Converts to this type from the input type.
Source§impl From<Transaction> for TransactionDto
impl From<Transaction> for TransactionDto
Source§fn from(tx: Transaction) -> Self
fn from(tx: Transaction) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
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