Payment attempt and status
PaymentAttempt tracks three aspects of one payment:
- What the client knows about its own submit (
SubmissionState): was it sent, did an answer arrive? - The business status the server reports (
PaymentStatusinside aPaymentStatusSnapshot). - How fresh the last observation is (
Observation:fresh,refreshing,unavailable).
Unknown is not failure
Section titled “Unknown is not failure”When a submit times out before a server reference arrives, the attempt keeps going as SubmissionState.outcomeUnknown. The server may already have charged. Only a host status check with the same attempt reference can resolve it.
“Unknown” means the client has no confirmed answer; it is not a provider status. The screen leads with “Don’t pay again.”, uses a hatched band to distinguish it from pending, and offers one action: check status.




The same rule holds everywhere: a timeout, an offline refresh or an elapsed countdown never becomes “failed” or “paid”. In transaction history a record with status: null is “not confirmed yet” and falls under In progress, never Unsuccessful.
Business statuses
Section titled “Business statuses”| Status | Meaning |
|---|---|
requiresAction |
The customer must act on host instructions |
processing |
The request is being executed |
pending |
The transaction is known but waits for payment, review or settlement; the host supplies the reason and actions |
succeeded, failed, canceled, expired |
Final (PaymentStatus.isTerminal) |
None of requiresAction, processing or pending allows the UI to infer success or to send a new payment automatically. Unknown wire values parse to null with PaymentStatus.tryParse, so your adapter can reject the snapshot instead of guessing.
Reconciling snapshots
Section titled “Reconciling snapshots”Send every status response through attempt.reconcile(snapshot). It returns a ReconcileResult: either the updated attempt, or the unchanged attempt plus a ReconcileRejection.
| Rejection | When |
|---|---|
wrongAttempt |
The snapshot belongs to another attempt |
referenceMismatch |
The server reference differs from the one already known |
stale |
Its revision is not newer than the current one (late or duplicate) |
successDowngrade |
A succeeded payment would change to another status without isCorrection: true (an official provider correction) |
final result = attempt.reconcile(snapshot);attempt = result.attempt;if (!result.applied) debugPrint('ignored: ${result.rejection}');No pay-again while unresolved
Section titled “No pay-again while unresolved”attempt.availableActions decides what PaymentStatusView can offer:
- Nothing was sent (
notSent): no actions. - The outcome is unknown, or no snapshot has arrived yet:
checkStatusonly. - Otherwise: the snapshot’s
allowedActions, minusstartNewAttemptunlessattempt.allowsNewAttemptis true.
allowsNewAttempt is true only when the submit was accepted, the status is final, it is not succeeded, and your host listed PaymentAction.startNewAttempt. So a new attempt appears only after a confirmed failure, cancellation or expiry, and only if you allow it. It never appears while the payment is pending or unknown.
The button blocks repeated taps while loading. Your backend must still prevent duplicate payments: keep the same idempotency key (attemptId) for every retry and status check of an attempt, and create a new key only for a new legitimate attempt.
Changed terms need new consent
Section titled “Changed terms need new consent”PaymentQuote.termsDifferFrom(other) is true when the total, the method or any line differs. Pass the previous quote to PaymentSummary and PaymentConfirmation as previousQuote: the summary shows a notice with both totals, and the confirmation keeps its action unreachable until the customer accepts the new total. A quote or method that changes after authorization needs review and a new authorization.
Countdowns use the host clock
Section titled “Countdowns use the host clock”PaymentInstructions and CountdownText take a clock function from your host. The countdown stops at zero without going negative and calls onElapsed once. Reaching zero is not proof that the customer did not pay: check status before any final decision.
Refunds are separate
Section titled “Refunds are separate”A refund never rewrites the original payment. RefundInfo (RefundStatus: none, pending, partial, refunded, failed) travels on the snapshot, the receipt data and TransactionRecord, and RefundSection shows it in its own section beside the original payment. A refunded payment keeps its original amount, unstruck, and its success state. Refund processing itself is your backend’s; the kit has no refund button.
Leaving is not cancelling
Section titled “Leaving is not cancelling”Closing a screen does not cancel a transaction. A sheet’s Close only closes the UI. Requesting cancellation (PaymentAction.requestCancel) is a separate host call, behind a confirmation, and the UI says “canceled” only after your host confirms it.
PaymentAttempt
class PaymentAttempt · lib/src/payment/payment_models.dart
Local record of one payment attempt.
attemptId is the client-side identity the host uses as idempotency reference; it stays the same for every retry or reconciliation of this attempt.
| Parameter | Type | Default | Description |
|---|---|---|---|
attemptId:required | String | — | — |
quoteId:required | String | — | — |
quoteRevision:required | int | — | — |
methodId:required | String | — | — |
submission: | SubmissionState | SubmissionState.notSent | — |
snapshot: | PaymentStatusSnapshot? | — | Last trusted snapshot; kept when a refresh fails so the UI can show the last-known state. |
observation: | Observation | Observation.fresh | — |
lastCheckedAt: | DateTime? | — | — |
SubmissionState
enum SubmissionState · lib/src/payment/payment_models.dart
What the client knows about its own submission, independent of the business status.
| Value | Description |
|---|---|
notSent | Prepared but not sent; may still be abandoned. |
sending | One submit call is in flight. |
accepted | The server acknowledged the attempt with a reference. |
outcomeUnknown | Sent, but no answer arrived. The server may have charged; only a host status check with the same attempt reference can resolve this. |
Observation
enum Observation · lib/src/payment/payment_models.dart
Freshness of the last observed status.
| Value | Description |
|---|---|
fresh | — |
refreshing | — |
unavailable | — |
PaymentStatusSnapshot
class PaymentStatusSnapshot · lib/src/payment/payment_models.dart
An authoritative status snapshot produced by the host adapter.
| Parameter | Type | Default | Description |
|---|---|---|---|
attemptId:required | String | — | — |
serverReference:required | String | — | — |
status:required | PaymentStatus | — | — |
revision:required | int | — | Monotonic server revision used to order snapshots. |
updatedAt:required | DateTime | — | — |
allowedActions: | Set<PaymentAction> | const {} | — |
safeReason: | String? | — | — |
refund: | RefundInfo | const RefundInfo(status: RefundStatus.none) | — |
instructions: | VirtualAccountInstructions? | — | — |
isCorrection: | bool | false | An official provider correction, the only way a succeeded payment may change to another business status. |
PaymentStatus
enum PaymentStatus · lib/src/payment/payment_models.dart
Business status reported by the host after the server knows the payment.
| Value | Description |
|---|---|
requiresAction | — |
processing | — |
pending | — |
succeeded | — |
failed | — |
canceled | — |
expired | — |
PaymentAction
enum PaymentAction · lib/src/payment/payment_models.dart
Actions the host currently allows for an attempt.
| Value | Description |
|---|---|
checkStatus | — |
viewInstructions | — |
requestCancel | — |
startNewAttempt | — |
viewReceipt | — |
contactSupport | — |
ReconcileResult
class ReconcileResult · lib/src/payment/payment_models.dart
ReconcileResult.applied(…)
| Parameter | Type | Default | Description |
|---|---|---|---|
attemptrequiredpositional | PaymentAttempt | — | — |
ReconcileResult.rejected(…)
| Parameter | Type | Default | Description |
|---|---|---|---|
attemptrequiredpositional | PaymentAttempt | — | — |
rejectionrequiredpositional | ReconcileRejection? | — | — |
ReconcileRejection
enum ReconcileRejection · lib/src/payment/payment_models.dart
| Value | Description |
|---|---|
wrongAttempt | — |
referenceMismatch | — |
stale | — |
successDowngrade | — |
RefundInfo
class RefundInfo · lib/src/payment/payment_models.dart
| Parameter | Type | Default | Description |
|---|---|---|---|
status:required | RefundStatus | — | — |
amount: | Money? | — | — |
updatedAt: | DateTime? | — | — |
safeReason: | String? | — | — |
RefundStatus
enum RefundStatus · lib/src/payment/payment_models.dart
Refund lifecycle, tracked separately so a refund never rewrites the original payment result.
| Value | Description |
|---|---|
none | — |
pending | — |
partial | — |
refunded | — |
failed | — |