PHP Класс Give_Payment, Give

This class is for working with payments in Give.
С версии: 1.5
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$ID integer The Payment ID.

Защищенные свойства (Protected)

Свойство Тип Описание
$_ID integer Protected non-read $_ID.
$address array The physical address used for the payment if provided
$completed_date string The date the payment was marked as 'complete'.
$currency string The the payment was made with
$customer_id integer The customer ID that made the payment
$date string The date the payment was created
$email string The email used for the payment
$fees array Array of global fees for this payment
$fees_total float The sum of the fee amounts
$first_name string The first name of the payee
$form_id string The Donation Form ID
$form_title string The Donation Form Title
$gateway string The gateway used to process the payment
$ip string IP Address payment was made from
$key string The unique donation payment key.
$last_name string The last name of the payee
$mode string The Gateway mode the payment was made in.
$new boolean Identify if the payment is a new one or existing.
$number string The Payment number (for use with sequential payments).
$old_status string When updating, the old status prior to the change
$parent_payment integer The parent payment (if applicable)
$post_date string The date the payment post was created.
$post_status string
$price_id string | integer The Donation Form Price ID
$status string The status of the donation payment.
$status_nicename string The display name of the current payment status.
$subtotal float The Subtotal fo the payment before fees
$total float Includes donation amount and fees.
$transaction_id string The transaction ID returned by the gateway
$user_id integer The User ID (if logged in) that made the payment

Открытые методы

Метод Описание
__construct ( integer $payment_id = false ) : mixed Setup the Give Payments class
__get ( string $key ) : mixed Magic GET function.
__isset ( string $name ) : boolean Magic ISSET function, which allows empty checks on protected elements
__set ( string $key, mixed $value ) Magic SET function
add_donation ( integer $form_id, array $args = [], array $options = [] ) : boolean Add a donation to a given payment
add_fee ( array $args, boolean $global = true ) : boolean Add a fee to a given payment
add_note ( string $note = false ) : void Add a note to a payment
array_convert ( ) : array Converts this object into an array for special cases
get_fees ( string $type = 'all' ) : array Get the fees, filterable by type
get_meta ( string $meta_key = '_give_payment_meta', boolean $single = true ) : mixed Get a post meta item for the payment
refund ( ) : void Change the status of the payment to refunded, and run the necessary changes
remove_donation ( integer $form_id, array $args = [] ) : boolean Remove a donation from the payment
remove_fee ( integer $key ) : boolean Remove a fee from the payment
remove_fee_by ( string $key, integer | string $value, boolean $global = false ) : boolean Remove a fee by the defined attributed
save ( ) : boolean Save
update_meta ( string $meta_key = '', string $meta_value = '', string $prev_value = '' ) : integer | boolean Update the post meta
update_payment_setup ( integer $payment_id ) : void Payment class object is storing various meta value in object parameter.
update_status ( string $status = false ) : boolean Set the payment status and run any status specific changes necessary.

Приватные методы

Метод Описание
decrease_fees ( float $amount ) : void Decrease the payment's subtotal.
decrease_subtotal ( float $amount ) : void Decrease the payment's subtotal.
delete_sales_logs ( ) : void Delete sales logs for this purchase
get_address ( ) : array Retrieve payment billing address
get_completed_date ( ) : string Retrieve payment completion date
get_currency ( ) : string Retrieve payment currency
get_customer_id ( ) : integer Retrieve payment customer ID
get_email ( ) : string Retrieve payment email
get_form_id ( ) : string Retrieve payment form id
get_gateway ( ) : string Retrieve payment gateway
get_ip ( ) : string Retrieve payment IP
get_key ( ) : string Retrieve payment key
get_number ( ) : integer | string Retrieve payment number
get_subtotal ( ) : float Retrieve payment subtotal
get_transaction_id ( ) : string Retrieve payment transaction ID
get_user_id ( ) : integer Retrieve payment user ID
get_user_info ( ) : array Retrieve payment user info
increase_fees ( float $amount ) : void Increase the payment's subtotal.
increase_subtotal ( float $amount ) : void Increase the payment's subtotal
insert_payment ( ) : integer | boolean Create the base of a payment.
maybe_alter_stats ( boolean $alter_store_earnings, boolean $alter_customer_value, boolean $alter_customer_purchase_count ) : void Used during the process of moving to refunded or pending, to decrement stats
process_cancelled ( ) : void Process when a payment moves to cancelled
process_failure ( ) : void Process when a payment is set to failed
process_pending ( ) : void Process when a payment moves to pending
process_refund ( ) : void When a payment is set to a status of 'refunded' process the necessary actions to reduce stats
process_revoked ( ) : void Process when a payment moves to revoked
recalculate_total ( ) : void Set or update the total for a payment.
setup_address ( ) : array Setup the Address for the payment
setup_completed_date ( ) : string Setup the payment completed date
setup_currency ( ) : string Setup the currency code
setup_customer_id ( ) : integer Setup the customer ID
setup_email ( ) : string Setup the email address for the donation.
setup_fees ( ) : array Setup any fees associated with the payment
setup_fees_total ( ) : float Setup the payment fees
setup_form_id ( ) : integer Setup the form ID
setup_form_title ( ) : string Setup the form title
setup_gateway ( ) : string Setup the gateway used for the payment
setup_ip ( ) : string Setup the IP Address for the payment
setup_mode ( ) : string Setup the payment mode
setup_payment ( integer $payment_id ) : boolean Setup payment properties
setup_payment_key ( ) : string Setup the payment key
setup_payment_number ( ) : integer | string Setup the payment number
setup_price_id ( ) : integer Setup the price ID
setup_subtotal ( ) : float Setup the payment subtotal
setup_total ( ) : float Setup the payment total
setup_transaction_id ( ) : string Setup the transaction ID
setup_user_id ( ) : integer Setup the User ID associated with the purchase
setup_user_info ( ) : array Setup the user info

