The WPSmartPay Payment System provides comprehensive functionality for processing payments, managing payment gateways, and handling payment-related events. This system includes hooks for payment processing, gateway management, currency handling, and payment status tracking.
Action Hooks
smartpay_before_payment_processing
Fires: Right before processing a payment request, after request validation and data preparation.
Parameters:
$payment_data
(array) — Prepared payment payload to be processed.
add_action('smartpay_before_payment_processing', function( $payment_data ) {
// Inspect or modify pending payment data, log, etc.
});
smartpay_{gateway}_ajax_process_payment
Type: Action (dynamic)
Fires: When initiating an AJAX-based gateway charge for a selected gateway.
Parameters:
$paymentData
(array) — Payment data to send to the gateway.
add_action('smartpay_stripe_ajax_process_payment', function( $paymentData ) {
// Handle Stripe AJAX payment initiation.
});
smartpay_{gateway}_process_payment
Type: Action (dynamic)
Fires: When initiating a non-AJAX gateway charge for a selected gateway.
Parameters:
$paymentData
(array) — Payment data to send to the gateway.
add_action('smartpay_free_process_payment', function( $paymentData ) {
// Mark free orders as paid immediately.
});
smartpay_payment_created
Fires: After a payment record is created and saved.
Parameters:
$payment
(SmartPay\Models\Payment) — Newly created payment model.
add_action('smartpay_payment_created', function( $payment ) {
// Notify services, Queue receipt email, analytics tracking, etc.
});
smartpay_payment_completed
Fires: When a payment status becomes completed.
Parameters:
$payment
(SmartPay\Models\Payment) — Completed payment model.
add_action('smartpay_payment_completed', function( $payment ) {
// Fulfill order, grant access, license activation, etc.
});
smartpay_payment_cancelled
Fires: When a payment transitions to cancelled states.
Parameters:
$payment
(SmartPay\Models\Payment)
add_action('smartpay_payment_cancelled', function( $payment ) {
// Revoke access, notify user, restore inventory.
});
smartpay_payment_failed / smartpay_payment_refunded / smartpay_payment_abandoned
Fires: On specific failure/refund/abandoned status changes.
Parameters:
$payment
(SmartPay\Models\Payment) - Payment Model
add_action('smartpay_payment_failed', function( $payment ) {
// Alert support team.
});
smartpay_before_payment_receipt / smartpay_before_payment_receipt_data / smartpay_after_payment_receipt / smartpay_payment_{gateway}_receipt
Fires: Around the payment receipt rendering and for gateway-specific (dynamic) receipt sections.
Parameters:
$payment
(SmartPay\Models\Payment) - Payment Model
add_action('smartpay_payment_paypal_receipt', function( $payment ) {
echo '<p>PayPal Transaction: ' . esc_html($payment->transaction_id) . '</p>';
});
Filter Hooks
smartpay_prepare_payment_data
Fires: When building the normalized payment payload from request data.
Parameters:
$prepared
(array) — Payment data array.$_data
(array) — Raw request data.
add_filter('smartpay_prepare_payment_data', function( $prepared, $_data ) {
$prepared['extra']['source'] = 'landing-page-7';
return $prepared;
}, 10, 2);
smartpay_payment_extra_data
Fires: Before saving the extra
payload on the payment model.
Parameters:
$extra
(array) — Extra payment data.
add_filter('smartpay_payment_extra_data', function( $extra ) {
$extra['utm'] = $_COOKIE['utm'] ?? [];
return $extra;
});
smartpay_currencies
Fires: When building the currency list.
Parameters:
$currencies
(array)
add_filter('smartpay_currencies', function( $currencies ) {
$currencies['XYZ'] = ['name' => 'Example', 'symbol' => '¤'];
return $currencies;
});
smartpay_gateways
Fires: To register available payment gateways.
Parameters:
$gateways
(array)
add_filter('smartpay_gateways', function( $gateways ) {
$gateways['mygateway'] = [ 'admin_label' => 'My Gateway', 'checkout_label' => 'My Gateway', 'gateway_icon' => 'https://...' ];
return $gateways;
});
smartpay_get_ip
Fires: When resolving the client IP address.
Parameters:
$ip
(string)
add_filter('smartpay_get_ip', function( $ip ) {
return $ip === '127.0.0.1' ? ($_SERVER['HTTP_X_REAL_IP'] ?? $ip) : $ip;
});
smartpay_get_available_payment_gateways
Fires: To alter the list of available gateways shown in settings UI.
Parameters:
$availableGateways
(array)
add_filter('smartpay_get_available_payment_gateways', function( $available ) {
$available['newpay'] = ['label' => 'NewPay'];
return $available;
});
smartpay_get_additional_payment_data
Fires: To add/alter calculated payment data (totals, billing info, etc.).
Parameters:
$paymentData
(array)
add_filter('smartpay_get_additional_payment_data', function( $paymentData ) {
$paymentData['note'] = 'VIP order';
return $paymentData;
});
Common Use Cases
Payment validation
Gateway integration
Payment tracking
Receipt customization
Currency support