Skip to main content

Status

Enum Status 

Source
#[non_exhaustive]
pub enum Status { Pending, RequiresAction, Authorized, Captured, Failed, Canceled, }
Expand description

Where a payment stands.

§Not every provider can produce every one of these

A caller that branches on a status a provider never sends has written a branch that never runs, and the compiler cannot say so. What each adapter can actually produce, from reading their mappings:

PendingRequiresActionAuthorizedCapturedFailedCanceled
Stripeyesyesyesyesnoyes
iyzico in_storeyesyesnoyesyesyes
iyzico classicyesyesyesyesyesno
PayTRnoyesnoyesnotice onlyno
Mollieyesyesyesyesyesyes
PayPalyesyesyesyesyesread-only

Five of those cells are worth knowing about.

Stripe never reports Failed. A PaymentIntent whose card was declined goes back to requires_payment_method, which arrives here as Status::RequiresAction — and that is honest, because the payer can try another card. A caller waiting for Failed from Stripe waits forever.

PayTR reports a refusal only on the payment notice. Its status query answers a payment that succeeded or an error, so Failed comes from Notice::charge and never from charge_status. Worse, that error is the same for a payment PayTR refused and an order it has never heard of — ErrorKind::NotFound either way, because PayTR sends nothing that separates them.

Mollie’s Failed is two of its own states. A payment it refused is failed; one the payer abandoned until it could no longer be paid is expired, which is neither a refusal nor a withdrawal and has no word here. Both arrive as Status::Failed, and which it was is in Charge::raw. A caller counting declines separately from abandoned checkouts reads it there.

iyzico’s classic API answers Authorized only for a payment it was asked to hold. classic::Client::start_checkout_form_preauth and preauth_with_saved_card are what ask; the ordinary form and /payment/auth take the money as they go and answer Status::Captured. One thing that cell hides: a payment read back after a hold reads as Captured too, because iyzico answers paymentStatus: SUCCESS for both and names no values for the field that would separate them. The adapter says so where a reader meets it.

PayPal’s Canceled is read-only. VOIDED is a real value of its order_status enum, but nothing kasapay-paypal calls ever produces one: its Provider::cancel always refuses, because PayPal’s Orders v2 API has no operation that withdraws an order. The only way this crate ever answers Canceled for PayPal is Provider::charge_status reading an order some other integration voided.

Each adapter’s own documentation says the same thing where a reader will meet it.

§Nothing here says a payment was refunded

No provider reports one as a status. Stripe’s PaymentIntent stays succeeded with the refunds beside it, PayTR lists them on the payment, and iyzico’s In-Store receipt sets a flag on a payment that is still captured. A variant only one of them could ever produce would be a branch that never runs for the others.

So “how much of this has gone back” is the adapter’s own refunds — Stripe’s and PayTR’s both answer a list — summed with Money::checked_add and compared against Charge::amount. Mollie is the one that answers the figure outright, as amountRefunded on a payment that still reads paid, and it is read off Charge::raw rather than off a status.

PayPal is the odd one out here rather than the usual shape: its capture carries PARTIALLY_REFUNDED and REFUNDED as two of the values of its own status field, the one thing this workspace reads to decide Status::Captured in the first place, rather than as a separate figure beside it. kasapay-paypal maps both to Status::Captured for the same reason every other refund fact is off Status — the money was taken, which is what that variant says — and the more specific answer is on Charge::raw there too.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Pending

Accepted, nothing more required yet, not settled.

§

RequiresAction

Stalled until the payer does something — see Charge::next_action.

§

Authorized

Funds are held but not taken.

§

Captured

Funds are taken.

§

Failed

Refused, and will not proceed.

§

Canceled

Withdrawn before it completed.

Implementations§

Source§

impl Status

Source

pub const fn is_open(self) -> bool

Whether the payment can still change without a further request from us.

Trait Implementations§

Source§

impl Clone for Status

Source§

fn clone(&self) -> Status

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 Copy for Status

Source§

impl Debug for Status

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Status

Source§

impl Hash for Status

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Status

Source§

fn eq(&self, other: &Status) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Status

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.