Maintenance
Payment Base creates the order before the customer is redirected to the
provider, so that an order number exists when they come back. That trade-off
buys a stable reference for the whole payment round trip, and it leaves a
class of rows behind: orders for customers who never return. They sit at
OXTRANSSTATUS = 'NOT_FINISHED' with their vouchers still spent.
Two mechanisms collect them, on different horizons.
Fast sweep |
Cleanup command |
Voucher release |
|
|---|---|---|---|
Trigger |
Inbound provider webhook |
Cron / manual |
Admin cancels or deletes an order |
Horizon |
|
|
Immediate |
Purpose |
Clear the way for a customer retrying their own checkout |
Collect orders nobody comes back for |
Give back a voucher the ended order was holding |
The fast sweep needs no configuration beyond its horizon — it runs by itself whenever a provider sends a webhook. The other two are described below.
The cleanup command
bin/oe-console oe:payments:not_finished:cleanup
Until this command existed there was no scheduled collector at all: cleanup only happened as a side effect of a customer retrying, or of an inbound provider webhook. A shop with neither accumulated those rows indefinitely.
For every order that is still at NOT_FINISHED, is not yet stornoed, and is
older than the configured period, the command:
marks the order
OXSTORNO = 1andOXTRANSSTATUS = 'CANCELLED'— the row is kept, so the order-number sequence stays free of gaps;releases the vouchers the unfinished order was holding;
cancels the linked payment contract, unless it is already committed or already in a terminal state.
Warning
Stock is not restored. That stays the shop’s own concern — payment-base does not know whether the shop reserves stock at order creation or at fulfillment.
Options
Option |
Meaning |
|---|---|
|
Age threshold in days. Overrides the Cleanup period module setting for this run. Must be a whole number, 1 or greater. |
|
Process at most this many orders in one run. Use it to bound the first sweep on a shop with a large backlog. |
|
Report what would be cleaned up without writing anything. |
|
Enterprise only. Without it, every subshop is processed. |
Note
--shop-id is registered globally by the Enterprise console subscriber,
not by this command. On Community Edition the option is simply absent.
Examples
# what would happen, using the configured period
bin/oe-console oe:payments:not_finished:cleanup --dry-run
# a wider period, bounded to 500 orders
bin/oe-console oe:payments:not_finished:cleanup --days=30 --limit=500
# a single subshop (Enterprise)
bin/oe-console oe:payments:not_finished:cleanup --shop-id=2
Running it from cron
Once a day is enough for the default seven-day period:
0 3 * * * /usr/bin/php /var/www/oxideshop/bin/oe-console oe:payments:not_finished:cleanup
Before the first scheduled run on an existing shop, do a --dry-run to see
how large the backlog is, and bound the first few runs with --limit.
Exit codes and reporting
The command reports how many orders it scanned and cleaned, how many contracts it cancelled and how many vouchers it released. Orders that could not be processed — a locked or malformed row — are counted separately, logged to the shop log, and do not abort the sweep: one bad row must not strand the rest of the backlog.
An unusable --days or --limit value returns Command::INVALID; a
failure of the sweep itself returns Command::FAILURE. A cron job that
prints success for a sweep which never happened would be worse than one that
prints nothing.
Releasing vouchers when an order ends
Independently of the sweeps, an order that ends in the admin — cancelled
(storno) or deleted outright — returns its vouchers to the pool, so the
customer can spend them again. The behaviour is governed by
blPaymentBaseReleaseVouchersOnOrderEnd (see Module Settings) and is on by
default.
Consumers that only need this one capability should depend on the narrow interface rather than on the order repository:
use OxidEsales\PaymentBase\Repository\VoucherReleaseInterface;
$released = $voucherRelease->releaseVouchers($orderId); // number of vouchers
It is split out on purpose: the abandoned-checkout collector needs the whole order repository, but a webhook that merely learns a payment ended needs only this — and should not be able to call order queries it has no business with.