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:
- The merchant opens the cashier with
merchantId,terminalId,userId, andsessionId. - Morefin loads the merchant and terminal.
- Morefin calls merchant
POST /verifyUser. - If
verifyUserfails, cashier creation stops. - Morefin upserts the customer profile from the
verifyUserresponse. - Morefin stores a cashier session.
- Cashier init attributes and
verifyUserattributes are stored in the session and later merged into transactionmetadata.attributes.
Important timing:
POST /verifyUseris 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:
- Persist order and transaction.
- Load payment data.
- Route to a payment provider account.
- Call merchant
POST /authorize. - Run fraud checks.
- Run provider authentication when required.
- Run provider transaction execution.
- Handle the provider result.
Merchant and provider timing:
- Merchant
/authorizeis synchronous and happens before provider execution. - If merchant
/authorizefails, 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, orFORM_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 /transferis 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
authCodeis present, merchantPOST /cancelis 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:
- Persist order and transaction.
- Load payment data.
- Route to a payment provider account.
- Call merchant
POST /authorize. - Run fraud checks.
- Run provider authentication when required.
- Run provider transaction execution.
- Handle the provider result.
What is different:
- Merchant
/transferis not scheduled by the normal approved callback for withdrawals. - Withdrawals commonly move into
PENDING_APPROVAL. PENDING_APPROVALmeans 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:
- Load provider, provider account, terminal configuration, and cached payment data.
- Call the provider withdrawal approval/authorization method synchronously.
- Finalize the transaction in Morefin.
- If that approval action succeeds, schedule merchant
POST /transferasynchronously.
Important behavior:
- This action does call the provider.
- This action does not call merchant
/authorize; that already happened during the initial withdrawal/process. - Merchant
/transferis 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 directlyAPPROVED. - 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:
- Finalize the transaction directly as
DECLINED.
Important behavior:
- No provider call.
- No merchant
/transfer. - No merchant
/cancelis 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:
- 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
APPROVEDwithtrigger_webhook=truecan trigger async merchant/transfer - forcing a transaction to
DECLINEDwithtrigger_webhook=truecan trigger async merchant/cancelif the transaction containsauthCode
Use FORCE only as an operator override, not as a normal cashier step.
Refund
Operator action:
REFUND
Supported on parent transactions of type:
PURCHASECAPTUREDEPOSIT
And only when:
- the order still has
refundRemainingAmount > 0
Execution order:
- Create and persist a refund management transaction.
- If the parent transaction is a
DEPOSIT, call merchantPOST /authorizesynchronously first. - Call the provider refund/management execution synchronously.
- Update transaction and order based on the provider result.
- For deposit refunds only:
- if approved, call merchant
POST /transfersynchronously - if transfer fails after provider approval, call merchant
POST /cancelsynchronously
- if approved, call merchant
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, orFORM_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 |