Receiving Stripe Webhooks on a wordpress website

I recently had the same problem and pippins stripe integration plugin seemed to answer it but it had a lot of extra code I did not need so I removed it and made a concise version just for the webhook integration: WPStripeWebhook. README is self explanatory. Basically make changes to includes/stripe_listener.php for your events. Also attaching readme here as per stackoverflow guidelines:

Usage:

  1. Copy the complete folder WPStripeWebhook in wp-content/plugins. Go
    to website admin page.

  2. Activate the WP Stripe webhook plugin for
    plugins section.

  3. After this Settings will start showing Stripe
    webhook settings section. Click on it. In the page fill the stripe
    keys and check test mode option if you want to test the plugin.
  4. In WPStripeWebhook/includes/stripe_listener.php, make changes for your
    event type and email or whatever you want to do in response to
    an event. It currently sends out an email.

Important notes and suggestions
For live mode, add stripe webhook endpoint (stripe account -> settings -> account settings -> webhook) like this

htps://yourdomain.com?webhook-listener=stripe

For testing locally on your machine, you can use Ultrahook. Its awesome! Set up your keys and username and start ultrahook on your machine using:

ultrahook -k your_ultrahook_key stripe 8888

Add a webhook endpoint url in your stripe account similar to this:

htp://stripe.your_ultrahook_username.ultrahook.com/your_wp_website_folder_name/stripe-listener.php?webhook-listener=stripe

And it should start working for you. Also, you might see 404 in ultrahook console. Just ignore it. I would suggest setting up debugging too. It really helps. For debugging, add these to your wp_config.php

define('WP_DEBUG', true); 
define( 'WP_DEBUG_LOG', true ); 
define('WP_DEBUG_DISPLAY', false ); 
@ini_set( 'display_errors', 0 ); 
define('SCRIPT_DEBUG', true );

After this, you should see a debug.log file in your wp-content folder and it will display errors and warnings and whatever you print using error_log()

Leave a Comment