Last active
October 3, 2018 12:34
-
-
Save forkbombe/1a078a165eb9ecd5f2b91b659745930d to your computer and use it in GitHub Desktop.
Create WordPress action hooks for Stripe Hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 protected]', 'Test', $contents); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment