Cashier Flows

This page describes the cashier transaction flows currently supported by the backend and when each side is involved:

  • merchant integration
  • payment provider
  • customer/browser action
  • operator action

Common Flow Before Any Transaction

Every cashier-backed transaction starts the same way:

  1. The merchant opens the cashier with merchantId, terminalId, userId, and sessionId.
  2. Morefin loads the merchant and terminal.
  3. Morefin calls merchant POST /verifyUser.
  4. If verifyUser fails, cashier creation stops.
  5. Morefin upserts the customer profile from the verifyUser response.
  6. Morefin stores a cashier session.
  7. Cashier init attributes and verifyUser attributes are stored in the session and later merged into transaction metadata.attributes.

Important timing:

  • POST /verifyUser is synchronous.
  • No provider call happens during cashier creation.
  • No transaction is created yet during cashier creation.

Validation Step

Before process, the cashier can call:

  • POST /api/transactions/{paymentMethod}/{transactionType}/validate

Validation creates temporary order/transaction objects, loads routing and payment method details, and checks whether the request can proceed.

Validation behavior:

  • no merchant /authorize
  • no merchant /transfer
  • no merchant /cancel
  • no provider execution
  • no transaction persistence

So validate is only a pre-flight check.

Failed Result Retry

When a cashier transaction reaches a failed result status, the result page includes a Back action.

The button label uses the $APP.PAYMENT_DETAILS.BACK_TO_PAYMENT_SELECTION translation key.

When the customer clicks Back, the original cashier entry/payment methods list is shown again, so the customer can choose another payment method or retry the payment flow.

Deposit

Deposit is created through:

  • POST /api/transactions/{paymentMethod}/deposit/process

Execution order:

  1. Persist order and transaction.
  2. Load payment data.
  3. Route to a payment provider account.
  4. Call merchant POST /authorize.
  5. Run fraud checks.
  6. Run provider authentication when required.
  7. Run provider transaction execution.
  8. Handle the provider result.

Merchant and provider timing:

  • Merchant /authorize is synchronous and happens before provider execution.
  • If merchant /authorize fails, the transaction is declined and the provider is not called.
  • Provider processing is synchronous until it returns a result.

Customer/browser waiting points:

  • If the provider returns ACTION_REQUIRED, REDIRECT, or FORM_SUBMIT, the cashier must wait for customer/browser completion.
  • If the provider returns PENDING, the transaction remains pending and waits for later provider completion.

Post-approval merchant transfer:

  • After a non-withdrawal cashier transaction is approved, merchant POST /transfer is scheduled asynchronously.
  • The cashier does not wait for this transfer job to finish.
  • If transfer retries are exhausted, the transaction is finalized as CONFLICTED.

Post-decline merchant cancel:

  • If a cashier transaction is declined after merchant authorization and an authCode is present, merchant POST /cancel is scheduled asynchronously.
  • The cashier does not wait for this cancel job to finish.
flowchart TD
    A["Cashier /process"] --> B["Persist order + transaction"]
    B --> C["Route provider account"]
    C --> D["Merchant /authorize (sync)"]
    D -->|fail| E["Declined, provider not called"]
    D -->|success| F["Provider auth/execute (sync)"]
    F --> G{"Provider result"}
    G -->|APPROVED| H["Transaction approved"]
    H --> I["Merchant /transfer scheduled async"]
    G -->|DECLINED| J["Transaction declined"]
    J --> K["Merchant /cancel scheduled async if authCode exists"]
    G -->|ACTION_REQUIRED / REDIRECT / FORM_SUBMIT| L["Cashier waits for customer/browser action"]
    G -->|PENDING| M["Cashier waits for provider completion"]

Withdrawal

Withdrawal is created through:

  • POST /api/transactions/{paymentMethod}/withdrawal/process

Initial execution order is the same shape as deposit:

  1. Persist order and transaction.
  2. Load payment data.
  3. Route to a payment provider account.
  4. Call merchant POST /authorize.
  5. Run fraud checks.
  6. Run provider authentication when required.
  7. Run provider transaction execution.
  8. Handle the provider result.

What is different:

  • Merchant /transfer is not scheduled by the normal approved callback for withdrawals.
  • Withdrawals commonly move into PENDING_APPROVAL.
  • PENDING_APPROVAL means cashier-side creation is done and the flow is now waiting for an operator action.

Waiting points:

  • Customer/browser waiting can still happen if the provider requires action.
  • Operator waiting happens when the withdrawal reaches PENDING_APPROVAL.

Approve Withdrawal

Operator action:

  • APPROVE_WITHDRAWAL

