Database Schema

Payment Base ships three Doctrine migrations under migration/data/ (Version20251031140000.php, Version20251031140100.php, Version20251031140200.php) that create six tables. The contract table is the heart of the model — it tracks the full payment lifecycle from intent to fulfillment.

All tables use the oe_payments_ prefix to avoid collisions with shop core tables and to make ownership obvious in production schemas.

Quick overview

Table

Purpose

oe_payments_contract

Smart-Contract aggregate: state, conditions, capture / refund totals.

oe_payments_transaction

Provider-agnostic ledger of authorizations, captures, refunds, voids.

oe_payments_customer

Provider-side customer identifiers and saved payment methods.

oe_payments_idempotency

Cached results for idempotent operations (createPayment, capture, …).

oe_payments_sessions

Provider checkout sessions tied to user / basket.

oe_payments_webhooklogs

Append-only log of every webhook received.

oe_payments_contract

Primary key: OXID. Engine InnoDB, charset latin1, collation latin1_general_ci.

Column

Type

Description

OXID

CHAR(32)

Contract ID (UUID).

OXSHOPID

INT

Shop ID (multi-shop support).

OXUSERID

CHAR(32)

FK to oxuser.OXID.

OXORDERID

CHAR(32) NULL

FK to oxorder.OXID — NULL until the contract is committed.

OXSTATE

VARCHAR(32)

draft, pending, ready_to_commit, committed, fulfilled, cancelled, expired, failed.

OXSTATEREASON

VARCHAR(255) NULL

Free-text reason if state is failed or cancelled.

OXBASKETDATA

TEXT

Immutable basket snapshot (JSON: items, discounts, totals).

OXTERMS

TEXT NULL

Terms & conditions the customer agreed to (JSON).

OXMETADATA

TEXT NULL

Additional metadata (JSON: IP, user agent, session ID).

OXCONDITIONS

TEXT

Conditions with status (JSON: payment_authorized, fraud_check_passed, …).

OXPROVIDER

VARCHAR(32) NULL

PSP: stripe, paypal, unzer, adyen, klarna, amazonpay.

OXPROVIDERORDERID

VARCHAR(128) NULL

Provider contract ID (PaymentIntent ID, Order ID, ChargePermission ID).

OXPROVIDERDATA

TEXT NULL

Provider-specific data (JSON).

OXCREATED

DATETIME

Contract creation timestamp.

OXUPDATED

DATETIME

Last update timestamp.

OXCOMMITTEDAT

DATETIME NULL

When the order was created (contract committed).

OXFULFILLEDAT

DATETIME NULL

When payment was captured (contract fulfilled).

OXCAPTUREDAMOUNT

DECIMAL(10,2) NULL

Captured payment amount.

OXREFUNDEDAMOUNT

DECIMAL(10,2) NULL

Total refunded amount (accumulates across partial refunds).

OXCAPTUREDAT

DATETIME NULL

When payment was captured.

OXREFUNDEDAT

DATETIME NULL

When the last refund was processed.

OXEXPIRESAT

DATETIME NULL

Contract expiration timestamp (default: +24 h after creation).

Indexes: IDX_STATE, IDX_USER, IDX_ORDER, IDX_PROVIDER_ORDER, IDX_CREATED, IDX_EXPIRES, IDX_STATE_EXPIRES.

The migration deliberately drops any existing FK_CONTRACT_ORDER foreign key on first run — the application maintains referential integrity to oxorder itself so test fixtures can TRUNCATE freely.

oe_payments_transaction

Primary key: OXID. Engine InnoDB, charset latin1, collation latin1_general_ci.

Column

Type

Description

OXID

CHAR(32)

Transaction ID.

OXSHOPID

INT

Shop ID.

OXORDERID

CHAR(32)

FK to oxorder.OXID.

OXCONTRACTID

CHAR(32) NULL

FK to oe_payments_contract.OXID (contract-aware).

OXPROVIDER

VARCHAR(32)

stripe, paypal, unzer, amazon, adyen, klarna.

OXPROVIDERORDERID

VARCHAR(128) NULL

Provider order / payment ID.

OXTRANSACTIONID

VARCHAR(128) NULL

Provider transaction ID.

OXTYPE

VARCHAR(32)

authorization, capture, refund, void.

OXSTATUS

VARCHAR(32)

pending, completed, failed, cancelled.

OXAMOUNT

DECIMAL(10,2)

Transaction amount.

OXCURRENCY

VARCHAR(3)

