-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from kynx/feature/additional-request-types
Implement all standard functions
- Loading branch information
Showing
11 changed files
with
413 additions
and
153 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 was deleted.
Oops, something went wrong.
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,28 @@ | ||
<?php | ||
namespace Omnipay\Dummy\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
use Omnipay\Common\Message\ResponseInterface; | ||
|
||
/** | ||
* Dummy UpdateCard/DeleteCard Request | ||
* | ||
* This is the request that will be called for any transaction which submits a cardReference. | ||
*/ | ||
class CardReferenceRequest extends AbstractRequest | ||
{ | ||
public function getData() | ||
{ | ||
$this->validate('cardReference'); | ||
return array('cardReference' => $this->getCardReference()); | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$data['reference'] = $this->getCardReference(); | ||
$data['success'] = 0 === substr($this->getCardReference(), -1, 1) % 2; | ||
$data['message'] = $data['success'] ? 'Success' : 'Failure'; | ||
|
||
return $this->response = new Response($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,32 @@ | ||
<?php | ||
namespace Omnipay\Dummy\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
use Omnipay\Common\Message\ResponseInterface; | ||
|
||
/** | ||
* Dummy Authorize/Purchase Request | ||
* | ||
* This is the request that will be called for any transaction which submits a credit card, | ||
* including `authorize` and `purchase` | ||
*/ | ||
class CreditCardRequest extends AbstractRequest | ||
{ | ||
public function getData() | ||
{ | ||
$this->validate('amount', 'card'); | ||
|
||
$this->getCard()->validate(); | ||
|
||
return array('amount' => $this->getAmount()); | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$data['reference'] = uniqid(); | ||
$data['success'] = 0 === substr($this->getCard()->getNumber(), -1, 1) % 2; | ||
$data['message'] = $data['success'] ? 'Success' : 'Failure'; | ||
|
||
return $this->response = new Response($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
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,28 @@ | ||
<?php | ||
namespace Omnipay\Dummy\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
use Omnipay\Common\Message\ResponseInterface; | ||
|
||
/** | ||
* Dummy Complete/Capture/Void/Refund Request | ||
* | ||
* This is the request that will be called for any transaction which submits a transactionReference. | ||
*/ | ||
class TransactionReferenceRequest extends AbstractRequest | ||
{ | ||
public function getData() | ||
{ | ||
$this->validate('transactionReference'); | ||
return array('transactionReference' => $this->getTransactionReference()); | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$data['reference'] = $this->getTransactionReference(); | ||
$data['success'] = strpos($this->getTransactionReference(), 'fail') !== false ? false : true; | ||
$data['message'] = $data['success'] ? 'Success' : 'Failure'; | ||
|
||
return $this->response = new Response($this, $data); | ||
} | ||
} |
Oops, something went wrong.