|
1
|
|
|
<?php namespace Arcanedev\Stripe\Exceptions; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class CardException |
|
5
|
|
|
* |
|
6
|
|
|
* @package Arcanedev\Stripe\Exceptions |
|
7
|
|
|
* @author ARCANEDEV <[email protected]> |
|
8
|
|
|
*/ |
|
9
|
|
|
class CardException extends StripeException |
|
10
|
|
|
{ |
|
11
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
12
|
|
|
| Properties |
|
13
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $declineCode; |
|
16
|
|
|
|
|
17
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
18
|
|
|
| Constructor |
|
19
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
20
|
|
|
*/ |
|
21
|
|
|
/** |
|
22
|
|
|
* CardException constructor. |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $message |
|
25
|
|
|
* @param int $code |
|
26
|
|
|
* @param string|null $type |
|
27
|
|
|
* @param string|null $stripeCode |
|
28
|
|
|
* @param string|null $httpBody |
|
29
|
|
|
* @param array $jsonBody |
|
30
|
|
|
* @param array $params |
|
31
|
|
|
* @param array $headers |
|
32
|
|
|
*/ |
|
33
|
12 |
|
public function __construct( |
|
34
|
|
|
$message, |
|
35
|
|
|
$code, |
|
36
|
|
|
$type, |
|
37
|
|
|
$stripeCode, |
|
38
|
|
|
$httpBody, |
|
39
|
|
|
array $jsonBody, |
|
40
|
|
|
array $params = [], |
|
41
|
|
|
array $headers = [] |
|
42
|
|
|
) { |
|
43
|
12 |
|
parent::__construct( |
|
44
|
12 |
|
$message, $code, $type, $stripeCode, $httpBody, $jsonBody, $params, $headers |
|
45
|
|
|
); |
|
46
|
|
|
|
|
47
|
|
|
// This one is not like the others because it was added later and we're trying to do our best |
|
48
|
|
|
// not to change the public interface of this class' constructor. |
|
49
|
|
|
// We should consider changing its implementation on the next major version bump of this library. |
|
50
|
12 |
|
$this->setDeclineCode( |
|
51
|
12 |
|
isset($jsonBody['error']['decline_code']) ? $jsonBody['error']['decline_code'] : null |
|
52
|
|
|
); |
|
53
|
12 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
56
|
|
|
| Getters & Setters |
|
57
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
58
|
|
|
*/ |
|
59
|
4 |
|
public function getDeclineCode() |
|
60
|
|
|
{ |
|
61
|
4 |
|
return $this->declineCode; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
12 |
|
private function setDeclineCode($declineCode) |
|
65
|
|
|
{ |
|
66
|
12 |
|
$this->declineCode = $declineCode; |
|
67
|
|
|
|
|
68
|
12 |
|
return $this; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|