Skip to content

Commit a898eb9

Browse files
committed
Code tidy, add makedoc and runtests scripts
1 parent 0dcf285 commit a898eb9

File tree

8 files changed

+265
-56
lines changed

8 files changed

+265
-56
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
composer.lock
33
composer.phar
44
phpunit.xml
5+
/.idea
6+
/documents
7+
.directory
8+
dirlist.app
9+
dirlist.cache
10+
dirlist.vendor

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
1010
processing library for PHP 5.3+. This package implements eWAY support for Omnipay.
1111

12+
[eWay](https://eway.io/about-eway) was launched in Australia in 1998 and now operates payment gateways
13+
in 8 countries.
14+
1215
## Installation
1316

1417
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
@@ -31,10 +34,19 @@ And run composer to update your dependencies:
3134

3235
The following gateways are provided by this package:
3336

34-
* Eway_Rapid
35-
* Eway_RapidShared
36-
* Eway_RapidDirect
37-
* Eway_Direct
37+
* Eway_Direct -- This gateway is deprecated. If you have existing code that uses it you can continue
38+
to do so but you should consider migrating to Eway_RapidDirect
39+
* Eway_RapidDirect -- This is the primary gateway used for direct card processing, i.e. where you collect the
40+
card details from the customer and pass them to eWay yourself via the API.
41+
* Eway_Rapid -- This is used for eWAY Rapid Transparent Redirect requests. The gateway is just
42+
called Eway_Rapid as it was the first implemented. Like other redirect gateways the purchase() call
43+
will return a redirect response and then requires you to redirect the customer to the eWay site for
44+
the actual purchase.
45+
* Eway_RapidShared -- This provides a hosted form for entering payment information, other than that
46+
it is similar to the Eway_Rapid gateway in functionality.
47+
48+
See the docblocks within the gateway classes for further information and links to the eWay gateway on
49+
line.
3850

3951
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
4052
repository.

makedoc.sh

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/bin/sh
2+
3+
#
4+
# Smart little documentation generator.
5+
# GPL/LGPL
6+
# (c) Del 2015 http://www.babel.com.au/
7+
#
8+
9+
APPNAME='Omnipay eWay Gateway Module'
10+
CMDFILE=apigen.cmd.$$
11+
DESTDIR=./documents
12+
13+
#
14+
# Find apigen, either in the path or as a local phar file
15+
#
16+
if [ -f apigen.phar ]; then
17+
APIGEN="php apigen.phar"
18+
19+
else
20+
APIGEN=`which apigen`
21+
if [ ! -f "$APIGEN" ]; then
22+
23+
# Search for phpdoc if apigen is not found.
24+
if [ -f phpDocumentor.phar ]; then
25+
PHPDOC="php phpDocumentor.phar"
26+
27+
else
28+
PHPDOC=`which phpdoc`
29+
if [ ! -f "$PHPDOC" ]; then
30+
echo "Neither apigen nor phpdoc is installed in the path or locally, please install one of them"
31+
echo "see http://www.apigen.org/ or http://www.phpdoc.org/"
32+
exit 1
33+
fi
34+
fi
35+
fi
36+
fi
37+
38+
#
39+
# As of version 4 of apigen need to use the generate subcommand
40+
#
41+
if [ ! -z "$APIGEN" ]; then
42+
APIGEN="$APIGEN generate"
43+
fi
44+
45+
#
46+
# Without any arguments this builds the entire system documentation,
47+
# making the cache file first if required.
48+
#
49+
if [ -z "$1" ]; then
50+
#
51+
# Check to see that the cache has been made.
52+
#
53+
if [ ! -f dirlist.cache ]; then
54+
echo "Making dirlist.cache file"
55+
$0 makecache
56+
fi
57+
58+
#
59+
# Build the apigen/phpdoc command in a file.
60+
#
61+
if [ ! -z "$APIGEN" ]; then
62+
echo "$APIGEN --php --tree --title '$APPNAME API Documentation' --destination $DESTDIR/main \\" > $CMDFILE
63+
cat dirlist.cache | while read dir; do
64+
echo "--source $dir \\" >> $CMDFILE
65+
done
66+
echo "" >> $CMDFILE
67+
68+
elif [ ! -z "$PHPDOC" ]; then
69+
echo "$PHPDOC --sourcecode --title '$APPNAME API Documentation' --target $DESTDIR/main --directory \\" > $CMDFILE
70+
cat dirlist.cache | while read dir; do
71+
echo "${dir},\\" >> $CMDFILE
72+
done
73+
echo "" >> $CMDFILE
74+
75+
else
76+
"Neither apigen nor phpdoc are found, how did I get here?"
77+
exit 1
78+
fi
79+
80+
#
81+
# Run the apigen command
82+
#
83+
rm -rf $DESTDIR/main
84+
mkdir -p $DESTDIR/main
85+
. ./$CMDFILE
86+
87+
/bin/rm -f ./$CMDFILE
88+
89+
#
90+
# The "makecache" argument causes the script to just make the cache file
91+
#
92+
elif [ "$1" = "makecache" ]; then
93+
echo "Find application source directories"
94+
find src -name \*.php -print | \
95+
(
96+
while read file; do
97+
grep -q 'class' $file && dirname $file
98+
done
99+
) | sort -u | \
100+
grep -v -E 'config|docs|migrations|phpunit|test|Test|views|web' > dirlist.app
101+
102+
echo "Find vendor source directories"
103+
find vendor -name \*.php -print | \
104+
(
105+
while read file; do
106+
grep -q 'class' $file && dirname $file
107+
done
108+
) | sort -u | \
109+
grep -v -E 'config|docs|migrations|phpunit|codesniffer|test|Test|views' > dirlist.vendor
110+
111+
#
112+
# Filter out any vendor directories for which apigen fails
113+
#
114+
echo "Filter source directories"
115+
mkdir -p $DESTDIR/tmp
116+
cat dirlist.app dirlist.vendor | while read dir; do
117+
if [ ! -z "$APIGEN" ]; then
118+
$APIGEN --quiet --title "Test please ignore" \
119+
--source $dir \
120+
--destination $DESTDIR/tmp && (
121+
echo "Including $dir"
122+
echo $dir >> dirlist.cache
123+
) || (
124+
echo "Excluding $dir"
125+
)
126+
127+
elif [ ! -z "$PHPDOC" ]; then
128+
$PHPDOC --quiet --title "Test please ignore" \
129+
--directory $dir \
130+
--target $DESTDIR/tmp && (
131+
echo "Including $dir"
132+
echo $dir >> dirlist.cache
133+
) || (
134+
echo "Excluding $dir"
135+
)
136+
137+
fi
138+
done
139+
echo "Documentation cache dirlist.cache built OK"
140+
141+
#
142+
# Clean up
143+
#
144+
/bin/rm -rf $DESTDIR/tmp
145+
146+
fi

runtests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
#
4+
# Command line runner for unit tests for composer projects
5+
# (c) Del 2015 http://www.babel.com.au/
6+
# No Rights Reserved
7+
#
8+
9+
#
10+
# Clean up after any previous test runs
11+
#
12+
mkdir -p documents
13+
rm -rf documents/coverage-html-new
14+
rm -f documents/coverage.xml
15+
16+
#
17+
# Run phpunit
18+
#
19+
vendor/bin/phpunit --coverage-html documents/coverage-html-new --coverage-clover documents/coverage.xml
20+
21+
if [ -d documents/coverage-html-new ]; then
22+
rm -rf documents/coverage-html
23+
mv documents/coverage-html-new documents/coverage-html
24+
fi
25+

src/DirectGateway.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* eWAY Legacy Direct XML Payments Gateway
44
*/
5-
5+
66
namespace Omnipay\Eway;
77

88
use Omnipay\Common\AbstractGateway;
@@ -15,6 +15,8 @@
1515
* NOTE: The APIs called by this gateway are older legacy APIs, new integrations should instead
1616
* use eWAY Rapid.
1717
*
18+
* Recent testing on this indicates that it no longer works -- perhaps we need to roll
19+
* back to an older code version to fix that?
1820
*/
1921
class DirectGateway extends AbstractGateway
2022
{

src/Message/DirectAbstractRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Omnipay\Eway\Message;
44

5-
use Omnipay\Common\Message\AbstractRequest;
5+
// use Omnipay\Common\Message\AbstractRequest;
66

77
/**
88
* eWAY Direct Abstract Request

src/Message/RapidDirectPurchaseRequest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* eWAY Rapid Direct Purchase Request
44
*/
5-
5+
66
namespace Omnipay\Eway\Message;
77

88
/**
@@ -13,8 +13,8 @@
1313
* eWAY Token (passed as the cardReference).
1414
*
1515
* Using Direct Connection to pass card details in the clear requires
16-
* proof of PCI compliance to eWAY. Alternatively they can be
17-
* encrypted using Client Side Encryption - in which case the card
16+
* proof of PCI compliance to eWAY. Alternatively they can be
17+
* encrypted using Client Side Encryption - in which case the card
1818
* number and CVN should be passed using the encryptedCardNumber and
1919
* encryptedCardCvv respectively (these are not in the CreditCard
2020
* object).
@@ -72,25 +72,25 @@ class RapidDirectPurchaseRequest extends RapidDirectAbstractRequest
7272
public function getData()
7373
{
7474
$data = $this->getBaseData();
75-
76-
$this->validate('amount', 'transactionType');
75+
76+
$this->validate('amount');
7777

7878
$data['Payment'] = array();
7979
$data['Payment']['TotalAmount'] = $this->getAmountInteger();
8080
$data['Payment']['InvoiceNumber'] = $this->getTransactionId();
8181
$data['Payment']['InvoiceDescription'] = $this->getDescription();
8282
$data['Payment']['CurrencyCode'] = $this->getCurrency();
8383
$data['Payment']['InvoiceReference'] = $this->getInvoiceReference();
84-
84+
8585
if ($this->getCardReference()) {
8686
$data['Method'] = 'TokenPayment';
8787
} else {
8888
$data['Method'] = 'ProcessPayment';
8989
}
90-
90+
9191
return $data;
9292
}
93-
93+
9494
/**
9595
* Get transaction endpoint.
9696
*

0 commit comments

Comments
 (0)