SignatureVerificationException.php 1.6 KB

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