- 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
- 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
sd-payment-success JavaScript Custom Event
Overview
The sd-payment-success event is a JavaScript CustomEvent dispatched on a SureDonation form after a payment gateway confirms a successful payment on the frontend.
This event allows developers to execute custom JavaScript, such as tracking conversions, displaying animations, triggering third-party integrations, or performing custom redirects, immediately after a successful donation without modifying the SureDonation core plugin.
How It Works
The sd-payment-success event is currently dispatched by the PayPal payment gateway.
Since PayPal completes the payment using its own PayPal Buttons interface instead of the form’s normal submission flow, SureDonation dispatches this custom event after the payment has been successfully verified and captured on the server.
Event Behavior
The event is dispatched as a standard DOM CustomEvent with the following properties:
| Property | Value |
| Event Name | sd-payment-success |
| Event Type | CustomEvent |
| Bubbles | Yes |
| Cancelable | No |
Because the event bubbles through the DOM, you can listen for it on:
- The specific donation form
- A parent container
- The document
Event Data
The event payload is available through event.detail.
| Property | Type | Description |
| gateway | string | Payment gateway that completed the donation (PayPal). |
| donationId | number | SureDonation donation record ID. |
| orderId | string | PayPal Order ID. |
| captureId | string | PayPal Capture ID. Returns an empty string if unavailable. |
| message | string | Success or receipt message returned by the server. Returns an empty string if unavailable. |
Listening for the Event
You can listen for the event globally on the document.
document.addEventListener('sd-payment-success', (event) => {
const {
gateway,
donationId,
orderId,
captureId,
message,
} = event.detail;
console.log(`Donation #${donationId} succeeded via ${gateway}`);
// Example: Send analytics event
if (window.gtag) {
window.gtag('event', 'donation_complete', {
transaction_id: orderId,
gateway,
});
}
});
Listening on a Specific Form
Because the event bubbles, you can also listen only on a specific SureDonation form.
const form = document.querySelector('.sd-form-container form');
form.addEventListener('sd-payment-success', (event) => {
    // Handle successful donation for this form.
});Default SureDonation Behavior
SureDonation includes its own frontend listener (initFormSubmission) that responds to the sd-payment-success event by calling the internal showSuccessMessage() method.
Depending on your campaign settings, SureDonation will automatically:
Redirect the Donor
If the campaign uses the Redirect confirmation type and a valid redirectUrl is configured, the donor is redirected after a successful payment.
For security reasons, invalid URLs, including protocol-relative URLs and non-HTTP(S) URLs, are rejected.
Display the Success Message
If no redirect is configured, SureDonation:
- Hides the donation form.
- Inserts the success message into .sd-success-box-description.
- Displays the success message container.
- Scrolls the page to the success message.
Common Use Cases
The sd-payment-success event can be used for:
- Tracking Google Analytics or GA4 conversions
- Sending Meta Pixel or other advertising events
- Triggering custom JavaScript integrations
- Displaying confetti or celebration animations
- Updating custom UI elements
- Running post-donation workflows
- Integrating with third-party frontend applications
Related Hooks
| Hook | Description |
| suredonation_donation_completed | Server-side action triggered after a successful donation for all supported payment gateways. |
| suredonation_enqueue_form_frontend_scripts | Enqueue custom frontend scripts for SureDonation forms. |
We don't respond to the article feedback, we use it to improve our support content.