-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebhook.php
More file actions
31 lines (24 loc) · 809 Bytes
/
Copy pathwebhook.php
File metadata and controls
31 lines (24 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/*
* Stripe PHP Webhook
* Respond to Stripe webhooks like jQuery events --- simple and elegant.
*
* Copyright (C) 2014 Jonathan Hogervorst. All rights reserved.
* This code is licensed under MIT license. See LICENSE for details.
*/
// Load Stripe and Stripe Webhook
require_once 'path/to/stripe-php/lib/Stripe.php';
require_once 'lib/StripeWebhook.php';
// Configure Stripe with your API key
Stripe::setApiKey('d8e8fca2dc0f896fd7cb4cb0031ba249');
// Load event handlers
require_once 'handlers.php';
// Or load event handlers from multiple files in one folder
foreach (glob('handlers/*.php') as $file) {
require_once $file;
}
// Get the Stripe event
$body = file_get_contents('php://input');
$event = json_decode($body);
// Execute the appropriate handlers for the event
S::trigger($event);