Skip to content

Instantly share code, notes, and snippets.

@NikV
Created July 10, 2015 23:08
Show Gist options
  • Save NikV/bb1ca7ce478c0c60d155 to your computer and use it in GitHub Desktop.
Save NikV/bb1ca7ce478c0c60d155 to your computer and use it in GitHub Desktop.
Examples for: gform_post_payment_callback
/**
* Send a notification after a user attempts a purchase
*
* @param $entry The Entries object
* @param array $action The Action Object
* $action = array(
* 'type' => 'cancel_subscription', // See Below
* 'transaction_id' => '', // What is the ID of the transaction made?
* 'subscription_id' => '', // What is the ID of the Subscription made?
* 'amount' => '0.00', // Amount to charge?
* 'entry_id' => 1, // What entry to check?
* 'transaction_type' => '',
* 'payment_status' => '',
* 'note' => ''
* );
*
* 'type' can be:
*
* - complete_payment
* - refund_payment
* - fail_payment
* - add_pending_payment
* - void_authorization
* - create_subscription
* - cancel_subscription
* - expire_subscription
* - add_subscription_payment
* - fail_subscription_payment
* @param array $result The object for possible results
*/
function gfroms_after_payment_callback( $entry, $action, $result ) {
// Check if there is a result
if ( $result ) {
// Get the form where this entry is from
$form = GFAPI::get_form( $entry['form_id'] );
// Lets send a form notification with the action that has occured
GFAPI::send_notifications( $form, $entry, rgar( $action, 'type' ) );
}
}
// Tells the notification to be sent only when this hook is found and to include the arguments
add_action( 'gform_post_payment_callback', 'gfroms_after_payment_callback', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment