gform_ppcp_webhookDescriptionUsageParametersExamples1. Add a notePlacementSource Code
Description
The gform_ppcp_webhook filter can be used to customize the webhook events processed by the Gravity Forms PayPal Checkout Add-On. The following event types are supported by default:
PAYMENT.CAPTURE.REFUNDED
PAYMENT.AUTHORIZATION.VOIDED
PAYMENT.CAPTURE.COMPLETED
PAYMENT.CAPTURE.DENIED
See the PayPal API Reference for a full list of event types for which webhooks can be sent.
Usage
The hook which would run for all PayPal Checkout feeds can be used like so:
add_filter( 'gform_ppcp_webhook', 'your_function_name', 10, 2 );
Parameters
$action array
An associative array containing the event details or an empty array for unsupported event types.
array(
'type' => '',
'amount' => '',
'transaction_type' => '',
'transaction_id' => '',
'subscription_id' => '',
'entry_id' => '',
'payment_status' => '',
'note' => '',
);
$event array
The PayPal Checkout event object for the webhook which was received. See the PayPal API Reference for details about the event properties.
Examples
1. Add a note
The following shows how you can add a custom note when an authorization is cancelled (voided).
add_filter( 'gform_ppcp_webhook', 'ppcp_webhook_action_note', 10, 2 );
function ppcp_webhook_action_note( $action, $event ) {
if ( rgar( $action, 'type' ) === 'PAYMENT.AUTHORIZATION.VOIDED' ) {
$action['note'] = sprintf( 'Authorization has been cancelled (voided). Transaction Id: %s', rgar( $action, 'transaction_id' ) );
}
return $action;
}
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
$action = apply_filters( 'gform_ppcp_webhook', $action, $event );
This hook is located in GF_PPCP::callback() in class-gf-ppcp.php.