Skip to main content

stripe_pay_core/money/
struct.rs

1use super::*;
2
3/// A currency amount stored in Stripe's smallest denomination.
4///
5/// Stripe never transmits a floating point amount, so `Money` keeps an
6/// integer minor-unit count plus the currency that determines how the
7/// value converts back to a major-unit decimal. Two USD is `200`
8/// minor units; two JPY is `2`, because JPY has no minor unit.
9///
10/// Accessors are generated by `#[derive(Getter)]`. Both fields are
11/// public because callers persist the raw minor-unit count straight
12/// into Stripe's `amount` parameter; `currency_code` pairs the two when
13/// a human-readable form is needed.
14#[derive(Clone, Copy, Debug, Eq, Getter, Hash, Ord, PartialEq, PartialOrd, serde::Serialize)]
15pub struct Money {
16    /// Amount in the currency's smallest denomination.
17    #[get(type(copy))]
18    pub(super) amount: i64,
19    /// The currency the amount is denominated in.
20    #[get(type(copy))]
21    pub(super) currency: Currency,
22}