Extending the plugin by action hooks

Introduction

You can extend WP Full Stripe without modifying the plugin code.

When certain events occur, the plugin fires WordPress actions that you can hook into.

Plugin actions

Action Fired when? / Which form? Parameters
fullstripe_before_payment_charge Before payment; Inline one-time payment forms $amount – Charge amount in the smallest unit for the currency
fullstripe_after_payment_charge After payment; Inline one-time payment forms $charge – The Stripe charge object as a result of the payment
fullstripe_before_checkout_payment_charge Before payment; Popup one-time payment forms $amount – Charge amount in the smallest unit for the currency
fullstripe_after_checkout_payment_charge After payment; Popup one-time payment forms $charge – The Stripe charge object as a result of the payment
fullstripe_before_subscription_charge Before payment; Inline subscription forms $stripePlanId – The id of the Stripe plan to be charged
fullstripe_after_subscription_charge After payment; Inline subscription forms $stripeCustomer – The Stripe customer object for which the subscription was charged
$additionalData – A associative array with the following indexes:
  ‘action_name’ : ‘fullstripe_after_subscription_charge’
  ‘customer’ : The Stripe customer object
  ‘macros’ : Placeholder token names, including custom fields
  ‘macroValues’ : Placeholder token names, see this knowledge base article for the details.
fullstripe_before_checkout_subscription_charge Before payment; Popup subscription forms $stripePlanId – The id of the Stripe plan to be charged
fullstripe_after_checkout_subscription_charge After payment; Popup subscription forms $stripeCustomer – The Stripe customer object for which the subscription was charged
$additionalData – A associative array with the following indexes:
  ‘action_name’ : ‘fullstripe_after_checkout_subscription_charge’
  ‘customer’ : The Stripe customer object
  ‘macros’ : Placeholder token names, including custom fields
  ‘macroValues’ : Placeholder token names, see this knowledge base article for the details.
fullstripe_before_card_capture Before saving card; Inline and popup forms $formName – Name of the form to be processed
fullstripe_after_card_capture After saving card; Inline and popup forms $stripeCustomer – The Stripe customer object created
fullstripe_setup_db After database updates
fullstripe_load_css_action After all plugin css files are enqueued
fullstripe_load_js_action After all plugin javascript files are enqueued

Important notes:

  • Charge amount in the smallest unit for the currency means: for $10.00 it’s 1000, for ¥10 it’s 10.

Example implementation

Let’s suppose that you created an inline one-time payment form, and embedded it into a page.

We can demonstrate how action hooks are called before and after payment by adding the following code to functions.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// WP Full Stripe action hook example  
//
// Add this code to the functions.php of your WordPress theme
 
function inline_form_before_charge($amount) {
    error_log("We are about to charge this amount: " . $amount);
}
 
add_action('fullstripe_before_payment_charge', 'inline_form_before_charge', 10, 1);
 
function inline_form_after_charge($charge) {
    error_log("This is the charge: " . print_r($charge, true));
}
 
add_action('fullstripe_after_payment_charge', 'inline_form_after_charge', 10, 1);

Make a test payment, and check out the error log of your webserver to see the log entries!

in For developers