Client payment flow

This commit is contained in:
David Bomba 2019-09-20 15:13:58 +10:00
parent 6037e30887
commit 4fd41dbe1d
15 changed files with 32 additions and 30 deletions

View File

@ -130,7 +130,6 @@ class InvoiceController extends Controller
return $invoice; return $invoice;
}); });
$formatted_total = Number::formatMoney($total, auth()->user()->client); $formatted_total = Number::formatMoney($total, auth()->user()->client);
$payment_methods = auth()->user()->client->getPaymentMethods($total); $payment_methods = auth()->user()->client->getPaymentMethods($total);

View File

@ -58,6 +58,7 @@ class CreateAccount
* Create company * Create company
*/ */
$company = CreateCompany::dispatchNow($this->request, $account); $company = CreateCompany::dispatchNow($this->request, $account);
$company->load('account');
/* /*
* Set default company * Set default company
*/ */

View File

@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
class CreatedClientActivity class CreatedClientActivity implements ShouldQueue
{ {
protected $activity_repo; protected $activity_repo;
/** /**

View File

@ -18,7 +18,7 @@ use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
class PaymentCreatedActivity class PaymentCreatedActivity implements ShouldQueue
{ {
protected $activityRepo; protected $activityRepo;
/** /**

View File

@ -16,7 +16,7 @@ use App\Repositories\ActivityRepository;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
class UpdateContactLastLogin class UpdateContactLastLogin implements ShouldQueue
{ {
/** /**
* Create the event listener. * Create the event listener.

View File

@ -20,7 +20,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreateInvoiceActivity class CreateInvoiceActivity implements ShouldQueue
{ {
protected $activity_repo; protected $activity_repo;
/** /**

View File

@ -20,7 +20,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class UpdateInvoiceActivity class UpdateInvoiceActivity implements ShouldQueue
{ {
protected $activity_repo; protected $activity_repo;
/** /**

View File

@ -17,7 +17,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
class SendVerificationNotification class SendVerificationNotification implements ShouldQueue
{ {
/** /**
* Create the event listener. * Create the event listener.

View File

@ -278,7 +278,12 @@ class Client extends BaseModel
*/ */
public function getPaymentMethods($amount) :array public function getPaymentMethods($amount) :array
{ {
//this method will get all the possible gateways a client can pay with
//but we also need to consider payment methods that are already stored
//so we MUST filter the company gateways and remove duplicates.
//
//Also need to harvest the list of client gateway tokens and present these
//for instant payment
$company_gateways = $this->getSetting('company_gateways'); $company_gateways = $this->getSetting('company_gateways');
if($company_gateways) if($company_gateways)

View File

@ -132,7 +132,7 @@ class StripePaymentDriver extends BasePaymentDriver
{ {
$intent['intent'] = $this->getSetupIntent(); $intent['intent'] = $this->getSetupIntent();
return view('portal.default.gateways.stripe.create_customer', array_merge($data, $intent)); return view('portal.default.gateways.stripe.add_credit_card', array_merge($data, $intent));
} }

View File

@ -239,9 +239,9 @@ class CreateUsersTable extends Migration
Schema::create('company_tokens', function (Blueprint $table) { Schema::create('company_tokens', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedInteger('company_id'); $table->unsignedInteger('company_id')->index();
$table->unsignedInteger('account_id'); $table->unsignedInteger('account_id');
$table->unsignedInteger('user_id')->index(); $table->unsignedInteger('user_id');
$table->string('token')->nullable(); $table->string('token')->nullable();
$table->string('name')->default(''); $table->string('name')->default('');

View File

@ -3,6 +3,8 @@
use App\DataMapper\ClientSettings; use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings; use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings; use App\DataMapper\DefaultSettings;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Helpers\Invoice\InvoiceCalc;
use App\Models\Account; use App\Models\Account;
use App\Models\Client; use App\Models\Client;
use App\Models\ClientContact; use App\Models\ClientContact;
@ -10,6 +12,7 @@ use App\Models\CompanyGateway;
use App\Models\CompanyToken; use App\Models\CompanyToken;
use App\Models\GatewayType; use App\Models\GatewayType;
use App\Models\GroupSetting; use App\Models\GroupSetting;
use App\Models\Invoice;
use App\Models\User; use App\Models\User;
use App\Models\UserAccount; use App\Models\UserAccount;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -104,6 +107,17 @@ class RandomDataSeeder extends Seeder
/** Invoice Factory */ /** Invoice Factory */
factory(\App\Models\Invoice::class,500)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]); factory(\App\Models\Invoice::class,500)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]);
$invoices = Invoice::all();
$invoices->each(function ($invoice){
$invoice_calc = new InvoiceCalc($invoice, $invoice->settings);
$invoice = $invoice_calc->build()->getInvoice();
$invoice->save();
});
/** Recurring Invoice Factory */ /** Recurring Invoice Factory */
factory(\App\Models\RecurringInvoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]); factory(\App\Models\RecurringInvoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);

View File

@ -72,7 +72,7 @@
</div> </div>
<!-- update payment methods --> <!-- update payment methods
<div class="row" style="margin-top: 30px;"> <div class="row" style="margin-top: 30px;">
<div class="col-sm-6 col-lg-3"> <div class="col-sm-6 col-lg-3">
<div class="card text-white bg-warning h-100"> <div class="card text-white bg-warning h-100">
@ -100,7 +100,7 @@
</div> </div>
</div> </div>
</div> </div>
-->
</div> </div>
</main> </main>
</body> </body>

View File

@ -1,17 +0,0 @@
<!-- Stripe Credit Card TOKEN Form-->
@if($token)
<!-- Stripe Credit Card TOKEN Form-->
@else
<!-- Stripe Credit Card Payment Form-->
<div class="py-md-5">
</div>
<!-- Stripe Credit Card Payment Form-->
@endif
@push('scripts')
<script src="https://js.stripe.com/v3/"></script>
@endpush