Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches: [ master ]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
deps: [ 'stable' ]
include:
- php: '8.1'
deps: 'lowest'

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Validate composer.json
run: composer validate --strict

- name: Install dependencies
run: |
if [ "${{ matrix.deps }}" = "lowest" ]; then
composer update --prefer-lowest --prefer-stable --no-interaction --no-progress
else
composer update --no-interaction --no-progress
fi

- name: Run lint
run: composer lint

- name: Run tests
run: composer test

- name: Run PHPStan
run: composer stan
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

82 changes: 82 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Architecture

## Overview

`omnipay-nabtransact` remains an Omnipay gateway package and keeps full Omnipay request/response compatibility.

This modernization adds a transport layer so the package can run with:

- Omnipay HTTP client (default, backward compatible)
- Native cURL transport (framework-agnostic alternative)
- Custom user transport via contract

## Design Goals

- Preserve Omnipay API surface and existing integrations.
- Keep non-breaking behavior for request classes and gateway methods.
- Improve reliability and testability through explicit transport contracts.
- Keep dependencies minimal.

## Project Map

```text
src/
DirectPostGateway.php
SecureXMLGateway.php
HostedPaymentGateway.php
UnionPayGateway.php

Message/
*Request.php
*Response.php

Transport/
TransportInterface.php
TransportResponse.php
OmnipayHttpClientTransport.php
CurlTransport.php

Enums/
TransactionType.php
```

## Runtime Flows

### 1) SecureXML requests

1. Gateway creates request through Omnipay (`authorize/purchase/capture/refund/echoTest`).
2. Request builds XML payload.
3. Request resolves transport in this order:
- explicit request transport (`setTransport()`)
- Omnipay adapter transport (default)
4. Response XML is mapped to `SecureXMLResponse`.

### 2) DirectPost / UnionPay

- Redirect-based requests remain unchanged.
- Fingerprint verification stays compatible.
- Backward-compat typo alias (`vefiyFingerPrint`) remains supported.
- DirectPost supports purchase, authorize, complete callbacks, store-only flow, and additive server-to-server operations (`capture`, `refund`, `void`).
- EMV 3DS order management is exposed via `createEMV3DSOrder()`.

### 3) Hosted Payment

- Redirect form flow remains unchanged.
- Environment endpoint selection now aligns correctly with `testMode`.

## Extension Points

- Implement `TransportInterface` for custom HTTP stacks.
- Inject custom transport per request via `setTransport($transport)`.

## Backward Compatibility

- Omnipay gateway class names and behavior remain intact.
- Existing request/response classes remain available.
- Deprecated typo method remains callable.

## Testing Strategy

- Request/response behavior tests for existing Omnipay flows.
- Dedicated tests for transport injection and endpoint correctness.
- Fingerprint verification coverage (success/failure).
132 changes: 120 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

**NAB Transact driver for the Omnipay PHP payment processing library**

