pub struct Payment {Show 37 fields
pub id: PaymentId,
pub payment_number: String,
pub order_id: Option<OrderId>,
pub invoice_id: Option<Uuid>,
pub customer_id: Option<CustomerId>,
pub status: PaymentTransactionStatus,
pub payment_method: PaymentMethodType,
pub amount: Decimal,
pub currency: CurrencyCode,
pub amount_refunded: Decimal,
pub external_id: Option<String>,
pub idempotency_key: Option<String>,
pub processor: Option<String>,
pub card_brand: Option<CardBrand>,
pub card_last4: Option<String>,
pub card_exp_month: Option<i32>,
pub card_exp_year: Option<i32>,
pub blockchain_network: Option<BlockchainNetwork>,
pub stablecoin_type: Option<StablecoinType>,
pub from_wallet_address: Option<String>,
pub to_wallet_address: Option<String>,
pub tx_hash: Option<String>,
pub block_number: Option<i64>,
pub confirmations: Option<i32>,
pub token_address: Option<String>,
pub ves_intent_id: Option<String>,
pub billing_email: Option<String>,
pub billing_name: Option<String>,
pub billing_address: Option<String>,
pub description: Option<String>,
pub failure_reason: Option<String>,
pub failure_code: Option<String>,
pub metadata: Option<String>,
pub paid_at: Option<DateTime<Utc>>,
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
A payment transaction
Fields§
§id: PaymentIdUnique payment ID
payment_number: StringHuman-readable payment number
order_id: Option<OrderId>Associated order ID (optional - can be standalone payment)
invoice_id: Option<Uuid>Associated invoice ID (optional)
customer_id: Option<CustomerId>Customer ID
status: PaymentTransactionStatusPayment status
payment_method: PaymentMethodTypePayment method used
amount: DecimalPayment amount
currency: CurrencyCodeCurrency code (ISO 4217)
amount_refunded: DecimalAmount refunded
external_id: Option<String>External payment processor ID (e.g., Stripe payment intent ID)
idempotency_key: Option<String>Idempotency key for safely retrying payment creation
processor: Option<String>Payment processor/gateway used
card_brand: Option<CardBrand>Card brand (if card payment)
card_last4: Option<String>Last 4 digits of card (if card payment)
card_exp_month: Option<i32>Card expiry month (if card payment)
card_exp_year: Option<i32>Card expiry year (if card payment)
blockchain_network: Option<BlockchainNetwork>Blockchain network (for crypto/stablecoin payments)
stablecoin_type: Option<StablecoinType>Stablecoin type (USDC, USDT, ssUSD, etc.)
from_wallet_address: Option<String>Sender wallet address
to_wallet_address: Option<String>Recipient wallet address
tx_hash: Option<String>On-chain transaction hash/signature
block_number: Option<i64>Block number where transaction was confirmed
confirmations: Option<i32>Number of on-chain confirmations
token_address: Option<String>Token contract/mint address (for token transfers)
ves_intent_id: Option<String>VES payment intent ID (for audit trail)
billing_email: Option<String>Billing email
billing_name: Option<String>Billing name
billing_address: Option<String>Billing address
description: Option<String>Payment description
failure_reason: Option<String>Failure reason (if failed)
failure_code: Option<String>Failure code from processor
metadata: Option<String>Metadata (JSON)
paid_at: Option<DateTime<Utc>>When payment was completed
version: i32Version for optimistic locking
created_at: DateTime<Utc>When payment was created
updated_at: DateTime<Utc>When payment was last updated
Implementations§
Source§impl Payment
impl Payment
Sourcepub fn refundable_remaining(&self) -> Decimal
pub fn refundable_remaining(&self) -> Decimal
The amount of this payment that has not yet been refunded.
Sourcepub fn validate_refund(
&self,
requested: Option<Decimal>,
) -> Result<Decimal, CommerceError>
pub fn validate_refund( &self, requested: Option<Decimal>, ) -> Result<Decimal, CommerceError>
Validate and resolve a refund request against this payment.
requested is the caller-supplied refund amount; when None the full
remaining refundable balance is used. Returns the resolved refund amount
on success.
§Errors
Returns crate::CommerceError::ValidationError when:
- the payment is not in a refundable status (only
Completed/PartiallyRefundedpayments can be refunded), - the requested (or resolved) amount is zero or negative, or
- the requested amount exceeds the remaining refundable balance.