Описание методов

__construct() публичный Метод

Setup the Give Payments class
С версии: 1.0
public __construct ( integer $payment_id = false ) : mixed
$payment_id integer A given payment
Результат mixed void|false

__get() публичный Метод

Magic GET function.
С версии: 1.5
public __get ( string $key ) : mixed
$key string The property.
Результат mixed The value.

__isset() публичный Метод

Magic ISSET function, which allows empty checks on protected elements
С версии: 1.5
public __isset ( string $name ) : boolean
$name string The attribute to get
Результат boolean If the item is set or not

__set() публичный Метод

Sets up the pending array for the save method
С версии: 1.5
public __set ( string $key, mixed $value )
$key string The property name
$value mixed The value of the property

add_donation() публичный Метод

Add a donation to a given payment
С версии: 1.5
public add_donation ( integer $form_id, array $args = [], array $options = [] ) : boolean
$form_id integer The donation form to add
$args array Other arguments to pass to the function
$options array List of donation options
Результат boolean True when successful, false otherwise

add_fee() публичный Метод

Add a fee to a given payment
С версии: 1.5
public add_fee ( array $args, boolean $global = true ) : boolean
$args array Array of arguments for the fee to add
$global boolean
Результат boolean If the fee was added

add_note() публичный Метод

Add a note to a payment
С версии: 1.0
public add_note ( string $note = false ) : void
$note string The note to add
Результат void

array_convert() публичный Метод

Converts this object into an array for special cases
public array_convert ( ) : array
Результат array The payment object as an array

get_fees() публичный Метод

Get the fees, filterable by type
С версии: 1.5
public get_fees ( string $type = 'all' ) : array
$type string All, item, fee
Результат array The Fees for the type specified

get_meta() публичный Метод

Get a post meta item for the payment
С версии: 1.5
public get_meta ( string $meta_key = '_give_payment_meta', boolean $single = true ) : mixed
$meta_key string The Meta Key
$single boolean Return single item or array
Результат mixed The value from the post meta

refund() публичный Метод

Change the status of the payment to refunded, and run the necessary changes
С версии: 1.5
public refund ( ) : void
Результат void

remove_donation() публичный Метод

Remove a donation from the payment
С версии: 1.5
public remove_donation ( integer $form_id, array $args = [] ) : boolean
$form_id integer The form ID to remove
$args array Arguments to pass to identify (quantity, amount, price_id)
Результат boolean If the item was removed or not

remove_fee() публичный Метод

Remove a fee from the payment
С версии: 1.5
public remove_fee ( integer $key ) : boolean
$key integer The array key index to remove
Результат boolean If the fee was removed successfully

remove_fee_by() публичный Метод

Remove a fee by the defined attributed
С версии: 1.5
public remove_fee_by ( string $key, integer | string $value, boolean $global = false ) : boolean
$key string The key to remove by
$value integer | string The value to search for
$global boolean False - removes the first value it fines, True - removes all matches.
Результат boolean If the item is removed

save() публичный Метод

Once items have been set, an update is needed to save them to the database.
public save ( ) : boolean
Результат boolean True of the save occurred, false if it failed or wasn't needed

update_meta() публичный Метод

Update the post meta
С версии: 1.5
public update_meta ( string $meta_key = '', string $meta_value = '', string $prev_value = '' ) : integer | boolean
$meta_key string The meta key to update
$meta_value string The meta value
$prev_value string Previous meta value
Результат integer | boolean Meta ID if the key didn't exist, true on successful update, false on failure

update_payment_setup() публичный Метод

So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. To prevent that user can use this function after updating any payment meta value ( in bulk or single update ).
С версии: 1.6
public update_payment_setup ( integer $payment_id ) : void
$payment_id integer Payment ID.
Результат void

update_status() публичный Метод

Set the payment status and run any status specific changes necessary.
С версии: 1.0
public update_status ( string $status = false ) : boolean
$status string The status to set the payment to.
Результат boolean $updated Returns if the status was successfully updated.

Описание свойств

$ID публичное свойство

The Payment ID.
С версии: 1.5
public int $ID
Результат integer

$_ID защищенное свойство

Protected non-read $_ID.
protected int $_ID
Результат integer

$address защищенное свойство

The physical address used for the payment if provided
С версии: 1.5
protected array $address
Результат array

$completed_date защищенное свойство

The date the payment was marked as 'complete'.
С версии: 1.5
protected string $completed_date
Результат string

$currency защищенное свойство

The the payment was made with
С версии: 1.5
protected string $currency
Результат string

$customer_id защищенное свойство

The customer ID that made the payment
С версии: 1.5
protected int $customer_id
Результат integer

$date защищенное свойство

The date the payment was created
С версии: 1.5
protected string $date
Результат string

$email защищенное свойство

The email used for the payment
С версии: 1.5
protected string $email
Результат string

$fees защищенное свойство

Array of global fees for this payment
С версии: 1.5
protected array $fees
Результат array

$fees_total защищенное свойство

The sum of the fee amounts
С версии: 1.5
protected float $fees_total
Результат float

$first_name защищенное свойство

The first name of the payee
С версии: 1.5
protected string $first_name
Результат string

$form_id защищенное свойство

The Donation Form ID
С версии: 1.5
protected string $form_id
Результат string

$form_title защищенное свойство

The Donation Form Title
С версии: 1.5
protected string $form_title
Результат string

$gateway защищенное свойство

The gateway used to process the payment
С версии: 1.5
protected string $gateway
Результат string

$ip защищенное свойство

IP Address payment was made from
С версии: 1.5
protected string $ip
Результат string

$key защищенное свойство

The unique donation payment key.
С версии: 1.5
protected string $key
Результат string

$last_name защищенное свойство

The last name of the payee
С версии: 1.5
protected string $last_name
Результат string

$mode защищенное свойство

The Gateway mode the payment was made in.
С версии: 1.5
protected string $mode
Результат string

$new защищенное свойство

Identify if the payment is a new one or existing.
С версии: 1.5
protected bool $new
Результат boolean

$number защищенное свойство

The Payment number (for use with sequential payments).
С версии: 1.5
protected string $number
Результат string

$old_status защищенное свойство

When updating, the old status prior to the change
С версии: 1.5
protected string $old_status
Результат string

$parent_payment защищенное свойство

The parent payment (if applicable)
С версии: 1.5
protected int $parent_payment
Результат integer

$post_date защищенное свойство

The date the payment post was created.
protected string $post_date
Результат string

$post_status защищенное свойство

protected string $post_status
Результат string

$price_id защищенное свойство

The Donation Form Price ID
С версии: 1.5
protected string|int $price_id
Результат string | integer

$status защищенное свойство

The status of the donation payment.
С версии: 1.5
protected string $status
Результат string

$status_nicename защищенное свойство

The display name of the current payment status.
С версии: 1.5
protected string $status_nicename
Результат string

$subtotal защищенное свойство

The Subtotal fo the payment before fees
С версии: 1.5
protected float $subtotal
Результат float

$total защищенное свойство

Includes donation amount and fees.
С версии: 1.5
protected float $total
Результат float

$transaction_id защищенное свойство

The transaction ID returned by the gateway
С версии: 1.5
protected string $transaction_id
Результат string

$user_id защищенное свойство

The User ID (if logged in) that made the payment
С версии: 1.5
protected int $user_id
Результат integer