Description
The gform_post_payment_status action fires after an entry’s payment status has been updated, and the payment was for the PayPal Standard Add-On.
Usage
add_action( 'gform_post_payment_status', 'your_function_name', 10, 8 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$feed | Feed Object | The PayPal configuration feed used to generate the transaction. |
$entry | Entry Object | The entry from which the transaction was originally generated. |
$status | string | The new payment status for this transaction. |
$transaction_id | string | The PayPal transaction ID for this transaction. |
$subscriber_id | integer | The PayPal subscriber ID for this transaction. Will be empty if the transaction is a one-time payment. |
$amount | float | The amount of the transaction. |
$pending_reason | string | If the payment status is set to “Pending”, the reason will be passed in this variable. |
$reason | string | If the payment status is set to “Reversed”, “Refunded”, or “Canceled_Reversal”, the reason for this change will be provided in this variable. |
Examples
Notify the Admin of Payment Status Changes
This example shows how to notify the site admin when a payment is completed, or in a special case.
add_action( 'gform_post_payment_status', 'admin_payment_notification', 10, 8 );
function admin_payment_notification( $feed, $entry, $status, $transaction_id, $subscriber_id, $amount, $pending_reason, $reason ) {
$admin_email = get_bloginfo( 'admin_email' );
if ( $status == 'Completed' ) {
wp_mail( $admin_email, 'Payment Successful!', 'Message about the successful payment' );
} elseif ( $status == 'Refunded' || $status == 'Reversed' || $status == 'Canceled_Reversal' ) {
wp_mail( $admin_email, "Payment $status", "There was an issue with this payment: $reason" );
}
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
do_action( 'gform_post_payment_status', $feed, $entry, $status, $transaction_id, $subscriber_id, $amount, $pending_reason, $reason );
This hook is located in GFPayPal::post_callback() in class-gf-paypal.php.