Skip to content

Instantly share code, notes, and snippets.

@forkbombe
Last active October 3, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forkbombe/1a078a165eb9ecd5f2b91b659745930d to your computer and use it in GitHub Desktop.
Save forkbombe/1a078a165eb9ecd5f2b91b659745930d to your computer and use it in GitHub Desktop.
Create WordPress action hooks for Stripe Hooks
<?php
class Stripe_Hook {
public function __construct() {
$this->listener();
}
public function listener() {
if (isset($_GET['wps-listener']) && $_GET['wps-listener'] == 'stripe') {
$input = @file_get_contents("php://input");
$json = json_decode($input);
do_action('stripe_' . $json->type, $json->data->object);
return false;
}
}
}
add_action('init', function() {
new Stripe_Hook();
});
<?php
// Example do something with hook
add_action('stripe_account.external_account.created', function($data) {
ob_start();
print_r($data);
$contents = ob_get_contents();
ob_end_clean();
wp_mail('email@email.com', 'Test', $contents);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment