@@ -18,6 +18,12 @@ final class HttpResponse
18
18
const HTTP_BAD_REQUEST = 400 ;
19
19
const HTTP_OK = 200 ;
20
20
21
+ /**
22
+ * @var Transaction status
23
+ */
24
+ const TRANSACTION_CANCEL = 'cancel ' ;
25
+ const TRANSACTION_SUCCESS = 'success ' ;
26
+
21
27
/**
22
28
* @var string pattern
23
29
*/
@@ -102,7 +108,7 @@ public function paymentStatus()
102
108
$ this ->updateTransaction ('success ' , $ response );
103
109
}
104
110
105
- if (Arr:: has ( $ response, ' message ' ) ) {
111
+ if ($ response[ ' transaction_status ' ] === self :: TRANSACTION_CANCEL ) {
106
112
$ this ->updateTransaction ('cancel ' , $ response );
107
113
}
108
114
@@ -190,12 +196,12 @@ protected function response(): array
190
196
$ body = $ this ->body ();
191
197
if (Arr::has ($ body , 'result.code ' )) {
192
198
$ message = Arr::get ($ body , 'result.description ' );
193
- $ result = array_merge ($ body , ['message ' => $ message ]);
199
+ $ result = array_merge ($ body , ['message ' => $ message, ' transaction_status ' => self :: TRANSACTION_CANCEL ]);
194
200
if (preg_match (self ::SUCCESS_CODE_PATTERN , Arr::get ($ body , 'result.code ' ))
195
201
|| preg_match (self ::SUCCESS_MANUAL_REVIEW_CODE_PATTERN , Arr::get ($ body , 'result.code ' ))
196
202
|| Arr::get ($ body , 'result.code ' ) == '000.200.100 '
197
203
) {
198
- return array_merge ($ result , ['status ' => self ::HTTP_OK ]);
204
+ return array_merge ($ result , ['transaction_status ' => self :: TRANSACTION_SUCCESS , ' status ' => self ::HTTP_OK ]);
199
205
}
200
206
201
207
return array_merge ($ result , ['status ' => self ::HTTP_UNPROCESSABLE_ENTITY ]);
0 commit comments