1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge branch 'v2' into v2-2606-client-portal-improvements

This commit is contained in:
David Bomba 2020-06-27 07:49:33 +10:00 committed by GitHub
commit 3e3dd95262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 143 additions and 51 deletions

View File

@ -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);
}

View File

@ -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'),
]);
}
}

View File

@ -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);
}

View File

@ -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.',
];

View File

@ -2,18 +2,20 @@
@section('meta_title', ctrans('texts.ach'))
@section('body')
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@if($token)
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
@foreach($invoices as $invoice)
<input type="hidden" name="hashed_ids[]" value="{{ $invoice->hashed_id }}">
@endforeach
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="{{ $token->meta->id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
</form>
@endif
<div class="container mx-auto">
<div class="grid grid-cols-6 gap-4">
@ -29,27 +31,36 @@
</p>
</div>
<div>
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@if($token)
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.payment_type') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ ctrans('texts.ach') }} ({{ ctrans('texts.bank_transfer') }}) (****{{ $token->meta->last4 }})
</dd>
</div>
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 flex items-center">
<dt class="text-sm leading-5 font-medium text-gray-500 mr-4">
{{ ctrans('texts.amount') }}
</dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span class="font-bold">{{ App\Utils\Number::formatMoney($amount, $client) }}</span>
</dd>
</div>
<div class="bg-gray-50 px-4 py-5 flex justify-end">
<button type="button" id="pay-now" class="button button-primary" onclick="document.getElementById('server-response').submit()">
{{ ctrans('texts.pay_now') }}
</button>
</div>
@else
<div class="bg-gray-50 px-4 py-5 sm:px-6 flex items-center">
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
<span>{{ ctrans('texts.bank_account_not_linked') }}</span>
<a class="button button-link" href="{{ route('client.payment_methods.index') }}">{{ ctrans('texts.add_payment_method') }}</a>
</dd>
</div>
@endif
</div>
</div>
</div>

View File

@ -0,0 +1,43 @@
@extends('portal.ninja2020.layout.clean')
@section('meta_title', ctrans('texts.set_password'))
@section('body')
<div class="flex h-screen">
<div class="m-auto md:w-1/3 lg:w-1/5">
<div class="flex flex-col">
<img src="{{ asset('images/invoiceninja-black-logo-2.png') }}" class="border-b border-gray-100 h-18 pb-4" alt="Invoice Ninja logo">
<h1 class="text-center text-3xl mt-10">{{ ctrans('texts.set_password') }}</h1>
<span class="text-gray-900 text-sm text-center">{{ ctrans('texts.update_password_on_confirm') }}</span>
<form action="{{ url()->current() }}" method="post" class="mt-6">
@csrf
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
<input type="password" name="password" id="password"
class="input"
autofocus>
@error('password')
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password_confirmation') }}</label>
<input type="password" name="password_confirmation" id="password_confirmation"
class="input"
autofocus>
@error('password_confirmation')
<div class="validation validation-fail">
{{ $message }}
</div>
@enderror
</div>
<div class="mt-5">
<button class="button button-primary button-block">{{ ctrans('texts.update') }}</button>
</div>
</form>
</div>
</div>
</div>
@endsection

View File

@ -38,7 +38,7 @@
@enderror
</div>
<div class="flex flex-col mt-4">
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
<label for="password" class="input-label">{{ ctrans('texts.password_confirmation') }}</label>
<input type="password" name="password_confirmation" id="password_confirmation"
class="input"
autofocus>

View File

@ -30,4 +30,5 @@ Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('passw
*/
Route::group(['middleware' => ['url_db']], function () {
Route::get('/user/confirm/{confirmation_code}', 'UserController@confirm');
Route::post('/user/confirm/{confirmation_code}', 'UserController@confirmWithPassword');
});