#[non_exhaustive]pub struct BasketItem {
pub id: Box<str>,
pub name: Box<str>,
pub category: Option<Box<str>>,
pub kind: ItemKind,
pub price: Money,
pub quantity: u32,
}Expand description
One line of what is being paid for.
BasketItem::price is what one of the thing costs, and
BasketItem::line_total is what the line comes to. The distinction is
not cosmetic: PayTR takes the unit price and the count as two fields, and
iyzico takes one figure and has nowhere to put a count, so an adapter that
guessed which of the two it had been handed would silently charge a basket
of three for one.
The sum of a basket does not have to equal
ChargeRequest::amount, and nothing here
checks that it does: an instalment surcharge is money the payer is charged
and not a line of the basket, which is exactly the difference
Charge::order_amount exists for.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: Box<str>The shop’s own id for it.
name: Box<str>What it is called.
category: Option<Box<str>>The category it sits in. iyzico asks; nobody else does.
kind: ItemKindWhether it ships.
price: MoneyWhat one of it costs. BasketItem::line_total is the whole line.
quantity: u32How many. PayTR sends this as its own field; iyzico has no such field, so its adapter sends the line total instead.
Implementations§
Source§impl BasketItem
impl BasketItem
Sourcepub fn new(
id: impl Into<Box<str>>,
name: impl Into<Box<str>>,
price: Money,
) -> BasketItem
pub fn new( id: impl Into<Box<str>>, name: impl Into<Box<str>>, price: Money, ) -> BasketItem
One line, priced.
Sourcepub fn category(self, category: impl Into<Box<str>>) -> BasketItem
pub fn category(self, category: impl Into<Box<str>>) -> BasketItem
Says which category it sits in.
Sourcepub const fn virtual_item(self) -> BasketItem
pub const fn virtual_item(self) -> BasketItem
Marks the line as something that does not ship.
Sourcepub const fn quantity(self, quantity: u32) -> BasketItem
pub const fn quantity(self, quantity: u32) -> BasketItem
Says how many of it.
Sourcepub fn line_total(&self) -> Result<Money, MoneyError>
pub fn line_total(&self) -> Result<Money, MoneyError>
What the line comes to: the unit price times the count.
Trait Implementations§
Source§impl Clone for BasketItem
impl Clone for BasketItem
Source§fn clone(&self) -> BasketItem
fn clone(&self) -> BasketItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BasketItem
impl Debug for BasketItem
impl Eq for BasketItem
Source§impl PartialEq for BasketItem
impl PartialEq for BasketItem
impl StructuralPartialEq for BasketItem
Auto Trait Implementations§
impl Freeze for BasketItem
impl RefUnwindSafe for BasketItem
impl Send for BasketItem
impl Sync for BasketItem
impl Unpin for BasketItem
impl UnsafeUnpin for BasketItem
impl UnwindSafe for BasketItem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.