Skip to content

Commit

Permalink
Merge pull request #1 from super11-barion/master
Browse files Browse the repository at this point in the history
Bugfix
  • Loading branch information
kiuka authored Apr 17, 2018
2 parents b95039b + 33a350d commit 18f4ea7
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function sendData($data)
\json_encode($data)
);

$httpResponse = (array) \json_decode($httpRequest->getBody()->getContents());
$httpResponse = (array)\json_decode($httpRequest->getBody()->getContents());
} catch (\Exception $e) {
$httpResponse = [
'error' => true,
Expand Down Expand Up @@ -312,7 +312,7 @@ public function setGuestCheckOut($value)
*/
public function getGuestCheckOut()
{
return $this->getParameter('guestCheckOut');
return $this->getParameter('guestCheckOut') ? 'true' : 'false';
}

/**
Expand Down Expand Up @@ -403,12 +403,24 @@ public function setRedirectUrl($value)
$this->setParameter('redirectUrl', $value);
}

protected function fixUrl($url, $defaultScheme = 'https')
{
if (!parse_url($url, PHP_URL_SCHEME)) {
$url = $defaultScheme . '://' . preg_replace('%^:?//%', '', $url);
}

return $url;
}

/**
* @return mixed
*/
public function getRedirectUrl()
{
return $this->getParameter('redirectUrl');
$redirectUrl = $this->getParameter('redirectUrl');
$redirectUrl = $this->fixUrl($redirectUrl);

return $redirectUrl;
}

/**
Expand All @@ -424,7 +436,10 @@ public function setCallbackUrl($value)
*/
public function getCallbackUrl()
{
return $this->getParameter('callbackUrl');
$callbackUrl = $this->getParameter('callbackUrl');
$callbackUrl = $this->fixUrl($callbackUrl);

return $callbackUrl;
}

/**
Expand Down Expand Up @@ -498,4 +513,4 @@ public function setNegativeAmountAllowed($negativeAmountAllowed)
{
$this->negativeAmountAllowed = $negativeAmountAllowed;
}
}
}

0 comments on commit 18f4ea7

Please sign in to comment.