├── .gitignore
├── .travis.yml
├── tests
├── Mock
│ ├── PurchaseSuccess.txt
│ ├── AnnulFailure.txt
│ ├── CaptureFailure.txt
│ ├── CreditFailure.txt
│ ├── CompletePurchaseFailure.txt
│ ├── PurchaseFailure.txt
│ ├── CompletePurchaseSuccess.txt
│ ├── AnnulSuccess.txt
│ ├── CaptureSuccess.txt
│ └── CreditSuccess.txt
├── Message
│ ├── CompletePurchaseRequestTest.php
│ ├── AnnulRequestTest.php
│ ├── CreditRequestTest.php
│ ├── CaptureRequestTest.php
│ ├── PurchaseRequestTest.php
│ └── ResponseTest.php
└── GatewayTest.php
├── src
├── Message
│ ├── ErrorResponse.php
│ ├── CaptureRequest.php
│ ├── AnnulRequest.php
│ ├── CreditRequest.php
│ ├── CompletePurchaseRequest.php
│ ├── Response.php
│ └── PurchaseRequest.php
└── Gateway.php
├── CONTRIBUTING.md
├── phpunit.xml.dist
├── LICENSE
├── composer.json
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | composer.lock
3 | composer.phar
4 | phpunit.xml
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 5.6
5 | - 7.0
6 | - 7.1
7 | - 7.2
8 | - 7.3
9 |
10 | before_script:
11 | - composer install -n --dev --prefer-source
12 |
13 | script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
14 |
--------------------------------------------------------------------------------
/tests/Mock/PurchaseSuccess.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 15:55:07 GMT
8 | Content-Length: 228
9 |
10 |
11 |
12 | f3d94dd5c0f743a788fc943402757c58
13 |
14 |
--------------------------------------------------------------------------------
/tests/Mock/AnnulFailure.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:55:41 GMT
8 | Content-Length: 245
9 |
10 |
11 |
12 |
13 | Unable to find transaction
14 |
15 |
--------------------------------------------------------------------------------
/tests/Mock/CaptureFailure.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:55:41 GMT
8 | Content-Length: 245
9 |
10 |
11 |
12 |
13 | Unable to find transaction
14 |
15 |
--------------------------------------------------------------------------------
/tests/Mock/CreditFailure.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:55:41 GMT
8 | Content-Length: 245
9 |
10 |
11 |
12 |
13 | Unable to find transaction
14 |
15 |
--------------------------------------------------------------------------------
/tests/Mock/CompletePurchaseFailure.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:55:41 GMT
8 | Content-Length: 245
9 |
10 |
11 |
12 |
13 | Unable to find transaction
14 |
15 |
16 |
--------------------------------------------------------------------------------
/tests/Mock/PurchaseFailure.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 15:53:42 GMT
8 | Content-Length: 259
9 |
10 |
11 |
12 |
13 | Missing parameter: 'Order Number'
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Message/ErrorResponse.php:
--------------------------------------------------------------------------------
1 | data['transactionId'];
20 | }
21 |
22 | public function getMessage()
23 | {
24 | return $this->data['responseCode'];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | * Fork the project.
4 | * Make your feature addition or bug fix.
5 | * Add tests for it. This is important so I don't break it in a future version unintentionally.
6 | * Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files.
7 | * Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
8 | style and that all tests pass.
9 | * Send the pull request.
10 | * Check that the Travis CI build passed. If not, rinse and repeat.
11 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
18 |
19 | ./src
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/tests/Mock/CompletePurchaseSuccess.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:53:34 GMT
8 | Content-Length: 474
9 |
10 |
11 |
12 | AUTH
13 | OK
14 | 090896
15 | 8a88d40cab5b47fab25e24d6228180a7
16 | 2013-02-22T17:53:33.9906245+01:00
17 | 424278
18 | 246
19 |
20 |
--------------------------------------------------------------------------------
/tests/Mock/AnnulSuccess.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Thu, 7 May 2015 16:53:34 GMT
8 | Content-Length: 474
9 |
10 |
11 |
12 | 389
13 | 3
14 | OK
15 | 3fece3574598c6ae3932fae5f38bc8af
16 | 2015-05-07T17:58:14.7503418+02:00
17 | 562923
18 |
19 | f12ed1e42982455f866dfc52e56aa1af
20 |
21 |
--------------------------------------------------------------------------------
/tests/Mock/CaptureSuccess.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Fri, 22 Feb 2013 16:53:34 GMT
8 | Content-Length: 474
9 |
10 |
11 |
12 | 389
13 | 3
14 | OK
15 | cc497f37603678c61a09fd5645959812
16 | 2015-05-07T17:58:14.7503418+02:00
17 | 562923
18 |
19 | 8544ffd97a104632854808128ef7308b
20 |
21 |
--------------------------------------------------------------------------------
/tests/Mock/CreditSuccess.txt:
--------------------------------------------------------------------------------
1 | HTTP/1.1 200 OK
2 | Cache-Control: private
3 | Content-Type: text/xml
4 | Server: Microsoft-IIS/7.5
5 | X-AspNet-Version: 4.0.30319
6 | X-Powered-By: ASP.NET
7 | Date: Thu, 7 May 2015 16:53:34 GMT
8 | Content-Length: 474
9 |
10 |
11 |
12 | 389
13 | 3
14 | OK
15 | 3fece3574598c6ae3932fae5f38bc8af
16 | 2015-05-07T17:58:14.7503418+02:00
17 | 562923
18 |
19 | f12ed1e42982455f866dfc52e56aa1af
20 |
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012-2013 Adrian Macneil
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "omnipay/netaxept",
3 | "type": "library",
4 | "description": "Netaxept driver for the Omnipay payment processing library",
5 | "keywords": [
6 | "netaxept",
7 | "gateway",
8 | "merchant",
9 | "omnipay",
10 | "pay",
11 | "payment"
12 | ],
13 | "homepage": "https://github.com/thephpleague/omnipay-netaxept",
14 | "license": "MIT",
15 | "authors": [
16 | {
17 | "name": "Adrian Macneil",
18 | "email": "adrian@adrianmacneil.com"
19 | },
20 | {
21 | "name": "Omnipay Contributors",
22 | "homepage": "https://github.com/thephpleague/omnipay-netaxept/contributors"
23 | }
24 | ],
25 | "autoload": {
26 | "psr-4": { "Omnipay\\Netaxept\\" : "src/" }
27 | },
28 | "require": {
29 | "omnipay/common": "~3.0"
30 | },
31 | "require-dev": {
32 | "omnipay/tests": "~3.0",
33 | "squizlabs/php_codesniffer": "^3"
34 | },
35 | "extra": {
36 | "branch-alias": {
37 | "dev-master": "2.0.x-dev"
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Message/CaptureRequest.php:
--------------------------------------------------------------------------------
1 |
11 | */
12 | class CaptureRequest extends PurchaseRequest
13 | {
14 | public function getData()
15 | {
16 | $data = array();
17 | $data['transactionAmount'] = $this->getAmountInteger();
18 | $data['transactionId'] = $this->getTransactionId();
19 | $data['merchantId'] = $this->getMerchantId();
20 | $data['token'] = $this->getPassword();
21 | $data['operation'] = 'CAPTURE';
22 |
23 | if (empty($data['transactionAmount']) || empty($data['transactionId'])) {
24 | throw new InvalidResponseException;
25 | }
26 |
27 | return $data;
28 | }
29 |
30 | public function sendData($data)
31 | {
32 | $url = $this->getEndpoint().'/Netaxept/Process.aspx?';
33 | $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data));
34 |
35 | return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents()));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Message/AnnulRequest.php:
--------------------------------------------------------------------------------
1 |
12 | */
13 | class AnnulRequest extends PurchaseRequest
14 | {
15 | public function getData()
16 | {
17 | $data = array();
18 | $data['transactionAmount'] = $this->getAmountInteger();
19 | $data['transactionId'] = $this->getTransactionId();
20 | $data['merchantId'] = $this->getMerchantId();
21 | $data['token'] = $this->getPassword();
22 | $data['operation'] = 'ANNUL';
23 |
24 | if (empty($data['transactionAmount']) || empty($data['transactionId'])) {
25 | throw new InvalidResponseException;
26 | }
27 |
28 | return $data;
29 | }
30 |
31 | public function sendData($data)
32 | {
33 | $url = $this->getEndpoint().'/Netaxept/Process.aspx?';
34 | $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data));
35 |
36 | return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents()));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Message/CreditRequest.php:
--------------------------------------------------------------------------------
1 |
12 | */
13 | class CreditRequest extends PurchaseRequest
14 | {
15 | public function getData()
16 | {
17 | $data = array();
18 | $data['transactionAmount'] = $this->getAmountInteger();
19 | $data['transactionId'] = $this->getTransactionId();
20 | $data['merchantId'] = $this->getMerchantId();
21 | $data['token'] = $this->getPassword();
22 | $data['operation'] = 'CREDIT';
23 |
24 | if (empty($data['transactionAmount']) || empty($data['transactionId'])) {
25 | throw new InvalidResponseException;
26 | }
27 |
28 | return $data;
29 | }
30 |
31 | public function sendData($data)
32 | {
33 | $url = $this->getEndpoint().'/Netaxept/Process.aspx?';
34 | $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data));
35 |
36 | return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents()));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/tests/Message/CompletePurchaseRequestTest.php:
--------------------------------------------------------------------------------
1 | getHttpClient();
22 | $this->httpRequest = $this->getHttpRequest();
23 |
24 | $this->request = new CompletePurchaseRequest($client, $this->httpRequest);
25 | }
26 |
27 | /**
28 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
29 | */
30 | public function testGetDataThrowsExceptionWithoutResponseCode()
31 | {
32 | $this->httpRequest->query->set('transactionId', 'TRANS-123');
33 |
34 | $this->request->getData();
35 | }
36 |
37 | /**
38 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
39 | */
40 | public function testGetDataThrowsExceptionWithoutTransactionId()
41 | {
42 | $this->httpRequest->query->set('responseCode', 'ABC-123');
43 |
44 | $this->request->getData();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Message/CompletePurchaseRequest.php:
--------------------------------------------------------------------------------
1 | httpRequest->query->get('responseCode');
16 | $data['transactionId'] = $this->httpRequest->query->get('transactionId');
17 | $data['merchantId'] = $this->getMerchantId();
18 | $data['token'] = $this->getPassword();
19 | $data['operation'] = 'SALE';
20 |
21 | if (empty($data['responseCode']) || empty($data['transactionId'])) {
22 | throw new InvalidResponseException;
23 | }
24 |
25 | return $data;
26 | }
27 |
28 | public function sendData($data)
29 | {
30 | if ('OK' !== $data['responseCode']) {
31 | return $this->response = new ErrorResponse($this, $data);
32 | }
33 |
34 | $url = $this->getEndpoint().'/Netaxept/Process.aspx?';
35 | $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data));
36 |
37 | return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents()));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tests/Message/AnnulRequestTest.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class AnnulRequestTest extends TestCase
11 | {
12 | /**
13 | * @var \Symfony\Component\HttpFoundation\Request
14 | */
15 | private $httpRequest;
16 |
17 | /**
18 | * @var \Omnipay\Netaxept\Message\AnnulRequest
19 | */
20 | private $request;
21 |
22 | public function setUp()
23 | {
24 | $client = $this->getHttpClient();
25 | $this->httpRequest = $this->getHttpRequest();
26 |
27 | $this->request = new AnnulRequest($client, $this->httpRequest);
28 | }
29 |
30 | /**
31 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
32 | */
33 | public function testGetDataThrowsExceptionWithoutTransactionAmount()
34 | {
35 | $this->httpRequest->query->set('transactionId', 'TRANS-123');
36 |
37 | $this->request->getData();
38 | }
39 |
40 | /**
41 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
42 | */
43 | public function testGetDataThrowsExceptionWithoutTransactionId()
44 | {
45 | $this->httpRequest->query->set('transactionAmount', 'ABC-123');
46 |
47 | $this->request->getData();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tests/Message/CreditRequestTest.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class CreditRequestTest extends TestCase
11 | {
12 | /**
13 | * @var \Symfony\Component\HttpFoundation\Request
14 | */
15 | private $httpRequest;
16 |
17 | /**
18 | * @var \Omnipay\Netaxept\Message\CreditRequest
19 | */
20 | private $request;
21 |
22 | public function setUp()
23 | {
24 | $client = $this->getHttpClient();
25 | $this->httpRequest = $this->getHttpRequest();
26 |
27 | $this->request = new CreditRequest($client, $this->httpRequest);
28 | }
29 |
30 | /**
31 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
32 | */
33 | public function testGetDataThrowsExceptionWithoutTransactionAmount()
34 | {
35 | $this->httpRequest->query->set('transactionId', 'TRANS-123');
36 |
37 | $this->request->getData();
38 | }
39 |
40 | /**
41 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
42 | */
43 | public function testGetDataThrowsExceptionWithoutTransactionId()
44 | {
45 | $this->httpRequest->query->set('transactionAmount', 'ABC-123');
46 |
47 | $this->request->getData();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/tests/Message/CaptureRequestTest.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | class CaptureRequestTest extends TestCase
11 | {
12 | /**
13 | * @var \Symfony\Component\HttpFoundation\Request
14 | */
15 | private $httpRequest;
16 |
17 | /**
18 | * @var \Omnipay\Netaxept\Message\CaptureRequest
19 | */
20 | private $request;
21 |
22 | public function setUp()
23 | {
24 | $client = $this->getHttpClient();
25 | $this->httpRequest = $this->getHttpRequest();
26 |
27 | $this->request = new CaptureRequest($client, $this->httpRequest);
28 | }
29 |
30 | /**
31 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
32 | */
33 | public function testGetDataThrowsExceptionWithoutTransactionAmount()
34 | {
35 | $this->httpRequest->query->set('transactionId', 'TRANS-123');
36 |
37 | $this->request->getData();
38 | }
39 |
40 | /**
41 | * @expectedException \Omnipay\Common\Exception\InvalidResponseException
42 | */
43 | public function testGetDataThrowsExceptionWithoutTransactionId()
44 | {
45 | $this->httpRequest->query->set('transactionAmount', 'ABC-123');
46 |
47 | $this->request->getData();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Message/Response.php:
--------------------------------------------------------------------------------
1 | data->ResponseCode) && 'OK' === (string) $this->data->ResponseCode;
16 | }
17 |
18 | public function isRedirect()
19 | {
20 | return !$this->isSuccessful() && 'RegisterResponse' === (string) $this->data->getName();
21 | }
22 |
23 | public function getTransactionReference()
24 | {
25 | return isset($this->data->TransactionId) ? (string) $this->data->TransactionId : null;
26 | }
27 |
28 | public function getMessage()
29 | {
30 | if (isset($this->data->Error->Message)) {
31 | return (string) $this->data->Error->Message;
32 | } elseif (isset($this->data->ResponseCode)) {
33 | return (string) $this->data->ResponseCode;
34 | }
35 | }
36 |
37 | public function getRedirectUrl()
38 | {
39 | if ($this->isRedirect()) {
40 | $data = array(
41 | 'merchantId' => $this->getRequest()->getMerchantId(),
42 | 'transactionId' => $this->getTransactionReference(),
43 | );
44 |
45 | return $this->getRequest()->getEndpoint().'/Terminal/Default.aspx?'.http_build_query($data);
46 | }
47 | }
48 |
49 | public function getRedirectMethod()
50 | {
51 | return 'GET';
52 | }
53 |
54 | public function getRedirectData()
55 | {
56 | return null;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Omnipay: Netaxept
2 |
3 | **Netaxept driver for the Omnipay PHP payment processing library**
4 |
5 | [](https://travis-ci.org/thephpleague/omnipay-netaxept)
6 | [](https://packagist.org/packages/omnipay/netaxept)
7 | [](https://packagist.org/packages/omnipay/netaxept)
8 |
9 | [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
10 | processing library for PHP 5.3+. This package implements Netaxept support for Omnipay.
11 |
12 | ## Installation
13 |
14 | Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
15 | to your `composer.json` file:
16 |
17 | ```json
18 | {
19 | "require": {
20 | "omnipay/netaxept": "~2.0"
21 | }
22 | }
23 | ```
24 |
25 | And run composer to update your dependencies:
26 |
27 | $ curl -s http://getcomposer.org/installer | php
28 | $ php composer.phar update
29 |
30 | ## Basic Usage
31 |
32 | The following gateways are provided by this package:
33 |
34 | * Netaxept
35 |
36 | For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
37 | repository.
38 |
39 | ## Support
40 |
41 | If you are having general issues with Omnipay, we suggest posting on
42 | [Stack Overflow](http://stackoverflow.com/). Be sure to add the
43 | [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.
44 |
45 | If you want to keep up to date with release anouncements, discuss ideas for the project,
46 | or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
47 | you can subscribe to.
48 |
49 | If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-netaxept/issues),
50 | or better yet, fork the library and submit a pull request.
51 |
--------------------------------------------------------------------------------
/src/Gateway.php:
--------------------------------------------------------------------------------
1 | '',
25 | 'password' => '',
26 | 'testMode' => false,
27 | );
28 | }
29 |
30 | public function getMerchantId()
31 | {
32 | return $this->getParameter('merchantId');
33 | }
34 |
35 | public function setMerchantId($value)
36 | {
37 | return $this->setParameter('merchantId', $value);
38 | }
39 |
40 | public function getPassword()
41 | {
42 | return $this->getParameter('password');
43 | }
44 |
45 | public function setPassword($value)
46 | {
47 | return $this->setParameter('password', $value);
48 | }
49 |
50 | public function purchase(array $parameters = array())
51 | {
52 | return $this->createRequest('\Omnipay\Netaxept\Message\PurchaseRequest', $parameters);
53 | }
54 |
55 | public function completePurchase(array $parameters = array())
56 | {
57 | return $this->createRequest('\Omnipay\Netaxept\Message\CompletePurchaseRequest', $parameters);
58 | }
59 |
60 | public function capture(array $parameters = array())
61 | {
62 | return $this->createRequest('\Omnipay\Netaxept\Message\CaptureRequest', $parameters);
63 | }
64 |
65 | public function void(array $parameters = array())
66 | {
67 | return $this->createRequest('\Omnipay\Netaxept\Message\AnnulRequest', $parameters);
68 | }
69 |
70 | public function credit(array $parameters = array())
71 | {
72 | return $this->createRequest('\Omnipay\Netaxept\Message\CreditRequest', $parameters);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/tests/Message/PurchaseRequestTest.php:
--------------------------------------------------------------------------------
1 | getHttpClient();
18 | $request = $this->getHttpRequest();
19 |
20 | $this->request = new PurchaseRequest($client, $request);
21 | }
22 |
23 | public function testGetDataWithCard()
24 | {
25 | $this->request->setMerchantId('MERCH-123');
26 | $this->request->setPassword('PASSWORD-123');
27 | $this->request->setAmount('1.23');
28 | $this->request->setCurrency('USD');
29 | $this->request->setTransactionId('ABC-123');
30 | $this->request->setReturnUrl('http://return.domain.com/');
31 | $this->request->setLanguage('en_GB');
32 |
33 | $card = new CreditCard(array(
34 | 'firstName' => 'John',
35 | 'lastName' => 'Doe',
36 | 'email' => 'test@email.com',
37 | 'phone' => '555-555-5555',
38 | 'address1' => '123 NW Blvd',
39 | 'address2' => 'Lynx Lane',
40 | 'postcode' => '66605',
41 | 'city' => 'Topeka',
42 | 'country' => 'USA',
43 | ));
44 | $this->request->setCard($card);
45 |
46 | $expected = array(
47 | 'merchantId' => 'MERCH-123',
48 | 'token' => 'PASSWORD-123',
49 | 'serviceType' => 'B',
50 | 'orderNumber' => 'ABC-123',
51 | 'currencyCode' => 'USD',
52 | 'amount' => 123,
53 | 'redirectUrl' => 'http://return.domain.com/',
54 | 'language' => 'en_GB',
55 | 'customerFirstName' => 'John',
56 | 'customerLastName' => 'Doe',
57 | 'customerEmail' => 'test@email.com',
58 | 'customerPhoneNumber' => '555-555-5555',
59 | 'customerAddress1' => '123 NW Blvd',
60 | 'customerAddress2' => 'Lynx Lane',
61 | 'customerPostcode' => '66605',
62 | 'customerTown' => 'Topeka',
63 | 'customerCountry' => 'USA',
64 | );
65 |
66 | $this->assertEquals($expected, $this->request->getData());
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/Message/PurchaseRequest.php:
--------------------------------------------------------------------------------
1 | getParameter('merchantId');
18 | }
19 |
20 | public function setMerchantId($value)
21 | {
22 | return $this->setParameter('merchantId', $value);
23 | }
24 |
25 | public function getPassword()
26 | {
27 | return $this->getParameter('password');
28 | }
29 |
30 | public function setPassword($value)
31 | {
32 | return $this->setParameter('password', $value);
33 | }
34 |
35 | public function getLanguage()
36 | {
37 | return $this->getParameter('language');
38 | }
39 |
40 | public function setLanguage($value)
41 | {
42 | return $this->setParameter('language', $value);
43 | }
44 |
45 | public function getData()
46 | {
47 | $this->validate('amount', 'currency', 'transactionId', 'returnUrl');
48 |
49 | $data = array();
50 | $data['merchantId'] = $this->getMerchantId();
51 | $data['token'] = $this->getPassword();
52 | $data['serviceType'] = 'B';
53 | $data['orderNumber'] = $this->getTransactionId();
54 | $data['currencyCode'] = $this->getCurrency();
55 | $data['amount'] = $this->getAmountInteger();
56 | $data['redirectUrl'] = $this->getReturnUrl();
57 | $data['language'] = $this->getLanguage();
58 |
59 | if ($this->getCard()) {
60 | $data['customerFirstName'] = $this->getCard()->getFirstName();
61 | $data['customerLastName'] = $this->getCard()->getLastName();
62 | $data['customerEmail'] = $this->getCard()->getEmail();
63 | $data['customerPhoneNumber'] = $this->getCard()->getPhone();
64 | $data['customerAddress1'] = $this->getCard()->getAddress1();
65 | $data['customerAddress2'] = $this->getCard()->getAddress2();
66 | $data['customerPostcode'] = $this->getCard()->getPostcode();
67 | $data['customerTown'] = $this->getCard()->getCity();
68 | $data['customerCountry'] = $this->getCard()->getCountry();
69 | }
70 |
71 | return $data;
72 | }
73 |
74 | public function sendData($data)
75 | {
76 | $url = $this->getEndpoint().'/Netaxept/Register.aspx?';
77 | $httpResponse = $this->httpClient->request('GET', $url.http_build_query($data));
78 |
79 | return $this->response = new Response($this, simplexml_load_string($httpResponse->getBody()->getContents()));
80 | }
81 |
82 | public function getEndpoint()
83 | {
84 | return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/tests/Message/ResponseTest.php:
--------------------------------------------------------------------------------
1 | getMockHttpResponse('PurchaseSuccess.txt');
12 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
13 | $response = new Response($this->getMockRequest(), $xml);
14 |
15 | $this->assertFalse($response->isSuccessful());
16 | $this->assertTrue($response->isRedirect());
17 | $this->assertEquals('f3d94dd5c0f743a788fc943402757c58', $response->getTransactionReference());
18 | $this->assertNull($response->getMessage());
19 | }
20 |
21 | public function testPurchaseFailure()
22 | {
23 | $httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt');
24 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
25 | $response = new Response($this->getMockRequest(), $xml);
26 |
27 | $this->assertFalse($response->isSuccessful());
28 | $this->assertFalse($response->isRedirect());
29 | $this->assertNull($response->getRedirectUrl());
30 | $this->assertNull($response->getRedirectData());
31 | $this->assertNull($response->getTransactionReference());
32 | $this->assertSame("Missing parameter: 'Order Number'", $response->getMessage());
33 | }
34 |
35 | public function testCompletePurchaseSuccess()
36 | {
37 | $httpResponse = $this->getMockHttpResponse('CompletePurchaseSuccess.txt');
38 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
39 | $response = new Response($this->getMockRequest(), $xml);
40 |
41 | $this->assertTrue($response->isSuccessful());
42 | $this->assertFalse($response->isRedirect());
43 | $this->assertEquals('8a88d40cab5b47fab25e24d6228180a7', $response->getTransactionReference());
44 | $this->assertSame('OK', $response->getMessage());
45 | }
46 |
47 | public function testCompletePurchaseFailure()
48 | {
49 | $httpResponse = $this->getMockHttpResponse('CompletePurchaseFailure.txt');
50 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
51 | $response = new Response($this->getMockRequest(), $xml);
52 |
53 | $this->assertFalse($response->isSuccessful());
54 | $this->assertFalse($response->isRedirect());
55 | $this->assertNull($response->getTransactionReference());
56 | $this->assertSame('Unable to find transaction', $response->getMessage());
57 | }
58 |
59 | public function testCaptureSuccess()
60 | {
61 | $httpResponse = $this->getMockHttpResponse('CaptureSuccess.txt');
62 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
63 | $response = new Response($this->getMockRequest(), $xml);
64 |
65 | $this->assertTrue($response->isSuccessful());
66 | $this->assertFalse($response->isRedirect());
67 | $this->assertEquals('cc497f37603678c61a09fd5645959812', $response->getTransactionReference());
68 | $this->assertSame('OK', $response->getMessage());
69 | }
70 |
71 | public function testCaptureFailure()
72 | {
73 | $httpResponse = $this->getMockHttpResponse('CaptureFailure.txt');
74 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
75 | $response = new Response($this->getMockRequest(), $xml);
76 |
77 | $this->assertFalse($response->isSuccessful());
78 | $this->assertFalse($response->isRedirect());
79 | $this->assertNull($response->getTransactionReference());
80 | $this->assertSame('Unable to find transaction', $response->getMessage());
81 | }
82 |
83 | public function testAnnulSuccess()
84 | {
85 | $httpResponse = $this->getMockHttpResponse('AnnulSuccess.txt');
86 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
87 | $response = new Response($this->getMockRequest(), $xml);
88 |
89 | $this->assertTrue($response->isSuccessful());
90 | $this->assertFalse($response->isRedirect());
91 | $this->assertEquals('3fece3574598c6ae3932fae5f38bc8af', $response->getTransactionReference());
92 | $this->assertSame('OK', $response->getMessage());
93 | }
94 |
95 | public function testAnnullFailure()
96 | {
97 | $httpResponse = $this->getMockHttpResponse('AnnulFailure.txt');
98 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
99 | $response = new Response($this->getMockRequest(), $xml);
100 |
101 | $this->assertFalse($response->isSuccessful());
102 | $this->assertFalse($response->isRedirect());
103 | $this->assertNull($response->getTransactionReference());
104 | $this->assertSame('Unable to find transaction', $response->getMessage());
105 | }
106 |
107 | public function testCreditSuccess()
108 | {
109 | $httpResponse = $this->getMockHttpResponse('CreditSuccess.txt');
110 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
111 | $response = new Response($this->getMockRequest(), $xml);
112 |
113 | $this->assertTrue($response->isSuccessful());
114 | $this->assertFalse($response->isRedirect());
115 | $this->assertEquals('3fece3574598c6ae3932fae5f38bc8af', $response->getTransactionReference());
116 | $this->assertSame('OK', $response->getMessage());
117 | }
118 |
119 | public function testCreditFailure()
120 | {
121 | $httpResponse = $this->getMockHttpResponse('CreditFailure.txt');
122 | $xml = simplexml_load_string($httpResponse->getBody()->getContents());
123 | $response = new Response($this->getMockRequest(), $xml);
124 |
125 | $this->assertFalse($response->isSuccessful());
126 | $this->assertFalse($response->isRedirect());
127 | $this->assertNull($response->getTransactionReference());
128 | $this->assertSame('Unable to find transaction', $response->getMessage());
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/tests/GatewayTest.php:
--------------------------------------------------------------------------------
1 | gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest());
14 | $this->gateway->setMerchantId('foo');
15 | $this->gateway->setPassword('bar');
16 |
17 | $this->options = array(
18 | 'amount' => '10.00',
19 | 'currency' => 'NOK',
20 | 'transactionId' => '123',
21 | 'returnUrl' => 'https://www.example.com/return',
22 | );
23 | }
24 |
25 | public function testPurchaseSuccess()
26 | {
27 | $this->setMockHttpResponse('PurchaseSuccess.txt');
28 |
29 | $response = $this->gateway->purchase($this->options)->send();
30 |
31 | $this->assertFalse($response->isSuccessful());
32 | $this->assertTrue($response->isRedirect());
33 | $this->assertEquals('f3d94dd5c0f743a788fc943402757c58', $response->getTransactionReference());
34 | $this->assertSame('GET', $response->getRedirectMethod());
35 | $this->assertSame('https://epayment.nets.eu/Terminal/Default.aspx?merchantId=foo&transactionId=f3d94dd5c0f743a788fc943402757c58', $response->getRedirectUrl());
36 | }
37 |
38 | public function testPurchaseFailure()
39 | {
40 | $this->setMockHttpResponse('PurchaseFailure.txt');
41 |
42 | $response = $this->gateway->purchase($this->options)->send();
43 |
44 | $this->assertFalse($response->isSuccessful());
45 | $this->assertFalse($response->isRedirect());
46 | $this->assertNull($response->getTransactionReference());
47 | $this->assertSame("Missing parameter: 'Order Number'", $response->getMessage());
48 | }
49 |
50 | public function testCompletePurchaseSuccess()
51 | {
52 | $this->getHttpRequest()->query->replace(
53 | array(
54 | 'responseCode' => 'OK',
55 | 'transactionId' => 'abc123',
56 | )
57 | );
58 |
59 | $this->setMockHttpResponse('CompletePurchaseSuccess.txt');
60 |
61 | $response = $this->gateway->completePurchase($this->options)->send();
62 |
63 | $this->assertTrue($response->isSuccessful());
64 | $this->assertFalse($response->isRedirect());
65 | $this->assertEquals('8a88d40cab5b47fab25e24d6228180a7', $response->getTransactionReference());
66 | $this->assertSame('OK', $response->getMessage());
67 | }
68 |
69 | public function testCompletePurchaseCancel()
70 | {
71 | $this->getHttpRequest()->query->replace(
72 | array(
73 | 'transactionId' => '1de59458487344759832716abf48109b',
74 | 'responseCode' => 'Cancel',
75 | )
76 | );
77 |
78 | $response = $this->gateway->completePurchase($this->options)->send();
79 |
80 | $this->assertFalse($response->isSuccessful());
81 | $this->assertFalse($response->isRedirect());
82 | $this->assertEquals('1de59458487344759832716abf48109b', $response->getTransactionReference());
83 | $this->assertEquals('Cancel', $response->getMessage());
84 | }
85 |
86 | public function testCompletePurchaseFailure()
87 | {
88 | $this->getHttpRequest()->query->replace(
89 | array(
90 | 'responseCode' => 'OK',
91 | 'transactionId' => 'abc123',
92 | )
93 | );
94 |
95 | $this->setMockHttpResponse('CompletePurchaseFailure.txt');
96 |
97 | $response = $this->gateway->completePurchase($this->options)->send();
98 |
99 | $this->assertFalse($response->isSuccessful());
100 | $this->assertFalse($response->isRedirect());
101 | $this->assertNull($response->getTransactionReference());
102 |
103 | $this->assertSame('Unable to find transaction', $response->getMessage());
104 | }
105 |
106 | public function testCaptureSuccess()
107 | {
108 | $this->setMockHttpResponse('CaptureSuccess.txt');
109 |
110 | $response = $this->gateway->capture($this->options)->send();
111 |
112 | $this->assertTrue($response->isSuccessful());
113 | $this->assertFalse($response->isRedirect());
114 | $this->assertEquals('cc497f37603678c61a09fd5645959812', $response->getTransactionReference());
115 | $this->assertSame('OK', $response->getMessage());
116 | }
117 |
118 | public function testCaptureFailure()
119 | {
120 | $this->setMockHttpResponse('CaptureFailure.txt');
121 |
122 | $response = $this->gateway->capture($this->options)->send();
123 |
124 | $this->assertFalse($response->isSuccessful());
125 | $this->assertFalse($response->isRedirect());
126 | $this->assertNull($response->getTransactionReference());
127 | $this->assertSame('Unable to find transaction', $response->getMessage());
128 | }
129 |
130 | public function testAnnulSuccess()
131 | {
132 | $this->setMockHttpResponse('AnnulSuccess.txt');
133 |
134 | $response = $this->gateway->capture($this->options)->send();
135 |
136 | $this->assertTrue($response->isSuccessful());
137 | $this->assertFalse($response->isRedirect());
138 | $this->assertEquals('3fece3574598c6ae3932fae5f38bc8af', $response->getTransactionReference());
139 | $this->assertSame('OK', $response->getMessage());
140 | }
141 |
142 | public function testAnnulFailure()
143 | {
144 | $this->setMockHttpResponse('AnnulFailure.txt');
145 |
146 | $response = $this->gateway->capture($this->options)->send();
147 |
148 | $this->assertFalse($response->isSuccessful());
149 | $this->assertFalse($response->isRedirect());
150 | $this->assertNull($response->getTransactionReference());
151 | $this->assertSame('Unable to find transaction', $response->getMessage());
152 | }
153 |
154 | public function testCreditSuccess()
155 | {
156 | $this->setMockHttpResponse('CreditSuccess.txt');
157 |
158 | $response = $this->gateway->capture($this->options)->send();
159 |
160 | $this->assertTrue($response->isSuccessful());
161 | $this->assertFalse($response->isRedirect());
162 | $this->assertEquals('3fece3574598c6ae3932fae5f38bc8af', $response->getTransactionReference());
163 | $this->assertSame('OK', $response->getMessage());
164 | }
165 |
166 | public function testCreditFailure()
167 | {
168 | $this->setMockHttpResponse('CreditFailure.txt');
169 |
170 | $response = $this->gateway->capture($this->options)->send();
171 |
172 | $this->assertFalse($response->isSuccessful());
173 | $this->assertFalse($response->isRedirect());
174 | $this->assertNull($response->getTransactionReference());
175 | $this->assertSame('Unable to find transaction', $response->getMessage());
176 | }
177 | }
178 |
--------------------------------------------------------------------------------