From 945ffb1b3e0ccc4d7e08f2697ee6014ca4b8b345 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 1 Mar 2019 14:23:30 +1300 Subject: [PATCH 1/2] Enotice fix from composer update --- vendor/omnipay/paypal/src/Message/RestResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/omnipay/paypal/src/Message/RestResponse.php b/vendor/omnipay/paypal/src/Message/RestResponse.php index e344a60e4..9cb30e3e3 100644 --- a/vendor/omnipay/paypal/src/Message/RestResponse.php +++ b/vendor/omnipay/paypal/src/Message/RestResponse.php @@ -89,7 +89,7 @@ public function getCardReference() public function isPaypalApproval() { - if (!isset($this->data['payer']['payment_method'])) { + if (!isset($this->data['payer']['payment_method']) || !isset($this->data['funding_instruments'])) { return false; } return ($this->data['payer']['payment_method'] === 'paypal'); From 725a10f6760e43c679a0d5cbd22704d0f83d5479 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 1 Mar 2019 14:37:02 +1300 Subject: [PATCH 2/2] Add NMI --- Metadata/omnipay_NMI_Direct.mgd.php | 51 +++ composer.json | 7 +- composer.lock | 50 ++- vendor/composer/autoload_psr4.php | 1 + vendor/composer/autoload_static.php | 5 + vendor/composer/installed.json | 49 +++ vendor/nerdmedia/omnipay-nmi/.gitignore | 5 + vendor/nerdmedia/omnipay-nmi/.travis.yml | 21 + vendor/nerdmedia/omnipay-nmi/CONTRIBUTING.md | 10 + vendor/nerdmedia/omnipay-nmi/LICENSE | 22 + vendor/nerdmedia/omnipay-nmi/README.md | 58 +++ vendor/nerdmedia/omnipay-nmi/composer.json | 36 ++ vendor/nerdmedia/omnipay-nmi/phpunit.xml.dist | 25 ++ .../omnipay-nmi/src/DirectPostGateway.php | 390 ++++++++++++++++++ .../src/Message/AbstractRequest.php | 348 ++++++++++++++++ .../src/Message/DirectPostAuthRequest.php | 129 ++++++ .../src/Message/DirectPostCaptureRequest.php | 24 ++ .../Message/DirectPostCreateCardRequest.php | 33 ++ .../src/Message/DirectPostCreditRequest.php | 10 + .../Message/DirectPostDeleteCardRequest.php | 22 + .../src/Message/DirectPostRefundRequest.php | 10 + .../src/Message/DirectPostResponse.php | 108 +++++ .../src/Message/DirectPostSaleRequest.php | 10 + .../Message/DirectPostUpdateCardRequest.php | 11 + .../src/Message/DirectPostVoidRequest.php | 20 + .../ThreeStepRedirectAbstractRequest.php | 342 +++++++++++++++ .../Message/ThreeStepRedirectAuthRequest.php | 129 ++++++ .../ThreeStepRedirectCaptureRequest.php | 49 +++ ...ThreeStepRedirectCompleteActionRequest.php | 29 ++ .../ThreeStepRedirectCreateCardRequest.php | 35 ++ .../ThreeStepRedirectCreditRequest.php | 14 + .../ThreeStepRedirectDeleteCardRequest.php | 30 ++ .../ThreeStepRedirectRefundRequest.php | 14 + .../src/Message/ThreeStepRedirectResponse.php | 116 ++++++ .../Message/ThreeStepRedirectSaleRequest.php | 14 + .../ThreeStepRedirectUpdateCardRequest.php | 28 ++ .../Message/ThreeStepRedirectVoidRequest.php | 45 ++ .../src/ThreeStepRedirectGateway.php | 171 ++++++++ .../DirectPostGatewayIntegrationTest.php | 91 ++++ .../tests/DirectPostGatewayTest.php | 231 +++++++++++ .../tests/Message/DirectPostResponseTest.php | 38 ++ .../tests/Mock/DirectPostAuthFailure.txt | 8 + .../tests/Mock/DirectPostAuthSuccess.txt | 8 + .../tests/Mock/DirectPostCaptureFailure.txt | 8 + .../tests/Mock/DirectPostCaptureSuccess.txt | 8 + .../Mock/DirectPostCreateCardFailure.txt | 7 + .../Mock/DirectPostCreateCardSuccess.txt | 7 + .../tests/Mock/DirectPostCreditFailure.txt | 8 + .../tests/Mock/DirectPostCreditSuccess.txt | 8 + .../Mock/DirectPostDeleteCardFailure.txt | 7 + .../Mock/DirectPostDeleteCardSuccess.txt | 7 + .../tests/Mock/DirectPostRefundFailure.txt | 8 + .../tests/Mock/DirectPostRefundSuccess.txt | 8 + .../tests/Mock/DirectPostSaleFailure.txt | 8 + .../tests/Mock/DirectPostSaleSuccess.txt | 8 + .../Mock/DirectPostUpdateCardFailure.txt | 7 + .../Mock/DirectPostUpdateCardSuccess.txt | 7 + .../tests/Mock/DirectPostVoidFailure.txt | 8 + .../tests/Mock/DirectPostVoidSuccess.txt | 8 + 59 files changed, 2967 insertions(+), 2 deletions(-) create mode 100644 Metadata/omnipay_NMI_Direct.mgd.php create mode 100644 vendor/nerdmedia/omnipay-nmi/.gitignore create mode 100644 vendor/nerdmedia/omnipay-nmi/.travis.yml create mode 100644 vendor/nerdmedia/omnipay-nmi/CONTRIBUTING.md create mode 100644 vendor/nerdmedia/omnipay-nmi/LICENSE create mode 100644 vendor/nerdmedia/omnipay-nmi/README.md create mode 100644 vendor/nerdmedia/omnipay-nmi/composer.json create mode 100644 vendor/nerdmedia/omnipay-nmi/phpunit.xml.dist create mode 100644 vendor/nerdmedia/omnipay-nmi/src/DirectPostGateway.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/AbstractRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostAuthRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCaptureRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreateCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreditRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostDeleteCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostRefundRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostResponse.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostSaleRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostUpdateCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostVoidRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAbstractRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAuthRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCaptureRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCompleteActionRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreateCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreditRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectDeleteCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectRefundRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectResponse.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectSaleRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectUpdateCardRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectVoidRequest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/src/ThreeStepRedirectGateway.php create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayIntegrationTest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayTest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Message/DirectPostResponseTest.php create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardSuccess.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidFailure.txt create mode 100644 vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidSuccess.txt diff --git a/Metadata/omnipay_NMI_Direct.mgd.php b/Metadata/omnipay_NMI_Direct.mgd.php new file mode 100644 index 000000000..7e0ff90b2 --- /dev/null +++ b/Metadata/omnipay_NMI_Direct.mgd.php @@ -0,0 +1,51 @@ + 'Api Key' (you might ? be able to get away with 'API Key' - need to check). You can provide as many or as + * few as you want of these and it's irrelevant which field you put them in but note that the signature field is the longest and that + * in future versions of CiviCRM hashing may be done on password and signature on the screen. + * + * - 'class_name' => 'Payment_OmnipayMultiProcessor', (always) + * + * - 'url_site_default' - this is ignored. But, by giving one you make it easier for people adding processors + * + * - 'billing_mode' - 1 = onsite, 4 = redirect offsite (including transparent redirects). + * + * - payment_mode - 1 = credit card, 2 = debit card, 3 = transparent redirect. In practice 3 means that billing details are gathered on-site so + * it may also be used with automatic redirects where address fields need to be mandatory for the signature. + * + * The record will be automatically inserted, updated, or deleted from the + * database as appropriate. For more details, see "hook_civicrm_managed" at: + * http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference + */ +return [ + [ + 'name' => 'OmniPay - NMI_DirectPost"', + 'entity' => 'payment_processor_type', + 'params' => [ + 'version' => 3, + 'title' => 'OmniPay - NMI', + 'name' => 'omnipay_NMI_DirectPost', + 'user_name_label' => 'username', + 'password_label' => 'password', + 'description' => 'NMI (Network Merchants Inc.) driver for the Omnipay PHP payment processing library', + 'class_name' => 'Payment_OmnipayMultiProcessor', + 'billing_mode' => 1, + ], + ], +]; diff --git a/composer.json b/composer.json index 53aaa6d09..dc9fb14ca 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,10 @@ { "type": "git", "url": "https://github.com/eileenmcnaughton/omnipay-paypal.git" + }, + { + "type": "git", + "url": "https://github.com/nerdmedia/omnipay-nmi.git" } ], @@ -31,7 +35,8 @@ "omnipay/common": "^3.0@dev", "dioscouri/omnipay-cybersource": "^3.0@dev", "fuzion/omnipay-mercanet": "^3.0@dev", - "razorpay/omnipay-razorpay": "^3.0@dev" + "razorpay/omnipay-razorpay": "^3.0@dev", + "nerdmedia/omnipay-nmi": "^3.0@dev" }, "require-dev": { "phpunit/phpunit": "5.7", diff --git a/composer.lock b/composer.lock index 8a8904dc1..93f36c53a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "086a2f642f40ad919e31d302d118d303", + "content-hash": "8ae90ec5c284dfa92264ed103a22c966", "packages": [ { "name": "clue/stream-filter", @@ -492,6 +492,53 @@ ], "time": "2019-02-07T18:01:35+00:00" }, + { + "name": "nerdmedia/omnipay-nmi", + "version": "3.04", + "source": { + "type": "git", + "url": "https://github.com/nerdmedia/omnipay-nmi.git", + "reference": "0d8ae95698b586fbd35b69bee5230853007d6aa7" + }, + "require": { + "league/omnipay": "^3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Omnipay\\NMI\\": "src/" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Steve Bazemore", + "email": "steve@nerdmedia.com" + } + ], + "description": "NMI (Network Merchants Inc.) driver for the Omnipay PHP payment processing library", + "homepage": "https://github.com/nerdmedia/omnipay-nmi", + "keywords": [ + "durango", + "gateway", + "inc", + "merchant", + "network", + "nmi", + "omnipay", + "pay", + "payment", + "purchase" + ], + "time": "2018-12-05T20:04:47+00:00" + }, { "name": "omnipay/authorizenet", "version": "3.2.0", @@ -3591,6 +3638,7 @@ "dioscouri/omnipay-cybersource": 20, "fuzion/omnipay-mercanet": 20, "razorpay/omnipay-razorpay": 20, + "nerdmedia/omnipay-nmi": 20, "omnipay/tests": 20 }, "prefer-stable": false, diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 57b3da5eb..373ad8f1e 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -24,6 +24,7 @@ 'Omnipay\\Razorpay\\' => array($vendorDir . '/razorpay/omnipay-razorpay/src'), 'Omnipay\\PaymentExpress\\' => array($vendorDir . '/omnipay/paymentexpress/src'), 'Omnipay\\PayPal\\' => array($vendorDir . '/omnipay/paypal/src'), + 'Omnipay\\NMI\\' => array($vendorDir . '/nerdmedia/omnipay-nmi/src'), 'Omnipay\\NABTransact\\' => array($vendorDir . '/sudiptpa/omnipay-nabtransact/src'), 'Omnipay\\Mollie\\' => array($vendorDir . '/omnipay/mollie/src'), 'Omnipay\\Mercanet\\' => array($vendorDir . '/fuzion/omnipay-mercanet/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 35eccb95d..73e903437 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -51,6 +51,7 @@ class ComposerStaticInit7c7bccbe7d16fd96ad45f827acd06a81 'Omnipay\\Razorpay\\' => 17, 'Omnipay\\PaymentExpress\\' => 23, 'Omnipay\\PayPal\\' => 15, + 'Omnipay\\NMI\\' => 12, 'Omnipay\\NABTransact\\' => 20, 'Omnipay\\Mollie\\' => 15, 'Omnipay\\Mercanet\\' => 17, @@ -165,6 +166,10 @@ class ComposerStaticInit7c7bccbe7d16fd96ad45f827acd06a81 array ( 0 => __DIR__ . '/..' . '/omnipay/paypal/src', ), + 'Omnipay\\NMI\\' => + array ( + 0 => __DIR__ . '/..' . '/nerdmedia/omnipay-nmi/src', + ), 'Omnipay\\NABTransact\\' => array ( 0 => __DIR__ . '/..' . '/sudiptpa/omnipay-nabtransact/src', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 36ce67566..85f29224b 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -720,6 +720,55 @@ "object graph" ] }, + { + "name": "nerdmedia/omnipay-nmi", + "version": "3.04", + "version_normalized": "3.04.0.0", + "source": { + "type": "git", + "url": "https://github.com/nerdmedia/omnipay-nmi.git", + "reference": "0d8ae95698b586fbd35b69bee5230853007d6aa7" + }, + "require": { + "league/omnipay": "^3" + }, + "time": "2018-12-05T20:04:47+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "installation-source": "source", + "autoload": { + "psr-4": { + "Omnipay\\NMI\\": "src/" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Steve Bazemore", + "email": "steve@nerdmedia.com" + } + ], + "description": "NMI (Network Merchants Inc.) driver for the Omnipay PHP payment processing library", + "homepage": "https://github.com/nerdmedia/omnipay-nmi", + "keywords": [ + "durango", + "gateway", + "inc", + "merchant", + "network", + "nmi", + "omnipay", + "pay", + "payment", + "purchase" + ] + }, { "name": "omnipay/authorizenet", "version": "3.2.0", diff --git a/vendor/nerdmedia/omnipay-nmi/.gitignore b/vendor/nerdmedia/omnipay-nmi/.gitignore new file mode 100644 index 000000000..1f4733d23 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/.gitignore @@ -0,0 +1,5 @@ +/vendor +composer.lock +composer.phar +phpunit.xml +.idea \ No newline at end of file diff --git a/vendor/nerdmedia/omnipay-nmi/.travis.yml b/vendor/nerdmedia/omnipay-nmi/.travis.yml new file mode 100644 index 000000000..ca0329fab --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/.travis.yml @@ -0,0 +1,21 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +env: + - SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.1" + - SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.1" + - SYMFONY_VERSION="2.1" GUZZLE_VERSION="3.*" + - SYMFONY_VERSION="2.*" GUZZLE_VERSION="3.*" + +before_script: + - composer self-update + - composer --version + - composer require symfony/http-foundation:${SYMFONY_VERSION} --no-update + - composer require guzzle/http:${GUZZLE_VERSION} --no-update + - composer install -n --dev --prefer-source + +script: vendor/bin/phpcs --standard=PSR2 src && vendor/bin/phpunit --coverage-text diff --git a/vendor/nerdmedia/omnipay-nmi/CONTRIBUTING.md b/vendor/nerdmedia/omnipay-nmi/CONTRIBUTING.md new file mode 100644 index 000000000..5083db09d --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Contributing Guidelines + +* Fork the project. +* Make your feature addition or bug fix. +* Add tests for it. This is important so I don't break it in a future version unintentionally. +* Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files. +* 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) +style and that all tests pass. +* Send the pull request. +* Check that the Travis CI build passed. If not, rinse and repeat. diff --git a/vendor/nerdmedia/omnipay-nmi/LICENSE b/vendor/nerdmedia/omnipay-nmi/LICENSE new file mode 100644 index 000000000..6d3df317f --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Matthieu Fauveau + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/nerdmedia/omnipay-nmi/README.md b/vendor/nerdmedia/omnipay-nmi/README.md new file mode 100644 index 000000000..ec99c62c1 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/README.md @@ -0,0 +1,58 @@ +# Omnipay: NMI (Network Merchants Inc.) + +**NMI (Network Merchants Inc.) driver for the Omnipay PHP payment processing library** + +[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment +processing library for PHP 5.3+. This package implements [NMI](https://www.nmi.com/) (Network Merchants Inc.) support for Omnipay. + +## Installation + +Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply require `nerdmedia/omnipay-nmi` with Composer: + +``` +composer require nerdmedia/omnipay-nmi:"3.x@dev" +``` + +## Basic Usage + +The following gateways are provided by this package: + +* NMI_DirectPost + +```php +$gateway = Omnipay::create('NMI_DirectPost'); +$gateway->setUsername('demo'); +$gateway->setPassword('password'); + +$request = $gateway->purchase([ + 'amount' => $amount, + 'card' => [ + 'number' => '4111111111111111', + 'expiryMonth' => '10', + 'expiryYear' => '25', + 'cvv' => '111' + ], + ... +])->send(); + +if ($response->isSuccessful()) { + // payment was successful: update database + dump($response); +} else { + // payment failed: display message to customer + dump('Error: ' . $response->getMessage()); +} +``` + +## Support + +If you are having general issues with Omnipay, we suggest posting on +[Stack Overflow](http://stackoverflow.com/). Be sure to add the +[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. + +If you want to keep up to date with release anouncements, discuss ideas for the project, +or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which +you can subscribe to. + +If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-authorizenet/issues), +or better yet, fork the library and submit a pull request. \ No newline at end of file diff --git a/vendor/nerdmedia/omnipay-nmi/composer.json b/vendor/nerdmedia/omnipay-nmi/composer.json new file mode 100644 index 000000000..8d6eadeb5 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/composer.json @@ -0,0 +1,36 @@ +{ + "name": "nerdmedia/omnipay-nmi", + "type": "library", + "description": "NMI (Network Merchants Inc.) driver for the Omnipay PHP payment processing library", + "keywords": [ + "gateway", + "merchant", + "omnipay", + "pay", + "payment", + "purchase", + "nmi", + "durango", + "network", + "inc" + ], + "homepage": "https://github.com/nerdmedia/omnipay-nmi", + "license": "MIT", + "authors": [ + { + "name": "Steve Bazemore", + "email": "steve@nerdmedia.com" + } + ], + "autoload": { + "psr-4": { "Omnipay\\NMI\\" : "src/" } + }, + "require": { + "league/omnipay": "^3" + }, + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/phpunit.xml.dist b/vendor/nerdmedia/omnipay-nmi/phpunit.xml.dist new file mode 100644 index 000000000..8a4bfc614 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + ./tests/ + + + + + + + + ./src + + + diff --git a/vendor/nerdmedia/omnipay-nmi/src/DirectPostGateway.php b/vendor/nerdmedia/omnipay-nmi/src/DirectPostGateway.php new file mode 100644 index 000000000..affc84a66 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/DirectPostGateway.php @@ -0,0 +1,390 @@ + '', + 'password' => '' + ); + } + + /** + * @return string + */ + public function getUsername() + { + return $this->getParameter('username'); + } + + /** + * @param string $value + * @return $this + */ + public function setUsername($value) + { + return $this->setParameter('username', $value); + } + + /** + * @return string + */ + public function getPassword() + { + return $this->getParameter('password'); + } + + /** + * @param string $value + * @return $this + */ + public function setPassword($value) + { + return $this->setParameter('password', $value); + } + + /** + * @return string + */ + public function getProcessorId() + { + return $this->getParameter('processor_id'); + } + + /** + * @param string $value + * @return $this + */ + public function setProcessorId($value) + { + return $this->setParameter('processor_id', $value); + } + + /** + * @return string + */ + public function getAuthorizationCode() + { + return $this->getParameter('authorization_code'); + } + + /** + * @param string $value + * @return $this + */ + public function setAuthorizationCode($value) + { + return $this->setParameter('authorization_code', $value); + } + + /** + * @return string + */ + public function getDescriptor() + { + return $this->getParameter('descriptor'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptor($value) + { + return $this->setParameter('descriptor', $value); + } + + /** + * @return string + */ + public function getDescriptorPhone() + { + return $this->getParameter('descriptor_phone'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorPhone($value) + { + return $this->setParameter('descriptor_phone', $value); + } + + /** + * @return string + */ + public function getDescriptorAddress() + { + return $this->getParameter('descriptor_address'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorAddress($value) + { + return $this->setParameter('descriptor_address', $value); + } + + /** + * @return string + */ + public function getDescriptorCity() + { + return $this->getParameter('descriptor_city'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorCity($value) + { + return $this->setParameter('descriptor_city', $value); + } + + /** + * @return string + */ + public function getDescriptorState() + { + return $this->getParameter('descriptor_state'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorState($value) + { + return $this->setParameter('descriptor_state', $value); + } + + /** + * @return string + */ + public function getDescriptorPostal() + { + return $this->getParameter('descriptor_postal'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorPostal($value) + { + return $this->setParameter('descriptor_postal', $value); + } + + /** + * @return string + */ + public function getDescriptorCountry() + { + return $this->getParameter('descriptor_country'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorCountry($value) + { + return $this->setParameter('descriptor_country', $value); + } + + /** + * @return string + */ + public function getDescriptorMcc() + { + return $this->getParameter('descriptor_mcc'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorMcc($value) + { + return $this->setParameter('descriptor_mcc', $value); + } + + /** + * @return string + */ + public function getDescriptorMerchantId() + { + return $this->getParameter('descriptor_merchant_id'); + } + + /** + * @param string $value + * @return $this + */ + public function setDescriptorMerchantId($value) + { + return $this->setParameter('descriptor_merchant_id', $value); + } + + /** + * @return string + */ + public function getDescriptorUrl() + { + return $this->getParameter('descriptor_url'); + } + + public function setDescriptorUrl($value) + { + return $this->setParameter('descriptor_url', $value); + } + + /** + * @return string + */ + public function getEndpoint() + { + return $this->endpoint; + } + + /** + * @param string $value + * @return $this + */ + public function setEndpoint($value) + { + return $this->setParameter('endpoint', $value); + } + + public function purchase(array $parameters = array()) + { + return $this->sale($parameters); + } + + public function authorize(array $parameters = array()) + { + return $this->auth($parameters); + } + + /** + * Transaction sales are submitted and immediately flagged for settlement. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostSaleRequest + */ + public function sale(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostSaleRequest', $parameters); + } + + /** + * Transaction authorizations are authorized immediately but are not flagged + * for settlement. These transactions must be flagged for settlement using + * the capture transaction type. Authorizations typically remain active for + * three to seven business days. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostAuthRequest + */ + public function auth(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostAuthRequest', $parameters); + } + + /** + * Transaction captures flag existing authorizations for settlement. + * Only authorizations can be captured. Captures can be submitted for an + * amount equal to or less than the original authorization. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostCaptureRequest + */ + public function capture(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostCaptureRequest', $parameters); + } + + /** + * Transaction voids will cancel an existing sale or captured authorization. + * In addition, non-captured authorizations can be voided to prevent any + * future capture. Voids can only occur if the transaction has not been settled. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostVoidRequest + */ + public function void(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostVoidRequest', $parameters); + } + + /** + * Transaction refunds will reverse a previously settled transaction. If the + * transaction has not been settled, it must be voided instead of refunded. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostRefundRequest + */ + public function refund(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostRefundRequest', $parameters); + } + + /** + * Transaction credits apply an amount to the cardholder's card that was not + * originally processed through the Gateway. In most situations credits are + * disabled as transaction refunds should be used instead. + * @param array $parameters + * @return \Omnipay\NMI\Message\DirectPostCreditRequest + */ + public function credit(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostCreditRequest', $parameters); + } + + /** + * @param array $parameters + * @return \Omnipay\NMI\Message\CreateCardRequest + */ + public function createCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostCreateCardRequest', $parameters); + } + + /** + * @param array $parameters + * @return \Omnipay\NMI\Message\UpdateCardRequest + */ + public function updateCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostUpdateCardRequest', $parameters); + } + + /** + * @param array $parameters + * @return \Omnipay\NMI\Message\DeleteCardRequest + */ + public function deleteCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\DirectPostDeleteCardRequest', $parameters); + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/AbstractRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/AbstractRequest.php new file mode 100644 index 000000000..d2c24c3a8 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/AbstractRequest.php @@ -0,0 +1,348 @@ +getParameter('username'); + } + + public function setUsername($value) + { + return $this->setParameter('username', $value); + } + + public function getPassword() + { + return $this->getParameter('password'); + } + + public function setPassword($value) + { + return $this->setParameter('password', $value); + } + + public function getProcessorId() + { + return $this->getParameter('processor_id'); + } + + public function setProcessorId($value) + { + return $this->setParameter('processor_id', $value); + } + + public function getAuthorizationCode() + { + return $this->getParameter('authorization_code'); + } + + public function setAuthorizationCode($value) + { + return $this->setParameter('authorization_code', $value); + } + + public function getDescriptor() + { + return $this->getParameter('descriptor'); + } + + public function setDescriptor($value) + { + return $this->setParameter('descriptor', $value); + } + + public function getDescriptorPhone() + { + return $this->getParameter('descriptor_phone'); + } + + public function setDescriptorPhone($value) + { + return $this->setParameter('descriptor_phone', $value); + } + + public function getDescriptorAddress() + { + return $this->getParameter('descriptor_address'); + } + + public function setDescriptorAddress($value) + { + return $this->setParameter('descriptor_address', $value); + } + + public function getDescriptorCity() + { + return $this->getParameter('descriptor_city'); + } + + public function setDescriptorCity($value) + { + return $this->setParameter('descriptor_city', $value); + } + + public function getDescriptorState() + { + return $this->getParameter('descriptor_state'); + } + + public function setDescriptorState($value) + { + return $this->setParameter('descriptor_state', $value); + } + + public function getDescriptorPostal() + { + return $this->getParameter('descriptor_postal'); + } + + public function setDescriptorPostal($value) + { + return $this->setParameter('descriptor_postal', $value); + } + + public function getDescriptorCountry() + { + return $this->getParameter('descriptor_country'); + } + + public function setDescriptorCountry($value) + { + return $this->setParameter('descriptor_country', $value); + } + + public function getDescriptorMcc() + { + return $this->getParameter('descriptor_mcc'); + } + + public function setDescriptorMcc($value) + { + return $this->setParameter('descriptor_mcc', $value); + } + + public function getDescriptorMerchantId() + { + return $this->getParameter('descriptor_merchant_id'); + } + + public function setDescriptorMerchantId($value) + { + return $this->setParameter('descriptor_merchant_id', $value); + } + + public function getDescriptorUrl() + { + return $this->getParameter('descriptor_url'); + } + + public function setDescriptorUrl($value) + { + return $this->setParameter('descriptor_url', $value); + } + + public function getOrderId() + { + return $this->getParameter('orderid'); + } + + public function setOrderId($value) + { + return $this->setParameter('orderid', $value); + } + + public function getOrderDescription() + { + return $this->getParameter('orderdescription'); + } + + public function setOrderDescription($value) + { + return $this->setParameter('orderdescription', $value); + } + + public function getTax() + { + return $this->getParameter('tax'); + } + + public function setTax($value) + { + return $this->setParameter('tax', $value); + } + + public function getShipping() + { + return $this->getParameter('shipping'); + } + + public function setShipping($value) + { + return $this->setParameter('shipping', $value); + } + + public function getPONumber() + { + return $this->getParameter('ponumber'); + } + + public function setPONumber($value) + { + return $this->setParameter('ponumber', $value); + } + + protected function getBaseData() + { + $data = array(); + + if (isset($this->type)) { + $data['type'] = $this->type; + } + + if (isset($this->customer_vault)) { + $data['customer_vault'] = $this->customer_vault; + } + + $data['username'] = $this->getUsername(); + $data['password'] = $this->getPassword(); + + if ($this->getProcessorId()) { + $data['processor_id'] = $this->getProcessorId(); + } + + if ($this->getAuthorizationCode()) { + $data['authorization_code'] = $this->getAuthorizationCode(); + } + + if ($this->getDescriptor()) { + $data['descriptor'] = $this->getDescriptor(); + } + + if ($this->getDescriptorPhone()) { + $data['descriptor_phone'] = $this->getDescriptorPhone(); + } + + if ($this->getDescriptorAddress()) { + $data['descriptor_address'] = $this->getDescriptorAddress(); + } + + if ($this->getDescriptorCity()) { + $data['descriptor_city'] = $this->getDescriptorCity(); + } + + if ($this->getDescriptorState()) { + $data['descriptor_state'] = $this->getDescriptorState(); + } + + if ($this->getDescriptorPostal()) { + $data['descriptor_postal'] = $this->getDescriptorPostal(); + } + + if ($this->getDescriptorCountry()) { + $data['descriptor_country'] = $this->getDescriptorCountry(); + } + + if ($this->getDescriptorMcc()) { + $data['descriptor_mcc'] = $this->getDescriptorMcc(); + } + + if ($this->getDescriptorMerchantId()) { + $data['descriptor_merchant_id'] = $this->getDescriptorMerchantId(); + } + + if ($this->getDescriptorUrl()) { + $data['descriptor_url'] = $this->getDescriptorUrl(); + } + + return $data; + } + + protected function getOrderData() + { + $data = array(); + + $data['orderid'] = $this->getOrderId(); + $data['orderdescription'] = $this->getOrderDescription(); + $data['tax'] = $this->getTax(); + $data['shipping'] = $this->getShipping(); + $data['ponumber'] = $this->getPONumber(); + $data['ipaddress'] = $this->getClientIp(); + if ($this->getCurrency()) { + $data['currency'] = $this->getCurrency(); + } + + return $data; + } + + protected function getBillingData() + { + $data = array(); + + if ($card = $this->getCard()) { + $data['firstname'] = $card->getBillingFirstName(); + $data['lastname'] = $card->getBillingLastName(); + $data['company'] = $card->getBillingCompany(); + $data['address1'] = $card->getBillingAddress1(); + $data['address2'] = $card->getBillingAddress2(); + $data['city'] = $card->getBillingCity(); + $data['state'] = $card->getBillingState(); + $data['zip'] = $card->getBillingPostcode(); + $data['country'] = $card->getBillingCountry(); + $data['phone'] = $card->getBillingPhone(); + $data['fax'] = $card->getBillingFax(); + $data['email'] = $card->getEmail(); + // $data['website'] = $card->getWebsite(); + } + + return $data; + } + + protected function getShippingData() + { + $data = array(); + + if ($card = $this->getCard()) { + $data['shipping_firstname'] = $card->getShippingFirstName(); + $data['shipping_lastname'] = $card->getShippingLastName(); + $data['shipping_company'] = $card->getShippingCompany(); + $data['shipping_address1'] = $card->getShippingAddress1(); + $data['shipping_address2'] = $card->getShippingAddress2(); + $data['shipping_city'] = $card->getShippingCity(); + $data['shipping_state'] = $card->getShippingState(); + $data['shipping_zip'] = $card->getShippingPostcode(); + $data['shipping_country'] = $card->getShippingCountry(); + $data['shipping_email'] = $card->getEmail(); + } + + return $data; + } + + public function sendData($data) + { + $httpResponse = $this->httpClient->request( + 'POST', + $this->getEndpoint(), + ['Content-Type' => 'application/x-www-form-urlencoded'], + http_build_query($data, '', '&') + ); + + return $this->response = new DirectPostResponse($this, $httpResponse->getBody()->getContents()); + } + + public function setEndpoint($value) + { + return $this->setParameter('endpoint', $value); + } + + public function getEndpoint() + { + return $this->endpoint; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostAuthRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostAuthRequest.php new file mode 100644 index 000000000..825c9d15a --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostAuthRequest.php @@ -0,0 +1,129 @@ +getParameter('merchant_defined_field_1'); + } + + /** + * Sets the first merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField1($value) + { + return $this->setParameter('merchant_defined_field_1', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField2() + { + return $this->getParameter('merchant_defined_field_2'); + } + + /** + * Sets the second merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField2($value) + { + return $this->setParameter('merchant_defined_field_2', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField3() + { + return $this->getParameter('merchant_defined_field_3'); + } + + /** + * Sets the third merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField3($value) + { + return $this->setParameter('merchant_defined_field_3', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField4() + { + return $this->getParameter('merchant_defined_field_4'); + } + + /** + * Sets the fourth merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField4($value) + { + return $this->setParameter('merchant_defined_field_4', $value); + } + + public function getData() + { + $this->validate('amount'); + + $data = $this->getBaseData(); + $data['amount'] = $this->getAmount(); + + if ($this->getMerchantDefinedField1()) { + $data['merchant_defined_field_1'] = $this->getMerchantDefinedField1(); + } + + if ($this->getMerchantDefinedField2()) { + $data['merchant_defined_field_2'] = $this->getMerchantDefinedField2(); + } + + if ($this->getMerchantDefinedField3()) { + $data['merchant_defined_field_3'] = $this->getMerchantDefinedField3(); + } + + if ($this->getMerchantDefinedField4()) { + $data['merchant_defined_field_4'] = $this->getMerchantDefinedField4(); + } + + if ($this->getCardReference()) { + $data['customer_vault_id'] = $this->getCardReference(); + + return $data; + } else { + $this->getCard()->validate(); + + $data['ccnumber'] = $this->getCard()->getNumber(); + $data['ccexp'] = $this->getCard()->getExpiryDate('my'); + $data['cvv'] = $this->getCard()->getCvv(); + + return array_merge( + $data, + $this->getOrderData(), + $this->getBillingData(), + $this->getShippingData() + ); + } + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCaptureRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCaptureRequest.php new file mode 100644 index 000000000..4c53f3ab9 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCaptureRequest.php @@ -0,0 +1,24 @@ +validate('transactionReference'); + + $data = $this->getBaseData(); + $data['transactionid'] = $this->getTransactionReference(); + + if ($this->getAmount() > 0) { + $data['amount'] = $this->getAmount(); + } + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreateCardRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreateCardRequest.php new file mode 100644 index 000000000..4c29a6057 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreateCardRequest.php @@ -0,0 +1,33 @@ +validate('card'); + $this->getCard()->validate(); + + $data = $this->getBaseData(); + + $data['ccnumber'] = $this->getCard()->getNumber(); + $data['ccexp'] = $this->getCard()->getExpiryDate('my'); + $data['payment'] = 'creditcard'; + + if ('update_customer' === $this->customer_vault) { + $data['customer_vault_id'] = $this->getCardReference(); + } + + return array_merge( + $data, + $this->getBillingData(), + $this->getShippingData() + ); + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreditRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreditRequest.php new file mode 100644 index 000000000..bf73d9ed6 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostCreditRequest.php @@ -0,0 +1,10 @@ +validate('cardReference'); + + $data = $this->getBaseData(); + + $data['customer_vault_id'] = $this->getCardReference(); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostRefundRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostRefundRequest.php new file mode 100644 index 000000000..c25f870e7 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostRefundRequest.php @@ -0,0 +1,10 @@ +request = $request; + parse_str($data, $this->data); + } + + public function isSuccessful() + { + return '1' === $this->getCode(); + } + + public function getCode() + { + return trim($this->data['response']); + } + + public function getResponseCode() + { + return trim($this->data['response_code']); + } + + public function getMessage() + { + return trim($this->data['responsetext']); + } + + public function getAuthorizationCode() + { + return trim($this->data['authcode']); + } + + public function getAVSResponse() + { + return trim($this->data['avsresponse']); + } + + public function getCVVResponse() + { + return trim($this->data['cvvresponse']); + } + + public function getOrderId() + { + return trim($this->data['orderid']); + } + + public function getTransactionReference() + { + return trim($this->data['transactionid']); + } + + public function getBillingFirstName() + { + if (isset($this->data['first_name'])) { + return trim($this->data['first_name']); + } + + return null; + } + + public function getBillingLastName() + { + if (isset($this->data['last_name'])) { + return trim($this->data['last_name']); + } + + return null; + } + + public function getProcessorId() + { + if (isset($this->data['processor_id'])) { + return trim($this->data['processor_id']); + } + + return null; + } + + public function getPlatformId() + { + if (isset($this->data['platform_id'])) { + return trim($this->data['platform_id']); + } + + return null; + } + + public function getCardReference() + { + if (isset($this->data['customer_vault_id'])) { + return trim($this->data['customer_vault_id']); + } + + return null; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostSaleRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostSaleRequest.php new file mode 100644 index 000000000..bc483d6ba --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/DirectPostSaleRequest.php @@ -0,0 +1,10 @@ +validate('transactionReference'); + + $data = $this->getBaseData(); + $data['transactionid'] = $this->getTransactionReference(); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAbstractRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAbstractRequest.php new file mode 100644 index 000000000..257dae27a --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAbstractRequest.php @@ -0,0 +1,342 @@ +getParameter('api_key'); + } + + /** + * @param string + * @return \Omnipay\Common\Message\AbstractRequest + */ + public function setApiKey($value) + { + return $this->setParameter('api_key', $value); + } + + /** + * @return string + */ + public function getRedirectUrl() + { + return $this->getParameter('redirect_url'); + } + + /** + * @param string + * @return \Omnipay\Common\Message\AbstractRequest + */ + public function setRedirectUrl($value) + { + return $this->setParameter('redirect_url', $value); + } + + /** + * @return string + */ + public function getTokenId() + { + return $this->getParameter('token_id'); + } + + /** + * @param string + * @return \Omnipay\Common\Message\AbstractRequest + */ + public function setTokenId($value) + { + return $this->setParameter('token_id', $value); + } + + /** + * Sets the card. + * + * @param CreditCard $value + * @return AbstractRequest Provides a fluent interface + */ + public function setCard($value) + { + if (!$value instanceof CreditCard) { + $value = new CreditCard($value); + } + + return $this->setParameter('card', $value); + } + + /** + * @return string + */ + public function getSecCode() + { + return $this->getParameter('sec_code'); + } + + /** + * @param string + * @return \Omnipay\Common\Message\AbstractRequest + */ + public function setSecCode($value) + { + return $this->setParameter('sec_code', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField1() + { + return $this->getParameter('merchant_defined_field_1'); + } + + /** + * Sets the first merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField1($value) + { + return $this->setParameter('merchant_defined_field_1', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField2() + { + return $this->getParameter('merchant_defined_field_2'); + } + + /** + * Sets the second merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField2($value) + { + return $this->setParameter('merchant_defined_field_2', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField3() + { + return $this->getParameter('merchant_defined_field_3'); + } + + /** + * Sets the third merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField3($value) + { + return $this->setParameter('merchant_defined_field_3', $value); + } + + /** + * @return string + */ + public function getMerchantDefinedField4() + { + return $this->getParameter('merchant_defined_field_4'); + } + + /** + * Sets the fourth merchant defined field. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setMerchantDefinedField4($value) + { + return $this->setParameter('merchant_defined_field_4', $value); + } + + /** + * @return array + */ + protected function getOrderData() + { + $data = array(); + + $data['order-id'] = $this->getOrderId(); + $data['order-description'] = $this->getOrderDescription(); + $data['tax-amount'] = $this->getTax(); + $data['shipping-amount'] = $this->getShipping(); + $data['po-number'] = $this->getPONumber(); + $data['ip-address'] = $this->getClientIp(); + + if ($this->getCurrency()) { + $data['currency'] = $this->getCurrency(); + } + + if ($this->getSecCode()) { + $data['sec-code'] = $this->getSecCode(); + } + + return $data; + } + + /** + * @return array + */ + protected function getBillingData() + { + $data = array(); + + if ($card = $this->getCard()) { + $data['billing'] = array( + 'first-name' => $card->getBillingFirstName(), + 'last-name' => $card->getBillingLastName(), + 'address1' => $card->getBillingAddress1(), + 'city' => $card->getBillingCity(), + 'state' => $card->getBillingState(), + 'postal' => $card->getBillingPostcode(), + 'country' => $card->getBillingCountry(), + 'phone' => $card->getBillingPhone(), + 'email' => $card->getEmail(), + 'company' => $card->getBillingCompany(), + 'address2' => $card->getBillingAddress2(), + 'fax' => $card->getBillingFax(), + ); + } + + return $data; + } + + /** + * @return array + */ + protected function getShippingData() + { + $data = array(); + + if ($card = $this->getCard()) { + $data['shipping'] = array( + 'first-name' => $card->getShippingFirstName(), + 'last-name' => $card->getShippingLastName(), + 'address1' => $card->getShippingAddress1(), + 'city' => $card->getShippingCity(), + 'state' => $card->getShippingState(), + 'postal' => $card->getShippingPostcode(), + 'country' => $card->getShippingCountry(), + 'email' => $card->getEmail(), + 'company' => $card->getShippingCompany(), + 'address2' => $card->getShippingAddress2(), + ); + } + + return $data; + } + + /** + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectResponse + */ + public function sendData($data) + { + $document = new SimpleXMLElement('<'.$this->type.'/>'); + $this->arrayToXml($document, $data); + + $httpResponse = $this->httpClient->request( + 'POST', + $this->getEndpoint(), + array( + 'Content-Type' => 'text/xml', + 'User-Agent' => 'Omnipay', + ), + $document->asXML() + ); + + $xml = static::xmlDecode($httpResponse); + + return $this->response = new ThreeStepRedirectResponse($this, $xml); + } + + /** + * Parse the XML response body and return a \SimpleXMLElement. + * + * In order to prevent XXE attacks, this method disables loading external + * entities. If you rely on external entities, then you must parse the + * XML response manually by accessing the response body directly. + * + * Copied from Response->xml() in Guzzle3 (copyright @mtdowling) + * @link https://github.com/guzzle/guzzle3/blob/v3.9.3/src/Guzzle/Http/Message/Response.php + * + * @param string|ResponseInterface $response + * @return \SimpleXMLElement + * @throws RuntimeException if the response body is not in XML format + * @link http://websec.io/2012/08/27/Preventing-XXE-in-PHP.html + * + */ + public static function xmlDecode($response) + { + if ($response instanceof \Psr\Http\Message\ResponseInterface) { + $body = $response->getBody()->__toString(); + } else { + $body = (string) $response; + } + + $errorMessage = null; + $internalErrors = libxml_use_internal_errors(true); + $disableEntities = libxml_disable_entity_loader(true); + libxml_clear_errors(); + + try { + $xml = new \SimpleXMLElement((string) $body ?: '', LIBXML_NONET); + } catch (\Exception $e) { + $errorMessage = $e->getMessage(); + } + + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + libxml_disable_entity_loader($disableEntities); + + if ($errorMessage !== null) { + throw new \InvalidArgumentException('SimpleXML error: ' . $errorMessage); + } + + return $xml; + } + + /** + * @param \SimpleXMLElement + * @param array + * @return void + */ + private function arrayToXml(SimpleXMLElement $parent, array $data) + { + foreach ($data as $name => $value) { + if (is_array($value)) { + $child = $parent->addChild($name); + $this->arrayToXml($child, $value); + } + else { + $parent->addChild($name, htmlspecialchars($value)); + } + } + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAuthRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAuthRequest.php new file mode 100644 index 000000000..4425620ad --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectAuthRequest.php @@ -0,0 +1,129 @@ +setParameter('dup_seconds', $value); + } + + /** + * @return string + */ + public function getDupSeconds() + { + return $this->getParameter('dup_seconds'); + } + + /** + * Sets the add customer. + * + * @param boolean + * @return AbstractRequest Provides a fluent interface + */ + public function setAddCustomer($value) + { + return $this->setParameter('add_customer', $value); + } + + /** + * @return string + */ + public function getAddCustomer() + { + return $this->getParameter('add_customer'); + } + + /** + * Sets the update customer. + * + * @param string + * @return AbstractRequest Provides a fluent interface + */ + public function setUpdateCustomer($value) + { + return $this->setParameter('update_customer', $value); + } + + /** + * @return string + */ + public function getUpdateCustomer() + { + return $this->getParameter('update_customer'); + } + + /** + * @return array + */ + public function getData() + { + $this->validate('amount'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'redirect-url' => $this->getRedirectUrl(), + 'amount' => $this->getAmount(), + ); + + if ($this->getDupSeconds()) { + $data['dup-seconds'] = $this->getDupSeconds(); + } + + if ($this->getMerchantDefinedField1()) { + $data['merchant-defined-field-1'] = $this->getMerchantDefinedField1(); + } + + if ($this->getMerchantDefinedField2()) { + $data['merchant-defined-field-2'] = $this->getMerchantDefinedField2(); + } + + if ($this->getMerchantDefinedField3()) { + $data['merchant-defined-field-3'] = $this->getMerchantDefinedField3(); + } + + if ($this->getMerchantDefinedField4()) { + $data['merchant-defined-field-4'] = $this->getMerchantDefinedField4(); + } + + if ($this->getCardReference()) { + $data['customer-vault-id'] = $this->getCardReference(); + } + else { + $data = array_merge( + $data, + $this->getOrderData(), + $this->getBillingData(), + $this->getShippingData() + ); + + if ($this->getAddCustomer()) { + $data['add-customer'] = []; + } + + if ($this->getUpdateCustomer()) { + $data['update-customer'] = [ + 'customer-vault-id' => $this->getUpdateCustomer(), + ]; + } + } + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCaptureRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCaptureRequest.php new file mode 100644 index 000000000..8d8948a62 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCaptureRequest.php @@ -0,0 +1,49 @@ +validate('transactionReference'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'transaction-id' => $this->getTransactionReference(), + ); + + if ($this->getAmount() > 0) { + $data['amount'] = $this->getAmount(); + } + + if ($this->getMerchantDefinedField1()) { + $data['merchant-defined-field-1'] = $this->getMerchantDefinedField1(); + } + + if ($this->getMerchantDefinedField2()) { + $data['merchant-defined-field-2'] = $this->getMerchantDefinedField2(); + } + + if ($this->getMerchantDefinedField3()) { + $data['merchant-defined-field-3'] = $this->getMerchantDefinedField3(); + } + + if ($this->getMerchantDefinedField4()) { + $data['merchant-defined-field-4'] = $this->getMerchantDefinedField4(); + } + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCompleteActionRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCompleteActionRequest.php new file mode 100644 index 000000000..57d57a002 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCompleteActionRequest.php @@ -0,0 +1,29 @@ +validate('token_id'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'token-id' => $this->getTokenId(), + ); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreateCardRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreateCardRequest.php new file mode 100644 index 000000000..89da02d6d --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreateCardRequest.php @@ -0,0 +1,35 @@ +validate('card'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'redirect-url' => $this->getRedirectUrl(), + ); + + $data = array_merge( + $data, + $this->getBillingData(), + $this->getShippingData() + ); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreditRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreditRequest.php new file mode 100644 index 000000000..b44164a3d --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectCreditRequest.php @@ -0,0 +1,14 @@ +validate('cardReference'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'redirect-url' => $this->getRedirectUrl(), + 'customer-vault-id' => $this->getCardReference(), + ); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectRefundRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectRefundRequest.php new file mode 100644 index 000000000..878816939 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectRefundRequest.php @@ -0,0 +1,14 @@ +request = $request; + $this->data = $data; + } + + /** + * @return boolean + */ + public function isSuccessful() + { + return '1' === $this->getCode(); + } + + /** + * @return string + */ + public function getCode() + { + return trim($this->data->{'result'}); + } + + /** + * @return string + */ + public function getResponseCode() + { + return trim($this->data->{'result-code'}); + } + + /** + * @return string + */ + public function getMessage() + { + return trim($this->data->{'result-text'}); + } + + public function getAuthorizationCode() + { + return trim($this->data->{'authorization-code'}); + } + + /** + * @return string + */ + public function getAVSResponse() + { + return trim($this->data->{'avs-result'}); + } + + /** + * @return string + */ + public function getCVVResponse() + { + return trim($this->data->{'cvv-result'}); + } + + /** + * @return string + */ + public function getOrderId() + { + return trim($this->data->{'order-id'}); + } + + /** + * @return string + */ + public function getTransactionReference() + { + return trim($this->data->{'transaction-id'}); + } + + /** + * @return string|null + */ + public function getCardReference() + { + if (isset($this->data->{'customer-vault-id'})) { + return trim($this->data->{'customer-vault-id'}); + } + + return null; + } + + /** + * @return string|null + */ + public function getFormUrl() + { + if (isset($this->data->{'form-url'})) { + return trim($this->data->{'form-url'}); + } + + return null; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectSaleRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectSaleRequest.php new file mode 100644 index 000000000..3b1599cb3 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectSaleRequest.php @@ -0,0 +1,14 @@ +validate('cardReference'); + + $data['customer-vault-id'] = $this->getCardReference(); + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectVoidRequest.php b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectVoidRequest.php new file mode 100644 index 000000000..f4328e362 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/Message/ThreeStepRedirectVoidRequest.php @@ -0,0 +1,45 @@ +validate('transactionReference'); + + $data = array( + 'api-key' => $this->getApiKey(), + 'transaction-id' => $this->getTransactionReference(), + ); + + if ($this->getMerchantDefinedField1()) { + $data['merchant-defined-field-1'] = $this->getMerchantDefinedField1(); + } + + if ($this->getMerchantDefinedField2()) { + $data['merchant-defined-field-2'] = $this->getMerchantDefinedField2(); + } + + if ($this->getMerchantDefinedField3()) { + $data['merchant-defined-field-3'] = $this->getMerchantDefinedField3(); + } + + if ($this->getMerchantDefinedField4()) { + $data['merchant-defined-field-4'] = $this->getMerchantDefinedField4(); + } + + return $data; + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/src/ThreeStepRedirectGateway.php b/vendor/nerdmedia/omnipay-nmi/src/ThreeStepRedirectGateway.php new file mode 100644 index 000000000..80ecb2aa4 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/src/ThreeStepRedirectGateway.php @@ -0,0 +1,171 @@ + '', + 'redirect_url' => '', + 'endpoint' => '', + ); + } + + /** + * @return string + */ + public function getApiKey() + { + return $this->getParameter('api_key'); + } + + /** + * @param string + * @return \Omnipay\Common\AbstractGateway + */ + public function setApiKey($value) + { + return $this->setParameter('api_key', $value); + } + + /** + * @return string + */ + public function getRedirectUrl() + { + return $this->getParameter('redirect_url'); + } + + /** + * @param string + * @return \Omnipay\Common\AbstractGateway + */ + public function setRedirectUrl($value) + { + return $this->setParameter('redirect_url', $value); + } + + /** + * Transaction sales are submitted and immediately flagged for settlement. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectSaleRequest + */ + public function sale(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectSaleRequest', $parameters); + } + + /** + * Transaction authorizations are authorized immediately but are not flagged + * for settlement. These transactions must be flagged for settlement using + * the capture transaction type. Authorizations typically remain active for + * three to seven business days. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectAuthRequest + */ + public function auth(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectAuthRequest', $parameters); + } + + /** + * Transaction captures flag existing authorizations for settlement. + * Only authorizations can be captured. Captures can be submitted for an + * amount equal to or less than the original authorization. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectCaptureRequest + */ + public function capture(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectCaptureRequest', $parameters); + } + + /** + * Transaction voids will cancel an existing sale or captured authorization. + * In addition, non-captured authorizations can be voided to prevent any + * future capture. Voids can only occur if the transaction has not been settled. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectVoidRequest + */ + public function void(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectVoidRequest', $parameters); + } + + /** + * Transaction refunds will reverse a previously settled transaction. If the + * transaction has not been settled, it must be voided instead of refunded. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectRefundRequest + */ + public function refund(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectRefundRequest', $parameters); + } + + /** + * Transaction credits apply an amount to the cardholder's card that was not + * originally processed through the Gateway. In most situations credits are + * disabled as transaction refunds should be used instead. + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectCreditRequest + */ + public function credit(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectCreditRequest', $parameters); + } + + /** + * @param array + * @return \Omnipay\NMI\Message\CreateCardRequest + */ + public function createCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectCreateCardRequest', $parameters); + } + + /** + * @param array + * @return \Omnipay\NMI\Message\UpdateCardRequest + */ + public function updateCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectUpdateCardRequest', $parameters); + } + + /** + * @param array + * @return \Omnipay\NMI\Message\DeleteCardRequest + */ + public function deleteCard(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectDeleteCardRequest', $parameters); + } + + /** + * @param array + * @return \Omnipay\NMI\Message\ThreeStepRedirectCompleteActionRequest + */ + public function completeAction(array $parameters = array()) + { + return $this->createRequest('\Omnipay\NMI\Message\ThreeStepRedirectCompleteActionRequest', $parameters); + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayIntegrationTest.php b/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayIntegrationTest.php new file mode 100644 index 000000000..d42e6053c --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayIntegrationTest.php @@ -0,0 +1,91 @@ +gateway = new DirectPostGateway(); + $this->gateway->setUsername('demo'); + $this->gateway->setPassword('password'); + + $this->purchaseOptions = array( + 'amount'=>'10.00', + 'card'=>$this->getValidCard() + ); + } + + /** + * Test an authorize transaction followed by a capture + */ + public function testAuthorizeCapture() + { + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertEquals('SUCCESS', $response->getMessage()); + + $captureResponse = $this->gateway->capture(array( + 'amount'=>'10.00', + 'transactionReference'=>$response->getTransactionReference() + ))->send(); + + $this->assertTrue($captureResponse->isSuccessful()); + $this->assertEquals('SUCCESS', $captureResponse->getMessage()); + } + + /** + * Test a purchase transaction followed by a refund + */ + public function testPurchaseRefund() + { + $response = $this->gateway->purchase($this->purchaseOptions)->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertEquals('SUCCESS', $response->getMessage()); + + $refundResponse = $this->gateway->refund(array( + 'transactionReference'=>$response->getTransactionReference() + ))->send(); + + $this->assertTrue($refundResponse->isSuccessful()); + $this->assertEquals('SUCCESS', $refundResponse->getMessage()); + } + + /** + * Test a purchase transaction followed by a void + */ + public function testPurchaseVoid() + { + $response = $this->gateway->purchase($this->purchaseOptions)->send(); + + $this->assertTrue($response->isSuccessful()); + $this->assertEquals('SUCCESS', $response->getMessage()); + + $voidResponse = $this->gateway->void(array( + 'transactionReference'=>$response->getTransactionReference() + ))->send(); + + $this->assertTrue($voidResponse->isSuccessful()); + $this->assertEquals('Transaction Void Successful', $voidResponse->getMessage()); + } +} \ No newline at end of file diff --git a/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayTest.php b/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayTest.php new file mode 100644 index 000000000..3678f7711 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/DirectPostGatewayTest.php @@ -0,0 +1,231 @@ +gateway = new DirectPostGateway($this->getHttpClient(), $this->getHttpRequest()); + + $this->purchaseOptions = array( + 'amount' => '10.00', + 'card' => $this->getValidCard() + ); + + $this->captureOptions = array( + 'amount' => '10.00', + 'transactionReference' => '2577708057' + ); + + $this->voidOptions = array( + 'transactionReference' => '2577708057' + ); + + $this->refundOptions = array( + 'transactionReference' => '2577725848' + ); + } + + public function testAuthorizeSuccess() + { + $this->setMockHttpResponse('DirectPostAuthSuccess.txt'); + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + } + + public function testAuthorizeFailure() + { + $this->setMockHttpResponse('DirectPostAuthFailure.txt'); + + $this->purchaseOptions['amount'] = '0.00'; + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('2577711599', $response->getTransactionReference()); + $this->assertSame('DECLINE', $response->getMessage()); + } + + public function testPurchaseSuccess() + { + $this->setMockHttpResponse('DirectPostSaleSuccess.txt'); + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577715564', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + } + + public function testPurchaseFailure() + { + $this->setMockHttpResponse('DirectPostSaleFailure.txt'); + + $this->purchaseOptions['amount'] = '0.00'; + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('2577715978', $response->getTransactionReference()); + $this->assertSame('DECLINE', $response->getMessage()); + } + + public function testCaptureSuccess() + { + $this->setMockHttpResponse('DirectPostCaptureSuccess.txt'); + + $response = $this->gateway->capture($this->captureOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + } + + public function testCaptureFailure() + { + $this->setMockHttpResponse('DirectPostCaptureFailure.txt'); + + $response = $this->gateway->capture($this->captureOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('A capture requires that the existing transaction be an AUTH REFID:143498124', $response->getMessage()); + } + + public function testVoidSuccess() + { + $this->setMockHttpResponse('DirectPostVoidSuccess.txt'); + + $response = $this->gateway->void($this->voidOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('Transaction Void Successful', $response->getMessage()); + } + + public function testVoidFailure() + { + $this->setMockHttpResponse('DirectPostVoidFailure.txt'); + + $response = $this->gateway->void($this->voidOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('Only transactions pending settlement can be voided REFID:143498494', $response->getMessage()); + } + + public function testRefundSuccess() + { + $this->setMockHttpResponse('DirectPostRefundSuccess.txt'); + + $response = $this->gateway->void($this->refundOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577725848', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + } + + public function testRefundFailure() + { + $this->setMockHttpResponse('DirectPostRefundFailure.txt'); + + $response = $this->gateway->void($this->refundOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('', $response->getTransactionReference()); + $this->assertSame('Refund amount may not exceed the transaction balance REFID:143498703', $response->getMessage()); + } + + public function testCreditSuccess() + { + $this->setMockHttpResponse('DirectPostCreditSuccess.txt'); + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577728141', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + } + + public function testCreditFailure() + { + $this->setMockHttpResponse('DirectPostCreditFailure.txt'); + + $this->purchaseOptions['amount'] = '0.00'; + + $response = $this->gateway->authorize($this->purchaseOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('', $response->getTransactionReference()); + $this->assertSame('Invalid amount REFID:143498834', $response->getMessage()); + } + + public function testCreateCardSuccess() + { + $this->setMockHttpResponse('DirectPostCreateCardSuccess.txt'); + + $response = $this->gateway->createCard($this->purchaseOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('452894459', $response->getCardReference()); + $this->assertSame('Customer Added', $response->getMessage()); + } + + public function testCreateCardFailure() + { + $this->setMockHttpResponse('DirectPostCreateCardFailure.txt'); + + $response = $this->gateway->createCard($this->purchaseOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame(null, $response->getCardReference()); + $this->assertSame('Invalid Credit Card Number REFID:3150032552', $response->getMessage()); + } + + public function testUpdateCardSuccess() + { + $this->setMockHttpResponse('DirectPostUpdateCardSuccess.txt'); + + $this->purchaseOptions['cardReference'] = '452894459'; + + $response = $this->gateway->updateCard($this->purchaseOptions)->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('452894459', $response->getCardReference()); + $this->assertSame('Customer Update Successful', $response->getMessage()); + } + + public function testUpdateCardFailure() + { + $this->setMockHttpResponse('DirectPostUpdateCardFailure.txt'); + + $this->purchaseOptions['cardReference'] = '000000000'; + + $response = $this->gateway->updateCard($this->purchaseOptions)->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('000000000', $response->getCardReference()); + $this->assertSame('Invalid Customer Vault Id REFID:3150033161', $response->getMessage()); + } + + public function testDeleteCardSuccess() + { + $this->setMockHttpResponse('DirectPostDeleteCardSuccess.txt'); + + $response = $this->gateway->deleteCard(array( + 'cardReference' => '452894459' + ))->send(); + $this->assertTrue($response->isSuccessful()); + $this->assertSame(null, $response->getCardReference()); + $this->assertSame('Customer Deleted', $response->getMessage()); + } + + public function testDeleteCardFailure() + { + $this->setMockHttpResponse('DirectPostDeleteCardFailure.txt'); + + $response = $this->gateway->deleteCard(array( + 'cardReference' => '000000000' + ))->send(); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('000000000', $response->getCardReference()); + $this->assertSame('Invalid Customer Vault Id REFID:3150033421', $response->getMessage()); + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Message/DirectPostResponseTest.php b/vendor/nerdmedia/omnipay-nmi/tests/Message/DirectPostResponseTest.php new file mode 100644 index 000000000..fe2f5174e --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Message/DirectPostResponseTest.php @@ -0,0 +1,38 @@ +getMockHttpResponse('DirectPostAuthSuccess.txt'); + $response = new DirectPostResponse($this->getMockRequest(), $httpResponse->getBody()); + $this->assertTrue($response->isSuccessful()); + $this->assertSame('2577708057', $response->getTransactionReference()); + $this->assertSame('SUCCESS', $response->getMessage()); + $this->assertSame('1', $response->getCode()); + $this->assertSame('100', $response->getResponseCode()); + $this->assertSame('123456', $response->getAuthorizationCode()); + $this->assertSame('', $response->getAVSResponse()); + $this->assertSame('M', $response->getCVVResponse()); + $this->assertSame('', $response->getOrderId()); + } + + public function testAuthorizeFailure() + { + $httpResponse = $this->getMockHttpResponse('DirectPostAuthFailure.txt'); + $response = new DirectPostResponse($this->getMockRequest(), $httpResponse->getBody()); + $this->assertFalse($response->isSuccessful()); + $this->assertSame('2577711599', $response->getTransactionReference()); + $this->assertSame('DECLINE', $response->getMessage()); + $this->assertSame('2', $response->getCode()); + $this->assertSame('200', $response->getResponseCode()); + $this->assertSame('', $response->getAuthorizationCode()); + $this->assertSame('', $response->getAVSResponse()); + $this->assertSame('M', $response->getCVVResponse()); + $this->assertSame('', $response->getOrderId()); + } +} diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthFailure.txt new file mode 100644 index 000000000..227faacc9 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:13:31 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 130 +Connection: close +Server: + +response=2&responsetext=DECLINE&authcode=&transactionid=2577711599&avsresponse=&cvvresponse=M&orderid=&type=auth&response_code=200 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthSuccess.txt new file mode 100644 index 000000000..d647fe907 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostAuthSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:08:07 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 136 +Connection: close +Server: + +response=1&responsetext=SUCCESS&authcode=123456&transactionid=2577708057&avsresponse=&cvvresponse=M&orderid=&type=auth&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureFailure.txt new file mode 100644 index 000000000..d37a5490d --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:25:28 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 200 +Connection: close +Server: + +response=3&responsetext=A capture requires that the existing transaction be an AUTH REFID:143498124&authcode=&transactionid=2577708057&avsresponse=&cvvresponse=&orderid=&type=capture&response_code=300 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureSuccess.txt new file mode 100644 index 000000000..50d488ac7 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCaptureSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:24:52 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 138 +Connection: close +Server: + +response=1&responsetext=SUCCESS&authcode=123456&transactionid=2577708057&avsresponse=&cvvresponse=&orderid=&type=capture&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardFailure.txt new file mode 100644 index 000000000..381348915 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardFailure.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:32:18 GMT +Server: Apache +Content-Length: 151 +Content-Type: text/html; charset=UTF-8 + +response=3&responsetext=Invalid Credit Card Number REFID:3150032552&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=300 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardSuccess.txt new file mode 100644 index 000000000..237e981cf --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreateCardSuccess.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:03:20 GMT +Server: Apache +Content-Length: 150 +Content-Type: text/html; charset=UTF-8 + +response=1&responsetext=Customer Added&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&customer_vault_id=452894459 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditFailure.txt new file mode 100644 index 000000000..fca447307 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:42:13 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 144 +Connection: close +Server: + +response=3&responsetext=Invalid amount REFID:143498834&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=credit&response_code=300 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditSuccess.txt new file mode 100644 index 000000000..85ba2cc7a --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostCreditSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:41:35 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 131 +Connection: close +Server: + +response=1&responsetext=SUCCESS&authcode=&transactionid=2577728141&avsresponse=&cvvresponse=&orderid=&type=credit&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardFailure.txt new file mode 100644 index 000000000..6cc87028f --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardFailure.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:47:06 GMT +Server: Apache +Content-Length: 178 +Content-Type: text/html; charset=UTF-8 + +response=3&responsetext=Invalid Customer Vault Id REFID:3150033421&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=300&customer_vault_id=000000000 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardSuccess.txt new file mode 100644 index 000000000..4070c8af5 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostDeleteCardSuccess.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:47:37 GMT +Server: Apache +Content-Length: 124 +Content-Type: text/html; charset=UTF-8 + +response=1&responsetext=Customer Deleted&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundFailure.txt new file mode 100644 index 000000000..17f35df95 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:39:14 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 182 +Connection: close +Server: + +response=3&responsetext=Refund amount may not exceed the transaction balance REFID:143498703&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=300 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundSuccess.txt new file mode 100644 index 000000000..97f93ace2 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostRefundSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:37:22 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 131 +Connection: close +Server: + +response=1&responsetext=SUCCESS&authcode=&transactionid=2577725848&avsresponse=&cvvresponse=&orderid=&type=refund&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleFailure.txt new file mode 100644 index 000000000..ed2038a25 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:20:20 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 130 +Connection: close +Server: + +response=2&responsetext=DECLINE&authcode=&transactionid=2577715978&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=200 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleSuccess.txt new file mode 100644 index 000000000..7af492bf4 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostSaleSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:19:43 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 136 +Connection: close +Server: + +response=1&responsetext=SUCCESS&authcode=123456&transactionid=2577715564&avsresponse=&cvvresponse=M&orderid=&type=sale&response_code=100 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardFailure.txt new file mode 100644 index 000000000..4d86d88e5 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardFailure.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:42:42 GMT +Server: Apache +Content-Length: 178 +Content-Type: text/html; charset=UTF-8 + +response=3&responsetext=Invalid Customer Vault Id REFID:3150033161&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=300&customer_vault_id=000000000 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardSuccess.txt new file mode 100644 index 000000000..1f8647bd6 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostUpdateCardSuccess.txt @@ -0,0 +1,7 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 17:41:07 GMT +Server: Apache +Content-Length: 162 +Content-Type: text/html; charset=UTF-8 + +response=1&responsetext=Customer Update Successful&authcode=&transactionid=&avsresponse=&cvvresponse=&orderid=&type=&response_code=100&customer_vault_id=452894459 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidFailure.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidFailure.txt new file mode 100644 index 000000000..85ffaefe8 --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidFailure.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:34:58 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 188 +Connection: close +Server: + +response=3&responsetext=Only transactions pending settlement can be voided REFID:143498494&authcode=&transactionid=2577708057&avsresponse=&cvvresponse=&orderid=&type=void&response_code=300 diff --git a/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidSuccess.txt b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidSuccess.txt new file mode 100644 index 000000000..68e79534e --- /dev/null +++ b/vendor/nerdmedia/omnipay-nmi/tests/Mock/DirectPostVoidSuccess.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +Date: Wed, 11 Feb 2015 00:33:05 GMT +Content-Type: text/html; charset=UTF-8 +Content-Length: 155 +Connection: close +Server: + +response=1&responsetext=Transaction Void Successful&authcode=123456&transactionid=2577708057&avsresponse=&cvvresponse=&orderid=&type=void&response_code=100