1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Improve Manual ACH payments

This commit is contained in:
David Bomba 2023-03-09 17:33:10 +11:00
parent ccc763593e
commit c197114ff0
5 changed files with 51 additions and 4 deletions

View File

@ -356,6 +356,20 @@ class ACH
$response = json_decode($request->gateway_response);
$bank_account_response = json_decode($request->bank_account_response);
if($response->status == 'requires_source_action' && $response->next_action->type == 'verify_with_microdeposits')
{
$method = $bank_account_response->payment_method->us_bank_account;
$method = $bank_account_response->payment_method->us_bank_account;
$method->id = $response->payment_method;
$method->state = 'unauthorized';
$method->next_action = $response->next_action->verify_with_microdeposits->hosted_verification_url;
$customer = $this->stripe->getCustomer($request->customer);
$cgt = $this->storePaymentMethod($method, GatewayType::BANK_TRANSFER, $customer);
return redirect()->route('client.payment_methods.show', ['payment_method' => $cgt->hashed_id]);
}
$method = $bank_account_response->payment_method->us_bank_account;
$method->id = $response->payment_method;
$method->state = 'authorized';
@ -547,6 +561,10 @@ class ACH
$payment_meta->type = GatewayType::BANK_TRANSFER;
$payment_meta->state = $state;
if(property_exists($method, 'next_action')) {
$payment_meta->next_action = $method->next_action;
}
$data = [
'payment_meta' => $payment_meta,
'token' => $method->id,

View File

@ -78,8 +78,21 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
$this->payment_completed = true;
}
}
nlog($transaction);
if(isset($transaction['payment_method']))
{
$cgt = ClientGatewayToken::where('token', $transaction['payment_method'])->first();
if($cgt && $cgt->meta?->state == 'unauthorized'){
$meta = $cgt->meta;
$meta->state = 'authorized';
$cgt->meta = $meta;
$cgt->save();
}
}
}
if ($this->payment_completed) {
return;

View File

@ -90,15 +90,21 @@ class UpdatePaymentMethods
);
foreach ($bank_methods->data as $method) {
$token_exists = ClientGatewayToken::where([
$token = ClientGatewayToken::where([
'gateway_customer_reference' => $customer->id,
'token' => $method->id,
'client_id' => $client->id,
'company_id' => $client->company_id,
])->exists();
])->first();
/* Already exists return */
if ($token_exists) {
if ($token) {
$meta = $token->meta;
$meta->state = 'authorized';
$token->meta = $meta;
$token->save();
continue;
}

View File

@ -213,6 +213,10 @@
errors.textContent = "You will receive an email with details on how to verify your bank account and process payment.";
errors.hidden = false;
document.getElementById('new-bank').style.visibility = 'hidden'
let gateway_response = document.getElementById('gateway_response');
gateway_response.value = JSON.stringify(paymentIntent);
document.getElementById('server-response').submit();
}
});

View File

@ -100,9 +100,15 @@
</div>
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
<div class="inline-flex rounded-md shadow-sm" x-data="{ open: false }">
@if (substr($payment_method->token, 0, 2) === 'pm')
<a href="{{ $payment_method->meta?->next_action }}" class="button button-primary bg-primary">
{{ ctrans('texts.complete_verification') }}
</a>
@else
<a href="{{ route('client.payment_methods.verification', ['payment_method' => $payment_method->hashed_id, 'method' => \App\Models\GatewayType::BANK_TRANSFER]) }}" class="button button-primary bg-primary">
{{ ctrans('texts.complete_verification') }}
</a>
@endif
</div>
</div>
</div>