Skip to content

Commit

Permalink
refactor: accept notification
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed May 3, 2022
1 parent 0336ffb commit 77a2fb8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 37 deletions.
22 changes: 21 additions & 1 deletion src/Message/AcceptNotificationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Omnipay\Aerotow\Message;

class AcceptNotificationRequest extends CompletePurchaseRequest
use Omnipay\Common\Message\NotificationInterface;

class AcceptNotificationRequest extends CompletePurchaseRequest implements NotificationInterface
{
/**
* @param array $data
Expand All @@ -12,4 +14,22 @@ public function sendData($data)
{
return $this->response = new AcceptNotificationResponse($this, $data);
}

public function getTransactionStatus()
{
return $this->getNotificationResponse()->getTransactionStatus();
}

public function getMessage()
{
return $this->getNotificationResponse()->getMessage();
}

/**
* @return AcceptNotificationResponse
*/
protected function getNotificationResponse()
{
return ! $this->response ? $this->send() : $this->response;
}
}
8 changes: 7 additions & 1 deletion src/Message/AcceptNotificationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

namespace Omnipay\Aerotow\Message;

class AcceptNotificationResponse extends CompletePurchaseResponse
use Omnipay\Common\Message\NotificationInterface;

class AcceptNotificationResponse extends CompletePurchaseResponse implements NotificationInterface
{
public function getTransactionStatus()
{
return $this->isSuccessful() ? self::STATUS_COMPLETED : self::STATUS_FAILED;
}
}
21 changes: 1 addition & 20 deletions src/Message/CompletePurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
use Omnipay\Aerotow\Traits\HasOrderInfo;
use Omnipay\Common\Exception\InvalidRequestException;
use Omnipay\Common\Message\AbstractRequest;
use Omnipay\Common\Message\NotificationInterface;

class CompletePurchaseRequest extends AbstractRequest implements NotificationInterface
class CompletePurchaseRequest extends AbstractRequest
{
use HasMerchant;
use HasOrderInfo;
Expand Down Expand Up @@ -52,24 +51,6 @@ public function sendData($data)
return $this->response = new CompletePurchaseResponse($this, $data);
}

public function getTransactionStatus()
{
return $this->getNotification()->getTransactionStatus();
}

public function getMessage()
{
return $this->getNotification()->getMessage();
}

/**
* @return NotificationInterface
*/
protected function getNotification()
{
return ! $this->response ? $this->send() : $this->response;
}

/**
* @return array
* @throws InvalidRequestException
Expand Down
8 changes: 1 addition & 7 deletions src/Message/CompletePurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace Omnipay\Aerotow\Message;

use Omnipay\Common\Message\AbstractResponse;
use Omnipay\Common\Message\NotificationInterface;

class CompletePurchaseResponse extends AbstractResponse implements NotificationInterface
class CompletePurchaseResponse extends AbstractResponse
{
/**
* Is the response successful?
Expand Down Expand Up @@ -36,9 +35,4 @@ public function getTransactionId()
{
return $this->data['Ordernum'];
}

public function getTransactionStatus()
{
return $this->isSuccessful() ? self::STATUS_COMPLETED : self::STATUS_FAILED;
}
}
16 changes: 8 additions & 8 deletions src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ public function sendData($data)
return $this->response = new PurchaseResponse($this, $data);
}

/**
* @return bool
*/
public function isAtm()
{
return $this->getGatewayName() === 'Aerotow_ATM';
}

/**
* @return array
* @throws InvalidRequestException
Expand Down Expand Up @@ -197,12 +205,4 @@ private function getCvsData()
'Hour' => $this->getHour(),
]);
}

/**
* @return bool
*/
public function isAtm()
{
return $this->getGatewayName() === 'Aerotow_ATM';
}
}

0 comments on commit 77a2fb8

Please sign in to comment.