mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 10:44:35 -04:00
Working on Authorize.net
This commit is contained in:
parent
0dc8b59ecc
commit
4985f94ce1
78
app/PaymentDrivers/AuthorizeNetAIMPaymentDriver.php
Normal file
78
app/PaymentDrivers/AuthorizeNetAIMPaymentDriver.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\PaymentDrivers;
|
||||||
|
|
||||||
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
|
use App\Factory\PaymentFactory;
|
||||||
|
use App\Jobs\Mail\PaymentFailureMailer;
|
||||||
|
use App\Jobs\Util\SystemLogger;
|
||||||
|
use App\Models\ClientGatewayToken;
|
||||||
|
use App\Models\GatewayType;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\PaymentType;
|
||||||
|
use App\Models\SystemLog;
|
||||||
|
use App\PaymentDrivers\Stripe\Utilities;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Stripe\PaymentIntent;
|
||||||
|
use Stripe\SetupIntent;
|
||||||
|
use Stripe\Stripe;
|
||||||
|
|
||||||
|
class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
|
||||||
|
{
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
protected $refundable = true;
|
||||||
|
|
||||||
|
protected $token_billing = true;
|
||||||
|
|
||||||
|
protected $can_authorise_credit_card = true;
|
||||||
|
|
||||||
|
protected $transactionReferenceParam = 'refId';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the gateway types
|
||||||
|
*/
|
||||||
|
public function gatewayTypes() :array
|
||||||
|
{
|
||||||
|
$types = [
|
||||||
|
GatewayType::CREDIT_CARD,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewForType($gateway_type_id)
|
||||||
|
{
|
||||||
|
switch ($gateway_type_id) {
|
||||||
|
case GatewayType::CREDIT_CARD:
|
||||||
|
case GatewayType::TOKEN:
|
||||||
|
return 'gateways.authorize.credit_card';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLoginId()
|
||||||
|
{
|
||||||
|
return $this->company_gateway->getConfigField('apiLoginId');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTransactionKey()
|
||||||
|
{
|
||||||
|
return $this->company_gateway->getConfigField('transactionKey');
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,7 @@
|
|||||||
"livewire/livewire": "^1.0",
|
"livewire/livewire": "^1.0",
|
||||||
"maennchen/zipstream-php": "^1.2",
|
"maennchen/zipstream-php": "^1.2",
|
||||||
"nwidart/laravel-modules": "^6.0",
|
"nwidart/laravel-modules": "^6.0",
|
||||||
|
"omnipay/authorizenet": "3.x@dev",
|
||||||
"omnipay/paypal": "^3.0",
|
"omnipay/paypal": "^3.0",
|
||||||
"omnipay/stripe": "^3.0",
|
"omnipay/stripe": "^3.0",
|
||||||
"predis/predis": "^1.1",
|
"predis/predis": "^1.1",
|
||||||
|
67
composer.lock
generated
67
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "723f03b92457a3f3410083e2b42f96c3",
|
"content-hash": "e34e27d2c285356d9251ab97646caf69",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asgrim/ofxparser",
|
"name": "asgrim/ofxparser",
|
||||||
@ -3840,6 +3840,70 @@
|
|||||||
],
|
],
|
||||||
"time": "2019-11-12T18:38:48+00:00"
|
"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",
|
"name": "omnipay/common",
|
||||||
"version": "v3.0.3",
|
"version": "v3.0.3",
|
||||||
@ -10997,6 +11061,7 @@
|
|||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
"beganovich/omnipay-checkout": 20,
|
"beganovich/omnipay-checkout": 20,
|
||||||
|
"omnipay/authorizenet": 20,
|
||||||
"webpatser/laravel-countries": 20
|
"webpatser/laravel-countries": 20
|
||||||
},
|
},
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
81
resources/js/clients/payment_methods/authorize-authorize-card.js
vendored
Normal file
81
resources/js/clients/payment_methods/authorize-authorize-card.js
vendored
Normal file
@ -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();
|
@ -0,0 +1,102 @@
|
|||||||
|
@extends('portal.ninja2020.layout.app')
|
||||||
|
@section('meta_title', ctrans('texts.add_credit_card'))
|
||||||
|
|
||||||
|
@push('head')
|
||||||
|
<meta name="authorize-public-key" content="{{ $gateway->getPublishableKey() }}">
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('body')
|
||||||
|
<form action="{{ route('client.payment_methods.store') }}" method="post" id="server_response">
|
||||||
|
@csrf
|
||||||
|
<input type="hidden" name="company_gateway_id" value="{{ $gateway->id }}">
|
||||||
|
<input type="hidden" name="gateway_type_id" value="1">
|
||||||
|
<input type="hidden" name="gateway_response" id="gateway_response">
|
||||||
|
<input type="hidden" name="is_default" id="is_default">
|
||||||
|
<input type="hidden" name="dataValue" id="dataValue" />
|
||||||
|
<input type="hidden" name="dataDescriptor" id="dataDescriptor" />
|
||||||
|
</form>
|
||||||
|
<div class="container mx-auto">
|
||||||
|
<div class="grid grid-cols-6 gap-4">
|
||||||
|
<div class="col-span-6 md:col-start-2 md:col-span-4">
|
||||||
|
<div class="alert alert-failure mb-4" hidden id="errors"></div>
|
||||||
|
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
|
||||||
|
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
|
||||||
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
{{ ctrans('texts.add_credit_card') }}
|
||||||
|
</h3>
|
||||||
|
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500" translate>
|
||||||
|
{{ ctrans('texts.authorize_for_future_use') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dl>
|
||||||
|
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
|
||||||
|
{{ ctrans('texts.name') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="cardholder_name" type="text" placeholder="{{ ctrans('texts.name') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.credit_card') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="card_number" type="text" placeholder="{{ ctrans('texts.card_number') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.expiration_month') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="expiration_month" type="text" placeholder="{{ ctrans('texts.expiration_month') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.expiration_year') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="expiration_year" type="text" placeholder="{{ ctrans('texts.expiration_year') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.cvv') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input class="input w-full" id="cvv" type="text" placeholder="{{ ctrans('texts.cvv') }}">
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||||
|
<dt class="text-sm leading-5 font-medium text-gray-500">
|
||||||
|
{{ ctrans('texts.save_as_default') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
|
<input type="checkbox" class="form-checkbox" name="proxy_is_default"
|
||||||
|
id="proxy_is_default"/>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white px-4 py-5 flex justify-end">
|
||||||
|
<button type="button" id="card_button">{{ ctrans('texts.add_payment_method') }}</button>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('footer')
|
||||||
|
|
||||||
|
@if($this->gateway->getConfigField('testMode'))
|
||||||
|
<script src="https://jstest.authorize.net/v1/Accept.js" charset="utf-8"></script>
|
||||||
|
@else
|
||||||
|
<script src="https://js.authorize.net/v1/Accept.js" charset="utf-8"></script>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<script src="{{ asset('js/clients/payment_methods/authorize-authorize-card.js') }}"></script>
|
||||||
|
@endpush
|
Loading…
x
Reference in New Issue
Block a user