-
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
10 changed files
with
613 additions
and
351 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
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,73 @@ | ||
<?php | ||
|
||
namespace Omnipay\Wirecard\Message\Checkout\Page; | ||
|
||
/** | ||
* Complete a Wirecard Checkout Page purchase transaction on the | ||
* user returning to the merchant shop. | ||
* Experimentally, this one class covers both the request and the response, | ||
* since not further requests back to the gateway are needed. | ||
* The advantage of doing this is that all the results needed are in the | ||
* initial request object. A merchant site can still send() that message | ||
* and get the same message back. | ||
* It should be possible to extend this as the notification handler too. If | ||
* so, then the HasFingerprintTrait becomes redundant. | ||
*/ | ||
|
||
use Omnipay\Common\Message\ResponseInterface as OmnipayResponseInterface; | ||
use Omnipay\Wirecard\Message\Checkout\AbstractRequest; | ||
use Omnipay\Wirecard\Message\AbstractResponse; | ||
use Omnipay\Wirecard\Message\HasDataTrait; | ||
|
||
class CompleteRequest extends AbstractRequest | ||
{ | ||
use HasDataTrait; | ||
|
||
/** | ||
* @inheric | ||
*/ | ||
public function getData() | ||
{ | ||
return $this->httpRequest->request->all(); | ||
} | ||
|
||
/** | ||
* Create a new Response message given the raw data in the response. | ||
*/ | ||
protected function createResponse($data) | ||
{ | ||
$this->validate('secret', 'transactionId'); | ||
|
||
$this->response = new CompleteResponse($this, $this->getData()); | ||
|
||
// Set the original transactionId and the secret, both for | ||
// validating the response. | ||
|
||
$this->response->setOriginalTransactionId($this->getTransactionId()); | ||
$this->response->setSecret($this->getSecret()); | ||
|
||
return $this->response; | ||
} | ||
|
||
/** | ||
* The secret for hashing. | ||
*/ | ||
public function setSecret($value) | ||
{ | ||
return $this->setParameter('secret', $value); | ||
} | ||
|
||
public function getSecret() | ||
{ | ||
return $this->getParameter('secret'); | ||
} | ||
|
||
/** | ||
* The transaction ID supplied by the gateway, in case the | ||
* application needs to look it up before calling send(). | ||
*/ | ||
public function getOriginalTransactionId() | ||
{ | ||
return $this->getDataValue(AbstractRequest::CUSTOM_FIELD_NAME_TRANSACTION_ID); | ||
} | ||
} |
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,82 @@ | ||
<?php | ||
|
||
namespace Omnipay\Wirecard\Message\Checkout\Page; | ||
|
||
/** | ||
* Complete a Wirecard Checkout Page purchase transaction on the | ||
* user returning to the merchant shop. | ||
* Experimentally, this one class covers both the request and the response, | ||
* since not further requests back to the gateway are needed. | ||
* The advantage of doing this is that all the results needed are in the | ||
* initial request object. A merchant site can still send() that message | ||
* and get the same message back. | ||
* It should be possible to extend this as the notification handler too. If | ||
* so, then the HasFingerprintTrait becomes redundant. | ||
*/ | ||
|
||
use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse; | ||
use Omnipay\Wirecard\Message\Checkout\AbstractRequest; | ||
use Omnipay\Wirecard\Message\AbstractResponse; | ||
use Omnipay\Wirecard\Message\HasDataTrait; | ||
use Omnipay\Wirecard\Message\HandlesNotificationTrait; | ||
|
||
class CompleteResponse extends OmnipayAbstractResponse | ||
{ | ||
use HasDataTrait; | ||
use HandlesNotificationTrait; | ||
|
||
protected $transactionIdCheckEnabled = true; | ||
|
||
protected $originalTransactionId; | ||
protected $secret; | ||
|
||
public function isRedirect() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* The secret for hashing. | ||
*/ | ||
public function setSecret($value) | ||
{ | ||
return $this->secret = $value; | ||
} | ||
|
||
public function getSecret() | ||
{ | ||
return $this->secret; | ||
} | ||
|
||
/** | ||
* The original transactionId that we are expecting to get back. | ||
*/ | ||
public function setOriginalTransactionId($value) | ||
{ | ||
$this->originalTransactionId = $value; | ||
return $this; | ||
} | ||
|
||
public function getOriginalTransactionId() | ||
{ | ||
return $this->originalTransactionId; | ||
} | ||
|
||
/** | ||
* We put the transaction ID into a custom field, which will be passed | ||
* through by the gateway to the notification data. | ||
*/ | ||
public function getTransactionId() | ||
{ | ||
return $this->getDataValue(AbstractRequest::CUSTOM_FIELD_NAME_TRANSACTION_ID); | ||
} | ||
|
||
/** | ||
* @inherit | ||
*/ | ||
public function isExpectedTransactionId() | ||
{ | ||
return $this->getTransactionId() | ||
&& $this->getTransactionId() === $this->getOriginalTransactionId(); | ||
} | ||
} |
Oops, something went wrong.