Description
Triggers when a payment has been completed through the form.
Usage
add_action( 'gform_post_payment_completed', 'my_function', 10, 2 );
Parameters
- $entry Entry Object
The entry object that was created. - $action array
The action that occurred. Contains things such as the amount, what occurred, and the transaction ID.
$action = array(
'type' => '',
'amount' => '',
'transaction_type' => '',
'transaction_id' => '',
'subscription_id' => '',
'entry_id' => '',
'payment_status' => '',
'note' => '',
);
Examples
Log the payment and entry details in the Gravity Forms log.
add_action( 'gform_post_payment_completed', function ( $entry, $action ) {
// Log payment completion and entry details.
GFCommon::log_debug( 'Payment completed: ' . print_r( $action, true ) );
GFCommon::log_debug( 'Entry details: ' . print_r( $entry, true ) );
// Log each item in the action array.
foreach ($action as $key => $value) {
GFCommon::log_debug( sprintf( 'Action %s: %s', $key, print_r( $value, true ) ) );
}
}, 10, 2 );
Source Code
do_action( 'gform_post_payment_completed', $entry, $action );
This action hook is located in GFPaymentAddOn::complete_payment() in includes/addon/class-gf-payment-addon.php.