From 7e1cc642471aaf4fa7c09e388d2110e14fc050e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Sat, 10 Apr 2021 10:44:06 +0200 Subject: [PATCH] Send ACH notification e-mail after connecting bank account --- .../ClientPortal/PaymentMethodController.php | 25 +---------- .../Gateways/ACHVerificationNotification.php | 43 +++++++++++++++++++ app/PaymentDrivers/Stripe/ACH.php | 13 +++++- .../ach-verification-notification.blade.php | 14 ++++++ routes/client.php | 2 +- 5 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 app/Mail/Gateways/ACHVerificationNotification.php create mode 100644 resources/views/email/gateways/ach-verification-notification.blade.php diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 1ed3c9c004..53fde312a8 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -89,29 +89,6 @@ class PaymentMethodController extends Controller ]); } - /** - * Show the form for editing the specified resource. - * - * @param int $id - * @return void - */ - public function edit($id) - { - // - } - - /** - * Update the specified resource in storage. - * - * @param Request $request - * @param int $id - * @return void - */ - public function update(Request $request, $id) - { - // - } - public function verify(ClientGatewayToken $payment_method) { $gateway = $this->getClientGateway(); @@ -151,7 +128,7 @@ class PaymentMethodController extends Controller event(new MethodDeleted($payment_method, auth('contact')->user()->company, Ninja::eventVars())); $payment_method->delete(); } catch (Exception $e) { - + nlog($e->getMessage()); return back(); diff --git a/app/Mail/Gateways/ACHVerificationNotification.php b/app/Mail/Gateways/ACHVerificationNotification.php new file mode 100644 index 0000000000..69bf8b30e4 --- /dev/null +++ b/app/Mail/Gateways/ACHVerificationNotification.php @@ -0,0 +1,43 @@ +view('email.gateways.ach-verification-notification'); + } +} diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 3d991a7edd..330ae6fdaf 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -14,8 +14,11 @@ namespace App\PaymentDrivers\Stripe; use App\Exceptions\PaymentFailed; use App\Http\Requests\Request; +use App\Jobs\Mail\NinjaMailerJob; +use App\Jobs\Mail\NinjaMailerObject; use App\Jobs\Mail\PaymentFailureMailer; use App\Jobs\Util\SystemLogger; +use App\Mail\Gateways\ACHVerificationNotification; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; @@ -47,7 +50,7 @@ class ACH return render('gateways.stripe.ach.authorize', array_merge($data)); } - public function authorizeResponse($request) + public function authorizeResponse(Request $request) { $this->stripe->init(); @@ -63,6 +66,14 @@ class ACH $client_gateway_token = $this->storePaymentMethod($source, $request->input('method'), $customer); + $mailer = new NinjaMailerObject(); + $mailer->mailable = new ACHVerificationNotification(); + $mailer->company = auth('contact')->user()->client->company; + $mailer->settings = auth('contact')->user()->client->company->settings; + $mailer->to_user = auth('contact')->user(); + + NinjaMailerJob::dispatchNow($mailer); + return redirect()->route('client.payment_methods.verification', ['payment_method' => $client_gateway_token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]); } diff --git a/resources/views/email/gateways/ach-verification-notification.blade.php b/resources/views/email/gateways/ach-verification-notification.blade.php new file mode 100644 index 0000000000..ffc804d990 --- /dev/null +++ b/resources/views/email/gateways/ach-verification-notification.blade.php @@ -0,0 +1,14 @@ +@component('email.template.master', ['design' => 'light']) + @slot('header') + @include('email.components.header', ['logo' => 'https://www.invoiceninja.com/wp-content/uploads/2015/10/logo-white-horizontal-1.png']) + @endslot + +

Hello,

+ +

Connecting bank accounts require verification. Stripe will automatically sends two + small deposits for this purpose. These deposits take 1-2 business days to appear on the customer's online + statement. +

+ +

Thank you!

+@endcomponent diff --git a/routes/client.php b/routes/client.php index 32ba6eb1b9..e4509bb18f 100644 --- a/routes/client.php +++ b/routes/client.php @@ -54,7 +54,7 @@ Route::group(['middleware' => ['auth:contact', 'locale', 'check_client_existence Route::get('payment_methods/{payment_method}/verification', 'ClientPortal\PaymentMethodController@verify')->name('payment_methods.verification'); Route::post('payment_methods/{payment_method}/verification', 'ClientPortal\PaymentMethodController@processVerification'); - Route::resource('payment_methods', 'ClientPortal\PaymentMethodController'); // name = (payment_methods. index / create / show / update / destroy / edit + Route::resource('payment_methods', 'ClientPortal\PaymentMethodController')->except(['edit', 'update']); // name = (payment_methods. index / create / show / update / destroy / edit Route::match(['GET', 'POST'], 'quotes/approve', 'ClientPortal\QuoteController@bulk')->name('quotes.bulk'); Route::get('quotes', 'ClientPortal\QuoteController@index')->name('quotes.index')->middleware('portal_enabled');