diff --git a/app/PaymentDrivers/AbstractPaymentDriver.php b/app/PaymentDrivers/AbstractPaymentDriver.php new file mode 100644 index 000000000000..ea7633f742e1 --- /dev/null +++ b/app/PaymentDrivers/AbstractPaymentDriver.php @@ -0,0 +1,23 @@ +setName($this->company_gateway->getConfigField('apiLoginId')); + $merchantAuthentication->setTransactionKey($this->company_gateway->getConfigField('transactionKey')); + + + $this->anet = new CreateTransactionRequest(); + $this->anet->setMerchantAuthentication($merchantAuthentication); + + return $this; + } + + public function fire() + { + + if($this->company_gateway->getConfigField('testMode')) + $env = ANetEnvironment::SANDBOX; + else + $env = ANetEnvironment::PRODUCTION; + + $controller = new CreateTransactionController($this->anet); + $response = $controller->executeWithApiResponse($env); + + return $response; + } + + + public function authorize() {} + + public function purchase() {} + + public function refund() {} + + +} diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php new file mode 100644 index 000000000000..27c71289823d --- /dev/null +++ b/app/PaymentDrivers/BaseDriver.php @@ -0,0 +1,66 @@ +company_gateway = $company_gateway; + + $this->invitation = $invitation; + + $this->client = $client; + } + + + public function authorize() {} + + public function purchase() {} + + public function refund() {} +} diff --git a/composer.json b/composer.json index 39a99a6e92c5..d692dc570dcc 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "php": ">=7.3", "ext-json": "*", "asgrim/ofxparser": "^1.2", + "authorizenet/authorizenet": "^2.0", "beganovich/omnipay-checkout": "dev-master", "cleverit/ubl_invoice": "^1.3", "composer/composer": "^1.10", diff --git a/composer.lock b/composer.lock index 8f8cc7fb21f2..df46734a207f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e34e27d2c285356d9251ab97646caf69", + "content-hash": "71160af87b4347c05f90402c2790540e", "packages": [ { "name": "asgrim/ofxparser", @@ -62,6 +62,49 @@ ], "time": "2018-10-29T10:10:13+00:00" }, + { + "name": "authorizenet/authorizenet", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/AuthorizeNet/sdk-php.git", + "reference": "7fa78e6397d363296e462c3b348573c17175b7a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/AuthorizeNet/sdk-php/zipball/7fa78e6397d363296e462c3b348573c17175b7a8", + "reference": "7fa78e6397d363296e462c3b348573c17175b7a8", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "php": ">=5.6" + }, + "require-dev": { + "phpmd/phpmd": "~2.0", + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "lib" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "proprietary" + ], + "description": "Official PHP SDK for Authorize.Net", + "homepage": "http://developer.authorize.net", + "keywords": [ + "authorize.net", + "authorizenet", + "ecommerce", + "payment" + ], + "time": "2019-01-14T13:32:41+00:00" + }, { "name": "aws/aws-sdk-php", "version": "3.138.10", @@ -684,12 +727,6 @@ "Xdebug", "performance" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - } - ], "time": "2020-03-01T12:26:26+00:00" }, { @@ -1021,20 +1058,6 @@ "sqlserver", "sqlsrv" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", - "type": "tidelift" - } - ], "time": "2020-04-20T17:19:26+00:00" }, { @@ -3840,70 +3863,6 @@ ], "time": "2019-11-12T18:38:48+00:00" }, - { - "name": "omnipay/authorizenet", - "version": "3.3.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/omnipay-authorizenet.git", - "reference": "8ccce3190c00d0a129c62dc1d1451d0125bab640" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/omnipay-authorizenet/zipball/8ccce3190c00d0a129c62dc1d1451d0125bab640", - "reference": "8ccce3190c00d0a129c62dc1d1451d0125bab640", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-libxml": "*", - "ext-simplexml": "*", - "omnipay/common": "^3" - }, - "require-dev": { - "omnipay/tests": "^3", - "phpro/grumphp": "^0.14", - "squizlabs/php_codesniffer": "^3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Omnipay\\AuthorizeNet\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Adrian Macneil", - "email": "adrian@adrianmacneil.com" - }, - { - "name": "Omnipay Contributors", - "homepage": "https://github.com/thephpleague/omnipay-authorizenet/contributors" - } - ], - "description": "Authorize.Net gateway for the Omnipay payment processing library", - "homepage": "https://github.com/thephpleague/omnipay-authorizenet", - "keywords": [ - "authorize", - "authorize net", - "authorize.net", - "gateway", - "merchant", - "omnipay", - "pay", - "payment" - ], - "time": "2019-04-27T22:33:23+00:00" - }, { "name": "omnipay/common", "version": "v3.0.3", @@ -5867,12 +5826,6 @@ "screenshot", "webpage" ], - "funding": [ - { - "url": "https://www.patreon.com/spatie", - "type": "patreon" - } - ], "time": "2020-04-20T10:33:41+00:00" }, { @@ -9461,6 +9414,70 @@ ], "time": "2018-11-21T21:40:54+00:00" }, + { + "name": "omnipay/authorizenet", + "version": "3.3.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/omnipay-authorizenet.git", + "reference": "8ccce3190c00d0a129c62dc1d1451d0125bab640" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/omnipay-authorizenet/zipball/8ccce3190c00d0a129c62dc1d1451d0125bab640", + "reference": "8ccce3190c00d0a129c62dc1d1451d0125bab640", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-libxml": "*", + "ext-simplexml": "*", + "omnipay/common": "^3" + }, + "require-dev": { + "omnipay/tests": "^3", + "phpro/grumphp": "^0.14", + "squizlabs/php_codesniffer": "^3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Omnipay\\AuthorizeNet\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Adrian Macneil", + "email": "adrian@adrianmacneil.com" + }, + { + "name": "Omnipay Contributors", + "homepage": "https://github.com/thephpleague/omnipay-authorizenet/contributors" + } + ], + "description": "Authorize.Net gateway for the Omnipay payment processing library", + "homepage": "https://github.com/thephpleague/omnipay-authorizenet", + "keywords": [ + "authorize", + "authorize net", + "authorize.net", + "gateway", + "merchant", + "omnipay", + "pay", + "payment" + ], + "time": "2019-04-27T22:33:23+00:00" + }, { "name": "phar-io/manifest", "version": "1.0.3", @@ -11061,7 +11078,6 @@ "minimum-stability": "dev", "stability-flags": { "beganovich/omnipay-checkout": 20, - "omnipay/authorizenet": 20, "webpatser/laravel-countries": 20 }, "prefer-stable": true, diff --git a/config/ninja.php b/config/ninja.php index 0d166c960aa3..62122a5c2730 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -67,6 +67,7 @@ return [ 'password' => 'password', 'stripe' => env('STRIPE_KEYS', ''), 'paypal' => env('PAYPAL_KEYS', ''), + 'authorize' => env('AUTHORIZE_KEYS',''), 'checkout' => env('CHECKOUT_KEYS',''), 'travis' => env('TRAVIS', false), 'test_email' => env('TEST_EMAIL', 'test@example.com'), diff --git a/tests/Integration/PaymentDrivers/AuthorizeTest.php b/tests/Integration/PaymentDrivers/AuthorizeTest.php new file mode 100644 index 000000000000..95888c28904c --- /dev/null +++ b/tests/Integration/PaymentDrivers/AuthorizeTest.php @@ -0,0 +1,57 @@ +markTestSkipped('authorize.net not configured'); + } + + } + + public function testUnpackingVars() + { + $vars = json_decode(config('ninja.testvars.authorize')); + + $this->assertTrue(property_exists($vars, 'apiLoginId')); + } + + public function testCreatePublicClientKey() + { + error_reporting (E_ALL & ~E_DEPRECATED); + + $vars = json_decode(config('ninja.testvars.authorize')); + + $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); + $merchantAuthentication->setName($vars->apiLoginId); + $merchantAuthentication->setTransactionKey($vars->transactionKey); + + $request = new AnetAPI\GetMerchantDetailsRequest(); + $request->setMerchantAuthentication($merchantAuthentication); + + $controller = new GetMerchantDetailsController($request); + + $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX); + + $this->assertNotNull($response->getPublicClientKey()); + } + +}