CoolCMS API

PaymentTransaction extends BaseEntity
in package
implements IdentifiableInterface uses IdentifiableTrait

AbstractYes

One transaction of a payment at the gateway.

A payment can have several transactions at a gateway: the customer repeats the attempt, the gateway retries a webhook, an SMS receipt arrives up to 12 times. The table is therefore an audit trail (how many times the payment was canceled) and the carrier of idempotence: only here can a repeated notification of the same transaction be recognized.

IMPORTANT: executedDatetime is a lock, not just information. The claim to execute the callback is made atomically (update … where executed_datetime is null and a check of the affected row count), because two notifications of one transaction can arrive concurrently (a gateway retry overlaps with the customer returning). A read followed by a write would let both through.

NOTE: a rejected notification is stored too (rejectReason) even though the payment status does not change; otherwise forgery attempts would leave no trace.

Attributes
#[MappedSuperclass]
#[TableAlias]
$alias: 'paymentTransaction'

Table of Contents

Interfaces

IdentifiableInterface
Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).

Properties

$amount  : string|null
Amount confirmed by the gateway for this transaction, not the payment amount.
$currencyCode  : string|null
$executedDatetime  : DateTime|null
IMPORTANT: lock for executing the callback, not just information; see the class docblock.
$gatewayPaymentId  : string|null
Transaction key at the gateway; `null` for the internal `credit` gate, which has none.
$id  : int|null
$insertDatetime  : DateTime
$paymentGateId  : int|null
$paymentId  : int|null
$referenceId  : string|null
What the gateway returned as our `payment_id` (order_number/refId/metadata/extOrderId/reference_id).
$rejectReason  : string|null
Filled for a rejected notification (deliverySecretMismatch, referenceMismatch, …).
$state  : string|null
Raw gateway status as received, for looking it up in the gateway portal.
$status  : int
Value of {@see \App\UI\Api\System\Enums\PaymentStatus}.
$subState  : string|null
$updateDatetime  : DateTime|null

Methods

__construct()  : mixed
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getAmount()  : string|null
getCurrencyCode()  : string|null
getExecutedDatetime()  : DateTime|null
getGatewayPaymentId()  : string|null
getId()  : int|null
getInsertDatetime()  : DateTime
getPaymentGateId()  : int|null
getPaymentId()  : int|null
getReferenceId()  : string|null
getRejectReason()  : string|null
getState()  : string|null
getStatus()  : int
getSubState()  : string|null
getUpdateDatetime()  : DateTime|null
isExecuted()  : bool
Whether the module callback has already been executed for this transaction.
isPersisted()  : bool
isRejected()  : bool
Whether the notification was rejected; a rejected transaction never determines the payment status.
setAmount()  : $this
setCurrencyCode()  : $this
setExecutedDatetime()  : $this
setGatewayPaymentId()  : $this
setId()  : $this
setInsertDatetime()  : $this
setPaymentGateId()  : $this
setPaymentId()  : $this
setReferenceId()  : $this
setRejectReason()  : $this
setState()  : $this
setStatus()  : $this
setSubState()  : $this
setUpdateDatetime()  : $this
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$amount

Amount confirmed by the gateway for this transaction, not the payment amount.

protected string|null $amount = null
Attributes
#[Column]
$name: 'amount'
$type: 'decimal'
$precision: 15
$scale: 3
$nullable: true

$currencyCode

protected string|null $currencyCode = null
Attributes
#[Column]
$name: 'currency_code'
$type: 'string'
$length: 3
$nullable: true

$executedDatetime

IMPORTANT: lock for executing the callback, not just information; see the class docblock.

protected DateTime|null $executedDatetime = null
Attributes
#[Column]
$name: 'executed_datetime'
$type: 'datetime'
$nullable: true
#[ExternalReadonly]

$gatewayPaymentId

Transaction key at the gateway; `null` for the internal `credit` gate, which has none.

protected string|null $gatewayPaymentId = null
Attributes
#[Column]
$name: 'gateway_payment_id'
$type: 'string'
$length: 255
$nullable: true

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'payment_transaction_id'
$type: 'integer'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

$paymentGateId

protected int|null $paymentGateId = null
Attributes
#[Column]
$name: 'cms_system_payment_gates_payment_gate_id'
$type: 'integer'
$nullable: true
$options: ['unsigned' => true]

$paymentId

protected int|null $paymentId = null
Attributes
#[Column]
$name: 'cms_system_payments_payment_id'
$type: 'integer'
$options: ['unsigned' => true]

$referenceId

What the gateway returned as our `payment_id` (order_number/refId/metadata/extOrderId/reference_id).

