OrderAffiliatePayouts extends OrderModel
Order Affiliate Payout Management
Table of Contents
Methods
| add() | Add an affiliate payout |
| delete() | Permanently deletes the given affiliate payout |
| edit() | Edit an affiliate payout |
| get() | Fetches the affiliate payout with the given ID |
| getAll() | Returns all payouts in the system for the given affiliate |
| getList() | Returns a list of payouts for the given affiliate |
| getListCount() | Returns the total number of payouts for the given affiliate |
| getStatusCount() | Retrieves the number of affiliate payouts given a payout status |
| getStatuses() | Returns all supported affiliate payout statuses in key/value pairs |
| validateAmount() | Validates that the requested amount id within the established limits |
| getAffiliatePayout() | Returns a partial affiliate payout query |
| getRules() | Returns all validation rules for adding/editing affiliate payouts |
| sendPayoutEmail() | Sends payout request notification email |
Methods
add()
Add an affiliate payout
public
add(array<string|int, mixed> $vars) : int
Parameters
- $vars : array<string|int, mixed>
-
An array of input data including:
- affiliate_id The ID of the affiliate requesting the payout
- payment_method_id The ID of the payment method the affiliate is requesting
- status The status of the payout
- requested_amount The amount of payout being requested
- requested_currency The currency of payout being requested
- paid_amount The amount of payout distributed so far
- paid_currency The currency in which payout has been given
Return values
int —The ID of the affiliate payout that was created, void on error
delete()
Permanently deletes the given affiliate payout
public
delete(int $payout_id) : mixed
Parameters
- $payout_id : int
-
The ID of the affiliate payout to delete
edit()
Edit an affiliate payout
public
edit(int $payout_id, array<string|int, mixed> $vars) : int
Parameters
- $payout_id : int
-
The ID of the affiliate payout to edit
- $vars : array<string|int, mixed>
-
An array of input data including:
- affiliate_id The ID of the affiliate requesting the payout
- payment_method_id The ID of the payment method the affiliate is requesting
- status The status of the payout
- requested_amount The amount of payout being requested
- requested_currency The currency of payout being requested
- paid_amount The amount of payout distributed so far
- paid_currency The currency in which payout has been given
Return values
int —The ID of the affiliate payout that was updated, void on error
get()
Fetches the affiliate payout with the given ID
public
get(int $payout_id) : mixed
Parameters
- $payout_id : int
-
The ID of the affiliate payout to fetch
Return values
mixed —A stdClass object representing the payout, false if no such payout exists
getAll()
Returns all payouts in the system for the given affiliate
public
getAll([array<string|int, mixed> $filters = [] ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters including:
- int $affiliate_id The ID of the affiliate to fetch payouts from
- string $status The status of the payouts to fetch:
- "pending" Only pending payouts
- "approved" Only approved payouts
- "declined" Only declined payouts
- null All payouts
- $order : array<string|int, mixed> = ['id' => 'desc']
-
A key/value pair array of fields to order the results by
Return values
array<string|int, mixed> —An array of stdClass objects, each representing a payout
getList()
Returns a list of payouts for the given affiliate
public
getList([array<string|int, mixed> $filters = [] ][, int $page = 1 ][, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters including:
- int $affiliate_id The ID of the affiliate to fetch payouts from
- string $status The status of the payouts to fetch:
- "pending" Only pending payouts
- "approved" Only approved payouts
- "declined" Only declined payouts
- null All payouts
- $page : int = 1
-
The page number of results to fetch
- $order : array<string|int, mixed> = ['id' => 'desc']
-
A key/value pair array of fields to order the results by
Return values
array<string|int, mixed> —An array of stdClass objects, each representing an payout
getListCount()
Returns the total number of payouts for the given affiliate
public
getListCount([array<string|int, mixed> $filters = [] ]) : int
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters including:
- int $affiliate_id The ID of the affiliate to fetch payouts from
- string $status The status of the payouts to fetch:
- "pending" Only pending payouts
- "approved" Only approved payouts
- "declined" Only declined payouts
- null All payouts
Return values
int —The total number of payouts for the given affiliate
getStatusCount()
Retrieves the number of affiliate payouts given a payout status
public
getStatusCount([string $status = 'active' ][, int $company_id = null ]) : int
Parameters
- $status : string = 'active'
-
The payout status type (optional, default 'active')
- $company_id : int = null
-
The ID of the company to count payouts for (optional)
Return values
int —The number of payouts of type $status
getStatuses()
Returns all supported affiliate payout statuses in key/value pairs
public
getStatuses() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of affiliate payout statuses
validateAmount()
Validates that the requested amount id within the established limits
public
validateAmount(mixed $amount, mixed $currency, mixed $affiliate_id) : bool
Parameters
- $amount : mixed
-
float The requested amount for the payout
- $currency : mixed
-
string The requested currency for the payout
- $affiliate_id : mixed
-
int The ID of the affiliate requesting the payout
Return values
bool —True if the amount is valid and between the limits
getAffiliatePayout()
Returns a partial affiliate payout query
private
getAffiliatePayout([array<string|int, mixed> $filters = [] ]) : Record
Parameters
- $filters : array<string|int, mixed> = []
-
A list of filters for the query
- company_id The ID of the company to which the affiliates for these payouts must be assigned
- status The payout status
- affiliate_id The ID of the affiliate to which the payouts are assigned
Return values
Record —A partially built affiliate payout query
getRules()
Returns all validation rules for adding/editing affiliate payouts
private
getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
An array of input key/value pairs
- $edit : bool = false
-
True if this if an edit, false otherwise
Return values
array<string|int, mixed> —An array of validation rules
sendPayoutEmail()
Sends payout request notification email
private
sendPayoutEmail(array<string|int, mixed> $payout) : mixed
Parameters
- $payout : array<string|int, mixed>
-
An array of input data including:
- affiliate_id The ID of the affiliate requesting the payout
- payment_method_id The ID of the payment method the affiliate is requesting
- status The status of the payout
- requested_amount The amount of payout being requested
- requested_currency The currency of payout being requested
- paid_amount The amount of payout distributed so far
- paid_currency The currency in which payout has been given