diff --git a/app/PaymentDrivers/AuthorizeNetAIMPaymentDriver.php b/app/PaymentDrivers/AuthorizeNetAIMPaymentDriver.php new file mode 100644 index 000000000000..37ca99c446bd --- /dev/null +++ b/app/PaymentDrivers/AuthorizeNetAIMPaymentDriver.php @@ -0,0 +1,78 @@ +company_gateway->getConfigField('apiLoginId'); + } + + public function getTransactionKey() + { + return $this->company_gateway->getConfigField('transactionKey'); + } +} diff --git a/composer.json b/composer.json index 39a99a6e92c5..e15f1be0d9d7 100644 --- a/composer.json +++ b/composer.json @@ -46,6 +46,7 @@ "livewire/livewire": "^1.0", "maennchen/zipstream-php": "^1.2", "nwidart/laravel-modules": "^6.0", + "omnipay/authorizenet": "3.x@dev", "omnipay/paypal": "^3.0", "omnipay/stripe": "^3.0", "predis/predis": "^1.1", diff --git a/composer.lock b/composer.lock index 34835e2fea15..8f8cc7fb21f2 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": "723f03b92457a3f3410083e2b42f96c3", + "content-hash": "e34e27d2c285356d9251ab97646caf69", "packages": [ { "name": "asgrim/ofxparser", @@ -3840,6 +3840,70 @@ ], "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", @@ -10997,6 +11061,7 @@ "minimum-stability": "dev", "stability-flags": { "beganovich/omnipay-checkout": 20, + "omnipay/authorizenet": 20, "webpatser/laravel-countries": 20 }, "prefer-stable": true, diff --git a/resources/js/clients/payment_methods/authorize-authorize-card.js b/resources/js/clients/payment_methods/authorize-authorize-card.js new file mode 100644 index 000000000000..70d6c83cc320 --- /dev/null +++ b/resources/js/clients/payment_methods/authorize-authorize-card.js @@ -0,0 +1,81 @@ +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ + +class AuthorizeAuthorizeCard { + constructor(key) { + this.key = key; + this.cardHolderName = document.getElementById("cardholder_name"); + this.cardButton = document.getElementById("card_button"); + + } + + handleAuthorization() { + + var authData = {}; + authData.clientKey = this.key; + authData.apiLoginID = "YOUR API LOGIN ID"; + + var cardData = {}; + cardData.cardNumber = document.getElementById("card_number").value; + cardData.month = document.getElementById("expiration_month").value; + cardData.year = document.getElementById("expiration_year").value; + cardData.cardCode = document.getElementById("cvv").value; + + var secureData = {}; + secureData.authData = authData; + secureData.cardData = cardData; + // If using banking information instead of card information, + // send the bankData object instead of the cardData object. + // + // secureData.bankData = bankData; + + Accept.dispatchData(secureData, responseHandler); + } + + responseHandler(response) { + + if (response.messages.resultCode === "Error") { + var i = 0; + while (i < response.messages.message.length) { + console.log( + response.messages.message[i].code + ": " + + response.messages.message[i].text + ); + i = i + 1; + } + } + else { + paymentFormUpdate(response.opaqueData); + } + + } + + paymentFormUpdate(opaqueData) { + document.getElementById("dataDescriptor").value = opaqueData.dataDescriptor; + document.getElementById("dataValue").value = opaqueData.dataValue; + document.getElementById("server_response").submit(); + } + + handle() { + + this.cardButton.addEventListener("click", () => { + this.handleAuthorization(); + }); + + return this; + } +} + +const publicKey = document.querySelector( + 'meta[name="authorize-public-key"]' +).content; + +/** @handle */ +new AuthorizeAuthorizeCard(publicKey).handle(); \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php b/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php new file mode 100644 index 000000000000..ceb81eb9d55b --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php @@ -0,0 +1,102 @@ +@extends('portal.ninja2020.layout.app') +@section('meta_title', ctrans('texts.add_credit_card')) + +@push('head') + +@endpush + +@section('body') +
++ {{ ctrans('texts.authorize_for_future_use') }} +
+