@@ -18,6 +18,12 @@ final class HttpResponse
1818 const HTTP_BAD_REQUEST = 400 ;
1919 const HTTP_OK = 200 ;
2020
21+ /**
22+ * @var Transaction status
23+ */
24+ const TRANSACTION_CANCEL = 'cancel ' ;
25+ const TRANSACTION_SUCCESS = 'success ' ;
26+
2127 /**
2228 * @var string pattern
2329 */
@@ -102,7 +108,7 @@ public function paymentStatus()
102108 $ this ->updateTransaction ('success ' , $ response );
103109 }
104110
105- if (Arr:: has ( $ response, ' message ' ) ) {
111+ if ($ response[ ' transaction_status ' ] === self :: TRANSACTION_CANCEL ) {
106112 $ this ->updateTransaction ('cancel ' , $ response );
107113 }
108114
@@ -190,12 +196,12 @@ protected function response(): array
190196 $ body = $ this ->body ();
191197 if (Arr::has ($ body , 'result.code ' )) {
192198 $ 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 ]);
194200 if (preg_match (self ::SUCCESS_CODE_PATTERN , Arr::get ($ body , 'result.code ' ))
195201 || preg_match (self ::SUCCESS_MANUAL_REVIEW_CODE_PATTERN , Arr::get ($ body , 'result.code ' ))
196202 || Arr::get ($ body , 'result.code ' ) == '000.200.100 '
197203 ) {
198- return array_merge ($ result , ['status ' => self ::HTTP_OK ]);
204+ return array_merge ($ result , ['transaction_status ' => self :: TRANSACTION_SUCCESS , ' status ' => self ::HTTP_OK ]);
199205 }
200206
201207 return array_merge ($ result , ['status ' => self ::HTTP_UNPROCESSABLE_ENTITY ]);
0 commit comments