├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── composer.json ├── makedoc.sh ├── phpunit.xml.dist ├── runtests.sh ├── src ├── Gateway.php └── Message │ ├── Request.php │ └── Response.php └── tests └── GatewayTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.lock 3 | composer.phar 4 | phpunit.xml 5 | .directory 6 | .idea 7 | dirlist.app 8 | dirlist.cache 9 | dirlist.vendor 10 | /documents 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - '5.6' 5 | - '7.0' 6 | - '7.1' 7 | - '7.2' 8 | - nightly 9 | 10 | env: 11 | - COMMON_VERSION="^2.0" 12 | - COMMON_VERSION="^3.0" 13 | 14 | matrix: 15 | fast_finish: true 16 | exclude: 17 | - php: '7.2' 18 | env: COMMON_VERSION="^2.0" 19 | - php: nightly 20 | env: COMMON_VERSION="^2.0" 21 | allow_failures: 22 | - php: nightly 23 | 24 | install: 25 | - if [ "$COMMON_VERSION" != "" ]; then composer require "omnipay/common:$COMMON_VERSION" "omnipay/tests:$COMMON_VERSION" --no-update; fi; 26 | - if [ "$COMMON_VERSION" == "^2.0" ]; then composer require "squizlabs/php_codesniffer:^1" --no-update; else composer require "squizlabs/php_codesniffer:^3" --no-update; fi; 27 | - composer install -n 28 | 29 | before_script: 30 | # Disable test listener in PHP 5.6, when testing against v3 of omnipay/tests because mockery's v1 listener 31 | # is not compatible with PHPUnit v5.7 32 | - if [ "$TRAVIS_PHP_VERSION" == "5.6" ] && [ "$COMMON_VERSION" == "^3.0" ]; then sed -i '//,/<\/listeners>/d' ./phpunit.xml.dist; fi; 33 | 34 | script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Omnipay: Manual 2 | 3 | **Manual driver for the Omnipay PHP payment processing library** 4 | 5 | [![Build Status](https://travis-ci.org/thephpleague/omnipay-manual.png?branch=master)](https://travis-ci.org/thephpleague/omnipay-manual) 6 | [![Latest Stable Version](https://poser.pugx.org/omnipay/manual/version.png)](https://packagist.org/packages/omnipay/manual) 7 | [![Total Downloads](https://poser.pugx.org/omnipay/manual/d/total.png)](https://packagist.org/packages/omnipay/manual) 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 Manual 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/manual": "~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 | * Manual 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-manual/issues), 50 | or better yet, fork the library and submit a pull request. 51 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omnipay/manual", 3 | "type": "library", 4 | "description": "Manual driver for the Omnipay payment processing library", 5 | "keywords": [ 6 | "gateway", 7 | "manual", 8 | "merchant", 9 | "omnipay", 10 | "pay", 11 | "payment" 12 | ], 13 | "homepage": "https://github.com/thephpleague/omnipay-manual", 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-manual/contributors" 23 | } 24 | ], 25 | "autoload": { 26 | "psr-4": { "Omnipay\\Manual\\" : "src/" } 27 | }, 28 | "require": { 29 | "omnipay/common": "^2.0||^3.0" 30 | }, 31 | "require-dev": { 32 | "omnipay/tests": "^2.0||^3.0" 33 | }, 34 | "extra": { 35 | "branch-alias": { 36 | "dev-master": "3.0.x-dev" 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /makedoc.sh: -------------------------------------------------------------------------------- 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 Manual 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 147 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | ./src 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /runtests.sh: -------------------------------------------------------------------------------- 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 | 26 | -------------------------------------------------------------------------------- /src/Gateway.php: -------------------------------------------------------------------------------- 1 | initialize(array( 27 | * 'testMode' => true, // Or false. Doesn't matter. 28 | * )); 29 | * ``` 30 | * 31 | * #### Authorize 32 | * 33 | * 34 | * // Do a purchase transaction on the gateway 35 | * try { 36 | * $transaction = $gateway->authorize(array( 37 | * 'amount' => '10.00', 38 | * 'currency' => 'AUD', 39 | * 'description' => 'This is a test transaction.', 40 | * )); 41 | * $response = $transaction->send(); 42 | * $data = $response->getData(); 43 | * echo "Gateway authorize response data == " . print_r($data, true) . "\n"; 44 | * 45 | * if ($response->isSuccessful()) { 46 | * echo "Transaction was successful!\n"; 47 | * } 48 | * } catch (\Exception $e) { 49 | * echo "Exception caught while attempting authorize.\n"; 50 | * echo "Exception type == " . get_class($e) . "\n"; 51 | * echo "Message == " . $e->getMessage() . "\n"; 52 | * } 53 | * 54 | * 55 | * In reality, Manual Gateway authorize() requests will always be successful and 56 | * will never throw an exception, but the above example shows that you can treat 57 | * manual payments just like any other payment type for any other gateway. 58 | */ 59 | class Gateway extends AbstractGateway 60 | { 61 | public function getName() 62 | { 63 | return 'Manual'; 64 | } 65 | 66 | public function getDefaultParameters() 67 | { 68 | return array(); 69 | } 70 | 71 | public function authorize(array $parameters = array()) 72 | { 73 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 74 | } 75 | 76 | public function purchase(array $parameters = array()) 77 | { 78 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 79 | } 80 | 81 | public function completePurchase(array $parameters = array()) 82 | { 83 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 84 | } 85 | 86 | public function completeAuthorise(array $parameters = array()) 87 | { 88 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 89 | } 90 | 91 | public function capture(array $parameters = array()) 92 | { 93 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 94 | } 95 | 96 | public function void(array $parameters = array()) 97 | { 98 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 99 | } 100 | 101 | public function refund(array $parameters = array()) 102 | { 103 | return $this->createRequest('\Omnipay\Manual\Message\Request', $parameters); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/Message/Request.php: -------------------------------------------------------------------------------- 1 | validate('amount'); 18 | 19 | return $this->getParameters(); 20 | } 21 | 22 | public function sendData($data) 23 | { 24 | return $this->response = new Response($this, $data); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Message/Response.php: -------------------------------------------------------------------------------- 1 | gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); 14 | 15 | $this->options = array( 16 | 'amount' => 1000 17 | ); 18 | } 19 | 20 | public function testAuthorize() 21 | { 22 | $response = $this->gateway->authorize($this->options)->send(); 23 | 24 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 25 | $this->assertTrue($response->isSuccessful()); 26 | $this->assertFalse($response->isRedirect()); 27 | $this->assertNull($response->getTransactionReference()); 28 | $this->assertNull($response->getMessage()); 29 | } 30 | 31 | public function testCapture() 32 | { 33 | $response = $this->gateway->capture($this->options)->send(); 34 | 35 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 36 | $this->assertTrue($response->isSuccessful()); 37 | $this->assertFalse($response->isRedirect()); 38 | $this->assertNull($response->getTransactionReference()); 39 | $this->assertNull($response->getMessage()); 40 | } 41 | 42 | public function testVoid() 43 | { 44 | $response = $this->gateway->void($this->options)->send(); 45 | 46 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 47 | $this->assertTrue($response->isSuccessful()); 48 | $this->assertFalse($response->isRedirect()); 49 | $this->assertNull($response->getTransactionReference()); 50 | $this->assertNull($response->getMessage()); 51 | } 52 | 53 | public function testRefund() 54 | { 55 | $response = $this->gateway->refund($this->options)->send(); 56 | 57 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 58 | $this->assertTrue($response->isSuccessful()); 59 | $this->assertFalse($response->isRedirect()); 60 | $this->assertNull($response->getTransactionReference()); 61 | $this->assertNull($response->getMessage()); 62 | } 63 | 64 | public function testPurchase() 65 | { 66 | $response = $this->gateway->purchase($this->options)->send(); 67 | 68 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 69 | $this->assertTrue($response->isSuccessful()); 70 | $this->assertFalse($response->isRedirect()); 71 | $this->assertNull($response->getTransactionReference()); 72 | $this->assertNull($response->getMessage()); 73 | } 74 | 75 | public function testCompletePurchase() 76 | { 77 | $response = $this->gateway->completePurchase($this->options)->send(); 78 | 79 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 80 | $this->assertTrue($response->isSuccessful()); 81 | $this->assertFalse($response->isRedirect()); 82 | $this->assertNull($response->getTransactionReference()); 83 | $this->assertNull($response->getMessage()); 84 | } 85 | 86 | public function testCompleteAuthorise() 87 | { 88 | $response = $this->gateway->completeAuthorise($this->options)->send(); 89 | 90 | $this->assertInstanceOf('\Omnipay\Manual\Message\Response', $response); 91 | $this->assertTrue($response->isSuccessful()); 92 | $this->assertFalse($response->isRedirect()); 93 | $this->assertNull($response->getTransactionReference()); 94 | $this->assertNull($response->getMessage()); 95 | } 96 | } 97 | --------------------------------------------------------------------------------