mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 15:44:30 -04:00
commit
60d5709ec8
@ -1 +1 @@
|
||||
5.1.2
|
||||
5.1.3
|
@ -315,7 +315,7 @@ class CheckData extends Command
|
||||
$total_invoice_payments += $credit_total_applied;
|
||||
} //todo this is contentious
|
||||
|
||||
nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
|
||||
// nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
|
||||
|
||||
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
||||
$wrong_paid_to_dates++;
|
||||
|
@ -120,7 +120,7 @@ class CreateSingleAccount extends Command
|
||||
$company_token->company_id = $company->id;
|
||||
$company_token->account_id = $account->id;
|
||||
$company_token->name = 'test token';
|
||||
$company_token->token = Str::random(64);
|
||||
$company_token->token = 'company-token-test';
|
||||
$company_token->is_system = true;
|
||||
|
||||
$company_token->save();
|
||||
|
@ -339,7 +339,7 @@ class DemoMode extends Command
|
||||
]);
|
||||
|
||||
|
||||
$vendor->id_number = $this->getNextVendorNumber($vendor);
|
||||
$vendor->number = $this->getNextVendorNumber($vendor);
|
||||
$vendor->save();
|
||||
}
|
||||
|
||||
|
66
app/Console/Commands/ParallelCheckData.php
Normal file
66
app/Console/Commands/ParallelCheckData.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App;
|
||||
use App\Jobs\Ninja\CheckCompanyData;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyLedger;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
use App\Models\Payment;
|
||||
use App\Utils\Ninja;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
use Mail;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Class CheckData.
|
||||
*/
|
||||
class ParallelCheckData extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'ninja:pcheck-data';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check company data in parallel';
|
||||
|
||||
protected $log = '';
|
||||
|
||||
protected $isValid = true;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$hash = Str::random(32);
|
||||
|
||||
Company::cursor()->each(function ($company) use ($hash){
|
||||
|
||||
CheckCompanyData::dispatch($company, $hash)->onQueue('checkdata');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -238,7 +238,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate1_total;
|
||||
|
||||
if ($item_tax_rate1_total > 0) {
|
||||
if ($item_tax_rate1_total != 0) {
|
||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate2_total;
|
||||
|
||||
if ($item_tax_rate2_total > 0) {
|
||||
if ($item_tax_rate2_total != 0) {
|
||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate3_total;
|
||||
|
||||
if ($item_tax_rate3_total > 0) {
|
||||
if ($item_tax_rate3_total != 0) {
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate1_total;
|
||||
|
||||
if ($item_tax_rate1_total > 0) {
|
||||
if ($item_tax_rate1_total != 0) {
|
||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate2_total;
|
||||
|
||||
if ($item_tax_rate2_total > 0) {
|
||||
if ($item_tax_rate2_total != 0) {
|
||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate3_total;
|
||||
|
||||
if ($item_tax_rate3_total > 0) {
|
||||
if ($item_tax_rate3_total != 0) {
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
}
|
||||
}
|
||||
|
335
app/Jobs/Ninja/CheckCompanyData.php
Normal file
335
app/Jobs/Ninja/CheckCompanyData.php
Normal file
@ -0,0 +1,335 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Jobs\Ninja;
|
||||
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyLedger;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\Middleware\RateLimited;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Turbo124\Beacon\Jobs\Database\MySQL\DbStatus;
|
||||
|
||||
class CheckCompanyData implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public $company;
|
||||
|
||||
public $hash;
|
||||
|
||||
public $company_data = [];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Company $company, string $hash)
|
||||
{
|
||||
$this->company = $company;
|
||||
$this->hash = $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$this->checkInvoiceBalances();
|
||||
$this->checkInvoicePayments();
|
||||
$this->checkPaidToDates();
|
||||
$this->checkClientBalances();
|
||||
$this->checkContacts();
|
||||
$this->checkCompanyData();
|
||||
|
||||
|
||||
if(Cache::has($this->hash))
|
||||
$cache_instance = Cache::get($this->hash);
|
||||
else
|
||||
$cache_instance = Cache::add($this->hash, '');
|
||||
|
||||
$cache_instance[$this->company->company_hash] = $this->company_data;
|
||||
|
||||
Cache::put($this->hash, $cache_instance, now()->addMinutes(30));
|
||||
|
||||
|
||||
nlog(Cache::get($this->hash));
|
||||
|
||||
}
|
||||
|
||||
public function middleware()
|
||||
{
|
||||
return [new RateLimited('checkdata')];
|
||||
}
|
||||
|
||||
|
||||
private function checkInvoiceBalances()
|
||||
{
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
foreach ($this->company->clients->where('is_deleted', 0)->cursor() as $client) {
|
||||
$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$credit_balance = $client->credits->where('is_deleted', false)->sum('balance');
|
||||
|
||||
if($client->balance != $invoice_balance)
|
||||
$invoice_balance -= $credit_balance;//doesn't make sense to remove the credit amount
|
||||
|
||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||
|
||||
if ($ledger && number_format($invoice_balance, 4) != number_format($client->balance, 4)) {
|
||||
$wrong_balances++;
|
||||
|
||||
$this->company_data[] = "# {$client->id} " . $client->present()->name.' - '.$client->number." - Balance Failure - Invoice Balances = {$invoice_balance} Client Balance = {$client->balance} Ledger Balance = {$ledger->balance}";
|
||||
|
||||
$this->isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->logMessage("{$wrong_balances} clients with incorrect balances");
|
||||
}
|
||||
|
||||
private function checkInvoicePayments()
|
||||
{
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
$this->company->clients->where('is_deleted', 0)->cursor()->each(function ($client) use ($wrong_balances) {
|
||||
$client->invoices->where('is_deleted', false)->whereIn('status_id', '!=', Invoice::STATUS_DRAFT)->each(function ($invoice) use ($wrong_balances, $client) {
|
||||
$total_amount = $invoice->payments->whereIn('status_id', [Payment::STATUS_PAID, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.amount');
|
||||
$total_refund = $invoice->payments->whereIn('status_id', [Payment::STATUS_PAID, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED])->sum('pivot.refunded');
|
||||
$total_credit = $invoice->credits->sum('amount');
|
||||
|
||||
$total_paid = $total_amount - $total_refund;
|
||||
$calculated_paid_amount = $invoice->amount - $invoice->balance - $total_credit;
|
||||
|
||||
if ((string)$total_paid != (string)($invoice->amount - $invoice->balance - $total_credit)) {
|
||||
$wrong_balances++;
|
||||
|
||||
$this->company_data[] = $client->present()->name.' - '.$client->id." - Total Amount = {$total_amount} != Calculated Total = {$calculated_paid_amount} - Total Refund = {$total_refund} Total credit = {$total_credit}";
|
||||
|
||||
$this->isValid = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$this->company_data[] = "{$wrong_balances} clients with incorrect invoice balances";
|
||||
}
|
||||
|
||||
private function checkPaidToDates()
|
||||
{
|
||||
$wrong_paid_to_dates = 0;
|
||||
$credit_total_applied = 0;
|
||||
|
||||
$this->company->clients->where('is_deleted', 0)->cursor()->each(function ($client) use ($wrong_paid_to_dates, $credit_total_applied) {
|
||||
$total_invoice_payments = 0;
|
||||
|
||||
foreach ($client->invoices->where('is_deleted', false)->where('status_id', '>', 1) as $invoice) {
|
||||
// $total_amount = $invoice->payments->whereNull('deleted_at')->sum('pivot.amount');
|
||||
// $total_refund = $invoice->payments->whereNull('deleted_at')->sum('pivot.refunded');
|
||||
|
||||
$total_amount = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])->sum('pivot.amount');
|
||||
$total_refund = $invoice->payments->where('is_deleted', false)->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment:: STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])->sum('pivot.refunded');
|
||||
|
||||
$total_invoice_payments += ($total_amount - $total_refund);
|
||||
}
|
||||
|
||||
foreach ($client->payments as $payment) {
|
||||
$credit_total_applied += $payment->paymentables->where('paymentable_type', App\Models\Credit::class)->sum(DB::raw('amount'));
|
||||
}
|
||||
|
||||
if ($credit_total_applied < 0) {
|
||||
$total_invoice_payments += $credit_total_applied;
|
||||
} //todo this is contentious
|
||||
|
||||
// nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
|
||||
|
||||
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
||||
$wrong_paid_to_dates++;
|
||||
|
||||
$this->company_data[] = $client->present()->name.'id = # '.$client->id." - Paid to date does not match Client Paid To Date = {$client->paid_to_date} - Invoice Payments = {$total_invoice_payments}";
|
||||
|
||||
$this->isValid = false;
|
||||
}
|
||||
});
|
||||
|
||||
$this->company_data[] = "{$wrong_paid_to_dates} clients with incorrect paid to dates";
|
||||
}
|
||||
|
||||
|
||||
private function checkClientBalances()
|
||||
{
|
||||
$wrong_balances = 0;
|
||||
$wrong_paid_to_dates = 0;
|
||||
|
||||
foreach ($this->company->clients->where('is_deleted', 0)->cursor() as $client) {
|
||||
//$invoice_balance = $client->invoices->where('is_deleted', false)->where('status_id', '>', 1)->sum('balance');
|
||||
$invoice_balance = Invoice::where('client_id', $client->id)->where('is_deleted', false)->where('status_id', '>', 1)->withTrashed()->sum('balance');
|
||||
$credit_balance = Credit::where('client_id', $client->id)->where('is_deleted', false)->withTrashed()->sum('balance');
|
||||
|
||||
/*Legacy - V4 will add credits to the balance - we may need to reverse engineer this and remove the credits from the client balance otherwise we need this hack here and in the invoice balance check.*/
|
||||
if($client->balance != $invoice_balance)
|
||||
$invoice_balance -= $credit_balance;
|
||||
|
||||
$ledger = CompanyLedger::where('client_id', $client->id)->orderBy('id', 'DESC')->first();
|
||||
|
||||
if ($ledger && (string) $invoice_balance != (string) $client->balance) {
|
||||
$wrong_paid_to_dates++;
|
||||
|
||||
$this->company_data[] = $client->present()->name.' - '.$client->id." - calculated client balances do not match {$invoice_balance} - ".rtrim($client->balance, '0');
|
||||
|
||||
$this->isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->company_data[] = "{$wrong_paid_to_dates} clients with incorrect client balances";
|
||||
}
|
||||
|
||||
private function checkContacts()
|
||||
{
|
||||
// check for contacts with the contact_key value set
|
||||
$contacts = DB::table('client_contacts')
|
||||
->where('company_id', $this->company_id)
|
||||
->whereNull('contact_key')
|
||||
->orderBy('id')
|
||||
->get(['id']);
|
||||
|
||||
$this->company_data[] = $contacts->count().' contacts without a contact_key';
|
||||
|
||||
if ($contacts->count() > 0) {
|
||||
$this->isValid = false;
|
||||
}
|
||||
|
||||
if ($this->option('fix') == 'true') {
|
||||
foreach ($contacts as $contact) {
|
||||
DB::table('client_contacts')
|
||||
->where('company_id', $this->company->id)
|
||||
->where('id', '=', $contact->id)
|
||||
->whereNull('contact_key')
|
||||
->update([
|
||||
'contact_key' => str_random(config('ninja.key_length')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// check for missing contacts
|
||||
$clients = DB::table('clients')
|
||||
->where('company_id', $this->company->id)
|
||||
->leftJoin('client_contacts', function ($join) {
|
||||
$join->on('client_contacts.client_id', '=', 'clients.id')
|
||||
->whereNull('client_contacts.deleted_at');
|
||||
})
|
||||
->groupBy('clients.id', 'clients.user_id', 'clients.company_id')
|
||||
->havingRaw('count(client_contacts.id) = 0');
|
||||
|
||||
if ($this->option('client_id')) {
|
||||
$clients->where('clients.id', '=', $this->option('client_id'));
|
||||
}
|
||||
|
||||
$clients = $clients->get(['clients.id', 'clients.user_id', 'clients.company_id']);
|
||||
|
||||
$this->company_data[] = $clients->count().' clients without any contacts';
|
||||
|
||||
if ($clients->count() > 0) {
|
||||
$this->isValid = false;
|
||||
}
|
||||
|
||||
if ($this->option('fix') == 'true') {
|
||||
foreach ($clients as $client) {
|
||||
$contact = new ClientContact();
|
||||
$contact->company_id = $client->company_id;
|
||||
$contact->user_id = $client->user_id;
|
||||
$contact->client_id = $client->id;
|
||||
$contact->is_primary = true;
|
||||
$contact->send_invoice = true;
|
||||
$contact->contact_key = str_random(config('ninja.key_length'));
|
||||
$contact->save();
|
||||
}
|
||||
}
|
||||
|
||||
// check for more than one primary contact
|
||||
$clients = DB::table('clients')
|
||||
->where('company_id', $this->company->id)
|
||||
->leftJoin('client_contacts', function ($join) {
|
||||
$join->on('client_contacts.client_id', '=', 'clients.id')
|
||||
->where('client_contacts.is_primary', '=', true)
|
||||
->whereNull('client_contacts.deleted_at');
|
||||
})
|
||||
->groupBy('clients.id')
|
||||
->havingRaw('count(client_contacts.id) != 1');
|
||||
|
||||
if ($this->option('client_id')) {
|
||||
$clients->where('clients.id', '=', $this->option('client_id'));
|
||||
}
|
||||
|
||||
$clients = $clients->get(['clients.id', DB::raw('count(client_contacts.id)')]);
|
||||
$this->company_data[] = $clients->count().' clients without a single primary contact';
|
||||
|
||||
if ($clients->count() > 0) {
|
||||
$this->isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function checkCompanyData()
|
||||
{
|
||||
$tables = [
|
||||
'activities' => [
|
||||
'invoice',
|
||||
'client',
|
||||
'client_contact',
|
||||
'payment',
|
||||
],
|
||||
'invoices' => [
|
||||
'client',
|
||||
],
|
||||
'payments' => [
|
||||
'client',
|
||||
],
|
||||
'products' => [
|
||||
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($tables as $table => $entityTypes) {
|
||||
foreach ($entityTypes as $entityType) {
|
||||
$tableName = $this->pluralizeEntityType($entityType);
|
||||
$field = $entityType;
|
||||
if ($table == 'companies') {
|
||||
$company_id = 'id';
|
||||
} else {
|
||||
$company_id = 'company_id';
|
||||
}
|
||||
$records = DB::table($table)
|
||||
->join($tableName, "{$tableName}.id", '=', "{$table}.{$field}_id")
|
||||
->where("{$table}.{$company_id}", '!=', DB::raw("{$tableName}.company_id"))
|
||||
->get(["{$table}.id"]);
|
||||
|
||||
if ($records->count()) {
|
||||
$this->isValid = false;
|
||||
$this->company_data[] = $records->count()." {$table} records with incorrect {$entityType} company id";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -932,6 +932,11 @@ class Import implements ShouldQueue
|
||||
],
|
||||
];
|
||||
|
||||
if(in_array($payment->status_id, [Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED])) {
|
||||
$this->processPaymentRefund($payment);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Payment::reguard();
|
||||
@ -941,6 +946,24 @@ class Import implements ShouldQueue
|
||||
$payment_repository = null;
|
||||
}
|
||||
|
||||
private function processPaymentRefund($payment)
|
||||
{
|
||||
$invoices = $payment->invoices()->get();
|
||||
|
||||
$invoices->each(function ($invoice) use($payment) {
|
||||
|
||||
if ($payment->refunded > 0 && in_array($invoice->status_id, [Invoice::STATUS_SENT])) {
|
||||
|
||||
$invoice->service()
|
||||
->updateBalance($payment->refunded)
|
||||
->updatePaidToDate($payment->refunded*-1)
|
||||
->updateStatus()
|
||||
->save();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private function updatePaymentForStatus($payment, $status_id) :Payment
|
||||
{
|
||||
// define('PAYMENT_STATUS_PENDING', 1);
|
||||
|
@ -133,6 +133,14 @@ class Activity extends StaticModel
|
||||
return $this->belongsTo(Invoice::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function quote()
|
||||
{
|
||||
return $this->belongsTo(Quote::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -100,11 +100,6 @@ class StripePaymentDriver extends BaseDriver
|
||||
// GatewayType::APPLE_PAY, // TODO:: Missing implementation
|
||||
];
|
||||
|
||||
// $this->invitation = false
|
||||
// $this->client doesn't exist
|
||||
// $this->client->country is relationship?
|
||||
// Missing Slovenia for Alipay
|
||||
|
||||
if ($this->company_gateway->getSofortEnabled()
|
||||
&& $this->client
|
||||
&& isset($this->client->country)
|
||||
@ -119,7 +114,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
$types[] = GatewayType::BANK_TRANSFER;
|
||||
}
|
||||
|
||||
if ($this->company_gateway->getAchEnabled()
|
||||
if ($this->company_gateway->getAlipayEnabled()
|
||||
&& $this->client
|
||||
&& isset($this->client->country)
|
||||
&& in_array($this->client->country->iso_3166_3, ['AUS', 'DNK', 'DEU', 'ITA', 'LUX', 'NOR', 'SVN', 'GBR', 'AUT', 'EST', 'GRC', 'JPN', 'MYS', 'PRT', 'ESP', 'USA', 'BEL', 'FIN', 'HKG', 'LVA', 'NLD', 'SGP', 'SWE', 'CAN', 'FRA', 'IRL', 'LTU', 'NZL', 'SVK', 'CHE'])) {
|
||||
|
@ -37,10 +37,12 @@ use App\Observers\ProposalObserver;
|
||||
use App\Observers\QuoteObserver;
|
||||
use App\Observers\TaskObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@ -53,6 +55,12 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
|
||||
/* Limits the number of parallel jobs fired per minute when checking data*/
|
||||
RateLimiter::for('checkdata', function ($job) {
|
||||
return Limit::perMinute(100);
|
||||
});
|
||||
|
||||
Relation::morphMap([
|
||||
'invoices' => Invoice::class,
|
||||
// 'credits' => \App\Models\Credit::class,
|
||||
|
@ -92,6 +92,7 @@ class PaymentMigrationRepository extends BaseRepository
|
||||
}
|
||||
|
||||
$payment->status_id = $data['status_id'];
|
||||
$payment->refunded = $data['refunded'];
|
||||
|
||||
if($payment->status_id == Payment::STATUS_CANCELLED)
|
||||
$payment->is_deleted = true;
|
||||
|
@ -16,9 +16,9 @@ use App\Services\AbstractService;
|
||||
|
||||
class UpdateBalance extends AbstractService
|
||||
{
|
||||
private $invoice;
|
||||
public $invoice;
|
||||
|
||||
private $balance_adjustment;
|
||||
public $balance_adjustment;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment)
|
||||
{
|
||||
@ -29,7 +29,7 @@ class UpdateBalance extends AbstractService
|
||||
public function run()
|
||||
{
|
||||
if ($this->invoice->is_deleted) {
|
||||
return;
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
$this->invoice->balance += floatval($this->balance_adjustment);
|
||||
|
@ -13,7 +13,7 @@ return [
|
||||
'require_https' => env('REQUIRE_HTTPS', true),
|
||||
'app_url' => rtrim(env('APP_URL', ''), '/'),
|
||||
'app_domain' => env('APP_DOMAIN', ''),
|
||||
'app_version' => '5.1.2',
|
||||
'app_version' => '5.1.3',
|
||||
'minimum_client_version' => '5.0.16',
|
||||
'terms_version' => '1.0.1',
|
||||
'api_secret' => env('API_SECRET', false),
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"video": false,
|
||||
"baseUrl": "https://localhost:8000/",
|
||||
"baseUrl": "https://localhost:8080/",
|
||||
"chromeWebSecurity": false,
|
||||
"env": {
|
||||
"runningEnvironment": "native"
|
||||
"runningEnvironment": "docker"
|
||||
}
|
||||
}
|
||||
|
106
cypress/integration/gateways/authorize.net_credit_card.spec.js
vendored
Normal file
106
cypress/integration/gateways/authorize.net_credit_card.spec.js
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
describe('Authorize.net: Credit card test', () => {
|
||||
before(() => {
|
||||
cy.artisan('migrate:fresh --seed');
|
||||
cy.artisan('ninja:create-single-account authorizenet');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.viewport('macbook-13');
|
||||
cy.wait(5000);
|
||||
cy.clientLogin();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.visit('/client/logout').visit('/client/login');
|
||||
});
|
||||
|
||||
it('should pay with new card', function () {
|
||||
cy.visit('/client/invoices').then((contentWindow) => {
|
||||
cy.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('#card_number').type('4007000000027')
|
||||
.get('#cardholder_name').type('Invoice Ninja Rocks')
|
||||
.get('[class=expiry]').type('12/28')
|
||||
.get('[name=cvc]').type('100');
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
});
|
||||
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/VolejRejNm');
|
||||
});
|
||||
|
||||
it('should pay with new card & save credit card for future use', function () {
|
||||
cy.visit('/client/invoices').then((contentWindow) => {
|
||||
cy.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('#card_number').type('4007000000027')
|
||||
.get('#cardholder_name').type('Invoice Ninja Rocks')
|
||||
.get('[class=expiry]').type('12/28')
|
||||
.get('[name=cvc]').type('100');
|
||||
|
||||
cy.get('[name=token-billing-checkbox]').first().check();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
});
|
||||
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Wpmbk5ezJn');
|
||||
});
|
||||
|
||||
it('should pay with saved card (token)', function () {
|
||||
cy.visit('/client/invoices')
|
||||
.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('[name=payment-type]').first().check();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.wait(2000);
|
||||
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Opnel5aKBz');
|
||||
});
|
||||
|
||||
|
||||
it('should be able to remove payment method', function () {
|
||||
cy.visit('/client/payment_methods')
|
||||
.get('[data-cy=view-payment-method]').click();
|
||||
|
||||
cy.get('#open-delete-popup').click();
|
||||
|
||||
cy.get('[data-cy=confirm-payment-removal]').click();
|
||||
|
||||
cy.url().should('contain', '/client/payment_methods');
|
||||
|
||||
cy.get('body').contains('Payment method has been successfully removed.');
|
||||
});
|
||||
|
||||
it('should be able to add credit card (standalone)', function () {
|
||||
cy.visit('/client/payment_methods')
|
||||
.get('[data-cy=add-payment-method]').click()
|
||||
.get('[data-cy=add-credit-card-link]').click();
|
||||
|
||||
cy.get('#card_number').type('4007000000027')
|
||||
.get('#cardholder_name').type('Invoice Ninja Rocks')
|
||||
.get('[class=expiry]').type('12/28')
|
||||
.get('[name=cvc]').type('100');
|
||||
|
||||
cy.get('#card_button').click();
|
||||
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payment_methods');
|
||||
});
|
||||
});
|
248
cypress/integration/gateways/stripe_ach.spec.js
vendored
Normal file
248
cypress/integration/gateways/stripe_ach.spec.js
vendored
Normal file
@ -0,0 +1,248 @@
|
||||
import axios from 'axios';
|
||||
|
||||
describe('Stripe: ACH testing', () => {
|
||||
before(() => {
|
||||
cy.artisan('migrate:fresh --seed');
|
||||
cy.artisan('ninja:create-single-account stripe');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let headers = {
|
||||
'X-API-Token': 'company-token-test',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
};
|
||||
|
||||
let gatewaysBody = {
|
||||
"gateway_key": "d14dd26a37cecc30fdd65700bfb55b23",
|
||||
"accepted_credit_cards": 0,
|
||||
"require_shipping_address": true,
|
||||
"require_billing_address": true,
|
||||
"require_client_name": false,
|
||||
"require_client_phone": false,
|
||||
"require_contact_name": false,
|
||||
"require_contact_email": false,
|
||||
"require_cvv": true,
|
||||
"update_details": true,
|
||||
"fees_and_limits": {
|
||||
"1": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"2": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"6": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
}
|
||||
},
|
||||
"system_logs": [],
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"1\",\"enable_sofort\":\"1\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"0\"}",
|
||||
"token_billing": "off",
|
||||
"test_mode": true,
|
||||
"label": "Stripe",
|
||||
"created_at": 1612791181,
|
||||
"updated_at": 1612792176,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"loadedAt": 1612792176934,
|
||||
"require_postal_code": false,
|
||||
"is_deleted": false
|
||||
};
|
||||
let clientBody = {
|
||||
"group_settings_id": "",
|
||||
"name": "Batz LLC",
|
||||
"display_name": "Batz LLC",
|
||||
"balance": 8323.7,
|
||||
"credit_balance": 0,
|
||||
"paid_to_date": 0,
|
||||
"client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9",
|
||||
"address1": "45804",
|
||||
"address2": "47988 Rex Mall",
|
||||
"city": "New Macberg",
|
||||
"state": "Florida",
|
||||
"postal_code": "43089-5809",
|
||||
"country_id": "840",
|
||||
"phone": "",
|
||||
"private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.",
|
||||
"public_notes": "",
|
||||
"website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur",
|
||||
"industry_id": "",
|
||||
"size_id": "",
|
||||
"vat_number": "157764830",
|
||||
"id_number": "",
|
||||
"number": "0001",
|
||||
"shipping_address1": "5181",
|
||||
"shipping_address2": "66797 Jedediah Isle Suite 479",
|
||||
"shipping_city": "Lake Rosariomouth",
|
||||
"shipping_state": "Nevada",
|
||||
"shipping_postal_code": "31693",
|
||||
"shipping_country_id": "4",
|
||||
"settings": {
|
||||
"currency_id": "1"
|
||||
},
|
||||
"last_login": 0,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"contacts": [
|
||||
{
|
||||
"first_name": "Rita",
|
||||
"last_name": "Pouros",
|
||||
"email": "user@example.com",
|
||||
"password": "**********",
|
||||
"phone": "+1-331-663-8498",
|
||||
"contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"is_primary": true,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm"
|
||||
},
|
||||
{
|
||||
"first_name": "Danika",
|
||||
"last_name": "Hauck",
|
||||
"email": "bbrakus@example.net",
|
||||
"password": "**********",
|
||||
"phone": "662-968-5275 x48146",
|
||||
"contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"is_primary": false,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "Wpmbk5ezJn"
|
||||
}
|
||||
],
|
||||
"activities": [],
|
||||
"ledger": [],
|
||||
"gateway_tokens": [],
|
||||
"documents": [],
|
||||
"system_logs": [],
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792565,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"isChanged": true,
|
||||
"is_deleted": false,
|
||||
"user_id": "VolejRejNm",
|
||||
"assigned_user_id": ""
|
||||
};
|
||||
|
||||
axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers})
|
||||
axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US.
|
||||
|
||||
cy.viewport('macbook-13');
|
||||
cy.clientLogin();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.visit('/client/logout').visit('/client/login');
|
||||
});
|
||||
|
||||
it('should be able to add bank account & verify it', function () {
|
||||
cy.visit('/client/payment_methods');
|
||||
|
||||
cy.get('[data-cy=add-payment-method]').click();
|
||||
cy.get('[data-cy=add-bank-account-link]').click();
|
||||
|
||||
cy.get('#account-holder-name').type('Invoice Ninja Rocks');
|
||||
cy.get('#country').select('US');
|
||||
cy.get('#currency').select('USD');
|
||||
cy.get('#routing-number').type('110000000');
|
||||
cy.get('#account-number').type('000123456789');
|
||||
cy.get('#accept-terms').check();
|
||||
|
||||
cy.get('#save-button').click();
|
||||
|
||||
cy.url().should('contain', 'method=2');
|
||||
|
||||
cy.get('[data-cy=verification-1st]').type('32');
|
||||
cy.get('[data-cy=verification-2nd]').type('45');
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.get('body').contains('Verification completed successfully');
|
||||
});
|
||||
|
||||
it('should be able to pay the invoice', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-2]').click();
|
||||
|
||||
cy.get('[name=payment-type]').first().check();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/');
|
||||
});
|
||||
|
||||
it('should be able to remove payment method', function () {
|
||||
cy.visit('/client/payment_methods');
|
||||
|
||||
cy.get('[data-cy=view-payment-method]').click();
|
||||
|
||||
cy.get('#open-delete-popup').click();
|
||||
|
||||
cy.get('[data-cy=confirm-payment-removal]').click();
|
||||
|
||||
cy.url().should('contain', '/client/payment_methods');
|
||||
|
||||
cy.get('body').contains('Payment method has been successfully removed.');
|
||||
});
|
||||
});
|
209
cypress/integration/gateways/stripe_alipay.spec.js
vendored
Normal file
209
cypress/integration/gateways/stripe_alipay.spec.js
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
import axios from "axios";
|
||||
|
||||
describe('Stripe: Alipay testing', () => {
|
||||
before(() => {
|
||||
cy.artisan('migrate:fresh --seed');
|
||||
cy.artisan('ninja:create-single-account checkout');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let headers = {
|
||||
'X-API-Token': 'company-token-test',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
};
|
||||
|
||||
let gatewaysBody = {
|
||||
"gateway_key": "d14dd26a37cecc30fdd65700bfb55b23",
|
||||
"accepted_credit_cards": 0,
|
||||
"require_shipping_address": true,
|
||||
"require_billing_address": true,
|
||||
"require_client_name": false,
|
||||
"require_client_phone": false,
|
||||
"require_contact_name": false,
|
||||
"require_contact_email": false,
|
||||
"require_cvv": true,
|
||||
"update_details": true,
|
||||
"fees_and_limits": {
|
||||
"1": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"2": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"6": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
}
|
||||
},
|
||||
"system_logs": [],
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"0\",\"enable_sofort\":\"0\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"1\"}",
|
||||
"token_billing": "off",
|
||||
"test_mode": true,
|
||||
"label": "Stripe",
|
||||
"created_at": 1612791181,
|
||||
"updated_at": 1612792176,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"loadedAt": 1612792176934,
|
||||
"require_postal_code": false,
|
||||
"is_deleted": false
|
||||
};
|
||||
let clientBody = {
|
||||
"group_settings_id": "",
|
||||
"name": "Batz LLC",
|
||||
"display_name": "Batz LLC",
|
||||
"balance": 8323.7,
|
||||
"credit_balance": 0,
|
||||
"paid_to_date": 0,
|
||||
"client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9",
|
||||
"address1": "45804",
|
||||
"address2": "47988 Rex Mall",
|
||||
"city": "New Macberg",
|
||||
"state": "Florida",
|
||||
"postal_code": "43089-5809",
|
||||
"country_id": "840",
|
||||
"phone": "",
|
||||
"private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.",
|
||||
"public_notes": "",
|
||||
"website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur",
|
||||
"industry_id": "",
|
||||
"size_id": "",
|
||||
"vat_number": "157764830",
|
||||
"id_number": "",
|
||||
"number": "0001",
|
||||
"shipping_address1": "5181",
|
||||
"shipping_address2": "66797 Jedediah Isle Suite 479",
|
||||
"shipping_city": "Lake Rosariomouth",
|
||||
"shipping_state": "Nevada",
|
||||
"shipping_postal_code": "31693",
|
||||
"shipping_country_id": "4",
|
||||
"settings": {
|
||||
"currency_id": "1"
|
||||
},
|
||||
"last_login": 0,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"contacts": [
|
||||
{
|
||||
"first_name": "Rita",
|
||||
"last_name": "Pouros",
|
||||
"email": "user@example.com",
|
||||
"password": "**********",
|
||||
"phone": "+1-331-663-8498",
|
||||
"contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"is_primary": true,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm"
|
||||
},
|
||||
{
|
||||
"first_name": "Danika",
|
||||
"last_name": "Hauck",
|
||||
"email": "bbrakus@example.net",
|
||||
"password": "**********",
|
||||
"phone": "662-968-5275 x48146",
|
||||
"contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"is_primary": false,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "Wpmbk5ezJn"
|
||||
}
|
||||
],
|
||||
"activities": [],
|
||||
"ledger": [],
|
||||
"gateway_tokens": [],
|
||||
"documents": [],
|
||||
"system_logs": [],
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792565,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"isChanged": true,
|
||||
"is_deleted": false,
|
||||
"user_id": "VolejRejNm",
|
||||
"assigned_user_id": ""
|
||||
};
|
||||
|
||||
axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers})
|
||||
axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US.
|
||||
|
||||
cy.viewport('macbook-13');
|
||||
cy.clientLogin();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.visit('/client/logout').visit('/client/login');
|
||||
});
|
||||
|
||||
it('should be able to pay using Alipay', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-2]').click();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.get('.common-ButtonGroup > .common-Button--default').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/');
|
||||
});
|
||||
});
|
@ -10,15 +10,14 @@ describe('Stripe: Credit card testing', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.visit('/client/logout');
|
||||
cy.visit('/client/logout').visit('/client/login');
|
||||
});
|
||||
|
||||
it('should pay with new card', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-0]').click();
|
||||
cy.visit('/client/invoices')
|
||||
.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('#cardholder-name').type('Invoice Ninja Rocks');
|
||||
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
||||
@ -28,15 +27,14 @@ describe('Stripe: Credit card testing', () => {
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/VolejRejNm');
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/VolejRejNm');
|
||||
});
|
||||
|
||||
it('should pay with new card & save credit card for future use', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-0]').click();
|
||||
cy.visit('/client/invoices')
|
||||
.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('#cardholder-name').type('Invoice Ninja Rocks');
|
||||
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
||||
@ -48,27 +46,25 @@ describe('Stripe: Credit card testing', () => {
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/Wpmbk5ezJn');
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Wpmbk5ezJn');
|
||||
});
|
||||
|
||||
it('should pay with saved card (token)', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-0]').click();
|
||||
cy.visit('/client/invoices')
|
||||
.get('[data-cy=pay-now]').first().click()
|
||||
.get('[data-cy=pay-now-dropdown]').click()
|
||||
.get('[data-cy=pay-with-0]').click();
|
||||
|
||||
cy.get('[name=payment-type]').first().check();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/Opnel5aKBz');
|
||||
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Opnel5aKBz');
|
||||
});
|
||||
|
||||
it('should be able to remove payment method', function () {
|
||||
cy.visit('/client/payment_methods');
|
||||
|
||||
cy.get('[data-cy=view-payment-method]').click();
|
||||
cy.visit('/client/payment_methods')
|
||||
.get('[data-cy=view-payment-method]').click();
|
||||
|
||||
cy.get('#open-delete-popup').click();
|
||||
|
||||
@ -80,10 +76,9 @@ describe('Stripe: Credit card testing', () => {
|
||||
});
|
||||
|
||||
it('should be able to add credit card (standalone)', function () {
|
||||
cy.visit('/client/payment_methods');
|
||||
|
||||
cy.get('[data-cy=add-payment-method]').click();
|
||||
cy.get('[data-cy=add-credit-card-link]').click();
|
||||
cy.visit('/client/payment_methods')
|
||||
.get('[data-cy=add-payment-method]').click()
|
||||
.get('[data-cy=add-credit-card-link]').click();
|
||||
|
||||
cy.get('#cardholder-name').type('Invoice Ninja Rocks');
|
||||
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
||||
@ -93,6 +88,8 @@ describe('Stripe: Credit card testing', () => {
|
||||
|
||||
cy.get('#authorize-card').click();
|
||||
|
||||
cy.url().should('contain', '/client/payment_methods');
|
||||
cy.location('pathname', {timeout: 60000})
|
||||
.should('include', '/client/payment_methods')
|
||||
.get('[data-cy=pm-last4]').contains('**** 4242');
|
||||
});
|
||||
});
|
209
cypress/integration/gateways/stripe_sofort.spec.js
vendored
Normal file
209
cypress/integration/gateways/stripe_sofort.spec.js
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
import axios from "axios";
|
||||
|
||||
describe('Stripe: SOFORT testing', () => {
|
||||
before(() => {
|
||||
cy.artisan('migrate:fresh --seed');
|
||||
cy.artisan('ninja:create-single-account checkout');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
let headers = {
|
||||
'X-API-Token': 'company-token-test',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
};
|
||||
|
||||
let gatewaysBody = {
|
||||
"gateway_key": "d14dd26a37cecc30fdd65700bfb55b23",
|
||||
"accepted_credit_cards": 0,
|
||||
"require_shipping_address": true,
|
||||
"require_billing_address": true,
|
||||
"require_client_name": false,
|
||||
"require_client_phone": false,
|
||||
"require_contact_name": false,
|
||||
"require_contact_email": false,
|
||||
"require_cvv": true,
|
||||
"update_details": true,
|
||||
"fees_and_limits": {
|
||||
"1": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"2": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
},
|
||||
"6": {
|
||||
"min_limit": -1,
|
||||
"max_limit": -1,
|
||||
"fee_amount": 0,
|
||||
"fee_percent": 0,
|
||||
"fee_cap": 0,
|
||||
"fee_tax_rate1": 0,
|
||||
"fee_tax_name1": "",
|
||||
"fee_tax_rate2": 0,
|
||||
"fee_tax_name2": "",
|
||||
"fee_tax_rate3": 0,
|
||||
"fee_tax_name3": "",
|
||||
"adjust_fee_percent": false,
|
||||
"is_enabled": true
|
||||
}
|
||||
},
|
||||
"system_logs": [],
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"1\",\"enable_sofort\":\"1\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"0\"}",
|
||||
"token_billing": "off",
|
||||
"test_mode": true,
|
||||
"label": "Stripe",
|
||||
"created_at": 1612791181,
|
||||
"updated_at": 1612792176,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"loadedAt": 1612792176934,
|
||||
"require_postal_code": false,
|
||||
"is_deleted": false
|
||||
};
|
||||
let clientBody = {
|
||||
"group_settings_id": "",
|
||||
"name": "Batz LLC",
|
||||
"display_name": "Batz LLC",
|
||||
"balance": 8323.7,
|
||||
"credit_balance": 0,
|
||||
"paid_to_date": 0,
|
||||
"client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9",
|
||||
"address1": "45804",
|
||||
"address2": "47988 Rex Mall",
|
||||
"city": "New Macberg",
|
||||
"state": "Florida",
|
||||
"postal_code": "43089-5809",
|
||||
"country_id": "276",
|
||||
"phone": "",
|
||||
"private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.",
|
||||
"public_notes": "",
|
||||
"website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur",
|
||||
"industry_id": "",
|
||||
"size_id": "",
|
||||
"vat_number": "157764830",
|
||||
"id_number": "",
|
||||
"number": "0001",
|
||||
"shipping_address1": "5181",
|
||||
"shipping_address2": "66797 Jedediah Isle Suite 479",
|
||||
"shipping_city": "Lake Rosariomouth",
|
||||
"shipping_state": "Nevada",
|
||||
"shipping_postal_code": "31693",
|
||||
"shipping_country_id": "4",
|
||||
"settings": {
|
||||
"currency_id": "1"
|
||||
},
|
||||
"last_login": 0,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"contacts": [
|
||||
{
|
||||
"first_name": "Rita",
|
||||
"last_name": "Pouros",
|
||||
"email": "user@example.com",
|
||||
"password": "**********",
|
||||
"phone": "+1-331-663-8498",
|
||||
"contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"is_primary": true,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm"
|
||||
},
|
||||
{
|
||||
"first_name": "Danika",
|
||||
"last_name": "Hauck",
|
||||
"email": "bbrakus@example.net",
|
||||
"password": "**********",
|
||||
"phone": "662-968-5275 x48146",
|
||||
"contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"is_primary": false,
|
||||
"send_email": true,
|
||||
"custom_value1": "",
|
||||
"custom_value2": "",
|
||||
"custom_value3": "",
|
||||
"custom_value4": "",
|
||||
"last_login": 0,
|
||||
"link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32",
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792539,
|
||||
"archived_at": 0,
|
||||
"id": "Wpmbk5ezJn"
|
||||
}
|
||||
],
|
||||
"activities": [],
|
||||
"ledger": [],
|
||||
"gateway_tokens": [],
|
||||
"documents": [],
|
||||
"system_logs": [],
|
||||
"created_at": 1612792539,
|
||||
"updated_at": 1612792565,
|
||||
"archived_at": 0,
|
||||
"id": "VolejRejNm",
|
||||
"isChanged": true,
|
||||
"is_deleted": false,
|
||||
"user_id": "VolejRejNm",
|
||||
"assigned_user_id": ""
|
||||
};
|
||||
|
||||
axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers})
|
||||
axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US.
|
||||
|
||||
cy.viewport('macbook-13');
|
||||
cy.clientLogin();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cy.visit('/client/logout').visit('/client/login');
|
||||
});
|
||||
|
||||
it('should be able to pay using SOFORT', function () {
|
||||
cy.visit('/client/invoices');
|
||||
|
||||
cy.get('[data-cy=pay-now]').first().click();
|
||||
cy.get('[data-cy=pay-now-dropdown]').click();
|
||||
cy.get('[data-cy=pay-with-2]').click();
|
||||
|
||||
cy.get('#pay-now').click();
|
||||
|
||||
cy.get('.common-ButtonGroup > .common-Button--default').click();
|
||||
|
||||
cy.url().should('contain', '/client/payments/');
|
||||
});
|
||||
});
|
2
cypress/support/commands.js
vendored
2
cypress/support/commands.js
vendored
@ -47,7 +47,7 @@ Cypress.Commands.add('clientLogin', () => {
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('iframeLoaded', { prevSubject: 'element' }, ($iframe) => {
|
||||
Cypress.Commands.add('iframeLoaded', {prevSubject: 'element'}, ($iframe) => {
|
||||
const contentWindow = $iframe.prop('contentWindow');
|
||||
return new Promise((resolve) => {
|
||||
if (contentWindow) {
|
||||
|
2
public/flutter_service_worker.js
vendored
2
public/flutter_service_worker.js
vendored
@ -26,7 +26,7 @@ const RESOURCES = {
|
||||
"assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "3e722fd57a6db80ee119f0e2c230ccff",
|
||||
"assets/fonts/MaterialIcons-Regular.otf": "1288c9e28052e028aba623321f7826ac",
|
||||
"/": "23224b5e03519aaa87594403d54412cf",
|
||||
"main.dart.js": "ea5e5c0e239e56013a4a49a241fd6c73",
|
||||
"main.dart.js": "93fbc078b098dc7bcc1141b23c81878b",
|
||||
"icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35",
|
||||
"icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed",
|
||||
"manifest.json": "77215c1737c7639764e64a192be2f7b8",
|
||||
|
28368
public/main.dart.js
vendored
28368
public/main.dart.js
vendored
File diff suppressed because one or more lines are too long
@ -77,7 +77,7 @@
|
||||
{{ $payment_method->meta->exp_month}} / {{ $payment_method->meta->exp_year }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
|
||||
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500" data-cy="pm-last4">
|
||||
@isset($payment_method->meta->last4)
|
||||
**** {{ $payment_method->meta->last4 }}
|
||||
@endisset
|
||||
|
@ -11,15 +11,15 @@
|
||||
<input type="hidden" name="source" value="{{ $token->token }}">
|
||||
|
||||
@component('portal.ninja2020.components.general.card-element', ['title' => '#1 ' . ctrans('texts.amount')])
|
||||
<input type="text" name="transactions[]" class="w-full input" required>
|
||||
<input type="text" name="transactions[]" class="w-full input" required data-cy="verification-1st">
|
||||
@endcomponent
|
||||
|
||||
@component('portal.ninja2020.components.general.card-element', ['title' => '#2 ' . ctrans('texts.amount')])
|
||||
<input type="text" name="transactions[]" class="w-full input" required>
|
||||
<input type="text" name="transactions[]" class="w-full input" required data-cy="verification-2nd">
|
||||
@endcomponent
|
||||
|
||||
|
||||
@component('portal.ninja2020.gateways.includes.pay_now', ['type' => 'submit'])
|
||||
{{ ctrans('texts.complete_verification')}}
|
||||
@endcomponent
|
||||
</form>
|
||||
@endsection
|
||||
@endsection
|
||||
|
Loading…
x
Reference in New Issue
Block a user