diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 13556fdc5d..e57cc00007 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -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); } diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index 889d4dea5c..5e34fc587e 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -15,6 +15,7 @@ namespace App\Http\Controllers\Traits; use App\Models\User; use App\Utils\Traits\UserSessionAttributes; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; /** * Class VerifiesUserEmail @@ -30,20 +31,49 @@ trait VerifiesUserEmail */ public function confirm() { - if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->route('confirmation_code'))->first()) { - $user->email_verified_at = now(); - $user->confirmation_code = null; - $user->save(); + $user = User::where('confirmation_code', request()->confirmation_code)->first(); + + // if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->input('confirmation_code'))->first()) { - return $this->render('auth.confirmed', [ - 'root' => 'themes', - 'message' => ctrans('texts.security_confirmation'), - ]); + if (!$user) { + return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]); } + if (is_null($user->password) || empty($user->password)) { + return $this->render('auth.confirmation_with_password', ['root' => 'themes']); + } + + $user->email_verified_at = now(); + $user->confirmation_code = null; + $user->save(); + return $this->render('auth.confirmed', [ 'root' => 'themes', - 'message' => ctrans('texts.wrong_confirmation'), + 'message' => ctrans('texts.security_confirmation'), + ]); + } + + public function confirmWithPassword() + { + $user = User::where('confirmation_code', request()->confirmation_code)->first(); + + if (!$user) { + return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]); + } + + request()->validate([ + 'password' => ['required', 'min:6', 'confirmed'], + ]); + + $user->password = Hash::make(request()->password); + + $user->email_verified_at = now(); + $user->confirmation_code = null; + $user->save(); + + return $this->render('auth.confirmed', [ + 'root' => 'themes', + 'message' => ctrans('texts.security_confirmation'), ]); } } diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index cff4ceda3e..3e329e14ba 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -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); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 74905738a8..d06eaaf5a9 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3223,7 +3223,8 @@ return [ 'month_invalid' => 'Provided month is not valid.', 'year_invalid' => 'Provided year is not valid.', - 'if_you_need_help' => 'If you need help you can either post to our', - + 'if_you_need_help' => 'If you need help you can either post to our', 'reversed' => 'Reversed', + 'update_password_on_confirm' => 'After updating password, your account will be confirmed.', + 'bank_account_not_linked' => 'To pay with bank account, first you have to add it as payment method.', ]; 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 46182a54c5..d4ffdf84a2 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/pay.blade.php @@ -2,18 +2,20 @@ @section('meta_title', ctrans('texts.ach')) @section('body') -
+ @if($token) + + @endif