pub struct Refund {
pub id: Option<RefundId>,
pub payment: PaymentId,
pub amount: Money,
pub status: RefundStatus,
pub next_action: Option<NextAction>,
pub provider: ProviderId,
pub raw: Raw,
}Expand description
Money given back off a payment, as the provider currently sees it.
Every field is public and the struct is open, for the same reason
Charge is: an adapter in someone else’s repository has
to be able to build one.
§There is no refunded status on the payment
Status has no variant for it and will not grow one — no
provider reports a refund as a payment status, so it would be a branch that
never runs for most of them. “Has all of this gone back” is these objects
summed with Money::checked_add against
Charge::amount, and each adapter has a call that
lists them.
Fields§
§id: Option<RefundId>How the provider names this refund, where it names it at all.
None is not a missing field: iyzico issues no identifier for a
refund. The nearest thing it has is the bank’s hostReference, which
exists only once the money has gone and so is no use for making the
attempt idempotent. So this is Option for the same reason
Charge::id is — a composed key handed back in
the field a real one lives in would read as a guarantee nobody made.
Read Id::source before writing one into a unique
index.
payment: PaymentIdThe payment the money came off.
amount: MoneyHow much went back.
What the provider says it refunded, not what was asked for. A provider
that refunds the remainder of a partly-refunded payment answers the
remainder here, and it is smaller than
RefundRequest::amount was.
status: RefundStatusWhere it stands.
next_action: Option<NextAction>What somebody must do before the money moves, if anything.
iyzico’s In-Store refund is the one that has one: it answers a deep
link into iyzico’s app, and the refund happens when the payer approves
it there. Everywhere else this is None — the refund was accepted by
the time the call answered.
provider: ProviderIdWhich provider this came from.
raw: RawThe provider’s own response, untouched.