Skip to main content

Gravity_Forms\Gravity_Forms\Notification\Payment_Stale_Handler

Class Payment_Stale_Handler

Since: 2.9.29 (Provides functionality for handling stale payment notifications.)

Source: includes/notification/class-payment-stale-handler.php:19

Details

  • Kind: class
  • Namespace: Gravity_Forms\Gravity_Forms\Notification

Methods

MethodDescription
activate_cron()Sets up the cron for processing stale payment notifications.
deactivate_cron()Deactivates the cron for processing stale payment notifications. This function is hooked to the 'gform_uninstalling' action and will run when Gravity Forms is uninstalled, to clean up the scheduled cron job.
maybe_execute_cron()This method allows executing the cron for processing stale payment notifications manually for debugging purposes. It checks for a "_execute_stale_payment_cron" query string parameter.
process_stale_payment_notifications()Processes stale payment notifications. This function is hooked to the 'gform_stale_payment_cron' and will run hourly to check for entries with a payment status of "Processing" that are older than a specified threshold (default is 60 minutes).
get_stale_entries()Retrieves entries that are considered to have a "stale" payment. These are entries with a payment status of "Processing" that are older than a specified threshold (default is 60 minutes).
get_stale_payment_notifications()Retrieves the notifications for a form that are configured to be sent for the "payment_stale" event.
has_stale_payment_notification()Checks if the form has at least one active stale payment notification configured.
send_stale_payment_notifications()Sends the stale payment notification for a given entry.
handle_payment_status_change()Handles the logic for when an entry's payment status changes. This function is hooked to the 'gform_post_payment_status_change' action and will run whenever an entry's payment status is updated.
add_entry_meta()Checks if the stale payment notification has already been processed for the given entry.
update_entry_meta()Updates the entry meta to indicate that the stale payment notification has been processed for the given entry. This will prevent the cron from sending multiple notifications for the same entry.
remove_entry_meta()Removes the entry meta that indicates that the stale payment notification needs to be processed for this entry.

Method Reference

activate_cron()

public function activate_cron()

Sets up the cron for processing stale payment notifications.

This cron will run hourly and check for entries with a payment status of "Processing" that are older than a specified threshold (default is 60 minutes). For each of those entries, it will send a notification and update the entry meta to indicate that the stale notification has been processed.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:30

deactivate_cron()

public function deactivate_cron()

Deactivates the cron for processing stale payment notifications. This function is hooked to the 'gform_uninstalling' action and will run when Gravity Forms is uninstalled, to clean up the scheduled cron job.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:47

maybe_execute_cron()

public function maybe_execute_cron()

This method allows executing the cron for processing stale payment notifications manually for debugging purposes. It checks for a "_execute_stale_payment_cron" query string parameter.

Returns

  • void

Source: includes/notification/class-payment-stale-handler.php:56

process_stale_payment_notifications()

public function process_stale_payment_notifications()

Processes stale payment notifications. This function is hooked to the 'gform_stale_payment_cron' and will run hourly to check for entries with a payment status of "Processing" that are older than a specified threshold (default is 60 minutes).

For each of those entries, it will send a notification and update the entry meta to indicate that the stale notification has been processed.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:70

get_stale_entries()

public function get_stale_entries()

Retrieves entries that are considered to have a "stale" payment. These are entries with a payment status of "Processing" that are older than a specified threshold (default is 60 minutes).

Returns

  • array — Returns an array of entries that are considered to have a "stale" payment.

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:103

get_stale_payment_notifications()

public function get_stale_payment_notifications( $form )

Retrieves the notifications for a form that are configured to be sent for the "payment_stale" event.

Parameters

NameTypeDefaultDescription
$formarrayThe form object to retrieve the notifications for.

Returns

  • array — An array of notifications that are configured to be sent for the "payment_stale" event.

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:140

has_stale_payment_notification()

public function has_stale_payment_notification( $form )

Checks if the form has at least one active stale payment notification configured.

Parameters

NameTypeDefaultDescription
$formarrayThe form object to check for stale payment notifications.

Returns

  • bool — Returns true if the form has at least one active stale payment notification, false otherwise.

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:155

send_stale_payment_notifications()

public function send_stale_payment_notifications( $entry )

Sends the stale payment notification for a given entry.

This function retrieves the notifications for the form that are configured to be sent for the "payment_stale" event and sends them. It also updates the entry meta to indicate that the stale notification has been processed for this entry, which will prevent the cron from sending multiple notifications for the same entry.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry object for which to send the stale payment notification.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:180

handle_payment_status_change()

public function handle_payment_status_change( $entry )

Handles the logic for when an entry's payment status changes. This function is hooked to the 'gform_post_payment_status_change' action and will run whenever an entry's payment status is updated.

When an entry's payment status is updated to "Processing" and the form has an active stale payment notification, it enables the stale payment notification functionality by ensuring the cron job is scheduled and adding an entry meta to include this entry in the stale payment notification cron process.

Parameters

NameTypeDefaultDescription
$entryThe entry object for which the payment status has changed.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:201

add_entry_meta()

public function add_entry_meta( $entry )

Checks if the stale payment notification has already been processed for the given entry.

If it hasn't, it adds an entry meta to indicate that the stale payment notification needs to be processed for this entry. This function should be called when an entry's payment status is updated to "Processing".

Parameters

NameTypeDefaultDescription
$entryarrayThe entry object for which to maybe add the stale payment notification meta.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:230

update_entry_meta()

public function update_entry_meta( $entry )

Updates the entry meta to indicate that the stale payment notification has been processed for the given entry. This will prevent the cron from sending multiple notifications for the same entry.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry object for which to update the stale payment notification meta.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:253

remove_entry_meta()

public function remove_entry_meta( $entry )

Removes the entry meta that indicates that the stale payment notification needs to be processed for this entry.

This function should be called when an entry's payment status is updated from "Processing" to any other status, to prevent the cron from sending a stale payment notification for this entry.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry object for which to remove the stale payment notification meta.

Returns

  • void

Since: 2.9.29

Source: includes/notification/class-payment-stale-handler.php:270