mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve Manual ACH payments
This commit is contained in:
parent
ccc763593e
commit
c197114ff0
@ -356,6 +356,20 @@ class ACH
|
|||||||
$response = json_decode($request->gateway_response);
|
$response = json_decode($request->gateway_response);
|
||||||
$bank_account_response = json_decode($request->bank_account_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 = $bank_account_response->payment_method->us_bank_account;
|
||||||
$method->id = $response->payment_method;
|
$method->id = $response->payment_method;
|
||||||
$method->state = 'authorized';
|
$method->state = 'authorized';
|
||||||
@ -547,6 +561,10 @@ class ACH
|
|||||||
$payment_meta->type = GatewayType::BANK_TRANSFER;
|
$payment_meta->type = GatewayType::BANK_TRANSFER;
|
||||||
$payment_meta->state = $state;
|
$payment_meta->state = $state;
|
||||||
|
|
||||||
|
if(property_exists($method, 'next_action')) {
|
||||||
|
$payment_meta->next_action = $method->next_action;
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'payment_meta' => $payment_meta,
|
'payment_meta' => $payment_meta,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
|
@ -78,8 +78,21 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
|
|
||||||
$this->payment_completed = true;
|
$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) {
|
if ($this->payment_completed) {
|
||||||
return;
|
return;
|
||||||
|
@ -90,15 +90,21 @@ class UpdatePaymentMethods
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($bank_methods->data as $method) {
|
foreach ($bank_methods->data as $method) {
|
||||||
$token_exists = ClientGatewayToken::where([
|
$token = ClientGatewayToken::where([
|
||||||
'gateway_customer_reference' => $customer->id,
|
'gateway_customer_reference' => $customer->id,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'company_id' => $client->company_id,
|
'company_id' => $client->company_id,
|
||||||
])->exists();
|
])->first();
|
||||||
|
|
||||||
/* Already exists return */
|
/* Already exists return */
|
||||||
if ($token_exists) {
|
if ($token) {
|
||||||
|
|
||||||
|
$meta = $token->meta;
|
||||||
|
$meta->state = 'authorized';
|
||||||
|
$token->meta = $meta;
|
||||||
|
$token->save();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,10 @@
|
|||||||
errors.textContent = "You will receive an email with details on how to verify your bank account and process payment.";
|
errors.textContent = "You will receive an email with details on how to verify your bank account and process payment.";
|
||||||
errors.hidden = false;
|
errors.hidden = false;
|
||||||
document.getElementById('new-bank').style.visibility = 'hidden'
|
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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,9 +100,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
|
<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 }">
|
<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">
|
<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') }}
|
{{ ctrans('texts.complete_verification') }}
|
||||||
</a>
|
</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user