PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.3
Booktics – Appointment Booking Calendar for Service Businesses v1.0.3
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / trunk / vendor / stripe / stripe-php / lib / Webhook.php

Webhook.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.3, at trunk/vendor/stripe/stripe-php/lib/Webhook.php

43 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Stripe;
4
5 abstract class Webhook
6 {
7 const DEFAULT_TOLERANCE = 300;
8
9 /**
10 * Returns an Event instance using the provided JSON payload. Throws an
11 * Exception\UnexpectedValueException if the payload is not valid JSON, and
12 * an Exception\SignatureVerificationException if the signature
13 * verification fails for any reason.
14 *
15 * @param string $payload the payload sent by Stripe
16 * @param string $sigHeader the contents of the signature header sent by
17 * Stripe
18 * @param string $secret secret used to generate the signature
19 * @param int $tolerance maximum difference allowed between the header's
20 * timestamp and the current time
21 *
22 * @throws Exception\UnexpectedValueException if the payload is not valid JSON,
23 * @throws Exception\SignatureVerificationException if the verification fails
24 *
25 * @return Event the Event instance
26 */
27 public static function constructEvent($payload, $sigHeader, $secret, $tolerance = self::DEFAULT_TOLERANCE)
28 {
29 WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance);
30
31 $data = \json_decode($payload, true);
32 $jsonError = \json_last_error();
33 if (null === $data && \JSON_ERROR_NONE !== $jsonError) {
34 $msg = "Invalid payload: {$payload} "
35 . "(json_last_error() was {$jsonError})";
36
37 throw new Exception\UnexpectedValueException($msg);
38 }
39
40 return Event::constructFrom($data);
41 }
42 }
43