1 | <?php |
||
18 | class VippsException extends \Exception |
||
19 | { |
||
20 | /** |
||
21 | * Initiate code description array. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | static public $codes = [ |
||
26 | 01 => "Provided credentials doesn't match", |
||
27 | 21 => "Reference Order ID is not valid", |
||
28 | 22 => "Reference Order ID is not in valid state", |
||
29 | 31 => "Merchant is blocked because of {}", |
||
30 | 32 => "Receiving limit of merchant has exceeded", |
||
31 | 33 => "Number of payment requests has been exceeded", |
||
32 | 34 => "Unique constraint violation of the order id", |
||
33 | 35 => "Requested Order not found", |
||
34 | 36 => "Merchant agreement not signed", |
||
35 | 37 => "Merchant not available or deactivated or blocked", |
||
36 | 41 => "User don’t have a valid card", |
||
37 | 42 => "Refused by issuer bank", |
||
38 | 43 => "Refused by issuer bank because of invalid amount", |
||
39 | 44 => "Refused by issuer because of expired card", |
||
40 | 45 => "Reservation failed for some unknown reason", |
||
41 | 51 => "Can't cancel already captured order", |
||
42 | 52 => "Cancellation failed", |
||
43 | 53 => "Can’t cancel order which is not reserved yet", |
||
44 | 61 => "Captured amount exceeds the reserved amount ordered", |
||
45 | 62 => "Can't capture cancelled order", |
||
46 | 63 => "Capture failed for some unknown reason, please use Get Payment Details API to know the exact status", |
||
47 | 71 => "Cant refund more than captured amount", |
||
48 | 72 => "Cant refund for reserved order, use cancellation API for the", |
||
49 | 73 => "Can't refund on cancelled order", |
||
50 | 74 => "Refund failed during debit from merchant account", |
||
51 | 81 => "User Not registered with vipps", |
||
52 | 82 => "User App Version is not supported", |
||
53 | 91 => "Transaction is not allowed", |
||
54 | 92 => "Transaction already processed", |
||
55 | 98 => "Too many concurrent requests", |
||
56 | 99 => "Internal error", |
||
57 | ]; |
||
58 | |||
59 | /** |
||
60 | * Error group. |
||
61 | * |
||
62 | * @var null |
||
63 | */ |
||
64 | protected $errorGroup; |
||
65 | |||
66 | /** |
||
67 | * Error code. |
||
68 | * |
||
69 | * @var int |
||
70 | */ |
||
71 | protected $errorCode = 0; |
||
72 | |||
73 | /** |
||
74 | * Error message. |
||
75 | * |
||
76 | * @var null |
||
77 | */ |
||
78 | protected $errorMessage; |
||
79 | |||
80 | /** |
||
81 | * VippsException constructor. |
||
82 | * |
||
83 | * @param string $message |
||
84 | * @param int $code |
||
85 | * @param \Exception|null $previous |
||
86 | */ |
||
87 | public function __construct($message = '', $code = 0, \Exception $previous = null) |
||
96 | |||
97 | /** |
||
98 | * @return mixed |
||
99 | */ |
||
100 | public function getErrorCode() |
||
104 | |||
105 | /** |
||
106 | * @return mixed |
||
107 | */ |
||
108 | public function getErrorGroup() |
||
112 | |||
113 | /** |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public function getErrorMessage() |
||
120 | |||
121 | /** |
||
122 | * Create new Exception from Response. |
||
123 | * |
||
124 | * @param $response |
||
125 | * @return self|null |
||
126 | */ |
||
127 | public static function createFromResponse(ResponseInterface $response) |
||
145 | |||
146 | /** |
||
147 | * @param $code |
||
148 | * @return null |
||
149 | */ |
||
150 | public static function getErrorCodeDescription($code = 0) |
||
157 | } |
||
158 |