-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
414 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidRequestException; | ||
use Omnipay\Common\Exception\InvalidResponseException; | ||
use Omnipay\Common\Message\NotificationInterface; | ||
use Omnipay\Gomypay\Traits\HasGomypay; | ||
|
||
class AcceptNotificationRequest extends AbstractRequest implements NotificationInterface | ||
{ | ||
use HasGomypay; | ||
|
||
public function getData() | ||
{ | ||
return $this->httpRequest->request->all(); | ||
} | ||
|
||
/** | ||
* @throws InvalidRequestException | ||
* @throws InvalidResponseException | ||
*/ | ||
public function sendData($data) | ||
{ | ||
$data = array_merge($data, ['Amount' => (int) $this->getAmount()]); | ||
|
||
if (! hash_equals($this->makeHash($data), $data['str_check'])) { | ||
throw new InvalidResponseException('Invalid hash'); | ||
} | ||
|
||
return $this->response = new AcceptNotificationResponse($this, $data); | ||
} | ||
|
||
public function getTransactionId() | ||
{ | ||
return $this->getNotificationResponse()->getTransactionId(); | ||
} | ||
|
||
public function getTransactionReference() | ||
{ | ||
return $this->getNotificationResponse()->getTransactionReference(); | ||
} | ||
|
||
public function getTransactionStatus() | ||
{ | ||
return $this->getNotificationResponse()->getTransactionStatus(); | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return $this->getNotificationResponse()->getMessage(); | ||
} | ||
|
||
private function getNotificationResponse() | ||
{ | ||
return ! $this->response ? $this->send() : $this->response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
use Omnipay\Common\Message\NotificationInterface; | ||
|
||
class AcceptNotificationResponse extends CompletePurchaseResponse implements NotificationInterface | ||
{ | ||
public function getTransactionStatus() | ||
{ | ||
return $this->isSuccessful() ? self::STATUS_COMPLETED : self::STATUS_FAILED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidRequestException; | ||
use Omnipay\Common\Exception\InvalidResponseException; | ||
use Omnipay\Gomypay\Traits\HasGomypay; | ||
|
||
class CompletePurchaseRequest extends AbstractRequest | ||
{ | ||
use HasGomypay; | ||
|
||
public function getData() | ||
{ | ||
return $this->httpRequest->query->all(); | ||
} | ||
|
||
/** | ||
* @throws InvalidRequestException | ||
* @throws InvalidResponseException | ||
*/ | ||
public function sendData($data) | ||
{ | ||
$data = array_merge($data, ['Amount' => (int) $this->getAmount()]); | ||
|
||
if (! hash_equals($this->makeHash($data), $data['str_check'])) { | ||
throw new InvalidResponseException('Invalid hash'); | ||
} | ||
|
||
return $this->response = new CompletePurchaseResponse($this, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Omnipay\Gomypay\Message; | ||
|
||
class CompletePurchaseResponse extends AbstractResponse | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return (int) $this->getCode() === 1; | ||
} | ||
|
||
public function getCode() | ||
{ | ||
return $this->data['result']; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return $this->data['ret_msg']; | ||
} | ||
|
||
public function getTransactionId() | ||
{ | ||
return $this->data['e_orderno']; | ||
} | ||
|
||
public function getTransactionReference() | ||
{ | ||
return $this->data['OrderID']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.