- Handle Custom Stripe Webhook Events
- suredonation_export_secret_option_keys Filter Hook
- suredonation_import_batch_complete Action Hook
- suredonation_import_complete Action Hook
- suredonation_import_donation_inserted Action Hook
- suredonation_import_donor_inserted Action Hook
- suredonation_import_session_created Action Hook
- suredonation_import_givewp_batch_complete Action Hook
- suredonation_import_givewp_session_created Action Hook
- suredonation_privacy_data_exported Action Hook
- Validate Field Filter Hook
- Validatable Blocks Filter Hook
- Update donation data, Filter Hook
- OttoKit Integration: suredonation_suretriggers_integration_data_filter Filter Hook
- suredonation_show_setup_gateway_notice Filter Hook
- suredonation_show_review_notice_gateway Filter Hook
- suredonation_show_review_notice_donation Filter Hook
- suredonation_registered_payment_methods Filter Hook
- suredonation_register_additional_blocks Filter Hook
- suredonation_receipt_html Filter Hook
- suredonation_phone_geo_enabled Filter Hook
- suredonation_phone_geo_api_hourly_cap Filter Hook
- suredonation_paypal_webhook_handle_event Filter Hook
- suredonation_paypal_sdk_args Filter Hook
- suredonation_output_campaign_meta_tags Filter Hook
- suredonation_new_donor_user_data Filter Hook
- suredonation_integration_payload Filter Hook
- suredonation_import_phase_mappers Filter Hook
- suredonation_import_givewp_phases Filter Hook
- suredonation_import_givewp_phase_mappers Filter Hook
- suredonation_import_donation_row Filter Hook
- suredonation_import_campaigns_limit Filter Hook
- suredonation_field_block_config Filter Hook
- suredonation_export_one_time_only Filter Hook
- suredonation_export_campaigns_limit Filter Hook
- suredonation_email_smart_tags Filter Hook
- suredonation_email_smart_tag_groups Filter Hook
- suredonation_email_field_char_limits Filter Hook
- suredonation_disable_default_styles Filter Hook
- suredonation_default_validation_messages Filter Hook
- suredonation_default_email_notifications Filter Hook
- suredonation_create_donation_data Filter Hook
- suredonation_config_abilities Filter Hook
- suredonation_available_payment_methods Filter Hook
- suredonation_allowed_form_html Filter Hook
- suredonation_allowed_form_blocks Filter Hook
- Validatable Blocks Filter Hook
- Update donation data, Filter Hook
- OttoKit Integration: suredonation_suretriggers_integration_data_filter Filter Hook
- suredonation_show_setup_gateway_notice Filter Hook
- suredonation_show_review_notice_gateway Filter Hook
- suredonation_show_review_notice_donation Filter Hook
- suredonation_registered_payment_methods Filter Hook
- suredonation_register_additional_blocks Filter Hook
- suredonation_receipt_html Filter Hook
- suredonation_phone_geo_enabled Filter Hook
- suredonation_phone_geo_api_hourly_cap Filter Hook
- suredonation_paypal_webhook_handle_event Filter Hook
- suredonation_paypal_sdk_args Filter Hook
- suredonation_output_campaign_meta_tags Filter Hook
- suredonation_new_donor_user_data Filter Hook
- suredonation_integration_payload Filter Hook
- suredonation_import_phase_mappers Filter Hook
- suredonation_import_givewp_phases Filter Hook
- suredonation_import_givewp_phase_mappers Filter Hook
- suredonation_import_donation_row Filter Hook
- suredonation_import_campaigns_limit Filter Hook
- suredonation_field_block_config Filter Hook
- suredonation_export_secret_option_keys Filter Hook
- suredonation_export_one_time_only Filter Hook
- suredonation_export_campaigns_limit Filter Hook
- suredonation_email_smart_tags Filter Hook
- suredonation_email_smart_tag_groups Filter Hook
- suredonation_email_field_char_limits Filter Hook
- suredonation_disable_default_styles Filter Hook
- suredonation_default_validation_messages Filter Hook
- suredonation_default_email_notifications Filter Hook
- suredonation_create_donation_data Filter Hook
- suredonation_config_abilities Filter Hook
- suredonation_available_payment_methods Filter Hook
- suredonation_allowed_form_html Filter Hook
- suredonation_allowed_form_blocks Filter Hook
- suredonation_import_batch_complete Action Hook
- suredonation_import_complete Action Hook
- suredonation_import_donation_inserted Action Hook
- suredonation_import_donor_inserted Action Hook
- suredonation_import_session_created Action Hook
- suredonation_import_givewp_batch_complete Action Hook
- suredonation_import_givewp_session_created Action Hook
- suredonation_privacy_data_exported Action Hook
- suredonation_enqueue_form_frontend_scripts Action Hook
- suredonation_after_form_duplicated Action Hook
- suredonation_email_sent Action Hook
- suredonation_donor_user_created Action Hook
- suredonation_donation_refunded Action Hook
- suredonation_donation_status_changed Action Hook
- suredonation_donation_completed Action Hook
- suredonation_new_donation Action Hook
- suredonation_donation_created Action Hook
suredonation_paypal_webhook_handle_event Filter Hook
Overview
The suredonation_paypal_webhook_handle_event filter allows developers to handle PayPal webhook events that are not processed natively by SureDonation.
SureDonation natively processes the following PayPal webhook events:
- PAYMENT.CAPTURE.COMPLETED
- PAYMENT.CAPTURE.DENIED
- PAYMENT.CAPTURE.REFUNDED
This filter runs for other event types, allowing developers to add custom handling for additional PayPal events. SureDonation Pro also uses this filter for events such as BILLING.SUBSCRIPTION.* and PAYMENT.SALE.*.
When to Use This Filter
Use this filter when you need to process a PayPal webhook event that is not handled by SureDonation by default.
For example, you can use it to:
- Handle subscription events.
- Process PayPal sale events.
- Record custom transaction information.
- Trigger custom workflows.
- Integrate PayPal events with another system.
Filter Signature
apply_filters( 'suredonation_paypal_webhook_handle_event', null, $event_type, $event_resource, $mode);Parameters
| Parameter | Type | Description |
| $value | bool|WP_Error|null | The current result. Starts as null, which indicates that the event has not been handled. |
| $event_type | string | The PayPal webhook event type. |
| $event_resource | array | Data associated with the PayPal webhook event. |
| $mode | string | The payment mode. |
Return Value
This filter uses a short-circuit contract. Your callback should return one of the following values:
| Return Value | Result |
| null | The event was not handled. The webhook is acknowledged. |
| true | The event was handled successfully. |
| WP_Error | Processing the event failed. |
Basic Usage
Use add_filter() to register your callback.
add_filter( 'suredonation_paypal_webhook_handle_event', 'your_custom_function', 10, 4);
function your_custom_function(
    $result,
    $event_type,
    $event_resource,
    $mode
) {
    // Return null if you do not handle this event.
    return $result;
}Example: Handle a PayPal Sale Event
The following example handles the PAYMENT.SALE.COMPLETED event.
add_filter( 'suredonation_paypal_webhook_handle_event', 'mysite_handle_sale', 10,  4);
function mysite_handle_sale(
    $result,
    $event_type,
    $event_resource,
    $mode
) {
    if ( 'PAYMENT.SALE.COMPLETED' === $event_type ) {
        mysite_record_sale( $event_resource );
        return true;
    }
    return $result;
}How the Example Works
- The callback receives the PayPal webhook event.
- It checks whether the event type is PAYMENT.SALE.COMPLETED.
- If the event matches, custom processing is performed.
- The callback returns true to indicate successful handling.
- Other event types return the original $result.
Example: Handle a Subscription Event
You can also use the filter to process PayPal subscription events.
add_filter(Â 'suredonation_paypal_webhook_handle_event', Â 'mysite_handle_subscription', 10, Â 4);
function mysite_handle_subscription(
    $result,
    $event_type,
    $event_resource,
    $mode
) {
    if ( 'BILLING.SUBSCRIPTION.CREATED' === $event_type ) {
        mysite_process_subscription( $event_resource );
        return true;
    }
    return $result;
}Handling Errors
If your custom processing fails, return a WP_Error.
add_filter( 'suredonation_paypal_webhook_handle_event', 'mysite_handle_custom_event', 10, 4);
function mysite_handle_custom_event(
    $result,
    $event_type,
    $event_resource,
    $mode
) {
    if ( 'PAYMENT.SALE.COMPLETED' === $event_type ) {
        $success = mysite_record_sale( $event_resource );
        if ( ! $success ) {
            return new WP_Error(
                'custom_processing_failed',
                __( 'Unable to process the PayPal sale.', 'my-plugin' )
            );
        }
        return true;
    }
    return $result;
}Webhook Processing Flow
The filter is part of the PayPal webhook processing flow:
- PayPal sends a webhook event to SureDonation.
- SureDonation identifies the PayPal event type.
- Natively supported events are processed by SureDonation.
- Other event types reach the default branch.
- The suredonation_paypal_webhook_handle_event filter is applied.
- Your callback can process the event.
- Return true when processing succeeds.
- Return null when the event is not handled.
- Return a WP_Error when processing fails.
Important: Return the Original Result
If your callback does not handle the event, always return the original $result.
return $result;
The initial value is null. Returning it ensures that unrelated PayPal webhook events are not incorrectly marked as handled.
Related Hooks
- Suredonation_webhook_handle_event: Allows developers to handle additional Stripe webhook events.
- Suredonation_paypal_sdk_args: Allows developers to modify PayPal SDK configuration arguments.
We don't respond to the article feedback, we use it to improve our support content.