Skip to content
Get started
Menu
Get started

Payment attempt and status

PaymentAttempt tracks three aspects of one payment:

  1. What the client knows about its own submit (SubmissionState): was it sent, did an answer arrive?
  2. The business status the server reports (PaymentStatus inside a PaymentStatusSnapshot).
  3. How fresh the last observation is (Observation: fresh, refreshing, unavailable).

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.

Unknown outcome: hatched amber band, Result not confirmed yet, the amount, Don't pay again, Check status.Unknown outcome: hatched amber band, Result not confirmed yet, the amount, Don't pay again, Check status.
Unknown: hatched band
Pending in Indonesian: solid amber band, Menunggu, the amount and an explanation.
Pending: solid band (Indonesian)
Transaction detail sheet in Indonesian for an unconfirmed payment: hatched band, Jangan bayar lagi, and Cek status.
The same rule in transaction history (Indonesian)

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.

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.

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}');

attempt.availableActions decides what PaymentStatusView can offer:

  • Nothing was sent (notSent): no actions.
  • The outcome is unknown, or no snapshot has arrived yet: checkStatus only.
  • Otherwise: the snapshot’s allowedActions, minus startNewAttempt unless attempt.allowsNewAttempt is 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.

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.

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.

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.

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.

ParameterTypeDefaultDescription
attemptId:requiredString——
quoteId:requiredString——
quoteRevision:requiredint——
methodId:requiredString——
submission:SubmissionStateSubmissionState.notSent—
snapshot:PaymentStatusSnapshot?—Last trusted snapshot; kept when a refresh fails so the UI can show the last-known state.
observation:ObservationObservation.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.

ValueDescription
notSentPrepared but not sent; may still be abandoned.
sendingOne submit call is in flight.
acceptedThe server acknowledged the attempt with a reference.
outcomeUnknownSent, 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.

ValueDescription
fresh—
refreshing—
unavailable—

PaymentStatusSnapshot

class PaymentStatusSnapshot · lib/src/payment/payment_models.dart

An authoritative status snapshot produced by the host adapter.

ParameterTypeDefaultDescription
attemptId:requiredString——
serverReference:requiredString——
status:requiredPaymentStatus——
revision:requiredint—Monotonic server revision used to order snapshots.
updatedAt:requiredDateTime——
allowedActions:Set<PaymentAction>const {}—
safeReason:String?——
refund:RefundInfoconst RefundInfo(status: RefundStatus.none)—
instructions:VirtualAccountInstructions?——
isCorrection:boolfalseAn 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.

ValueDescription
requiresAction—
processing—
pending—
succeeded—
failed—
canceled—
expired—

PaymentAction

enum PaymentAction · lib/src/payment/payment_models.dart

Actions the host currently allows for an attempt.

ValueDescription
checkStatus—
viewInstructions—
requestCancel—
startNewAttempt—
viewReceipt—
contactSupport—

ReconcileResult

class ReconcileResult · lib/src/payment/payment_models.dart

ReconcileResult.applied(…)

ParameterTypeDefaultDescription
attemptrequiredpositionalPaymentAttempt——

ReconcileResult.rejected(…)

ParameterTypeDefaultDescription
attemptrequiredpositionalPaymentAttempt——
rejectionrequiredpositionalReconcileRejection?——

ReconcileRejection

enum ReconcileRejection · lib/src/payment/payment_models.dart

ValueDescription
wrongAttempt—
referenceMismatch—
stale—
successDowngrade—

RefundInfo

class RefundInfo · lib/src/payment/payment_models.dart

ParameterTypeDefaultDescription
status:requiredRefundStatus——
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.

ValueDescription
none—
pending—
partial—
refunded—
failed—