WP SmartPay fires action hooks and filter hooks at every major point in the payment and subscription lifecycle. Third-party plugins, themes, and custom code can hook into these to extend behavior without modifying SmartPay's source files.
Payment Lifecycle Hooks
Actions
| Hook |
When it fires |
Parameters |
smartpay_payment_created |
New payment record inserted |
$payment (Payment model) |
smartpay_payment_completed |
Payment status changes to completed |
$payment_id, $payment |
smartpay_payment_failed |
Payment status changes to failed |
$payment_id, $payment |
smartpay_payment_refunded |
A refund is issued on a payment |
$payment_id, $amount |
smartpay_update_payment_status |
Any payment status change |
$payment_id, $new_status, $old_status |
Filters
| Hook |
What it filters |
Parameters |
smartpay_prepare_payment_data |
Payment data array before insert |
$payment_data, $raw_data |
smartpay_payment_success_redirect_url |
URL to redirect to after successful payment |
$url, $payment_id |
smartpay_payment_failure_message |
Error message shown on payment failure |
$message, $payment_data |
Subscription Lifecycle Hooks
Actions
| Hook |
When it fires |
Parameters |
smartpay_pro_subscription_created |
New subscription created |
$subscription |
smartpay_pro_subscription_renewed |
Renewal payment succeeds |
$subscription, $payment |
smartpay_pro_subscription_cancelled |
Subscription cancelled |
$subscription |
smartpay_pro_subscription_completed |
Fixed-term subscription finishes all installments |
$subscription |
smartpay_pro_subscription_failing |
Renewal payment fails |
$subscription |
Gateway Hooks
Each gateway follows a consistent naming pattern:
| Hook pattern |
Gateway slug examples |
Purpose |
smartpay_{gateway}_ajax_process_payment |
stripe, paypal, razorpay |
Handles AJAX form submission for that gateway |
smartpay_{gateway}_process_payment |
Same as above |
Direct payment processing (non-AJAX) |
smartpay_gateways |
— |
Filter to register a new gateway |
Form / Checkout Hooks
| Hook |
When it fires |
smartpay_checkout_before_form |
Before the payment form renders |
smartpay_checkout_after_form |
After the payment form renders |
smartpay_checkout_validate |
On form submission, before gateway processing — add custom validation here |
smartpay_form_fields |
Filter to add or remove fields from the checkout form |
Example: Run Custom Code on Payment Completion
add_action( 'smartpay_payment_completed', function( $payment_id, $payment ) {
$customer_email = $payment->email;
$amount = $payment->amount; // in smallest currency unit
// Custom logic here — e.g., add to custom DB table, send third-party API call
my_plugin_handle_payment( $customer_email, $amount );
}, 10, 2 );
Example: Customize the Success Redirect URL
add_filter( 'smartpay_payment_success_redirect_url', function( $url, $payment_id ) {
// Redirect VIP customers to a different thank-you page
$payment = smartpay_get_payment( $payment_id );
if ( $payment && $payment->amount >= 19900 ) {
return home_url( '/vip-thank-you/' );
}
return $url;
}, 10, 2 );
Finding All Available Hooks
- Free plugin hooks: search
do_action( and apply_filters( in ../smartpay/app/
- Pro plugin hooks: search in
app/ — all Pro-specific hooks use the smartpay_pro_ prefix
- Gateway-specific hooks: check each gateway's class file in
app/Gateways/