[![CI](https://github.com/sudiptpa/omnipay-nabtransact/actions/workflows/ci.yml/badge.svg)](https://github.com/sudiptpa/omnipay-nabtransact/actions/workflows/ci.yml)
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP. This package implements NAB Transact support for Omnipay.

[![StyleCI](https://styleci.io/repos/74269379/shield?style=flat&branch=master)](https://styleci.io/repos/74269379)
[![Build Status](https://travis-ci.org/sudiptpa/omnipay-nabtransact.svg?branch=master&style=flat-square)](https://travis-ci.org/sudiptpa/omnipay-nabtransact)
[![Latest Stable Version](https://poser.pugx.org/sudiptpa/omnipay-nabtransact/v/stable?style=flat-square)](https://packagist.org/packages/sudiptpa/omnipay-nabtransact)
[![Total Downloads](https://poser.pugx.org/sudiptpa/omnipay-nabtransact/downloads?style=flat-square)](https://packagist.org/packages/sudiptpa/omnipay-nabtransact)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/sudiptpa/omnipay-nabtransact/master/LICENSE)
Expand All @@ -25,6 +24,7 @@ The following gateways are provided by this package:

* NABTransact_DirectPost (NAB Transact Direct Post v2)
* NABTransact_SecureXML (NAB Transact SecurePay XML)
* NABTransact_HostedPayment (NAB Hosted Payment Page)
* NABTransact_UnionPay (UnionPay via NAB Transact)

### NAB Transact SecureXML API
Expand Down Expand Up @@ -117,23 +117,23 @@ The following gateways are provided by this package:
$gateway->setTestMode(true);
$gateway->setHasEMV3DSEnabled(true);

$card = new CreditCard(array(
$card = new CreditCard([
'firstName' => 'Sujip',
'lastName' => 'Thapa',
'number' => '4444333322221111',
'expiryMonth' => '10',
'expiryYear' => '2030',
'cvv' => '123',
));
]);

$response = $gateway->purchase(array(
$response = $gateway->purchase([
'amount' => '12.00',
'transactionId' => 'ORDER-ZYX8',
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402'
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402',
'currency' => 'AUD',
'card' => $card,
'clientIp' => '192.168.1.1'
))
])
->send();

if ($response->isRedirect()) {
Expand All @@ -148,6 +148,82 @@ The following gateways are provided by this package:

```

#### DirectPost Store Only

```php
$gateway = Omnipay::create('NABTransact_DirectPost');
$gateway->setMerchantId('XYZ0010');
$gateway->setTransactionPassword('abcd1234');
$gateway->setTestMode(true);

$response = $gateway->store([
'transactionId' => 'STORE-ORDER-100',
'returnUrl' => 'http://example.com/payment/response',
'card' => $card,
])->send();

if ($response->isRedirect()) {
$response->redirect();
}
```

#### DirectPost Capture (Complete Preauth, Server-to-Server)

```php
$gateway = Omnipay::create('NABTransact_DirectPost');
$gateway->setMerchantId('XYZ0010');
$gateway->setTransactionPassword('abcd1234');
$gateway->setTestMode(true);

$response = $gateway->capture([
'transactionId' => 'CAPTURE-ORDER-100',
'transactionReference' => 'NAB-ORIGINAL-TXN-ID',
'amount' => '12.00',
'currency' => 'AUD',
])->send();

if ($response->isSuccessful()) {
echo 'Capture successful: '.$response->getTransactionReference();
}
```

#### DirectPost Refund (Server-to-Server)

```php
$response = $gateway->refund([
'transactionId' => 'REFUND-ORDER-100',
'transactionReference' => 'NAB-SETTLED-TXN-ID',
'amount' => '5.00',
'currency' => 'AUD',
])->send();
```

#### DirectPost Reversal/Void (Server-to-Server)

```php
$response = $gateway->void([
'transactionId' => 'VOID-ORDER-100',
'transactionReference' => 'NAB-AUTH-TXN-ID',
'amount' => '12.00',
])->send();
```

#### EMV 3DS Order Creation API

```php
$response = $gateway->createEMV3DSOrder([
'amount' => '12.00',
'currency' => 'AUD',
'clientIp' => '203.0.113.10',
'transactionReference' => 'ORDER-REF-100',
])->send();

if ($response->isSuccessful()) {
echo 'Order ID: '.$response->getOrderId();
echo 'Simple Token: '.$response->getSimpleToken();
}
```

### NAB Transact DirectPost v2 UnionPay Online Payment

```php
Expand All @@ -162,12 +238,12 @@ The following gateways are provided by this package:
* The parameter transactionId must be alpha-numeric and 8 to 32 characters in length
*/

$response = $gateway->purchase(array(
$response = $gateway->purchase([
'amount' => '12.00',
'transactionId' => '1234566789205067',
'currency' => 'AUD',
'returnUrl' => 'http://example.com/payment/response',
))
])
->send();

if ($response->isRedirect()) {
Expand All @@ -185,13 +261,13 @@ The following gateways are provided by this package:

$gateway->setTestMode(true);

$response = $gateway->completePurchase(array(
$response = $gateway->completePurchase([
'amount' => '12.00',
'transactionId' => '1234566789205067',
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402'
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402',
'currency' => 'AUD',
'returnUrl' => 'http://example.com/payment/response',
))
])
->send();

if ($response->isSuccessful()) {
Expand All @@ -205,6 +281,33 @@ The following gateways are provided by this package:
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

## Framework-Agnostic Transport Option

Omnipay support remains the default behavior. SecureXML requests can now also use a framework-agnostic cURL transport:

```php
use Omnipay\NABTransact\Transport\CurlTransport;

$request = $gateway->purchase([
'amount' => '10.00',
'transactionId' => 'ORDER-1000',
'card' => $card,
]);

$request->setTransport(new CurlTransport());
$response = $request->send();
```

DirectPost server-to-server operations (`capture`, `refund`, `void`, `createEMV3DSOrder`) can use the same transport injection pattern.

See `ARCHITECTURE.md` for design details and extension points.

## NAB Feature Coverage

Core payment features are mapped in `docs/feature-matrix.md` with request/response classes and test coverage.
For a contributor-friendly package map, see `docs/features-implemented-tree.md`.
This package targets payment-processing API coverage and does not include NAB admin/reporting portal features.

## Contributing

Contributions are **welcome** and will be fully **credited**.
Expand All @@ -223,3 +326,8 @@ you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/sudiptpa/nabtransact/issues),
or better yet, fork the library and submit a pull request.


## Architecture

See `ARCHITECTURE.md` for package structure, flow, and extension points.
Loading