Skip to content
Last updated

WHMCS\Billing\Payment\Transaction

Class · extends AbstractModel

A payment transaction.

A Transaction tracks a payment or refund made to a Client via a specific Invoice.

If the Transaction is a payment by a client toward an invoice, the value of the transaction will be stored in "amountIn."

If the Transaction is a payment by the operator of this WHMCS install to a Client by way of a Refund, the value of the transaction is stored in "amountOut."

Traits

  • ModelRelationBillingNote

Properties

TypeNameDescription
``$timestamps

Methods

client

public function client()

A transaction can belong to a client.

Returns \Illuminate\Database\Eloquent\Relations\BelongsTo

invoice

public function invoice()

A transaction can belong to an invoice.

Returns \Illuminate\Database\Eloquent\Relations\BelongsTo

refunds

public function refunds(): HasMany

originalTransaction

public function originalTransaction(): BelongsTo

scopeLookup

public function scopeLookup($query, $gateway, $transactionId)

Perform a transaction lookup for a given gateway and transaction ID.

Parameters

TypeNameDescription
\Illuminate\Database\Eloquent\Builder$query
string$gateway
string$transactionId

Returns \Illuminate\Database\Eloquent\Builder

scopeNotBillingNotes

public function scopeNotBillingNotes($query)

Parameters

TypeNameDescription
\Illuminate\Database\Eloquent\Builder$query

Returns \Illuminate\Database\Eloquent\Builder

gateway

public function gateway(): ?Gateway

Load the transaction's gateway module, if known to the transaction.

Returns Gateway\|null

gatewaySafe

public function gatewaySafe(): ?Gateway

Load the transaction's gateway module in a fail-silent manner.

Returns Gateway\|null

gatewaySupports

public function gatewaySupports(string $feature): bool

Determine if this transaction's gateway supports the requested feature. False will be returned for a failing or inactive gateway.

Parameters

TypeNameDescription
string$featureThe feature to check for

Returns bool

gatewayCallIfSupports

public function gatewayCallIfSupports($default, string $feature, array $params = [])

Call and return the result of the specified gateway feature of this transaction's gateway, if the gateway and the feature is available; otherwise return the $default value.

Parameters

TypeNameDescription
mixed$defaultThe value to return if the gateway or feature is not available.
string$featureThe gateway's feature to call.
array$paramsThe parameters required by the gateway feature.

Returns mixed

getFormattedTransactionIdAttribute

public function getFormattedTransactionIdAttribute()

Retrieve the transaction after formatting.

Returns string\|null

isBillingNoteReference

public function isBillingNoteReference(): bool

isCreditNoteReference

public function isCreditNoteReference(): bool

isDebitNoteReference

public function isDebitNoteReference(): bool

isInvoiceReference

public function isInvoiceReference(): bool

getReferenceIdMarkup

public function getReferenceIdMarkup(): string

getTransactionIdMarkup

public function getTransactionIdMarkup(): string

Returns string — Return the transaction ID including possible markup for consistent decoration.

public function getBillingNoteLink(): string
public function getLink(): string

isUnique

public static function isUnique($gateway, $transactionId): bool

Parameters

TypeNameDescription
string$gateway
string$transactionId

Returns bool

assertUnique

public static function assertUnique($gateway, $transactionId): void

Parameters

TypeNameDescription
string$gateway
string$transactionId

getRefundsAttribute

public function getRefundsAttribute(): Collection

refundToClientCredit

public function refundToClientCredit(?float $partialAmount = null, ?float $partialFees = null): ?Transaction

getTypeAttribute

public function getTypeAttribute(): LedgerType