| 1 |
<?php |
| 2 |
|
| 3 |
namespace Stripe\Exception; |
| 4 |
|
| 5 |
/** |
| 6 |
* SignatureVerificationException is thrown when the signature verification for |
| 7 |
* a webhook fails. |
| 8 |
*/ |
| 9 |
class SignatureVerificationException extends \Exception implements ExceptionInterface |
| 10 |
{ |
| 11 |
protected $httpBody; |
| 12 |
protected $sigHeader; |
| 13 |
|
| 14 |
/** |
| 15 |
* Creates a new SignatureVerificationException exception. |
| 16 |
* |
| 17 |
* @param string $message the exception message |
| 18 |
* @param null|string $httpBody the HTTP body as a string |
| 19 |
* @param null|string $sigHeader the `Stripe-Signature` HTTP header |
| 20 |
* |
| 21 |
* @return SignatureVerificationException |
| 22 |
*/ |
| 23 |
public static function factory( |
| 24 |
$message, |
| 25 |
$httpBody = null, |
| 26 |
$sigHeader = null |
| 27 |
) { |
| 28 |
$instance = new static($message); |
| 29 |
$instance->setHttpBody($httpBody); |
| 30 |
$instance->setSigHeader($sigHeader); |
| 31 |
|
| 32 |
return $instance; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Gets the HTTP body as a string. |
| 37 |
* |
| 38 |
* @return null|string |
| 39 |
*/ |
| 40 |
public function getHttpBody() |
| 41 |
{ |
| 42 |
return $this->httpBody; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Sets the HTTP body as a string. |
| 47 |
* |
| 48 |
* @param null|string $httpBody |
| 49 |
*/ |
| 50 |
public function setHttpBody($httpBody) |
| 51 |
{ |
| 52 |
$this->httpBody = $httpBody; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Gets the `Stripe-Signature` HTTP header. |
| 57 |
* |
| 58 |
* @return null|string |
| 59 |
*/ |
| 60 |
public function getSigHeader() |
| 61 |
{ |
| 62 |
return $this->sigHeader; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Sets the `Stripe-Signature` HTTP header. |
| 67 |
* |
| 68 |
* @param null|string $sigHeader |
| 69 |
*/ |
| 70 |
public function setSigHeader($sigHeader) |
| 71 |
{ |
| 72 |
$this->sigHeader = $sigHeader; |
| 73 |
} |
| 74 |
} |
| 75 |
|