Skip to content

Commit 92ffc1d

Browse files
authored
Merge pull request #41 from sudiptpa/chore-modernize-legacy-tests
feat:: modernize legacy tests
2 parents b076bdc + 53c7fee commit 92ffc1d

File tree

71 files changed

+3190
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3190
-275
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
15+
deps: [ 'stable' ]
16+
include:
17+
- php: '8.1'
18+
deps: 'lowest'
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
coverage: none
28+
29+
- name: Validate composer.json
30+
run: composer validate --strict
31+
32+
- name: Install dependencies
33+
run: |
34+
if [ "${{ matrix.deps }}" = "lowest" ]; then
35+
composer update --prefer-lowest --prefer-stable --no-interaction --no-progress
36+
else
37+
composer update --no-interaction --no-progress
38+
fi
39+
40+
- name: Run lint
41+
run: composer lint
42+
43+
- name: Run tests
44+
run: composer test
45+
46+
- name: Run PHPStan
47+
run: composer stan

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

ARCHITECTURE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Architecture
2+
3+
## Overview
4+
5+
`omnipay-nabtransact` remains an Omnipay gateway package and keeps full Omnipay request/response compatibility.
6+
7+
This modernization adds a transport layer so the package can run with:
8+
9+
- Omnipay HTTP client (default, backward compatible)
10+
- Native cURL transport (framework-agnostic alternative)
11+
- Custom user transport via contract
12+
13+
## Design Goals
14+
15+
- Preserve Omnipay API surface and existing integrations.
16+
- Keep non-breaking behavior for request classes and gateway methods.
17+
- Improve reliability and testability through explicit transport contracts.
18+
- Keep dependencies minimal.
19+
20+
## Project Map
21+
22+
```text
23+
src/
24+
DirectPostGateway.php
25+
SecureXMLGateway.php
26+
HostedPaymentGateway.php
27+
UnionPayGateway.php
28+
29+
Message/
30+
*Request.php
31+
*Response.php
32+
33+
Transport/
34+
TransportInterface.php
35+
TransportResponse.php
36+
OmnipayHttpClientTransport.php
37+
CurlTransport.php
38+
39+
Enums/
40+
TransactionType.php
41+
```
42+
43+
## Runtime Flows
44+
45+
### 1) SecureXML requests
46+
47+
1. Gateway creates request through Omnipay (`authorize/purchase/capture/refund/echoTest`).
48+
2. Request builds XML payload.
49+
3. Request resolves transport in this order:
50+
- explicit request transport (`setTransport()`)
51+
- Omnipay adapter transport (default)
52+
4. Response XML is mapped to `SecureXMLResponse`.
53+
54+
### 2) DirectPost / UnionPay
55+
56+
- Redirect-based requests remain unchanged.
57+
- Fingerprint verification stays compatible.
58+
- Backward-compat typo alias (`vefiyFingerPrint`) remains supported.
59+
- DirectPost supports purchase, authorize, complete callbacks, store-only flow, and additive server-to-server operations (`capture`, `refund`, `void`).
60+
- EMV 3DS order management is exposed via `createEMV3DSOrder()`.
61+
62+
### 3) Hosted Payment
63+
64+
- Redirect form flow remains unchanged.
65+
- Environment endpoint selection now aligns correctly with `testMode`.
66+
67+
## Extension Points
68+
69+
- Implement `TransportInterface` for custom HTTP stacks.
70+
- Inject custom transport per request via `setTransport($transport)`.
71+
72+
## Backward Compatibility
73+
74+
- Omnipay gateway class names and behavior remain intact.
75+
- Existing request/response classes remain available.
76+
- Deprecated typo method remains callable.
77+
78+
## Testing Strategy
79+
80+
- Request/response behavior tests for existing Omnipay flows.
81+
- Dedicated tests for transport injection and endpoint correctness.
82+
- Fingerprint verification coverage (success/failure).

README.md

Lines changed: 120 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

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

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

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

2625
* NABTransact_DirectPost (NAB Transact Direct Post v2)
2726
* NABTransact_SecureXML (NAB Transact SecurePay XML)
27+
* NABTransact_HostedPayment (NAB Hosted Payment Page)
2828
* NABTransact_UnionPay (UnionPay via NAB Transact)
2929

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

120-
$card = new CreditCard(array(
120+
$card = new CreditCard([
121121
'firstName' => 'Sujip',
122122
'lastName' => 'Thapa',
123123
'number' => '4444333322221111',
124124
'expiryMonth' => '10',
125125
'expiryYear' => '2030',
126126
'cvv' => '123',
127-
));
127+
]);
128128

129-
$response = $gateway->purchase(array(
129+
$response = $gateway->purchase([
130130
'amount' => '12.00',
131131
'transactionId' => 'ORDER-ZYX8',
132-
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402'
132+
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402',
133133
'currency' => 'AUD',
134134
'card' => $card,
135135
'clientIp' => '192.168.1.1'
136-
))
136+
])
137137
->send();
138138

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

