Skip to content

Commit

Permalink
Fix setting appended on responses
Browse files Browse the repository at this point in the history
  • Loading branch information
prinx committed Apr 27, 2021
1 parent 41907eb commit bf0ab36
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Payswitch/MobileMoneyStatusCheckerResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function on($condition, $callback)

foreach ($this->responses['data'] as $transactionId => $response) {
$this->setCurrentResponseData($response->getResponse());
$this->setCurrentAppendedData($transactionId);
$this->setCurrentAppendedData($transactionId, $response);

if ($isCustomCondition) {
$matchesCondition = $this->{'is'.ucfirst($condition)}();
Expand Down Expand Up @@ -389,13 +389,10 @@ public function populateCustomCurrentResponseDataNames()
return $this->currentResponse;
}

public function setCurrentAppendedData($transactionId)
public function setCurrentAppendedData($transactionId, $response)
{
if (
$this->currentResponse instanceof MobileMoneyStatus &&
array_key_exists($transactionId, $this->appended)
) {
$this->currentResponse->setAppended($this->appended[$transactionId]);
if (array_key_exists($transactionId, $this->appended)) {
$response->setAppended($this->appended[$transactionId]);
}
}

Expand Down Expand Up @@ -432,7 +429,7 @@ public function getResponses()
*/
public function append(array $toAppend)
{
$this->appended = array_merge($this->appended, $toAppend);
$this->appended = array_replace($this->appended, $toAppend);

return $this;
}
Expand Down

0 comments on commit bf0ab36

Please sign in to comment.