Operations
The Operations API lets you perform subsequent actions on existing payment transactions — refund a completed payment, cancel an unpaid link, capture an authorized amount, or void an authorization. Ottu provides a unified API: you send the same payload structure regardless of the payment gateway, and Ottu handles the gateway-specific communication.
Ottu supports six operations. Three are internal (handled within Ottu's system): cancel, expire, and delete. Three are external (synchronized with the payment gateway): refund, capture, and void. When an external operation succeeds, Ottu creates a child transaction linked to the original, recording the new state, amount, and gateway response.
Operations via the Operations API do not work with foreign currencies. If the customer paid using currency exchange (e.g., MID is KWD but customer paid in USD), external operations will fail. The payment currency must match the MID currency.
Ottu offers SDKs and tools to speed up your integration. See Getting Started for all available options.
When to Use
- Refunding a completed payment — return funds to the customer after a paid or captured transaction.
- Capturing an authorized payment — settle funds for transactions in the
authorizedstate (full or partial). - Voiding an authorization — cancel an
authorizedtransaction before capture, so the customer is not charged. - Cancelling an unpaid payment link — stop a payment that's
created,pending,cod, orattempted. - Expiring stale sessions — automatically invalidate incomplete payment transactions.
- Deleting transactions — remove obsolete or test transactions (soft delete for paid, hard delete for others).
Setup
Before performing any operation, you need an existing payment transaction with a session_id or order_no:
- Via the Checkout API — create a payment transaction programmatically.
- Via the Ottu Dashboard — create a transaction manually.
Store the session_id securely — it's required for all operation requests. Prefer session_id over order_no as it's always present in the response.
Guide
Workflow
- Merchant sends an operation request with
session_id,operationtype, and optionalamount. - For internal operations (cancel, expire, delete) — Ottu updates the transaction state directly.
- For external operations (refund, capture, void) — Ottu communicates with the payment gateway.
- On success — a child transaction is created, linked to the original, recording the result.
Step-by-Step
All operations use the same endpoint: POST /b/pbl/v2/operation/
-
Send the operation request with the
operationtype,session_id, and optionalamount:{"operation": "refund","session_id": "2a956e4c9294c2c0e9253c21b1a592ceb4018c68","amount": "20.00"} -
Use the
Tracking-Keyheader (recommended for external operations) to prevent duplicate operations and retrieve status:Tracking-Key: "unique-tracking-id"If you send a subsequent request with the same
Tracking-Keyandsession_id, Ottu returns the latest status of the original operation instead of creating a new one. The key is stored in the child transaction data on success.Tracking-Keyis for operations, not chargesDirect-charge endpoints (Native Payments — Apple Pay, Google Pay, auto-debit, wallet, cash) use a separate
Idempotency-Keyheader instead. A replayedTracking-Keyreturns the original operation's status, whereas a replayedIdempotency-Keyon a charge is rejected with409 Conflictbefore charging. -
Handle the response — on success, the response includes the child transaction details (amount, state, gateway response). On failure, an error message indicates why the operation was rejected.
Use the extra object field for additional gateway-specific parameters. For example, the Instant Fund Gratification (IFG) feature for instant refunds is configured via extra.
Use Cases
Internal Operations
Cancel
Halts a payment in progress. Applicable to transactions in created, pending, cod, or attempted state. The merchant stops a payment that hasn't reached completion.
Expire
Invalidates an incomplete payment transaction. Targets created, pending, or attempted states. Transitions the transaction to expired, from which it cannot be resumed.
Delete
Removes transactions no longer needed:
paid,authorized, orcod/cash→ soft delete (removed from reports, recoverable from Deleted Transactions)- All other states → hard delete (permanent removal)
External Operations
Capture
Settles authorized funds. Only applicable to authorized transactions. Supports full or partial capture (cannot exceed the authorized amount). Creates a child transaction on success.
Refund
Returns funds to the customer. Applicable to paid or captured transactions. For authorized transactions, a capture must be completed first. Supports full or partial refund. Ottu offers an approval feature for refunds, enabling a checker role to approve or reject requests.
Refund to M-Wallet
Instead of returning funds through the original payment gateway, you can refund a payment directly to the customer's wallet balance. The customer can then spend that credit at any future Ottu checkout in the same currency. See M-Wallet for the full feature overview.
When to use:
- The customer's original card has expired or been reissued.
- You want to issue store credit, loyalty, or goodwill credit without payment-gateway fees.
- The original gateway doesn't support refunds for that transaction type.
Set destination: "wallet" on the refund operation request. The destination field defaults to "pg" when omitted, preserving the original refund behavior. See the API Reference below for the full request schema and interactive try-it-out.
Tracking-Key for idempotencyWallet credits are immutable — a duplicate refund-to-wallet call creates a second uneditable credit entry (the gateway path fails on duplicates; the wallet path does not). Always include the Tracking-Key header so retries deduplicate. See the Guide above for the full idempotency contract.
Behavior:
- A wallet account is created automatically if one doesn't exist for the (merchant, customer, currency) combination.
- The credit is recorded as an immutable ledger entry — corrections require an opposing reversal entry.
- The original payment session is linked to the credit entry for audit.
- No PII is stored on the wallet service.
- Disputes against the original payment after a refund-to-wallet can be resolved manually — contact [email protected] to raise a reversal.
Errors:
| HTTP | Code | When |
|---|---|---|
| 400 | account_inactive | Wallet account is suspended |
| 400 | policy_violation | Refund amount violates a wallet policy rule |
| 409 | idempotency_conflict | Same Idempotency-Key reused with different payload |
| 422 | validation_error | Schema validation failed on the refund payload |
For the full wallet integration, including the read APIs and SDK behavior, see M-Wallet. For the merchant dashboard workflow, see Refund to M-Wallet (business docs).
Void
Cancels an authorization before capture. Only applicable to authorized transactions. The customer is not charged.
Not all payment gateways support all external operations. If a gateway doesn't support an operation, Ottu rejects the API call with an error message. See supported operations by gateway.
API Reference
Select the operation to see its example payload and the full interactive API schema:
- Refund
- Refund to M-Wallet
- Capture
- Void
- Cancel
- Expire
- Delete
{
"operation": "refund",
"session_id": "your_session_id",
"amount": "20.00"
}
Operations
{
"operation": "refund",
"session_id": "your_session_id",
"destination": "wallet"
}
Operations
{
"operation": "capture",
"session_id": "your_session_id",
"amount": "100.00"
}
Operations
{
"operation": "void",
"session_id": "your_session_id"
}
Operations
{
"operation": "cancel",
"session_id": "your_session_id"
}
Operations
{
"operation": "expire",
"session_id": "your_session_id"
}
Operations
{
"operation": "delete",
"session_id": "your_session_id"
}
Operations
FAQ
What's Next?
- Webhooks — Receive notifications when operations complete
- Checkout API — Create payment sessions to operate on
- Payment States — Understand how operations change transaction states