Skip to content

Commit b07f30e

Browse files
committed
NAB Transact XML API Integration
0 parents  commit b07f30e

17 files changed

+866
-0
lines changed

.coveralls.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage_clover: ./clover.xml
2+
json_path: ./coveralls-upload.json

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/vendor
2+
composer.lock
3+
composer.phar
4+
phpunit.xml
5+
php-cs-fixer.phar
6+
phpcbf.phar
7+
phpcs.phar

.scrutinizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tools:
2+
external_code_coverage: true

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
- 5.6
8+
- 7.0
9+
- hhvm
10+
11+
before_script:
12+
- composer install -n --dev --prefer-source
13+
14+
script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text
15+
16+
after_script: vendor/bin/coveralls -v

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Omnipay: NAB Transact
2+
3+
**NAB Transact driver for the Omnipay PHP payment processing library**
4+
5+
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
6+
processing library for PHP 5.3+. This package implements NAB Transact support for Omnipay.
7+
8+
[![StyleCI](https://styleci.io/repos/73980655/shield?branch=master)](https://styleci.io/repos/73980655)
9+
[![Build Status](https://travis-ci.org/sudiptpa/nabtransact.svg?branch=master)](https://travis-ci.org/sudiptpa/nabtransact)
10+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sudiptpa/nabtransact/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sudiptpa/nabtransact/?branch=master)
11+
[![Latest Stable Version](https://poser.pugx.org/sudiptpa/nabtransact/version.png)](https://packagist.org/packages/sudiptpa/nabtransact)
12+
13+
## Installation
14+
15+
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
16+
to your `composer.json` file:
17+
18+
```json
19+
{
20+
"require": {
21+
"sudiptpa/nabtransact": "~2.0"
22+
}
23+
}
24+
```
25+
26+
And run composer to update your dependencies:
27+
28+
$ curl -s http://getcomposer.org/installer | php
29+
$ php composer.phar update
30+
31+
## Basic Usage
32+
33+
The following gateways are provided by this package:
34+
35+
* NAB Transact SecureXML API*
36+
37+
```php
38+
use Omnipay\Omnipay;
39+
use Omnipay\Common\CreditCard;
40+
41+
$gateway = Omnipay::create('NABTransact_SecureXML');
42+
$gateway->setMerchantId('ABC0001');
43+
$gateway->setTransactionPassword('abc123');
44+
$gateway->setTestMode(true);
45+
46+
$card = new CreditCard(
47+
[
48+
'number' => '4444333322221111',
49+
'expiryMonth' => '6',
50+
'expiryYear' => '2020',
51+
'cvv' => '123',
52+
]
53+
);
54+
55+
$transaction = $gateway->purchase(
56+
[
57+
'amount' => '10.00',
58+
'currency' => 'AUD',
59+
'transactionId' => 'XYZ100',
60+
'card' => $card,
61+
]
62+
);
63+
64+
$response = $transaction->send();
65+
66+
if ($response->isSuccessful()) {
67+
echo sprintf('Transaction %s was successful!', $response->getTransactionReference());
68+
} else {
69+
echo sprintf('Transaction %s failed: %s', $response->getTransactionReference(), $response->getMessage());
70+
}
71+
72+
```
73+
74+
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
75+
repository.
76+
77+
## Support
78+
79+
If you are having general issues with Omnipay, we suggest posting on
80+
[Stack Overflow](http://stackoverflow.com/). Be sure to add the
81+
[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.
82+
83+
If you want to keep up to date with release anouncements, discuss ideas for the project,
84+
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
85+
you can subscribe to.
86+
87+
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/sudiptpa/nabtransact/issues),
88+
or better yet, fork the library and submit a pull request.

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "sudiptpa/omnipay-nabtransact",
3+
"type": "library",
4+
"description": "NAB Transact driver for the Omnipay payment processing library",
5+
"keywords": [
6+
"gateway",
7+
"merchant",
8+
"omnipay",
9+
"pay",
10+
"payment",
11+
"nabtransact"
12+
],
13+
"homepage": "https://github.com/sudiptpa/nabtransact",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "Sujip Thapa",
18+
"email": "sudiptpa@gmail.com"
19+
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Omnipay\\NABTransact\\" : "src/"
24+
}
25+
},
26+
"require": {
27+
"omnipay/common": "~2.3"
28+
},
29+
"require-dev": {
30+
"omnipay/tests": "~2.0",
31+
"satooshi/php-coveralls": "1.0.0",
32+
"fzaninotto/faker": "~1.4"
33+
},
34+
"extra": {
35+
"branch-alias": {
36+
"dev-master": "2.0.x-dev"
37+
}
38+
}
39+
}

phpunit.xml.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<testsuites>
13+
<testsuite name="NAB Transact Test Suite">
14+
<directory>./tests/</directory>
15+
</testsuite>
16+
</testsuites>
17+
<listeners>
18+
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
19+
</listeners>
20+
<filter>
21+
<whitelist>
22+
<directory>./src</directory>
23+
</whitelist>
24+
</filter>
25+
</phpunit>

src/Message/AbstractRequest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace Omnipay\NABTransact\Message;
4+
5+
/**
6+
* NABTransact Abstract Request.
7+
*/
8+
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
9+
{
10+
/**
11+
* @var mixed
12+
*/
13+
public $testEndpoint;
14+
15+
/**
16+
* @var mixed
17+
*/
18+
public $liveEndpoint;
19+
20+
/**
21+
* @return mixed
22+
*/
23+
public function getMerchantId()
24+
{
25+
return $this->getParameter('merchantId');
26+
}
27+
28+
/**
29+
* @param $value
30+
* @return mixed
31+
*/
32+
public function setMerchantId($value)
33+
{
34+
return $this->setParameter('merchantId', $value);
35+
}
36+
37+
/**
38+
* @return mixed
39+
*/
40+
public function getTransactionPassword()
41+
{
42+
return $this->getParameter('transactionPassword');
43+
}
44+
45+
/**
46+
* @param $value
47+
* @return mixed
48+
*/
49+
public function setTransactionPassword($value)
50+
{
51+
return $this->setParameter('transactionPassword', $value);
52+
}
53+
54+
/**
55+
* @return mixed
56+
*/
57+
public function getEndpoint()
58+
{
59+
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
60+
}
61+
}

0 commit comments

Comments
 (0)