Skip to content

Commit

Permalink
Fix requests to comply with the specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovit committed Feb 17, 2016
1 parent 47d047e commit 0fba23a
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions src/Borica/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ public function register($protocolVersion = '2.0', $oneTimeTicket = null)
* Check the status of a transaction with Borica.
*
* @param string $protocolVersion
* @param string $oneTimeTicket
* @return string
*/
public function status($protocolVersion = '2.0', $oneTimeTicket = null)
public function status($protocolVersion = '2.0')
{
$message = self::REGISTER_TRANSACTION;
$message .= $this->getDate();
Expand All @@ -94,10 +93,6 @@ public function status($protocolVersion = '2.0', $oneTimeTicket = null)
$message .= $this->getCurrency();
}

if ($protocolVersion == '2.0') {
$message .= str_pad($oneTimeTicket, 6);
}

$message = $this->signMessage($message);

return "{$this->getGatewayURL()}transactionStatusReport?eBorica=" . urlencode(base64_encode($message));
Expand All @@ -107,10 +102,9 @@ public function status($protocolVersion = '2.0', $oneTimeTicket = null)
* Register a delayed request.
*
* @param string $protocolVersion
* @param string $oneTimeTicket
* @return string
*/
public function registerDelayedRequest($protocolVersion = '2.0', $oneTimeTicket = null)
public function registerDelayedRequest($protocolVersion = '2.0')
{
$message = self::DELAYED_AUTHORIZATION_REQUEST;
$message .= $this->getDate();
Expand All @@ -125,10 +119,6 @@ public function registerDelayedRequest($protocolVersion = '2.0', $oneTimeTicket
$message .= $this->getCurrency();
}

if ($protocolVersion == '2.0') {
$message .= str_pad($oneTimeTicket, 6);
}

$message = $this->signMessage($message);

return "{$this->getGatewayURL()}manageTransaction?eBorica=" . urlencode(base64_encode($message));
Expand All @@ -137,13 +127,23 @@ public function registerDelayedRequest($protocolVersion = '2.0', $oneTimeTicket
/**
* Complete an already registered transaction.
*
* @param string $protocolVersion
* @return string
*/
public function completeDelayedRequest()
public function completeDelayedRequest($protocolVersion = '2.0')
{
$message = self::DELAYED_AUTHORIZATION_COMPLETE;
$message .= $this->getOrderID();
$message .= $this->getDate();
$message .= $this->getAmount();
$message .= $this->getTerminalID();
$message .= $this->getOrderID();
$message .= $this->getDescription();
$message .= $this->getLanguage();
$message .= $this->verifyProtocolVersion($protocolVersion) ? $protocolVersion : '1.0';

if ($protocolVersion != '1.0') {
$message .= $this->getCurrency();
}

$message = $this->signMessage($message);

Expand All @@ -153,13 +153,23 @@ public function completeDelayedRequest()
/**
* Cancel already registered delayed request.
*
* @param string $protocolVersion
* @return string
*/
public function reverseDelayedRequest()
public function reverseDelayedRequest($protocolVersion = '2.0')
{
$message = self::DELAYED_AUTHORIZATION_REVERSAL;
$message .= $this->getOrderID();
$message .= $this->getDate();
$message .= $this->getAmount();
$message .= $this->getTerminalID();
$message .= $this->getOrderID();
$message .= $this->getDescription();
$message .= $this->getLanguage();
$message .= $this->verifyProtocolVersion($protocolVersion) ? $protocolVersion : '1.0';

if ($protocolVersion != '1.0') {
$message .= $this->getCurrency();
}

$message = $this->signMessage($message);

Expand All @@ -169,13 +179,19 @@ public function reverseDelayedRequest()
/**
* Reverse a payment.
*
* @param string $protocolVersion
* @return string
*/
public function reverse()
public function reverse($protocolVersion = '2.0')
{
$message = self::REVERSAL;
$message .= $this->getOrderID();
$message .= $this->getDate();
$message .= $this->getAmount();
$message .= $this->getTerminalID();
$message .= $this->getOrderID();
$message .= $this->getDescription();
$message .= $this->getLanguage();
$message .= $this->verifyProtocolVersion($protocolVersion) ? $protocolVersion : '1.0';

$message = $this->signMessage($message);

Expand Down

0 comments on commit 0fba23a

Please sign in to comment.