1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Fix ACH payments with tokens

This commit is contained in:
Benjamin Beganović 2020-06-26 13:25:58 +02:00
parent 0103251534
commit 525a1d065c
4 changed files with 58 additions and 39 deletions

View File

@ -44,8 +44,12 @@ class PaymentMethodController extends Controller
{
$gateway = auth()->user()->client->getCreditCardGateway();
return $gateway->driver(auth()->user()->client)->authorizeView(GatewayType::CREDIT_CARD);
$data['gateway'] = $gateway;
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->authorizeView($data);
}
/**
@ -57,9 +61,11 @@ class PaymentMethodController extends Controller
public function store(Request $request)
{
$gateway = auth()->user()->client->getCreditCardGateway();
return $gateway->driver(auth()->user()->client)->authorizeResponseView($request->all());
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->authorizeResponse($request);
}
/**
@ -104,7 +110,7 @@ class PaymentMethodController extends Controller
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH')
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->verificationView($payment_method);
}
@ -114,7 +120,7 @@ class PaymentMethodController extends Controller
return $gateway
->driver(auth()->user()->client)
->setPaymentMethod('App\\PaymentDrivers\\Stripe\\ACH')
->setPaymentMethod(GatewayType::BANK_TRANSFER)
->processVerification($payment_method);
}

View File

@ -172,7 +172,7 @@ class StripePaymentDriver extends BasePaymentDriver
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function authorizeCreditCardResponse($request)
public function authorizeResponse($request)
{
return $this->payment_method->authorizeResponse($request);
}

View File

@ -3224,4 +3224,6 @@ return [
'year_invalid' => 'Provided year is not valid.',
'if_you_need_help' => 'If you need help you can either post to our',
'bank_account_not_linked' => 'To pay with bank account, first you have to add it as payment method.',
];

View File

@ -2,18 +2,20 @@
@section('meta_title', ctrans('texts.ach'))
@section('body')
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@if($token)
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@endif
<div class="container mx-auto">
<div class="grid grid-cols-6 gap-4">
@ -29,27 +31,36 @@
</p>
</div>
<div>
<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.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white 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.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@if($token)
<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.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white 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.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@else
<div class="bg-gray-50 px-4 py-5 sm:px-6 flex items-center">
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span>{{ ctrans('texts.bank_account_not_linked') }}</span>
<a class="button button-link" href="{{ route('client.payment_methods.index') }}">{{ ctrans('texts.add_payment_method') }}</a>
</dd>
</div>
@endif
</div>
</div>
</div>