Skip to content

Commit

Permalink
fix(sdk): fix unable to access undefined property on stdClass
Browse files Browse the repository at this point in the history
  • Loading branch information
faso-dev committed Dec 23, 2021
1 parent 59507b4 commit ac4f640
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Http/XMLHttp.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function request(string $url, array $headers, mixed $body, bool $w
return [
$errno,
$error,
TransactionResponse::fromXMLResponse(XMLResponse::parse("<response>$response</response>"))
XMLResponse::parse("<response>$response</response>")
];
}

Expand Down
10 changes: 8 additions & 2 deletions src/Sdk/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ public function on(callable $success, callable $error): mixed
/**
* @var $errno int
* @var $error string
* @var $response TransactionResponse
* @var $response mixed
*/
[$errno, $errorMessage, $response] = $this->processRequest();
if ($errno > 0) {
return $error($errorMessage, $errno);
}

$response = TransactionResponse::fromXMLResponse($response);

if ($response->getStatus() !== 200) {
return $error($response->getMessage(), $response->getStatus());
}
Expand All @@ -58,12 +61,15 @@ public function handleTransaction(): TransactionResponse
/**
* @var $errno int
* @var $errorMessage string
* @var $response TransactionResponse
* @var $response mixed
*/
[$errno, $errorMessage, $response] = $this->processRequest();
if ($errno > 0) {
throw new TransactionException($errorMessage, $errno);
}

$response = TransactionResponse::fromXMLResponse($response);

if ($response->getStatus() !== 200) {
throw new TransactionException($response->getMessage(), $response->getStatus());
}
Expand Down

0 comments on commit ac4f640

Please sign in to comment.