/** * Handle Stripe webhooks */ function stripe_webhook_handler($environment) { $body = get_post_data(); $event_json = json_decode($body); $event_id = $event_json->id; $gateway = new StripeClient($environment); $event = $gateway->getEvent($event_id); if (!$event) { return array('success' => false, 'message' => 'Stripe Event for this webhook was not found'); } $ia = elgg_set_ignore_access(true); $ha = access_get_show_hidden_status(); access_show_hidden_entities(true); $result = elgg_trigger_plugin_hook_handler($event->type, 'stripe.events', array('environment' => $environment, 'event' => $event), array('success' => true)); access_show_hidden_entities($ha); elgg_set_ignore_access($ia); return $result; }