PHP Class Give_Payment, Give

This class is for working with payments in Give.
Since: 1.5
Datei anzeigen Open project: wordimpress/give Class Usage Examples

Public Properties

Property Type Description
$ID integer The Payment ID.

Protected Properties

Property Type Description
$_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

Public Methods

Method Description
__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.

Private Methods

Method Description
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

Method Details

__construct() public method

Setup the Give Payments class
Since: 1.0
public __construct ( integer $payment_id = false ) : mixed
$payment_id integer A given payment
return mixed void|false

__get() public method

Magic GET function.
Since: 1.5
public __get ( string $key ) : mixed
$key string The property.
return mixed The value.

__isset() public method

Magic ISSET function, which allows empty checks on protected elements
Since: 1.5
public __isset ( string $name ) : boolean
$name string The attribute to get
return boolean If the item is set or not

__set() public method

Sets up the pending array for the save method
Since: 1.5
public __set ( string $key, mixed $value )
$key string The property name
$value mixed The value of the property

add_donation() public method

Add a donation to a given payment
Since: 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
return boolean True when successful, false otherwise

add_fee() public method

Add a fee to a given payment
Since: 1.5
public add_fee ( array $args, boolean $global = true ) : boolean
$args array Array of arguments for the fee to add
$global boolean
return boolean If the fee was added

add_note() public method

Add a note to a payment
Since: 1.0
public add_note ( string $note = false ) : void
$note string The note to add
return void

array_convert() public method

Converts this object into an array for special cases
public array_convert ( ) : array
return array The payment object as an array

get_fees() public method

Get the fees, filterable by type
Since: 1.5
public get_fees ( string $type = 'all' ) : array
$type string All, item, fee
return array The Fees for the type specified

get_meta() public method

Get a post meta item for the payment
Since: 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
return mixed The value from the post meta

refund() public method

Change the status of the payment to refunded, and run the necessary changes
Since: 1.5
public refund ( ) : void
return void

remove_donation() public method

Remove a donation from the payment
Since: 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)
return boolean If the item was removed or not

remove_fee() public method

Remove a fee from the payment
Since: 1.5
public remove_fee ( integer $key ) : boolean
$key integer The array key index to remove
return boolean If the fee was removed successfully

remove_fee_by() public method

Remove a fee by the defined attributed
Since: 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.
return boolean If the item is removed

save() public method

Once items have been set, an update is needed to save them to the database.
public save ( ) : boolean
return boolean True of the save occurred, false if it failed or wasn't needed

update_meta() public method

Update the post meta
Since: 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
return integer | boolean Meta ID if the key didn't exist, true on successful update, false on failure

update_payment_setup() public method

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 ).
Since: 1.6
public update_payment_setup ( integer $payment_id ) : void
$payment_id integer Payment ID.
return void

update_status() public method

Set the payment status and run any status specific changes necessary.
Since: 1.0
public update_status ( string $status = false ) : boolean
$status string The status to set the payment to.
return boolean $updated Returns if the status was successfully updated.

Property Details

$ID public_oe property

The Payment ID.
Since: 1.5
public int $ID
return integer

$_ID protected_oe property

Protected non-read $_ID.
protected int $_ID
return integer

$address protected_oe property

The physical address used for the payment if provided
Since: 1.5
protected array $address
return array

$completed_date protected_oe property

The date the payment was marked as 'complete'.
Since: 1.5
protected string $completed_date
return string

$currency protected_oe property

The the payment was made with
Since: 1.5
protected string $currency
return string

$customer_id protected_oe property

The customer ID that made the payment
Since: 1.5
protected int $customer_id
return integer

$date protected_oe property

The date the payment was created
Since: 1.5
protected string $date
return string

$email protected_oe property

The email used for the payment
Since: 1.5
protected string $email
return string

$fees protected_oe property

Array of global fees for this payment
Since: 1.5
protected array $fees
return array

$fees_total protected_oe property

The sum of the fee amounts
Since: 1.5
protected float $fees_total
return float

$first_name protected_oe property

The first name of the payee
Since: 1.5
protected string $first_name
return string

$form_id protected_oe property

The Donation Form ID
Since: 1.5
protected string $form_id
return string

$form_title protected_oe property

The Donation Form Title
Since: 1.5
protected string $form_title
return string

$gateway protected_oe property

The gateway used to process the payment
Since: 1.5
protected string $gateway
return string

$ip protected_oe property

IP Address payment was made from
Since: 1.5
protected string $ip
return string

$key protected_oe property

The unique donation payment key.
Since: 1.5
protected string $key
return string

$last_name protected_oe property

The last name of the payee
Since: 1.5
protected string $last_name
return string

$mode protected_oe property

The Gateway mode the payment was made in.
Since: 1.5
protected string $mode
return string

$new protected_oe property

Identify if the payment is a new one or existing.
Since: 1.5
protected bool $new
return boolean

$number protected_oe property

The Payment number (for use with sequential payments).
Since: 1.5
protected string $number
return string

$old_status protected_oe property

When updating, the old status prior to the change
Since: 1.5
protected string $old_status
return string

$parent_payment protected_oe property

The parent payment (if applicable)
Since: 1.5
protected int $parent_payment
return integer

$post_date protected_oe property

The date the payment post was created.
protected string $post_date
return string

$post_status protected_oe property

protected string $post_status
return string

$price_id protected_oe property

The Donation Form Price ID
Since: 1.5
protected string|int $price_id
return string | integer

$status protected_oe property

The status of the donation payment.
Since: 1.5
protected string $status
return string

$status_nicename protected_oe property

The display name of the current payment status.
Since: 1.5
protected string $status_nicename
return string

$subtotal protected_oe property

The Subtotal fo the payment before fees
Since: 1.5
protected float $subtotal
return float

$total protected_oe property

Includes donation amount and fees.
Since: 1.5
protected float $total
return float

$transaction_id protected_oe property

The transaction ID returned by the gateway
Since: 1.5
protected string $transaction_id
return string

$user_id protected_oe property

The User ID (if logged in) that made the payment
Since: 1.5
protected int $user_id
return integer