CardException.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace Stripe\Exception;
  3. /**
  4. * CardException is thrown when a user enters a card that can't be charged for
  5. * some reason.
  6. */
  7. class CardException extends ApiErrorException
  8. {
  9. protected $declineCode;
  10. protected $stripeParam;
  11. /**
  12. * Creates a new CardException exception.
  13. *
  14. * @param string $message the exception message
  15. * @param null|int $httpStatus the HTTP status code
  16. * @param null|string $httpBody the HTTP body as a string
  17. * @param null|array $jsonBody the JSON deserialized body
  18. * @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array
  19. * @param null|string $stripeCode the Stripe error code
  20. * @param null|string $declineCode the decline code
  21. * @param null|string $stripeParam the parameter related to the error
  22. *
  23. * @return CardException
  24. */
  25. public static function factory(
  26. $message,
  27. $httpStatus = null,
  28. $httpBody = null,
  29. $jsonBody = null,
  30. $httpHeaders = null,
  31. $stripeCode = null,
  32. $declineCode = null,
  33. $stripeParam = null
  34. ) {
  35. $instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $stripeCode);
  36. $instance->setDeclineCode($declineCode);
  37. $instance->setStripeParam($stripeParam);
  38. return $instance;
  39. }
  40. /**
  41. * Gets the decline code.
  42. *
  43. * @return null|string
  44. */
  45. public function getDeclineCode()
  46. {
  47. return $this->declineCode;
  48. }
  49. /**
  50. * Sets the decline code.
  51. *
  52. * @param null|string $declineCode
  53. */
  54. public function setDeclineCode($declineCode)
  55. {
  56. $this->declineCode = $declineCode;
  57. }
  58. /**
  59. * Gets the parameter related to the error.
  60. *
  61. * @return null|string
  62. */
  63. public function getStripeParam()
  64. {
  65. return $this->stripeParam;
  66. }
  67. /**
  68. * Sets the parameter related to the error.
  69. *
  70. * @param null|string $stripeParam
  71. */
  72. public function setStripeParam($stripeParam)
  73. {
  74. $this->stripeParam = $stripeParam;
  75. }
  76. }