#[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:
Pending | RequiresAction | Authorized | Captured | Failed | Canceled | |
|---|---|---|---|---|---|---|
| Stripe | yes | yes | yes | yes | no | yes |
iyzico in_store | yes | yes | no | yes | yes | yes |
iyzico classic | yes | yes | yes | yes | yes | no |
| PayTR | no | yes | no | yes | notice only | no |
| Mollie | yes | yes | yes | yes | yes | yes |
| PayPal | yes | yes | yes | yes | yes | read-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
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.