1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for AUthorize.net

This commit is contained in:
David Bomba 2020-06-17 21:15:24 +10:00
parent 6b9cca14fb
commit f82953b44b
6 changed files with 71 additions and 18 deletions

View File

@ -75,13 +75,16 @@ class AuthorizeCreditCard
$authorise_payment_method = new AuthorizePaymentMethod($this->authorize);
$payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data);
$payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId();
if($request->has('store_card') && $request->input('store_card')){
info($request->input('store_card'));
if($request->has('store_card') && $request->input('store_card') === 'true'){
$authorise_payment_method->payment_method = GatewayType::CREDIT_CARD;
$client_gateway_token = $authorise_payment_method->createClientGatewayToken($payment_profile, $gateway_customer_reference);
}
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile, $data['amount_with_fee']);
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($gateway_customer_reference, $payment_profile_id, $data['amount_with_fee']);
return $this->handleResponse($data, $request);
@ -91,7 +94,7 @@ class AuthorizeCreditCard
{
$client_gateway_token = ClientGatewayToken::find($this->decodePrimaryKey($request->token));
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($client_gateway_token->gateway_customer_reference, $client_gateway_token->token, $request->input('amount'));
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($client_gateway_token->gateway_customer_reference, $client_gateway_token->token, $request->input('amount_with_fee'));
return $this->handleResponse($data, $request);
}
@ -121,7 +124,7 @@ class AuthorizeCreditCard
$payment->currency_id = $this->authorize->client->getSetting('currency_id');
$payment->date = Carbon::now();
$payment->transaction_reference = $response->getTransactionResponse()->getTransId();
$payment->amount = $request->input('amount');
$payment->amount = $request->input('amount_with_fee');
$payment->currency_id = $this->authorize->client->getSetting('currency_id');
$payment->client->getNextPaymentNumber($this->authorize->client);
$payment->save();
@ -145,7 +148,7 @@ class AuthorizeCreditCard
}
private function processFailedResponse($data, $request)
{
{ dd($data);
info(print_r($data,1));
}

View File

@ -11,7 +11,7 @@ $factory->define(App\Models\Company::class, function (Faker $faker) {
'db' => config('database.default'),
'settings' => CompanySettings::defaults(),
'custom_fields' => (object) [
'invoice1' => '1|date',
'invoice1' => 'Custom Date|date',
// 'invoice2' => '2|switch',
// 'invoice3' => '3|',
// 'invoice4' => '4',

View File

@ -141,6 +141,8 @@ var AuthorizeAuthorizeCard = /*#__PURE__*/function () {
_defineProperty(this, "handle", function () {
if (_this.cardButton) {
_this.cardButton.addEventListener("click", function () {
_this.cardButton.disabled = true;
_this.handleAuthorization();
});
}
@ -154,6 +156,8 @@ var AuthorizeAuthorizeCard = /*#__PURE__*/function () {
var _loop = function _loop() {
var item = _step.value;
item.addEventListener('click', function () {
item.disabled = true;
_this.handlePayNowAction(item.dataset.id);
});
};
@ -208,6 +212,7 @@ var AuthorizeAuthorizeCard = /*#__PURE__*/function () {
document.getElementById("server_response").submit();
}
this.cardButton.disabled = false;
return false;
}
}]);

View File

@ -7,7 +7,7 @@
"/js/clients/payment_methods/authorize-authorize-card.js": "/js/clients/payment_methods/authorize-authorize-card.js?id=7f63b5cd48631432a424",
"/js/clients/payment_methods/authorize-stripe-card.js": "/js/clients/payment_methods/authorize-stripe-card.js?id=420e22ba244289dd75f8",
"/js/clients/payments/alipay.js": "/js/clients/payments/alipay.js?id=cf114848ef8a3633a51b",
"/js/clients/payments/authorize-credit-card-payment.js": "/js/clients/payments/authorize-credit-card-payment.js?id=1b765d273ca55c87f910",
"/js/clients/payments/authorize-credit-card-payment.js": "/js/clients/payments/authorize-credit-card-payment.js?id=a474e669b65198f7ce6f",
"/js/clients/payments/card-js.min.js": "/js/clients/payments/card-js.min.js?id=3fe6822360e6c456d1a2",
"/js/clients/payments/checkout.com.js": "/js/clients/payments/checkout.com.js?id=31df208670107e18f59d",
"/js/clients/payments/process.js": "/js/clients/payments/process.js?id=f4c4b09d4454070a6db6",

View File

@ -55,6 +55,7 @@ class AuthorizeAuthorizeCard {
responseHandler(response) {
if (response.messages.resultCode === "Error") {
var i = 0;
@ -70,7 +71,8 @@ class AuthorizeAuthorizeCard {
document.getElementById("server_response").submit();
}
this.cardButton.disabled=false;
return false;
}
@ -83,6 +85,8 @@ class AuthorizeAuthorizeCard {
{
this.cardButton.addEventListener("click", () => {
this.cardButton.disabled = true;
this.handleAuthorization();
});
@ -94,7 +98,7 @@ class AuthorizeAuthorizeCard {
for(let item of this.payNowButton) {
item.addEventListener('click', () => {
item.disabled = true;
this.handlePayNowAction(item.dataset.id);
});

View File

@ -31,10 +31,22 @@
<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.enter_payment') }}
</h3>
</div>
<div>
@if($tokens->count() == 0)
<dl>
<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.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ App\Utils\Number::formatMoney($amount_with_fee, $client) }}
</dd>
</div>
@include('portal.ninja2020.gateways.authorize.credit_card')
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
@ -51,21 +63,50 @@
</div>
</dl>
@else
<!-- TODO Iterate through the tokens and display the card type and last4 and present
a button for payment -->
<ul>
@foreach($tokens as $token)
<li>
{{ $token->meta->brand }} : {{ $token->meta->last4 }} : <button class="button button-primary pay_now_button" data-id="{{ $token->hashed_id }}">{{ ctrans('texts.pay_now') }}</button>
</li>
@endforeach
</ul>
<div>
<dl>
<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.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ App\Utils\Number::formatMoney($amount_with_fee, $client) }}
</dd>
</div>
@foreach($tokens as $token)
<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">
{{ $token->meta->brand }} : {{ $token->meta->last4 }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<button class="button button-primary pay_now_button" data-id="{{ $token->hashed_id }}">{{ ctrans('texts.pay_now') }}</button>
</dd>
</div>
@endforeach
</dl>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection
@push('footer')