Currency code (ISO 4217).

OXPAYMENTMETHODID

VARCHAR(64) NULL

Payment method ID.

OXPAYMENTMETHODTYPE

VARCHAR(32) NULL

Payment method type (card, sepa_debit, …).

OXPARENTTRANSACTIONID

CHAR(32) NULL

FK to parent transaction (for refunds / voids).

OXCREATED

DATETIME

Transaction creation timestamp.

OXUPDATED

DATETIME

Last update timestamp.

Indexes: IDX_ORDER, IDX_CONTRACT, IDX_PROVIDER_ORDER, IDX_TRANSACTION_ID, IDX_TYPE_STATUS, IDX_PARENT.

Foreign keys: FK_OE_TX_CONTRACT (OXCONTRACTID → contract, ON DELETE SET NULL); FK_OE_TX_PARENT (self-referential for the refund / void chain).

oe_payments_customer

1:1 mapping between OXID users and their PSP-side customer record.

Column

Type

Description

OXID

CHAR(32)

Row ID.

OXUSERID

CHAR(32)

FK to oxuser.OXID (1:1, enforced by UK_USER).

OXPAYMENTCUSTOMERID

VARCHAR(128) NULL

Provider customer ID.

OXDEFAULTPAYMENTMETHOD

VARCHAR(64) NULL

Default saved payment method ID.

OXSAVEDPAYMENTMETHODS

TEXT NULL

JSON array of saved payment methods.

OXBILLINGAGREEMENT

BOOLEAN

Whether the customer has an active billing agreement.

OXLASTPAYMENTDATE

DATETIME NULL

Last successful payment timestamp.

OXCREATED / OXUPDATED

DATETIME

Standard timestamps.

oe_payments_idempotency

Stores the result of idempotent operations so retried requests return the cached outcome instead of re-executing the side effect.

The table cleans itself: every insert (save, claim, a new rate-limit window) deletes up to 500 expired rows. No cron job is needed, and an old backlog is worked off 500 rows at a time.

Column

Type

Description

OXID

CHAR(32)

Row ID.

OXKEY

VARCHAR(128)

Idempotency key (unique, UK_KEY).

OXORDERID

CHAR(32)

Order ID the operation applied to.

OXOPERATION

VARCHAR(32)

createPayment, capturePayment, refundPayment.

OXRESULT

TEXT NULL

Cached result (JSON).

OXSTATUS

VARCHAR(32) NULL

processing, completed, failed.

OXCREATED / OXEXPIRES

DATETIME

Created timestamp and TTL.

Indexes: UK_KEY, IDX_EXPIRES, IDX_ORDER_OPERATION.

oe_payments_sessions

Tracks provider checkout sessions so an interrupted flow can be resumed.

Column

Type

Description

OXID

CHAR(32)

Row ID.

OXPROVIDER

VARCHAR(32)

PSP.

OXSESSIONID

VARCHAR(128)

Provider session ID.

OXUSERID

CHAR(32) NULL

FK to oxuser.OXID (NULL for guest checkouts).

OXBASKETID

CHAR(32) NULL

Basket reference.

OXDATA

TEXT NULL

Session payload (JSON).

OXCREATED / OXEXPIRES

DATETIME

Created timestamp and TTL.

Indexes: IDX_SESSION, IDX_USER, IDX_EXPIRES.

oe_payments_webhooklogs

Append-only log of every webhook received. Deduplicated by provider event ID for idempotent replays.

Column

Type

Description

OXID

CHAR(32)

Log entry ID.

OXEVENTID

VARCHAR(128)

Provider webhook event ID (unique, UK_EVENT_ID).

OXEVENTTYPE

VARCHAR(128) NULL

Event type (payment_intent.succeeded, …).

OXPROVIDER

VARCHAR(32) NULL

PSP.

OXCONTRACTID

CHAR(32) NULL

FK to oe_payments_contract.OXID (FK_OE_WEBHOOK_CONTRACT, ON DELETE SET NULL).

OXSTATUS

VARCHAR(32)

received, processed, failed.

OXRECEIVEDAT

DATETIME

When the webhook arrived.

OXERROR

TEXT NULL

Error message if processing failed.

OXPAYLOAD

TEXT NULL

Raw webhook payload (JSON).

OXPROCESSEDAT

DATETIME NULL

When the webhook was processed.

Indexes: UK_EVENT_ID, IDX_CONTRACT, IDX_STATUS, IDX_RECEIVED_AT.