Skip to content

Commit 15b5cd3

Browse files
committed
Return error string during request_poll()
1 parent c1d5672 commit 15b5cd3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

hmrc-gateway.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function request_list($message_class) {
173173

174174
}
175175

176-
public function request_poll($request) {
176+
public function request_poll($request, $return_error = false) {
177177

178178
//--------------------------------------------------
179179
// Honour timeout
@@ -205,7 +205,15 @@ public function request_poll($request) {
205205

206206
if ($this->response_qualifier == 'error') {
207207

208-
exit_with_error('Error from gateway "' . $this->response_object->Body->ErrorResponse->Error->Text . '"', $this->response_debug);
208+
if ($return_error && isset($this->response_object->Body->ErrorResponse->Error->Text) && isset($this->response_object->Header->MessageDetails->CorrelationID)) {
209+
210+
return strval($this->response_object->Body->ErrorResponse->Error->Text) . ' (' . strval($this->response_object->Header->MessageDetails->CorrelationID) . ')';
211+
212+
} else {
213+
214+
exit_with_error('Error from gateway "' . $this->response_object->Body->ErrorResponse->Error->Text . '"', $this->response_debug);
215+
216+
}
209217

210218
} else if ($this->response_qualifier == 'acknowledgement') {
211219

0 commit comments

Comments
 (0)