-
Notifications
You must be signed in to change notification settings - Fork 11
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 #4 from antonioperic/master
Adding capture option
- Loading branch information
Showing
15 changed files
with
524 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidResponseException; | ||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* Netaxept Annul Request | ||
* | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class AnnulRequest extends PurchaseRequest | ||
{ | ||
public function getData() | ||
{ | ||
$data = array(); | ||
$data['transactionAmount'] = $this->getAmountInteger(); | ||
$data['transactionId'] = $this->getTransactionId(); | ||
$data['merchantId'] = $this->getMerchantId(); | ||
$data['token'] = $this->getPassword(); | ||
$data['operation'] = 'ANNUL'; | ||
|
||
if (empty($data['transactionAmount']) || empty($data['transactionId'])) { | ||
throw new InvalidResponseException; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$url = $this->getEndpoint().'/Netaxept/Process.aspx?'; | ||
$httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); | ||
|
||
return $this->response = new Response($this, $httpResponse->xml()); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidResponseException; | ||
|
||
/** | ||
* Netaxept Capture Request | ||
* | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class CaptureRequest extends PurchaseRequest | ||
{ | ||
public function getData() | ||
{ | ||
$data = array(); | ||
$data['transactionAmount'] = $this->getAmountInteger(); | ||
$data['transactionId'] = $this->getTransactionId(); | ||
$data['merchantId'] = $this->getMerchantId(); | ||
$data['token'] = $this->getPassword(); | ||
$data['operation'] = 'CAPTURE'; | ||
|
||
if (empty($data['transactionAmount']) || empty($data['transactionId'])) { | ||
throw new InvalidResponseException; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$url = $this->getEndpoint().'/Netaxept/Process.aspx?'; | ||
$httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); | ||
|
||
return $this->response = new Response($this, $httpResponse->xml()); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Common\Exception\InvalidResponseException; | ||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* Netaxept Credit Request | ||
* | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class CreditRequest extends PurchaseRequest | ||
{ | ||
public function getData() | ||
{ | ||
$data = array(); | ||
$data['transactionAmount'] = $this->getAmountInteger(); | ||
$data['transactionId'] = $this->getTransactionId(); | ||
$data['merchantId'] = $this->getMerchantId(); | ||
$data['token'] = $this->getPassword(); | ||
$data['operation'] = 'CREDIT'; | ||
|
||
if (empty($data['transactionAmount']) || empty($data['transactionId'])) { | ||
throw new InvalidResponseException; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$url = $this->getEndpoint().'/Netaxept/Process.aspx?'; | ||
$httpResponse = $this->httpClient->get($url.http_build_query($data))->send(); | ||
|
||
return $this->response = new Response($this, $httpResponse->xml()); | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
/** | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class AnnulRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var \Symfony\Component\HttpFoundation\Request | ||
*/ | ||
private $httpRequest; | ||
|
||
/** | ||
* @var \Omnipay\Netaxept\Message\AnnulRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp() | ||
{ | ||
$client = $this->getHttpClient(); | ||
$this->httpRequest = $this->getHttpRequest(); | ||
|
||
$this->request = new AnnulRequest($client, $this->httpRequest); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionAmount() | ||
{ | ||
$this->httpRequest->query->set('transactionId', 'TRANS-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionId() | ||
{ | ||
$this->httpRequest->query->set('transactionAmount', 'ABC-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
/** | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class CaptureRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var \Symfony\Component\HttpFoundation\Request | ||
*/ | ||
private $httpRequest; | ||
|
||
/** | ||
* @var \Omnipay\Netaxept\Message\CaptureRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp() | ||
{ | ||
$client = $this->getHttpClient(); | ||
$this->httpRequest = $this->getHttpRequest(); | ||
|
||
$this->request = new CaptureRequest($client, $this->httpRequest); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionAmount() | ||
{ | ||
$this->httpRequest->query->set('transactionId', 'TRANS-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionId() | ||
{ | ||
$this->httpRequest->query->set('transactionAmount', 'ABC-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace Omnipay\Netaxept\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
/** | ||
* @author Antonio Peric-Mazar <antonio@locastic.com> | ||
*/ | ||
class CreditRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var \Symfony\Component\HttpFoundation\Request | ||
*/ | ||
private $httpRequest; | ||
|
||
/** | ||
* @var \Omnipay\Netaxept\Message\CreditRequest | ||
*/ | ||
private $request; | ||
|
||
public function setUp() | ||
{ | ||
$client = $this->getHttpClient(); | ||
$this->httpRequest = $this->getHttpRequest(); | ||
|
||
$this->request = new CreditRequest($client, $this->httpRequest); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionAmount() | ||
{ | ||
$this->httpRequest->query->set('transactionId', 'TRANS-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
|
||
/** | ||
* @expectedException \Omnipay\Common\Exception\InvalidResponseException | ||
*/ | ||
public function testGetDataThrowsExceptionWithoutTransactionId() | ||
{ | ||
$this->httpRequest->query->set('transactionAmount', 'ABC-123'); | ||
|
||
$this->request->getData(); | ||
} | ||
} |
Oops, something went wrong.