Below is a list of action hooks that are available in the Stripe Payments Plugin.
Table of Contents
Payment Process
asp_ng_before_payment_processing
Fired before payment processing has begun.
Parameters:
$post_data (array)
Has combined payment info data from $_POST array.
asp_stripe_payment_completed
This hook executes after a transaction is completed. This can be used to do some additional tasks after a transaction takes place.
Parameters:
$data (array)
Payment info data array.
$charge (array)
Charge object from Stripe.
Below is an example of how to use this hook:
add_action('asp_stripe_payment_completed', 'asp_after_txn_callback', 10 ,2); function asp_after_txn_callback ($post_data, $charge) { //Do stuff //$charge is the Stripe charge object. //print_r($post_data);//Lets see what info is in this array. }
Subscription Addon Related
asp_subscription_canceled
This hook is triggered after a subscription is cancelled.
add_action ('asp_subscription_canceled', 'my_sub_cancel_handler', 10, 2);
function my_sub_cancel_handler($sub_id, $event_data) {
ASP_Debug_Logger::log(json_encode($event_data));
}
$sub_id
is Stripe’s subscription ID.$event_data
is event data received from Stripe’s hook.
This code dumps the event data into plugin’s debug log (if it’s enabled). This way you would be able to test and see what kind of data is available.
asp_subscription_invoice_paid
This hook is triggered after a subscription payment is charged
add_action ('asp_subscription_invoice_paid', 'my_sub_paid', 10, 2);
function my_sub_paid($sub_post_id, $data) {
ASP_Debug_Logger::log(json_encode($data));
}
$sub_post_id
is the post ID of the subscription.$data
is event data received from Stripe’s hook.
This code dumps the event data into plugin’s debug log (if it’s enabled). This way you would be able to test and see what kind of data is available.
Miscellaneous
asp_clear_external_caches
This hook executes when plugin needs external caching plugins to clear page cache. Currently only fired after plugin settings update.