149149
```
150150

151+
#### DirectPost Store Only
152+
153+
```php
154+
$gateway = Omnipay::create('NABTransact_DirectPost');
155+
$gateway->setMerchantId('XYZ0010');
156+
$gateway->setTransactionPassword('abcd1234');
157+
$gateway->setTestMode(true);
158+
159+
$response = $gateway->store([
160+
'transactionId' => 'STORE-ORDER-100',
161+
'returnUrl' => 'http://example.com/payment/response',
162+
'card' => $card,
163+
])->send();
164+
165+
if ($response->isRedirect()) {
166+
$response->redirect();
167+
}
168+
```
169+
170+
#### DirectPost Capture (Complete Preauth, Server-to-Server)
171+
172+
```php
173+
$gateway = Omnipay::create('NABTransact_DirectPost');
174+
$gateway->setMerchantId('XYZ0010');
175+
$gateway->setTransactionPassword('abcd1234');
176+
$gateway->setTestMode(true);
177+
178+
$response = $gateway->capture([
179+
'transactionId' => 'CAPTURE-ORDER-100',
180+
'transactionReference' => 'NAB-ORIGINAL-TXN-ID',
181+
'amount' => '12.00',
182+
'currency' => 'AUD',
183+
])->send();
184+
185+
if ($response->isSuccessful()) {
186+
echo 'Capture successful: '.$response->getTransactionReference();
187+
}
188+
```
189+
190+
#### DirectPost Refund (Server-to-Server)
191+
192+
```php
193+
$response = $gateway->refund([
194+
'transactionId' => 'REFUND-ORDER-100',
195+
'transactionReference' => 'NAB-SETTLED-TXN-ID',
196+
'amount' => '5.00',
197+
'currency' => 'AUD',
198+
])->send();
199+
```
200+
201+
#### DirectPost Reversal/Void (Server-to-Server)
202+
203+
```php
204+
$response = $gateway->void([
205+
'transactionId' => 'VOID-ORDER-100',
206+
'transactionReference' => 'NAB-AUTH-TXN-ID',
207+
'amount' => '12.00',
208+
])->send();
209+
```
210+
211+
#### EMV 3DS Order Creation API
212+
213+
```php
214+
$response = $gateway->createEMV3DSOrder([
215+
'amount' => '12.00',
216+
'currency' => 'AUD',
217+
'clientIp' => '203.0.113.10',
218+
'transactionReference' => 'ORDER-REF-100',
219+
])->send();
220+
221+
if ($response->isSuccessful()) {
222+
echo 'Order ID: '.$response->getOrderId();
223+
echo 'Simple Token: '.$response->getSimpleToken();
224+
}
225+
```
226+
151227
### NAB Transact DirectPost v2 UnionPay Online Payment
152228

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

165-
$response = $gateway->purchase(array(
241+
$response = $gateway->purchase([
166242
'amount' => '12.00',
167243
'transactionId' => '1234566789205067',
168244
'currency' => 'AUD',
169245
'returnUrl' => 'http://example.com/payment/response',
170-
))
246+
])
171247
->send();
172248

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

186262
$gateway->setTestMode(true);
187263

188-
$response = $gateway->completePurchase(array(
264+
$response = $gateway->completePurchase([
189265
'amount' => '12.00',
190266
'transactionId' => '1234566789205067',
191-
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402'
267+
'transactionReference' => '11fc42b0-bb7a-41a4-8b3c-096b3fd4d402',
192268
'currency' => 'AUD',
193269
'returnUrl' => 'http://example.com/payment/response',
194-
))
270+
])
195271
->send();
196272

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

284+
## Framework-Agnostic Transport Option
285+
286+
Omnipay support remains the default behavior. SecureXML requests can now also use a framework-agnostic cURL transport:
287+
288+
```php
289+
use Omnipay\NABTransact\Transport\CurlTransport;
290+
291+
$request = $gateway->purchase([
292+
'amount' => '10.00',
293+
'transactionId' => 'ORDER-1000',
294+
'card' => $card,
295+
]);
296+
297+
$request->setTransport(new CurlTransport());
298+
$response = $request->send();
299+
```
300+
301+
DirectPost server-to-server operations (`capture`, `refund`, `void`, `createEMV3DSOrder`) can use the same transport injection pattern.
302+
303+
See `ARCHITECTURE.md` for design details and extension points.
304+
305+
## NAB Feature Coverage
306+
307+
Core payment features are mapped in `docs/feature-matrix.md` with request/response classes and test coverage.
308+
For a contributor-friendly package map, see `docs/features-implemented-tree.md`.
309+
This package targets payment-processing API coverage and does not include NAB admin/reporting portal features.
310+
208311
## Contributing
209312

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

224327
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/sudiptpa/nabtransact/issues),
225328
or better yet, fork the library and submit a pull request.
329+
330+
331+
## Architecture
332+
333+
See `ARCHITECTURE.md` for package structure, flow, and extension points.

0 commit comments

Comments
 (0)