2019-05-14 06:05:05 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-14 06:05:05 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Tests;
|
|
|
|
|
2019-09-11 07:32:47 +02:00
|
|
|
use App\DataMapper\ClientSettings;
|
2019-09-18 14:43:37 +02:00
|
|
|
use App\DataMapper\CompanySettings;
|
2019-10-02 12:22:10 +02:00
|
|
|
use App\DataMapper\DefaultSettings;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Factory\ClientFactory;
|
2019-11-21 09:38:57 +01:00
|
|
|
use App\Factory\CompanyUserFactory;
|
2020-01-30 04:02:25 +01:00
|
|
|
use App\Factory\CreditFactory;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Factory\InvoiceFactory;
|
2019-12-16 12:34:38 +01:00
|
|
|
use App\Factory\InvoiceInvitationFactory;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Factory\InvoiceItemFactory;
|
2019-05-24 07:13:17 +02:00
|
|
|
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
2019-11-16 04:12:29 +01:00
|
|
|
use App\Helpers\Invoice\InvoiceSum;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Models\Client;
|
2019-09-18 14:43:37 +02:00
|
|
|
use App\Models\CompanyGateway;
|
2019-10-02 12:22:10 +02:00
|
|
|
use App\Models\CompanyToken;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Models\Credit;
|
2019-09-11 07:32:47 +02:00
|
|
|
use App\Models\GroupSetting;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Models\Invoice;
|
2019-12-16 12:34:38 +01:00
|
|
|
use App\Models\InvoiceInvitation;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Models\Quote;
|
|
|
|
use App\Models\RecurringInvoice;
|
2019-11-20 06:41:49 +01:00
|
|
|
use App\Models\User;
|
2019-05-27 12:48:52 +02:00
|
|
|
use App\Utils\Traits\GeneratesCounter;
|
2019-05-14 06:05:05 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Support\Carbon;
|
2019-11-16 04:12:29 +01:00
|
|
|
use Illuminate\Support\Facades\Cache;
|
2020-01-09 21:15:10 +01:00
|
|
|
use Illuminate\Support\Facades\Hash;
|
2019-11-16 04:12:29 +01:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class MockAccountData
|
|
|
|
* @package Tests\Unit
|
|
|
|
*/
|
|
|
|
trait MockAccountData
|
|
|
|
{
|
2020-03-21 06:37:30 +01:00
|
|
|
use MakesHash;
|
|
|
|
use GeneratesCounter;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public $account;
|
2019-05-27 12:48:52 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public $company;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public $user;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public $client;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2019-10-02 12:22:10 +02:00
|
|
|
public $token;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-02-19 21:44:12 +01:00
|
|
|
public $invoice;
|
|
|
|
|
|
|
|
public $quote;
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
public function makeTestData()
|
|
|
|
{
|
2019-11-16 04:12:29 +01:00
|
|
|
|
|
|
|
/* Warm up the cache !*/
|
|
|
|
$cached_tables = config('ninja.cached_tables');
|
|
|
|
|
|
|
|
foreach ($cached_tables as $name => $class) {
|
2020-01-02 00:09:34 +01:00
|
|
|
|
|
|
|
// check that the table exists in case the migration is pending
|
|
|
|
if (! Schema::hasTable((new $class())->getTable())) {
|
|
|
|
continue;
|
2019-11-16 04:12:29 +01:00
|
|
|
}
|
2020-01-02 00:09:34 +01:00
|
|
|
if ($name == 'payment_terms') {
|
|
|
|
$orderBy = 'num_days';
|
|
|
|
} elseif ($name == 'fonts') {
|
|
|
|
$orderBy = 'sort_order';
|
|
|
|
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
|
|
|
$orderBy = 'name';
|
|
|
|
} else {
|
|
|
|
$orderBy = 'id';
|
|
|
|
}
|
|
|
|
$tableData = $class::orderBy($orderBy)->get();
|
|
|
|
if ($tableData->count()) {
|
|
|
|
Cache::forever($name, $tableData);
|
|
|
|
}
|
2019-11-16 04:12:29 +01:00
|
|
|
}
|
|
|
|
|
2019-05-14 06:05:05 +02:00
|
|
|
$this->account = factory(\App\Models\Account::class)->create();
|
|
|
|
$this->company = factory(\App\Models\Company::class)->create([
|
|
|
|
'account_id' => $this->account->id,
|
|
|
|
]);
|
|
|
|
|
2020-02-17 21:07:32 +01:00
|
|
|
$settings = CompanySettings::defaults();
|
|
|
|
|
|
|
|
$settings->company_logo = 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png';
|
|
|
|
$settings->website = 'www.invoiceninja.com';
|
|
|
|
$settings->address1 = 'Address 1';
|
|
|
|
$settings->address2 = 'Address 2';
|
|
|
|
$settings->city = 'City';
|
|
|
|
$settings->state = 'State';
|
|
|
|
$settings->postal_code = 'Postal Code';
|
|
|
|
$settings->phone = '555-343-2323';
|
|
|
|
$settings->email = 'user@example.com';
|
|
|
|
$settings->country_id = '840';
|
|
|
|
$settings->vat_number = 'vat number';
|
|
|
|
$settings->id_number = 'id number';
|
|
|
|
|
|
|
|
$this->company->settings = $settings;
|
|
|
|
$this->company->save();
|
|
|
|
|
2019-05-14 06:05:05 +02:00
|
|
|
$this->account->default_company_id = $this->company->id;
|
|
|
|
$this->account->save();
|
|
|
|
|
2019-11-20 06:41:49 +01:00
|
|
|
$this->user = User::whereEmail('user@example.com')->first();
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
if (!$this->user) {
|
2019-11-20 06:41:49 +01:00
|
|
|
$this->user = factory(\App\Models\User::class)->create([
|
2020-03-24 10:15:30 +01:00
|
|
|
'account_id' => $this->account->id,
|
2020-01-09 21:15:10 +01:00
|
|
|
'password' => Hash::make('ALongAndBriliantPassword'),
|
2019-11-20 06:41:49 +01:00
|
|
|
'confirmation_code' => $this->createDbHash(config('database.default'))
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2019-11-21 09:38:57 +01:00
|
|
|
$cu = CompanyUserFactory::create($this->user->id, $this->company->id, $this->account->id);
|
|
|
|
$cu->is_owner = true;
|
|
|
|
$cu->is_admin = true;
|
|
|
|
$cu->save();
|
|
|
|
|
2019-10-02 12:22:10 +02:00
|
|
|
$this->token = \Illuminate\Support\Str::random(64);
|
|
|
|
|
|
|
|
$company_token = CompanyToken::create([
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'account_id' => $this->account->id,
|
|
|
|
'name' => 'test token',
|
|
|
|
'token' => $this->token,
|
|
|
|
]);
|
|
|
|
|
2019-11-21 09:38:57 +01:00
|
|
|
// $this->user->companies()->attach($this->company->id, [
|
|
|
|
// 'account_id' => $this->account->id,
|
|
|
|
// 'is_owner' => 1,
|
|
|
|
// 'is_admin' => 1,
|
|
|
|
// 'is_locked' => 0,
|
|
|
|
// 'permissions' => '',
|
|
|
|
// 'settings' => json_encode(DefaultSettings::userSettings()),
|
|
|
|
// ]);
|
2019-10-02 12:22:10 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
// $this->client = ClientFactory::create($this->company->id, $this->user->id);
|
|
|
|
// $this->client->save();
|
2020-02-17 21:07:32 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->client = factory(\App\Models\Client::class)->create([
|
2020-02-17 21:07:32 +01:00
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
]);
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
factory(\App\Models\ClientContact::class, 1)->create([
|
2019-12-16 12:34:38 +01:00
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
'is_primary' => 1,
|
2020-02-17 10:37:44 +01:00
|
|
|
'send_email' => true,
|
2019-12-16 12:34:38 +01:00
|
|
|
]);
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
factory(\App\Models\ClientContact::class, 1)->create([
|
2019-12-16 12:34:38 +01:00
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
'company_id' => $this->company->id,
|
2020-02-17 10:37:44 +01:00
|
|
|
'send_email' => true
|
2019-12-16 12:34:38 +01:00
|
|
|
]);
|
|
|
|
|
2019-09-11 07:32:47 +02:00
|
|
|
$gs = new GroupSetting;
|
|
|
|
$gs->name = 'Test';
|
|
|
|
$gs->company_id = $this->client->company_id;
|
2019-09-19 07:50:05 +02:00
|
|
|
$gs->settings = ClientSettings::buildClientSettings($this->company->settings, $this->client->settings);
|
2019-12-16 12:34:38 +01:00
|
|
|
|
|
|
|
$gs_settings = $gs->settings;
|
|
|
|
$gs_settings->website = 'http://staging.invoicing.co';
|
|
|
|
$gs->settings = $gs_settings;
|
2019-09-11 07:32:47 +02:00
|
|
|
$gs->save();
|
|
|
|
|
|
|
|
$this->client->group_settings_id = $gs->id;
|
|
|
|
$this->client->save();
|
2019-10-22 04:07:00 +02:00
|
|
|
|
2020-02-22 03:25:49 +01:00
|
|
|
$this->invoice = InvoiceFactory::create($this->company->id, $this->user->id);//stub the company and user_id
|
2019-05-14 06:05:05 +02:00
|
|
|
$this->invoice->client_id = $this->client->id;
|
|
|
|
|
2020-02-22 03:25:49 +01:00
|
|
|
// $this->invoice = factory(\App\Models\Invoice::class)->create([
|
|
|
|
// 'user_id' => $this->user->id,
|
|
|
|
// 'client_id' => $this->client->id,
|
|
|
|
// 'company_id' => $this->company->id,
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->invoice->line_items = $this->buildLineItems();
|
|
|
|
$this->invoice->uses_inclusive_taxes = false;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2019-10-22 04:07:00 +02:00
|
|
|
$this->invoice->save();
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->invoice_calc = new InvoiceSum($this->invoice);
|
|
|
|
$this->invoice_calc->build();
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->invoice = $this->invoice_calc->getInvoice();
|
2019-05-14 12:27:47 +02:00
|
|
|
|
2020-02-17 10:37:44 +01:00
|
|
|
$this->invoice->setRelation('client', $this->client);
|
|
|
|
$this->invoice->setRelation('company', $this->company);
|
|
|
|
|
2019-05-14 06:05:05 +02:00
|
|
|
$this->invoice->save();
|
|
|
|
|
2020-02-04 08:51:44 +01:00
|
|
|
$this->invoice->service()->markSent();
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
$this->quote = factory(\App\Models\Quote::class)->create([
|
|
|
|
'user_id' => $this->user->id,
|
|
|
|
'client_id' => $this->client->id,
|
|
|
|
'company_id' => $this->company->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->quote->line_items = $this->buildLineItems();
|
|
|
|
$this->quote->uses_inclusive_taxes = false;
|
|
|
|
|
|
|
|
$this->quote->save();
|
|
|
|
|
|
|
|
$this->quote_calc = new InvoiceSum($this->quote);
|
|
|
|
$this->quote_calc->build();
|
|
|
|
|
|
|
|
$this->quote = $this->quote_calc->getQuote();
|
|
|
|
|
|
|
|
$this->quote->number = $this->getNextQuoteNumber($this->client);
|
|
|
|
|
|
|
|
$this->quote->setRelation('client', $this->client);
|
|
|
|
$this->quote->setRelation('company', $this->company);
|
|
|
|
|
|
|
|
$this->quote->save();
|
2020-01-30 04:02:25 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->credit = CreditFactory::create($this->company->id, $this->user->id);
|
2020-01-30 04:02:25 +01:00
|
|
|
$this->credit->client_id = $this->client->id;
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->credit->line_items = $this->buildLineItems();
|
2020-02-01 21:45:23 +01:00
|
|
|
$this->credit->amount = 10;
|
|
|
|
$this->credit->balance = 10;
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->credit->uses_inclusive_taxes = false;
|
2020-01-30 04:02:25 +01:00
|
|
|
|
|
|
|
$this->credit->save();
|
2019-12-16 12:34:38 +01:00
|
|
|
|
2020-03-04 00:51:50 +01:00
|
|
|
|
|
|
|
$this->credit_calc = new InvoiceSum($this->credit);
|
|
|
|
$this->credit_calc->build();
|
|
|
|
|
|
|
|
$this->credit = $this->credit_calc->getCredit();
|
|
|
|
$this->credit->service()->markSent();
|
|
|
|
|
2019-12-16 12:34:38 +01:00
|
|
|
$contacts = $this->invoice->client->contacts;
|
|
|
|
|
|
|
|
$contacts->each(function ($contact) {
|
|
|
|
$invitation = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
|
|
|
|
->whereClientContactId($contact->id)
|
|
|
|
->whereInvoiceId($this->invoice->id)
|
|
|
|
->first();
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
if (!$invitation && $contact->send_email) {
|
2019-12-16 12:34:38 +01:00
|
|
|
$ii = InvoiceInvitationFactory::create($this->invoice->company_id, $this->invoice->user_id);
|
|
|
|
$ii->invoice_id = $this->invoice->id;
|
|
|
|
$ii->client_contact_id = $contact->id;
|
|
|
|
$ii->save();
|
2020-03-21 06:37:30 +01:00
|
|
|
} elseif ($invitation && !$contact->send_email) {
|
2019-12-16 12:34:38 +01:00
|
|
|
$invitation->delete();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-02-15 12:49:31 +01:00
|
|
|
$invitations = InvoiceInvitation::whereCompanyId($this->invoice->company_id)
|
|
|
|
->whereInvoiceId($this->invoice->id);
|
|
|
|
|
|
|
|
$this->invoice->setRelation('invitations', $invitations);
|
|
|
|
|
|
|
|
$this->invoice->save();
|
|
|
|
|
2020-02-20 22:05:01 +01:00
|
|
|
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount);
|
|
|
|
// UpdateCompanyLedgerWithInvoice::dispatchNow($this->invoice, $this->invoice->amount, $this->invoice->company);
|
2019-05-16 07:36:53 +02:00
|
|
|
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now();
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(2);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(10);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(15);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
|
|
|
|
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now()->addMinutes(20);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
|
|
|
$recurring_invoice = InvoiceToRecurringInvoiceFactory::create($this->invoice);
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->next_send_date = Carbon::now()->addDays(10);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->status_id = RecurringInvoice::STATUS_ACTIVE;
|
|
|
|
$recurring_invoice->remaining_cycles = 2;
|
2019-09-22 12:25:05 +02:00
|
|
|
$recurring_invoice->start_date = Carbon::now();
|
2019-05-24 11:23:38 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-11-27 11:27:24 +01:00
|
|
|
$recurring_invoice->number = $this->getNextInvoiceNumber($this->invoice->client);
|
2019-05-24 07:13:17 +02:00
|
|
|
$recurring_invoice->save();
|
|
|
|
|
2019-09-18 14:43:37 +02:00
|
|
|
$gs = new GroupSetting;
|
|
|
|
$gs->company_id = $this->company->id;
|
|
|
|
$gs->user_id = $this->user->id;
|
2019-09-19 07:50:05 +02:00
|
|
|
$gs->settings = ClientSettings::buildClientSettings(CompanySettings::defaults(), ClientSettings::defaults());
|
2019-09-18 14:43:37 +02:00
|
|
|
$gs->name = 'Default Client Settings';
|
|
|
|
$gs->save();
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
if (config('ninja.testvars.stripe')) {
|
2019-09-18 14:43:37 +02:00
|
|
|
$cg = new CompanyGateway;
|
|
|
|
$cg->company_id = $this->company->id;
|
|
|
|
$cg->user_id = $this->user->id;
|
2019-09-24 13:22:41 +02:00
|
|
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
2019-09-18 14:43:37 +02:00
|
|
|
$cg->require_cvv = true;
|
2019-10-17 13:49:09 +02:00
|
|
|
$cg->show_billing_address = true;
|
2019-09-18 14:43:37 +02:00
|
|
|
$cg->show_shipping_address = true;
|
|
|
|
$cg->update_details = true;
|
|
|
|
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
|
|
|
$cg->save();
|
|
|
|
|
|
|
|
|
|
|
|
$cg = new CompanyGateway;
|
|
|
|
$cg->company_id = $this->company->id;
|
|
|
|
$cg->user_id = $this->user->id;
|
2019-09-24 13:22:41 +02:00
|
|
|
$cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23';
|
2019-09-18 14:43:37 +02:00
|
|
|
$cg->require_cvv = true;
|
2019-10-17 13:49:09 +02:00
|
|
|
$cg->show_billing_address = true;
|
2019-09-18 14:43:37 +02:00
|
|
|
$cg->show_shipping_address = true;
|
|
|
|
$cg->update_details = true;
|
|
|
|
$cg->config = encrypt(config('ninja.testvars.stripe'));
|
|
|
|
$cg->save();
|
|
|
|
}
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2019-09-18 14:43:37 +02:00
|
|
|
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
private function buildLineItems()
|
|
|
|
{
|
|
|
|
$line_items = [];
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$item = InvoiceItemFactory::create();
|
|
|
|
$item->quantity = 1;
|
|
|
|
$item->cost =10;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
$line_items[] = $item;
|
2019-05-14 06:05:05 +02:00
|
|
|
|
2020-03-06 08:50:42 +01:00
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
|
|
|
// $line_items[] = $item;
|
2020-03-05 08:14:57 +01:00
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
return $line_items;
|
|
|
|
}
|
|
|
|
}
|