# 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

| Type | Name | Description |
|  --- | --- | --- |
| `` | `$timestamps` |  |


## Methods

### client

```php
public function client()
```

A transaction can belong to a client.

**Returns** `\Illuminate\Database\Eloquent\Relations\BelongsTo`

### invoice

```php
public function invoice()
```

A transaction can belong to an invoice.

**Returns** `\Illuminate\Database\Eloquent\Relations\BelongsTo`

### refunds

```php
public function refunds(): HasMany
```

### originalTransaction

```php
public function originalTransaction(): BelongsTo
```

### scopeLookup

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

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `\Illuminate\Database\Eloquent\Builder` | `$query` |  |
| `string` | `$gateway` |  |
| `string` | `$transactionId` |  |


**Returns** `\Illuminate\Database\Eloquent\Builder`

### scopeNotBillingNotes

```php
public function scopeNotBillingNotes($query)
```

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `\Illuminate\Database\Eloquent\Builder` | `$query` |  |


**Returns** `\Illuminate\Database\Eloquent\Builder`

### gateway

```php
public function gateway(): ?Gateway
```

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

**Returns** `Gateway\|null`

### gatewaySafe

```php
public function gatewaySafe(): ?Gateway
```

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

**Returns** `Gateway\|null`

### gatewaySupports

```php
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**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$feature` | The feature to check for |


**Returns** `bool`

### gatewayCallIfSupports

```php
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**

| Type | Name | Description |
|  --- | --- | --- |
| `mixed` | `$default` | The value to return if the gateway or feature is not available. |
| `string` | `$feature` | The gateway's feature to call. |
| `array` | `$params` | The parameters required by the gateway feature. |


**Returns** `mixed`

### getFormattedTransactionIdAttribute

```php
public function getFormattedTransactionIdAttribute()
```

Retrieve the transaction after formatting.

**Returns** `string\|null`

### isBillingNoteReference

```php
public function isBillingNoteReference(): bool
```

### isCreditNoteReference

```php
public function isCreditNoteReference(): bool
```

### isDebitNoteReference

```php
public function isDebitNoteReference(): bool
```

### isInvoiceReference

```php
public function isInvoiceReference(): bool
```

### getReferenceIdMarkup

```php
public function getReferenceIdMarkup(): string
```

### getTransactionIdMarkup

```php
public function getTransactionIdMarkup(): string
```

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

### getBillingNoteLink

```php
public function getBillingNoteLink(): string
```

### getLink

```php
public function getLink(): string
```

### isUnique

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$gateway` |  |
| `string` | `$transactionId` |  |


**Returns** `bool`

### assertUnique

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

**Parameters**

| Type | Name | Description |
|  --- | --- | --- |
| `string` | `$gateway` |  |
| `string` | `$transactionId` |  |


### getRefundsAttribute

```php
public function getRefundsAttribute(): Collection
```

### refundToClientCredit

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

### getTypeAttribute

```php
public function getTypeAttribute(): LedgerType
```