protected string|null $referenceId = null
Attributes
#[Column]
$name: 'reference_id'
$type: 'string'
$length: 255
$nullable: true

$rejectReason

Filled for a rejected notification (deliverySecretMismatch, referenceMismatch, …).

protected string|null $rejectReason = null
Attributes
#[Column]
$name: 'reject_reason'
$type: 'string'
$length: 255
$nullable: true

$state

Raw gateway status as received, for looking it up in the gateway portal.

protected string|null $state = null
Attributes
#[Column]
$name: 'state'
$type: 'string'
$length: 64
$nullable: true

$status

Value of {@see \App\UI\Api\System\Enums\PaymentStatus}.

protected int $status = 0
Attributes
#[Column]
$name: 'status'
$type: 'integer'

$subState

protected string|null $subState = null
Attributes
#[Column]
$name: 'sub_state'
$type: 'string'
$length: 64
$nullable: true

$updateDatetime

protected DateTime|null $updateDatetime = null
Attributes
#[Column]
$name: 'update_datetime'
$type: 'datetime'
$nullable: true
#[ExternalReadonly]

Methods

__construct()

public __construct([int|null $id = null ][, int|null $paymentId = null ][, int|null $paymentGateId = null ][, string|null $gatewayPaymentId = null ][, string|null $referenceId = null ][, int $status = 0 ][, string|null $state = null ][, string|null $subState = null ][, string|null $amount = null ][, string|null $currencyCode = null ][, string|null $rejectReason = null ][, DateTime|null $executedDatetime = null ][, DateTime $insertDatetime = new DateTime() ][, DateTime|null $updateDatetime = null ]) : mixed
Parameters
$id : int|null = null
$paymentId : int|null = null
$paymentGateId : int|null = null
$gatewayPaymentId : string|null = null
$referenceId : string|null = null
$status : int = 0
$state : string|null = null
$subState : string|null = null
$amount : string|null = null
$currencyCode : string|null = null
$rejectReason : string|null = null
$executedDatetime : DateTime|null = null
$insertDatetime : DateTime = new DateTime()
$updateDatetime : DateTime|null = null

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getCurrencyCode()

public getCurrencyCode() : string|null
Return values
string|null

getExecutedDatetime()

public getExecutedDatetime() : DateTime|null
Return values
DateTime|null

getGatewayPaymentId()

public getGatewayPaymentId() : string|null
Return values
string|null

getInsertDatetime()

public getInsertDatetime() : DateTime
Return values
DateTime

getReferenceId()

public getReferenceId() : string|null
Return values
string|null

getRejectReason()

public getRejectReason() : string|null
Return values
string|null

getUpdateDatetime()

public getUpdateDatetime() : DateTime|null
Return values
DateTime|null

isExecuted()

Whether the module callback has already been executed for this transaction.

public isExecuted() : bool
Return values
bool

isRejected()

Whether the notification was rejected; a rejected transaction never determines the payment status.

public isRejected() : bool
Return values
bool

setAmount()

public setAmount(string|null $amount) : $this
Parameters
$amount : string|null
Return values
$this

setCurrencyCode()

public setCurrencyCode(string|null $currencyCode) : $this
Parameters
$currencyCode : string|null
Return values
$this

setExecutedDatetime()

public setExecutedDatetime(DateTime|null $executedDatetime) : $this
Parameters
$executedDatetime : DateTime|null
Return values
$this

setGatewayPaymentId()

public setGatewayPaymentId(string|null $gatewayPaymentId) : $this
Parameters
$gatewayPaymentId : string|null
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setInsertDatetime()

public setInsertDatetime(DateTime $insertDatetime) : $this
Parameters
$insertDatetime : DateTime
Return values
$this

setPaymentGateId()

public setPaymentGateId(int|null $paymentGateId) : $this
Parameters
$paymentGateId : int|null
Return values
$this

setPaymentId()

public setPaymentId(int|null $paymentId) : $this
Parameters
$paymentId : int|null
Return values
$this

setReferenceId()

public setReferenceId(string|null $referenceId) : $this
Parameters
$referenceId : string|null
Return values
$this

setRejectReason()

public setRejectReason(string|null $rejectReason) : $this
Parameters
$rejectReason : string|null
Return values
$this

setState()

public setState(string|null $state) : $this
Parameters
$state : string|null
Return values
$this

setStatus()

public setStatus(int $status) : $this
Parameters
$status : int
Return values
$this

setSubState()

public setSubState(string|null $subState) : $this
Parameters
$subState : string|null
Return values
$this

setUpdateDatetime()

public setUpdateDatetime(DateTime|null $updateDatetime) : $this
Parameters
$updateDatetime : DateTime|null
Return values
$this

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results