diff --git a/app/Http/Requests/Invoice/StoreInvoiceRequest.php b/app/Http/Requests/Invoice/StoreInvoiceRequest.php index 6b17e0e0b3d7..d8e05af55f3a 100644 --- a/app/Http/Requests/Invoice/StoreInvoiceRequest.php +++ b/app/Http/Requests/Invoice/StoreInvoiceRequest.php @@ -79,7 +79,9 @@ class StoreInvoiceRequest extends Request $input = $this->decodePrimaryKeys($input); - $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + if (isset($input['line_items']) && is_array($input['line_items'])) + $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; + $input['amount'] = 0; $input['balance'] = 0; diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index e818842fe834..afbe0999a6f7 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -76,7 +76,7 @@ class UpdateInvoiceRequest extends Request $input['id'] = $this->invoice->id; - if (isset($input['line_items'])) { + if (isset($input['line_items']) && is_array($input['line_items'])) { $input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : []; } diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 8dbee2d534ef..7e96cd3439be 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -143,21 +143,24 @@ class ACH $data['customer'] = $this->stripe->findOrCreateCustomer(); $data['amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $intent = - $this->stripe->createPaymentIntent([ - 'amount' => $data['amount'], - 'currency' => $data['currency'], - 'setup_future_usage' => 'off_session', - 'customer' => $data['customer']->id, - 'payment_method_types' => ['us_bank_account'], - ] - ); + $intent = false; - $data['client_secret'] = $intent->client_secret; + if(count($data['tokens']) == 0) + { + $intent = + $this->stripe->createPaymentIntent([ + 'amount' => $data['amount'], + 'currency' => $data['currency'], + 'setup_future_usage' => 'off_session', + 'customer' => $data['customer']->id, + 'payment_method_types' => ['us_bank_account'], + ] + ); + } + $data['client_secret'] = $intent ? $intent->client_secret : false; - return render('gateways.stripe.ach.pay_instant_verification', $data); - // return render('gateways.stripe.ach.pay', $data); + return render('gateways.stripe.ach.pay', $data); } public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) @@ -217,11 +220,21 @@ class ACH } + public function handlePaymentIntentResponse($request) + { + nlog($request->all()); + dd($request->all()); + } + public function paymentResponse($request) { $this->stripe->init(); + //it may be a payment intent here. + if($request->input('client_secret')) + $this->handlePaymentIntentResponse($request); + $source = ClientGatewayToken::query() ->where('id', $this->decodePrimaryKey($request->source)) ->where('company_id', auth()->guard('contact')->user()->client->company->id) diff --git a/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php index 684287124574..3c4dd4e332eb 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php @@ -1,8 +1,22 @@ @extends('portal.ninja2020.layout.payments', ['gateway_title' => 'ACH', 'card_title' => 'ACH']) +@section('gateway_head') + @if($gateway->company_gateway->getConfigField('account_id')) + + + @else + + @endif + + + + +@endsection + @section('gateway_content') + + @if(count($tokens) > 0) - @include('portal.ninja2020.gateways.includes.payment_details') @@ -15,6 +29,8 @@ + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) @@ -32,33 +48,201 @@ @endisset @endcomponent + @include('portal.ninja2020.gateways.includes.pay_now') + @else - @component('portal.ninja2020.components.general.card-element-single', ['title' => 'ACH', 'show_title' => false]) - {{ ctrans('texts.bank_account_not_linked') }} - {{ ctrans('texts.add_payment_method') }} + + @component('portal.ninja2020.components.general.card-element-single') + + @endcomponent + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_name')]) + + @endcomponent + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.email')]) + + @endcomponent +
+
+ Connect a bank account +
+
+ +
+
@endif - @include('portal.ninja2020.gateways.includes.pay_now') @endsection @push('footer') + + @endpush diff --git a/resources/views/portal/ninja2020/gateways/stripe/ach/pay_instant_verification.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ach/pay_instant_verification.blade.php index a5841604a1f9..007b204e0ffc 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/ach/pay_instant_verification.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/pay_instant_verification.blade.php @@ -33,16 +33,18 @@ @endisset @endcomponent - @else - @component('portal.ninja2020.components.general.card-element-single', ['title' => 'ACH', 'show_title' => false]) - {{ ctrans('texts.bank_account_not_linked') }} - {{ ctrans('texts.add_payment_method') }} - - @endcomponent - @endif - @include('portal.ninja2020.gateways.includes.pay_now') + + @else + + @component('portal.ninja2020.components.general.card-element-single', ['title' => 'ACH', 'show_title' => false]) + Pay with a new bank account. + + + @endcomponent + + @endif + @endsection @push('footer')