Supported only when:

  • transaction type is WITHDRAWAL
  • status is PENDING_APPROVAL

Execution order:

  1. Load provider, provider account, terminal configuration, and cached payment data.
  2. Call the provider withdrawal approval/authorization method synchronously.
  3. Finalize the transaction in Morefin.
  4. If that approval action succeeds, schedule merchant POST /transfer asynchronously.

Important behavior:

  • This action does call the provider.
  • This action does not call merchant /authorize; that already happened during the initial withdrawal /process.
  • Merchant /transfer is scheduled after approval succeeds.
  • The operator call does not wait for merchant transfer completion.

Status behavior:

  • The approval action usually finalizes the transaction to PENDING, not directly APPROVED.
  • After that, the system is still waiting for final provider completion to move to a terminal status.
flowchart TD
    A["Operator approves withdrawal"] --> B["Provider withdrawal approval call (sync)"]
    B -->|fail| C["Finalize as declined/error"]
    B -->|success| D["Finalize as PENDING"]
    D --> E["Merchant /transfer scheduled async"]
    E --> F["Wait for final provider completion"]

Decline Withdrawal

Operator action:

  • DECLINE_WITHDRAWAL

Supported only when:

  • transaction type is WITHDRAWAL
  • status is PENDING_APPROVAL

Execution order:

  1. Finalize the transaction directly as DECLINED.

Important behavior:

  • No provider call.
  • No merchant /transfer.
  • No merchant /cancel is currently triggered here.
  • The action is synchronous from the operator perspective.

Force

Operator action:

  • FORCE

Supported on:

  • any transaction type
  • any current status

Execution order:

  1. Finalize the transaction manually to the requested status.

Important behavior:

  • No provider call.
  • No merchant integration call by itself.
  • If trigger_webhook=false, Morefin stores the manual status change and skips approved/declined callbacks.
  • If trigger_webhook=true, the normal approved/declined callbacks run.

Practical consequence for cashier transactions:

  • forcing a non-withdrawal transaction to APPROVED with trigger_webhook=true can trigger async merchant /transfer
  • forcing a transaction to DECLINED with trigger_webhook=true can trigger async merchant /cancel if the transaction contains authCode

Use FORCE only as an operator override, not as a normal cashier step.

Refund

Operator action:

  • REFUND

Supported on parent transactions of type:

  • PURCHASE
  • CAPTURE
  • DEPOSIT

And only when:

  • the order still has refundRemainingAmount > 0

Execution order:

  1. Create and persist a refund management transaction.
  2. If the parent transaction is a DEPOSIT, call merchant POST /authorize synchronously first.
  3. Call the provider refund/management execution synchronously.
  4. Update transaction and order based on the provider result.
  5. For deposit refunds only:
    • if approved, call merchant POST /transfer synchronously
    • if transfer fails after provider approval, call merchant POST /cancel synchronously

Important behavior:

  • Deposit refund is the only refund path with merchant integration.
  • Purchase/capture refund uses provider flow only.
  • Management actions do not support ACTION_REQUIRED, REDIRECT, or FORM_SUBMIT.
  • So refund does not wait for customer/browser action.
flowchart TD
    A["Refund action"] --> B{"Parent transaction type"}
    B -->|DEPOSIT| C["Merchant /authorize (sync)"]
    B -->|PURCHASE or CAPTURE| D["Skip merchant authorize"]
    C -->|fail| E["Refund declined before provider"]
    C -->|success| F["Provider refund call (sync)"]
    D --> F
    F -->|approved| G{"Deposit refund?"}
    G -->|yes| H["Merchant /transfer (sync)"]
    H -->|fail| I["Merchant /cancel (sync)"]
    G -->|no| J["Refund completed"]
    H -->|success| J
    F -->|declined| K["Refund declined"]

Summary By Flow

Flow Merchant /authorize Provider call Merchant /transfer Merchant /cancel Waits for customer/browser Waits for operator
Deposit Yes, sync before provider Yes Yes, async after approval Yes, async on decline if authCode exists Possible No
Withdrawal Yes, sync before provider Yes Not in normal approval callback Not in normal withdrawal decline action Possible Possible, when PENDING_APPROVAL
Approve Withdrawal No Yes, sync Yes, async after approval action succeeds No No No, this is the operator step
Decline Withdrawal No No No No No No, this is the operator step
Force No No Only indirectly, if callbacks are enabled Only indirectly, if callbacks are enabled No No, this is the operator step
Refund on Deposit Yes, sync before provider Yes, sync Yes, sync Yes, sync if transfer fails No No
Refund on Purchase/Capture No Yes, sync No No No No

Cashier Bootstrapper

Cashier Merchant Platform Integration