Skip to main content

Charge

Struct Charge 

Source
pub struct Charge {
    pub id: Option<PaymentId>,
    pub order: Option<OrderRef>,
    pub amount: Money,
    pub order_amount: Option<Money>,
    pub status: Status,
    pub next_action: Option<NextAction>,
    pub provider: ProviderId,
    pub raw: Raw,
}
Expand description

A charge, as the provider currently sees it.

Every field is public and the struct is open: a provider adapter living outside this workspace has to be able to build one.

Fields§

§id: Option<PaymentId>

How the provider names this payment, where it names it at all.

None is a payment nothing identifies yet — an iyzico checkout form the payer has not finished has no paymentId — and it is None rather than an empty string so that it cannot be handed back as a handle and quietly read as a payment nobody made. A provider that never issues one and has nothing to compose one from answers None here always, and ErrorKind::Unsupported to Provider::charge_status.

Read PaymentId::source before writing one into a unique index.

§order: Option<OrderRef>

The order reference the charge was created against, when the provider kept it.

§amount: Money

What the payer is charged. The money that moves.

Not always what the goods came to: an instalment surcharge lands here and not on the basket. This is the figure that reconciles against a bank statement.

§order_amount: Option<Money>

What the goods came to, when the provider reports it separately and it differs from Charge::amount.

None does not mean the two are equal — it means this provider does not say. Stripe has no basket at all at the payment level, so it never answers; iyzico’s price and PayTR’s payment_amount do.

§status: Status

Where it stands.

§next_action: Option<NextAction>

What the payer must do next, if anything.

§provider: ProviderId

Which provider this came from.

§raw: Raw

The provider’s own response, untouched.

The escape hatch: everything kasapay does not model is still here.

Trait Implementations§

Source§

impl Clone for Charge

Source§

fn clone(&self) -> Charge

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Charge

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.