Merge pull request #9387 from turbo124/v5-develop

Import customers from all gateways
This commit is contained in:
David Bomba 2024-03-19 10:54:30 +11:00 committed by GitHub
commit abc3cc5897
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
76 changed files with 1542 additions and 471 deletions

View File

@ -11,53 +11,54 @@
namespace App\Console\Commands;
use App\DataMapper\ClientRegistrationFields;
use App\DataMapper\CompanySettings;
use App\DataMapper\FeesAndLimits;
use App\Events\Invoice\InvoiceWasCreated;
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
use App\Factory\GroupSettingFactory;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceItemFactory;
use App\Factory\RecurringInvoiceFactory;
use App\Factory\SubscriptionFactory;
use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Libraries\MultiDB;
use App\Models\Account;
use App\Models\BankIntegration;
use App\Models\BankTransaction;
use App\Models\BankTransactionRule;
use stdClass;
use Carbon\Carbon;
use Faker\Factory;
use App\Models\Task;
use App\Models\User;
use App\Utils\Ninja;
use App\Models\Quote;
use App\Models\Client;
use App\Models\ClientContact;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\CompanyToken;
use App\Models\Country;
use App\Models\Credit;
use App\Models\Vendor;
use App\Models\Account;
use App\Models\Company;
use App\Models\Country;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\Product;
use App\Models\Project;
use App\Models\Quote;
use App\Models\RecurringInvoice;
use App\Models\Task;
use App\Models\TaskStatus;
use App\Models\TaxRate;
use App\Models\User;
use App\Models\Vendor;
use App\Libraries\MultiDB;
use App\Models\TaskStatus;
use App\Models\CompanyToken;
use App\Models\ClientContact;
use App\Models\VendorContact;
use App\Repositories\InvoiceRepository;
use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter;
use App\Models\CompanyGateway;
use App\Factory\InvoiceFactory;
use App\Models\BankIntegration;
use App\Models\BankTransaction;
use App\Utils\Traits\MakesHash;
use Carbon\Carbon;
use Faker\Factory;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use App\Models\RecurringInvoice;
use App\DataMapper\FeesAndLimits;
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\Factory\InvoiceItemFactory;
use App\Helpers\Invoice\InvoiceSum;
use App\Models\BankTransactionRule;
use App\Factory\GroupSettingFactory;
use App\Factory\SubscriptionFactory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Cache;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Support\Facades\Schema;
use stdClass;
use App\Repositories\InvoiceRepository;
use App\Factory\RecurringInvoiceFactory;
use App\Events\Invoice\InvoiceWasCreated;
use App\DataMapper\ClientRegistrationFields;
use App\Jobs\Company\CreateCompanyTaskStatuses;
use App\Events\RecurringInvoice\RecurringInvoiceWasCreated;
class CreateSingleAccount extends Command
{
@ -951,7 +952,7 @@ class CreateSingleAccount extends Command
}
if (config('ninja.testvars.paytrace.decrypted') && ($this->gateway == 'all' || $this->gateway == 'paytrace')) {
if (config('ninja.testvars.paytrace') && ($this->gateway == 'all' || $this->gateway == 'paytrace')) {
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
@ -960,7 +961,7 @@ class CreateSingleAccount extends Command
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.paytrace.decrypted'));
$cg->config = encrypt(config('ninja.testvars.paytrace'));
$cg->save();
@ -1015,6 +1016,85 @@ class CreateSingleAccount extends Command
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.eway') && ($this->gateway == 'all' || $this->gateway == 'eway')) {
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = '944c20175bbe6b9972c05bcfe294c2c7';
$cg->require_cvv = true;
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.eway'));
$cg->save();
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.gocardless') && ($this->gateway == 'all' || $this->gateway == 'gocardless')) {
$c_settings = ClientSettings::defaults();
$c_settings->currency_id = '2';
$client = Client::factory()->create([
'user_id' => $user->id,
'company_id' => $company->id,
'name' => 'cypress',
'country_id' => 826,
'settings' => $c_settings
]);
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'b9886f9257f0c6ee7c302f1c74475f6c';
$cg->require_cvv = true;
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.gocardless'));
$cg->save();
$gateway_types = $cg->driver($client)->gatewayTypes();
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
if (config('ninja.testvars.forte') && ($this->gateway == 'all' || $this->gateway == 'forte')) {
$cg = new CompanyGateway();
$cg->company_id = $company->id;
$cg->user_id = $user->id;
$cg->gateway_key = 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs';
$cg->require_cvv = true;
$cg->require_billing_address = true;
$cg->require_shipping_address = true;
$cg->update_details = true;
$cg->config = encrypt(config('ninja.testvars.forte'));
$cg->save();
$gateway_types = $cg->driver()->gatewayTypes();
$fees_and_limits = new stdClass();
$fees_and_limits->{$gateway_types[0]} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
}
private function createRecurringInvoice(Client $client)

View File

@ -229,7 +229,7 @@ class CompanySettings extends BaseSettings
public $require_quote_signature = false; //@TODO ben to confirm
//email settings
public $email_sending_method = 'default'; //enum 'default','gmail','office365' 'client_postmark', 'client_mailgun', 'mailgun' //@implemented
public $email_sending_method = 'default'; //enum 'default','gmail','office365' 'client_postmark', 'client_mailgun', 'mailgun', 'client_brevo' //@implemented
public $gmail_sending_user_id = '0'; //@implemented

View File

@ -329,7 +329,9 @@ class InvoiceFilters extends QueryFilters
if($sort_col[0] == 'number') {
// return $this->builder->orderByRaw('CAST(number AS UNSIGNED), number ' . $dir);
return $this->builder->orderByRaw('ABS(number) ' . $dir);
// return $this->builder->orderByRaw("number REGEXP '^[A-Za-z]+$',CAST(number as SIGNED INTEGER),CAST(REPLACE(number,'-','')AS SIGNED INTEGER) ,number");
// return $this->builder->orderByRaw('ABS(number) ' . $dir);
return $this->builder->orderByRaw("REGEXP_REPLACE(number,'[^0-9]+','')+0 " . $dir);
}
return $this->builder->orderBy($sort_col[0], $dir);

View File

@ -11,27 +11,29 @@
namespace App\Http\Controllers;
use App\Models\Client;
use App\Libraries\MultiDB;
use Illuminate\Http\Response;
use App\Models\CompanyGateway;
use App\Utils\Traits\MakesHash;
use App\DataMapper\FeesAndLimits;
use App\Jobs\Util\ApplePayDomain;
use Illuminate\Support\Facades\Cache;
use App\Factory\CompanyGatewayFactory;
use App\Filters\CompanyGatewayFilters;
use App\Repositories\CompanyRepository;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Transformers\CompanyGatewayTransformer;
use App\PaymentDrivers\Stripe\Jobs\StripeWebhook;
use App\PaymentDrivers\CheckoutCom\CheckoutSetupWebhook;
use App\Http\Requests\CompanyGateway\BulkCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\CreateCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\DestroyCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\EditCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\ShowCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\StoreCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\TestCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\StoreCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\CreateCompanyGatewayRequest;
use App\Http\Requests\CompanyGateway\UpdateCompanyGatewayRequest;
use App\Jobs\Util\ApplePayDomain;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\PaymentDrivers\CheckoutCom\CheckoutSetupWebhook;
use App\PaymentDrivers\Stripe\Jobs\StripeWebhook;
use App\Repositories\CompanyRepository;
use App\Transformers\CompanyGatewayTransformer;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Http\Response;
use App\Http\Requests\CompanyGateway\DestroyCompanyGatewayRequest;
/**
* Class CompanyGatewayController.
@ -53,6 +55,9 @@ class CompanyGatewayController extends BaseController
private string $checkout_key = '3758e7f7c6f4cecf0f4f348b9a00f456';
private string $forte_key = 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs';
/**
* CompanyGatewayController constructor.
* @param CompanyRepository $company_repo
@ -226,6 +231,13 @@ class CompanyGatewayController extends BaseController
StripeWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id);
} elseif($company_gateway->gateway_key == $this->checkout_key) {
CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->id);
} elseif($company_gateway->gateway_key == $this->forte_key) {
dispatch(function () use ($company_gateway) {
MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->updateFees();
})->afterResponse();
}
return $this->itemResponse($company_gateway);
@ -408,6 +420,13 @@ class CompanyGatewayController extends BaseController
if($company_gateway->gateway_key == $this->checkout_key) {
CheckoutSetupWebhook::dispatch($company_gateway->company->company_key, $company_gateway->fresh()->id);
}elseif($company_gateway->gateway_key == $this->forte_key){
dispatch(function () use ($company_gateway) {
MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->updateFees();
})->afterResponse();
}
return $this->itemResponse($company_gateway);
@ -544,4 +563,20 @@ class CompanyGatewayController extends BaseController
}
public function importCustomers(TestCompanyGatewayRequest $request, CompanyGateway $company_gateway)
{
//Throttle here
// if (Cache::get("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}"))
// return response()->json(['message' => ctrans('texts.import_started')], 200);
dispatch(function () use($company_gateway) {
MultiDB::setDb($company_gateway->company->db);
$company_gateway->driver()->importCustomers();
})->afterResponse();
Cache::put("throttle_polling:import_customers:{$company_gateway->company->company_key}:{$company_gateway->hashed_id}", true, 300);
return response()->json(['message' => ctrans('texts.import_started')], 200);
}
}

View File

@ -55,7 +55,17 @@ class SmtpController extends BaseController
(new \Illuminate\Mail\MailServiceProvider(app()))->register();
try {
Mail::mailer('smtp')->to($user->email, $user->present()->name())->send(new TestMailServer('Email Server Works!', strlen($company->settings->custom_sending_email) > 1 ? $company->settings->custom_sending_email : $user->email));
$sending_email = (isset($company->settings->custom_sending_email) && stripos($company->settings->custom_sending_email, "@")) ? $company->settings->custom_sending_email : $user->email;
$sending_user = (isset($company->settings->email_from_name) && strlen($company->settings->email_from_name) > 2) ? $company->settings->email_from_name : $user->name();
$mailable = new TestMailServer('Email Server Works!', $sending_email);
$mailable->from($sending_email,$sending_user);
Mail::mailer('smtp')
->to($user->email, $user->present()->name())
->send($mailable);
} catch (\Exception $e) {
app('mail.manager')->forgetMailers();
return response()->json(['message' => $e->getMessage()], 400);

View File

@ -33,15 +33,15 @@ class UploadBankIntegrationRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -33,15 +33,15 @@ class UploadBankTransactionRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -45,18 +45,18 @@ class StoreClientRequest extends Request
$user = auth()->user();
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
/* Ensure we have a client name, and that all emails are unique*/

View File

@ -44,15 +44,15 @@ class UpdateClientRequest extends Request
$user = auth()->user();
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
} else {
$rules['documents'] = 'bail|sometimes|array';
}

View File

@ -33,15 +33,15 @@ class UploadClientRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -30,15 +30,15 @@ class UploadCompanyRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -47,17 +47,17 @@ class StoreCreditRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
/** @var \App\Models\User $user */

View File

@ -49,17 +49,17 @@ class UpdateCreditRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['number'] = ['bail', 'sometimes', 'nullable', Rule::unique('credits')->where('company_id', $user->company()->id)->ignore($this->credit->id)];

View File

@ -33,15 +33,15 @@ class UploadCreditRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -33,15 +33,15 @@ class UploadExpenseRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -30,15 +30,15 @@ class UploadGroupSettingRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -44,17 +44,17 @@ class StoreInvoiceRequest extends Request
$user = auth()->user();
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['client_id'] = 'bail|required|exists:clients,id,company_id,'.$user->company()->id.',is_deleted,0';

View File

@ -46,17 +46,17 @@ class UpdateInvoiceRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
// $rules['id'] = new LockedInvoiceRule($this->invoice);

View File

@ -33,15 +33,15 @@ class UploadInvoiceRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -123,17 +123,17 @@ class StorePaymentRequest extends Request
];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -52,17 +52,17 @@ class UpdatePaymentRequest extends Request
}
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -33,15 +33,15 @@ class UploadPaymentRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -32,17 +32,17 @@ class StoreProductRequest extends Request
public function rules()
{
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['cost'] = 'sometimes|numeric';

View File

@ -35,17 +35,17 @@ class UpdateProductRequest extends Request
public function rules()
{
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['cost'] = 'numeric';

View File

@ -32,15 +32,15 @@ class UploadProductRequest extends Request
{
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -51,17 +51,17 @@ class StoreProjectRequest extends Request
}
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);

View File

@ -48,17 +48,17 @@ class UpdateProjectRequest extends Request
$rules['budgeted_hours'] = 'sometimes|numeric';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);

View File

@ -33,15 +33,15 @@ class UploadProjectRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -54,17 +54,17 @@ class StorePurchaseOrderRequest extends Request
$rules['line_items'] = 'array';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
} else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['status_id'] = 'nullable|integer|in:1,2,3,4,5';

View File

@ -56,17 +56,17 @@ class UpdatePurchaseOrderRequest extends Request
$rules['is_amount_discount'] = ['boolean'];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['status_id'] = 'sometimes|integer|in:1,2,3,4,5';

View File

@ -33,15 +33,15 @@ class UploadPurchaseOrderRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -46,17 +46,17 @@ class StoreQuoteRequest extends Request
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['number'] = ['nullable', Rule::unique('quotes')->where('company_id', $user->company()->id)];

View File

@ -43,17 +43,17 @@ class UpdateQuoteRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}

View File

@ -33,15 +33,15 @@ class UploadQuoteRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -57,15 +57,15 @@ class StoreRecurringExpenseRequest extends Request
$rules['currency_id'] = 'bail|required|integer|exists:currencies,id';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);

View File

@ -49,15 +49,15 @@ class UpdateRecurringExpenseRequest extends Request
$rules['category_id'] = 'bail|nullable|sometimes|exists:expense_categories,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);

View File

@ -30,15 +30,15 @@ class UploadRecurringExpenseRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -46,17 +46,17 @@ class StoreRecurringInvoiceRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;

View File

@ -45,17 +45,17 @@ class UpdateRecurringInvoiceRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['number'] = ['bail', 'sometimes', Rule::unique('recurring_invoices')->where('company_id', $user->company()->id)->ignore($this->recurring_invoice->id)];

View File

@ -33,15 +33,15 @@ class UploadRecurringInvoiceRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -46,15 +46,15 @@ class StoreRecurringQuoteRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;

View File

@ -38,15 +38,15 @@ class UpdateRecurringQuoteRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
if ($this->number) {

View File

@ -30,15 +30,15 @@ class UploadRecurringQuoteRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $rules;

View File

@ -20,7 +20,7 @@ class Request extends FormRequest
use MakesHash;
use RuntimeFormRequest;
protected $file_validation = 'sometimes|file|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx,webp,xml,zip,csv,ods,odt,odp|max:100000';
protected $file_validation = 'sometimes|file|max:100000|mimes:png,ai,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx,webp,xml,zip,csv,ods,odt,odp';
/**
* Get the validation rules that apply to the request.
*
@ -31,6 +31,15 @@ class Request extends FormRequest
return [];
}
public function fileValidation()
{
if(config('ninja.upload_extensions'))
return $this->file_validation. ",".config('ninja.upload_extensions');
return $this->file_validation;
}
public function globalRules($rules)
{
$merge_rules = [];

View File

@ -79,17 +79,17 @@ class StoreTaskRequest extends Request
}];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}

View File

@ -85,17 +85,17 @@ class UpdateTaskRequest extends Request
}];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);

View File

@ -33,15 +33,15 @@ class UploadTaskRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -61,17 +61,17 @@ class StoreVendorRequest extends Request
$rules['currency_id'] = 'bail|required|exists:currencies,id';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';

View File

@ -62,17 +62,17 @@ class UpdateVendorRequest extends Request
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}else {
$rules['documents'] = 'bail|sometimes|array';
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['language_id'] = 'bail|nullable|sometimes|exists:languages,id';

View File

@ -30,15 +30,15 @@ class UploadVendorRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = $this->file_validation;
$rules['documents.*'] = $this->fileValidation();
} elseif ($this->file('documents')) {
$rules['documents'] = $this->file_validation;
$rules['documents'] = $this->fileValidation();
}
if ($this->file('file') && is_array($this->file('file'))) {
$rules['file.*'] = $this->file_validation;
$rules['file.*'] = $this->fileValidation();
} elseif ($this->file('file')) {
$rules['file'] = $this->file_validation;
$rules['file'] = $this->fileValidation();
}
$rules['is_public'] = 'sometimes|boolean';

View File

@ -85,6 +85,8 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
$this->bank_integration->company->notification(new GenericNinjaAdminNotification($content))->ninja();
sleep(5);
throw $e;
}
if (!$this->nordigen_account) {

View File

@ -74,7 +74,7 @@ class BankTransactionSync implements ShouldQueue
if ($account->isEnterprisePaidClient()) {
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_YODLEE)->where('auto_sync', true)->where('disabled_upstream', 0)->cursor()->each(function ($bank_integration) use ($account) {
(new ProcessBankTransactionsYodlee($account->id, $bank_integration))->handle();
(new ProcessBankTransactionsYodlee($account->bank_integration_account_id, $bank_integration))->handle();
});
}
@ -90,7 +90,14 @@ class BankTransactionSync implements ShouldQueue
if ((Ninja::isSelfHost() || (Ninja::isHosted() && $account->isEnterprisePaidClient()))) {
$account->bank_integrations()->where('integration_type', BankIntegration::INTEGRATION_TYPE_NORDIGEN)->where('auto_sync', true)->where('disabled_upstream', 0)->cursor()->each(function ($bank_integration) {
(new ProcessBankTransactionsNordigen($bank_integration))->handle();
try {
(new ProcessBankTransactionsNordigen($bank_integration))->handle();
}
catch(\Exception $e) {
sleep(20);
}
sleep(5);
});
}

View File

@ -76,12 +76,12 @@ class SendRecurring implements ShouldQueue
$invoice = $invoice->service()
->markSent()
->applyNumber()
->fillDefaults()
->fillDefaults(true)
->adjustInventory()
->save();
} else {
$invoice = $invoice->service()
->fillDefaults()
->fillDefaults(true)
->save();
}

View File

@ -494,7 +494,7 @@ class Account extends BaseModel
return 0;
}
if (Carbon::createFromTimestamp($this->created_at)->diffInWeeks() == 0) {
if (Carbon::createFromTimestamp($this->created_at)->diffInWeeks() <= 1) {
return 20;
}

View File

@ -132,6 +132,7 @@ class CompanyGateway extends BaseModel
// const TYPE_EWAY = 313;
// const TYPE_FORTE = 314;
// const PAYPAL_PPCP = 323;
// const SQUARE = 320;
public $gateway_consts = [
'38f2c48af60c7dd69e04248cbb24c36e' => 300,
@ -144,7 +145,7 @@ class CompanyGateway extends BaseModel
'8fdeed552015b3c7b44ed6c8ebd9e992' => 309,
'd6814fc83f45d2935e7777071e629ef9' => 310,
'bbd736b3254b0aabed6ad7fda1298c88' => 311,
'1bd651fb213ca0c9d66ae3c336dc77e7' => 312,
'1bd651fb213ca0c9d66ae3c336dc77e8' => 312,
'944c20175bbe6b9972c05bcfe294c2c7' => 313,
'kivcvjexxvdiyqtj3mju5d6yhpeht2xs' => 314,
'65faab2ab6e3223dbe848b1686490baz' => 320,

View File

@ -193,9 +193,16 @@ class AuthorizePaymentDriver extends BaseDriver
public function import()
{
$this->init();
return (new AuthorizeCustomer($this))->importCustomers();
}
public function importCustomers()
{
return $this->import();
}
public function auth(): bool
{
return $this->init()->getPublicClientKey() ?? false;

View File

@ -811,4 +811,9 @@ class BaseDriver extends AbstractPaymentDriver
{
return true;
}
public function importCustomers()
{
}
}

View File

@ -12,29 +12,40 @@
namespace App\PaymentDrivers;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use Exception;
use App\Models\Client;
use Braintree\Gateway;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\Models\ClientContact;
use App\Factory\ClientFactory;
use Illuminate\Support\Carbon;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Factory\ClientContactFactory;
use App\PaymentDrivers\Braintree\ACH;
use App\PaymentDrivers\Braintree\CreditCard;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Database\QueryException;
use App\PaymentDrivers\Braintree\PayPal;
use Braintree\Gateway;
use Exception;
use Illuminate\Support\Facades\Validator;
use App\PaymentDrivers\Braintree\CreditCard;
class BraintreePaymentDriver extends BaseDriver
{
use GeneratesCounter;
public $refundable = true;
public $token_billing = true;
public $can_authorise_credit_card = true;
private bool $completed = true;
/**
* @var Gateway;
*/
@ -304,7 +315,7 @@ class BraintreePaymentDriver extends BaseDriver
try {
$ct =$this->init()->gateway->clientToken()->generate();
nlog($ct);
return true;
}
catch(\Exception $e) {
@ -313,4 +324,181 @@ class BraintreePaymentDriver extends BaseDriver
return false;
}
private function find(string $customer_id = '') {
try {
return $this->init()->gateway->customer()->find($customer_id);
}
catch(\Exception $e){
return false;
}
return false;
}
private function findTokens(string $gateway_customer_reference)
{
return ClientGatewayToken::where('company_id', $this->company_gateway->company_id)
->where('gateway_customer_reference', $gateway_customer_reference)
->exists();
}
private function getToken(string $token, string $gateway_customer_reference)
{
return ClientGatewayToken::where('company_id', $this->company_gateway->company_id)
->where('gateway_customer_reference', $gateway_customer_reference)
->where('token', $token)
->first();
}
private function findClient(string $email) {
return ClientContact::where('company_id', $this->company_gateway->company_id)
->where('email', $email)
->first()->client ?? false;
}
private function addClientCards(Client $client, array $cards)
{
$this->client = $client;
foreach($cards as $card) {
if($this->getToken($card->token, $card->customerId) || Carbon::createFromDate($card->expirationYear, $card->expirationMonth, '1')->lt(now()))
continue;
$payment_meta = new \stdClass();
$payment_meta->exp_month = (string) $card->expirationMonth;
$payment_meta->exp_year = (string) $card->expirationYear;
$payment_meta->brand = (string) $card->cardType;
$payment_meta->last4 = (string) $card->last4;
$payment_meta->type = GatewayType::CREDIT_CARD;
$data = [
'payment_meta' => $payment_meta,
'token' => $card->token,
'payment_method_id' => GatewayType::CREDIT_CARD,
];
$this->storeGatewayToken($data, ['gateway_customer_reference' => $card->customerId]);
nlog("adding card to customer payment profile");
}
}
public function createNinjaClient(mixed $customer): Client
{
$client = ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id);
$b_business_address = count($customer->addresses) >= 1 ? $customer->addresses[0] : false;
$b_shipping_address = count($customer->addresses) > 1 ? $customer->addresses[1] : false;
$import_client_data = [];
if($b_business_address) {
$braintree_address =
[
'address1' => $b_business_address->extendedAddress ?? '',
'address2' => $b_business_address->streetAddress ?? '',
'city' => $b_business_address->locality ?? '',
'postal_code' => $b_business_address->postalCode ?? '',
'state' => $b_business_address->region ?? '',
'country_id' => $b_business_address->countryCodeNumeric ?? '840',
];
$import_client_data = array_merge($import_client_data, $braintree_address);
}
if($b_shipping_address) {
$braintree_shipping_address =
[
'shipping_address1' => $b_shipping_address->extendedAddress ?? '',
'shipping_address2' => $b_shipping_address->streetAddress ?? '',
'shipping_city' => $b_shipping_address->locality ?? '',
'shipping_postal_code' => $b_shipping_address->postalCode ?? '',
'shipping_state' => $b_shipping_address->region ?? '',
'shipping_country_id' => $b_shipping_address->countryCodeNumeric ?? '840',
];
$import_client_data = array_merge($import_client_data, $braintree_shipping_address);
}
$client->fill($import_client_data);
$client->phone = $customer->phone ?? '';
$client->name = $customer->company ?? $customer->firstName;
$settings = $client->settings;
$settings->currency_id = (string) $this->company_gateway->company->settings->currency_id;
$client->settings = $settings;
$client->save();
$contact = ClientContactFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id);
$contact->first_name = $customer->firstName ?? '';
$contact->last_name = $customer->lastName ?? '';
$contact->email = $customer->email ?? '';
$contact->phone = $customer->phone ?? '';
$contact->client_id = $client->id;
$contact->saveQuietly();
if (! isset($client->number) || empty($client->number)) {
$x = 1;
do {
try {
$client->number = $this->getNextClientNumber($client);
$client->saveQuietly();
$this->completed = false;
} catch (QueryException $e) {
$x++;
if ($x > 10) {
$this->completed = false;
}
}
} while ($this->completed);
} else {
$client->saveQuietly();
}
return $client;
}
public function importCustomers()
{
$customers = $this->init()->gateway->customer()->all();
foreach($customers as $c){
$customer = $this->find($c->id);
// nlog(count($customer->creditCards). " Exists for {$c->id}");
if(!$customer)
continue;
$client = $this->findClient($customer->email);
if(!$this->findTokens($c->id) && !$client) {
//customer is not referenced in the system - create client
$client = $this->createNinjaClient($customer);
// nlog("Creating new Client");
}
$this->addClientCards($client, $customer->creditCards);
// nlog("Adding Braintree Client: {$c->id} => {$client->id}");
}
}
}

View File

@ -12,37 +12,38 @@
namespace App\PaymentDrivers;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Http\Requests\Gateways\Checkout3ds\Checkout3dsRequest;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use Exception;
use App\Models\Company;
use App\Models\GatewayType;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\SystemLog;
use Checkout\CheckoutSdk;
use Checkout\Environment;
use Checkout\Common\Phone;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\CheckoutCom\CheckoutWebhook;
use App\PaymentDrivers\CheckoutCom\CreditCard;
use App\PaymentDrivers\CheckoutCom\Utilities;
use App\Utils\Traits\SystemLogTrait;
use Illuminate\Support\Carbon;
use App\Jobs\Util\SystemLogger;
use App\Exceptions\PaymentFailed;
use App\Models\ClientGatewayToken;
use Checkout\CheckoutApiException;
use App\Utils\Traits\SystemLogTrait;
use Checkout\Payments\RefundRequest;
use Illuminate\Support\Facades\Auth;
use Checkout\CheckoutArgumentException;
use Checkout\CheckoutAuthorizationException;
use Checkout\CheckoutSdk;
use Checkout\Common\Phone;
use Checkout\Customers\CustomerRequest;
use Checkout\Environment;
use Checkout\CheckoutAuthorizationException;
use App\PaymentDrivers\CheckoutCom\Utilities;
use Checkout\Payments\Request\PaymentRequest;
use App\PaymentDrivers\CheckoutCom\CreditCard;
use App\PaymentDrivers\CheckoutCom\CheckoutWebhook;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use Checkout\Payments\Request\Source\RequestIdSource;
use App\Http\Requests\Gateways\Checkout3ds\Checkout3dsRequest;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use Checkout\Payments\Previous\PaymentRequest as PreviousPaymentRequest;
use Checkout\Payments\Previous\Source\RequestIdSource as SourceRequestIdSource;
use Checkout\Payments\RefundRequest;
use Checkout\Payments\Request\PaymentRequest;
use Checkout\Payments\Request\Source\RequestIdSource;
use Exception;
use Illuminate\Support\Facades\Auth;
class CheckoutComPaymentDriver extends BaseDriver
{
@ -546,4 +547,75 @@ class CheckoutComPaymentDriver extends BaseDriver
}
return false;
}
private function getToken(string $token, $gateway_customer_reference)
{
return ClientGatewayToken::query()
->where('company_id', $this->company_gateway->company_id)
->where('gateway_customer_reference', $gateway_customer_reference)
->where('token', $token)
->first();
}
/**
* ImportCustomers
*
* Only their methods because checkout.com
* does not have a list route for customers
*
* @return void
*/
public function importCustomers()
{
$this->init();
$this->company_gateway
->company
->clients()
->cursor()
->each(function ($client){
if(!str_contains($client->present()->email(), "@"))
return;
try{
$customer = $this->gateway->getCustomersClient()->get($client->present()->email());
}
catch(\Exception $e) {
nlog("Checkout: Customer not found");
return;
}
$this->client = $client;
nlog($customer['instruments']);
foreach($customer['instruments'] as $card)
{
if(
$card['type'] != 'card' ||
Carbon::createFromDate($card['expiry_year'], $card['expiry_month'], '1')->lt(now()) ||
$this->getToken($card['id'], $customer['id'])
)
continue;
$payment_meta = new \stdClass();
$payment_meta->exp_month = (string) $card['expiry_month'];
$payment_meta->exp_year = (string) $card['expiry_year'];
$payment_meta->brand = (string) $card['scheme'];
$payment_meta->last4 = (string) $card['last4'];
$payment_meta->type = (int) GatewayType::CREDIT_CARD;
$data = [
'payment_meta' => $payment_meta,
'token' => $card['id'],
'payment_method_id' => GatewayType::CREDIT_CARD,
];
$this->storeGatewayToken($data, ['gateway_customer_reference' => $customer['id']]);
}
});
}
}

View File

@ -220,4 +220,15 @@ class EwayPaymentDriver extends BaseDriver
return (bool) count($response->getErrors()) == 0;
}
/**
* importCustomers
*
* No support
* @return void
*/
public function importCustomers()
{
return true;
}
}

View File

@ -0,0 +1,137 @@
<?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://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Factory;
use App\Models\Client;
use App\Models\Company;
class ForteCustomerFactory
{
public function convertToNinja(array $customer, Company $company): array
{
return
collect([
'name' => $customer['company_name'] ?? $customer['first_name'],
'contacts' => [
[
'first_name' => $customer['first_name'],
'last_name' => $customer['last_name'],
'email' => $this->getBillingAddress($customer)['email'],
'phone' => $this->getBillingAddress($customer)['phone'],
]
],
'settings' => [
'currency_id' => $company->settings->currency_id,
],
])->merge($this->getShippingAddress($customer))
->merge($this->getBillingAddress($customer))
->toArray();
}
// public function convertToGateway(Client $client): array
// {
// }
private function getBillingAddress(array $customer): array
{
if(isset($customer['default_billing_address_token'])) {
foreach($customer['addresses'] as $address) {
if($address['address_token'] != $customer['default_billing_address_token'])
continue;
return [
'address1' => $address['physical_address']['street_line1'],
'address2' => $address['physical_address']['street_line2'],
'city' => $address['physical_address']['locality'],
'state' => $address['physical_address']['region'],
'postal_code' => $address['physical_address']['postal_code'],
'country_id' => '840',
'email' => $address['email'],
'phone' => $address['phone'],
];
}
}
if(isset($customer['addresses'][0])) {
$address = $customer['addresses'][0];
return [
'address1' => $address['physical_address']['street_line1'],
'address2' => $address['physical_address']['street_line2'],
'city' => $address['physical_address']['locality'],
'state' => $address['physical_address']['region'],
'postal_code' => $address['physical_address']['postal_code'],
'email' => $address['email'],
'phone' => $address['phone'],
'country_id' => '840',
];
}
return ['email' => '', 'phone' => ''];
}
private function getShippingAddress(array $customer): array
{
if(isset($customer['default_shipping_address_token'])) {
foreach($customer['addresses'] as $address) {
if($address['address_token'] != $customer['default_shipping_address_token']) {
continue;
}
return [
'shipping_address1' => $address['physical_address']['street_line1'],
'shipping_address2' => $address['physical_address']['street_line2'],
'shipping_city' => $address['physical_address']['locality'],
'shipping_state' => $address['physical_address']['region'],
'shipping_postal_code' => $address['physical_address']['postal_code'],
'shipping_country_id' => '840',
];
}
}
if(isset($customer['addresses'][1])){
$address = $customer['addresses'][1];
return [
'shipping_address1' => $address['physical_address']['street_line1'],
'shipping_address2' => $address['physical_address']['street_line2'],
'shipping_city' => $address['physical_address']['locality'],
'shipping_state' => $address['physical_address']['region'],
'shipping_postal_code' => $address['physical_address']['postal_code'],
'shipping_country_id' => '840',
'email' => $address['email'],
'phone' => $address['phone'],
];
}
return ['email' => '', 'phone' => ''];
}
}

View File

@ -0,0 +1,59 @@
<?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://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Factory;
use App\Models\Company;
class PaytraceCustomerFactory
{
public function convertToNinja($customer, Company $company): array
{
return
collect([
'name' => $customer->billing_address->name ?? $customer->shipping_address->name,
'contacts' => [
[
'first_name' => $customer->billing_address->name ?? $customer->shipping_address->name,
'last_name' => '',
'email' => $customer->email,
'phone' => $customer->phone,
]
],
'currency_id' => $company->settings->currency_id,
'address1' => $customer->billing_address->street_address,
'address2' => $customer->billing_address->street_address2,
'city' => $customer->billing_address->city,
'state' => $customer->billing_address->state,
'postal_code' => $customer->billing_address->zip,
'country_id' => '840',
'shipping_address1' => $customer->shipping_address->street_address,
'shipping_address2' => $customer->shipping_address->street_address2,
'shipping_city' => $customer->shipping_address->city,
'shipping_state' => $customer->shipping_address->state,
'shipping_postal_code' => $customer->shipping_address->zip,
'shipping_country_id' => '840',
'settings' => [
'currency_id' => $company->settings->currency_id,
],
'card' => [
'token' => $customer->customer_id,
'last4' => $customer->credit_card->masked_number,
'expiry_month' => $customer->credit_card->expiration_month,
'expiry_year' => $customer->credit_card->expiration_year,
],
])
->toArray();
}
}

View File

@ -0,0 +1,132 @@
<?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://www.elastic.co/licensing/elastic-license
*/
namespace App\PaymentDrivers\Factory;
use App\Models\Company;
use App\Models\GatewayType;
class SquareCustomerFactory
{
/*
{
"id": "A537H7KAQWSAF8M8EM1Y23E16M",
"created_at": "2021-10-28T20:19:07.692Z",
"updated_at": "2024-01-09T20:14:21Z",
"cards": [
{
"id": "ccof:oG9wEmGAvoAnrBGt3GB",
"card_brand": "VISA",
"last_4": "5858",
"exp_month": 10,
"exp_year": 2023,
"cardholder_name": "Amelia Earhart",
"billing_address": {
"address_line_1": "500 Electric Ave",
"locality": "New York",
"administrative_district_level_1": "NY",
"postal_code": "94103",
"country": "US"
}
},
{
"id": "gftc:06c30c2b9772458a9e87b2880ee2ce1a",
"card_brand": "SQUARE_GIFT_CARD",
"last_4": "0895",
"exp_month": 12,
"exp_year": 2050,
"billing_address": {
"postal_code": "94103"
}
}
],
"given_name": "Amelia",
"family_name": "Earhart",
"email_address": "Amelia.Earhart@example.com",
"address": {
"address_line_1": "123 Main St",
"locality": "Seattle",
"administrative_district_level_1": "WA",
"postal_code": "98121",
"country": "US"
},
"phone_number": "1-212-555-4240",
"note": "a customer on seller account",
"reference_id": "YOUR_REFERENCE_ID",
"company_name": "ACME",
"preferences": {
"email_unsubscribed": false
},
"creation_source": "THIRD_PARTY",
"segment_ids": [
"8QJTJCE6AZSN6.REACHABLE",
"8QJTJCE6AZSN6.CARDS_ON_FILE",
"gv2:8H24YRM74H2030XWJWP9F0MAEW",
"gv2:4TR2NFVP8N63D9K1FZ5E62VD78"
],
"version": 4
},
*/
public function convertToNinja($customer, Company $company): array
{
$cards = [];
foreach($customer->getCards() ?? [] as $card){
$meta = new \stdClass;
$meta->exp_month = $card->getExpMonth();
$meta->exp_year = $card->getExpYear();
$meta->last4 = $card->getLast4();
$meta->brand = $card->getCardBrand();
$meta->type = GatewayType::CREDIT_CARD;
$cards[] = [
'token' => $card->getId(),
'payment_meta' => $meta,
'payment_method_id' => GatewayType::CREDIT_CARD,
'gateway_customer_reference' => $customer->getId(),
];
}
$address = $customer->getAddress();
return
collect([
'name' => $customer->getCompanyName() ?? ($customer->getGivenName() ?? '' ." " . $customer->getFamilyName() ?? ''),
'contacts' => [
[
'first_name' => $customer->getGivenName(),
'last_name' => $customer->getFamilyName(),
'email' => $customer->getEmailAddress(),
'phone' => $customer->getPhoneNumber(),
]
],
'currency_id' => $company->settings->currency_id,
'address1' => $address->getAddressLine1(),
'address2' => $address->getAddressLine2(),
'city' => $address->getLocality(),
'state' => $address->getAdministrativeDistrictLevel1(),
'postal_code' => $address->getPostalCode(),
'country_id' => '840',
'settings' => [
'currency_id' => $company->settings->currency_id,
],
'cards' => $cards,
])
->toArray();
}
}

View File

@ -14,11 +14,16 @@ namespace App\PaymentDrivers;
use App\Models\Payment;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\ClientContact;
use App\Factory\ClientFactory;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use App\PaymentDrivers\Forte\ACH;
use Illuminate\Support\Facades\Http;
use App\Repositories\ClientRepository;
use App\PaymentDrivers\Forte\CreditCard;
use App\Repositories\ClientContactRepository;
use App\PaymentDrivers\Factory\ForteCustomerFactory;
class FortePaymentDriver extends BaseDriver
{
@ -184,6 +189,9 @@ class FortePaymentDriver extends BaseDriver
];
}
////////////////////////////////////////////
// DB
///////////////////////////////////////////
public function auth(): bool
{
@ -204,8 +212,117 @@ class FortePaymentDriver extends BaseDriver
return $response->successful();
}
// public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
// {
// return $this->payment_method->yourTokenBillingImplmentation();
// }
public function baseUri(): string
{
$forte_base_uri = "https://sandbox.forte.net/api/v3/";
if ($this->company_gateway->getConfigField('testMode') == false) {
$forte_base_uri = "https://api.forte.net/v3/";
}
return $forte_base_uri;
}
private function getOrganisationId(): string
{
return $this->company_gateway->getConfigField('organizationId');
}
public function getLocationId(): string
{
return $this->company_gateway->getConfigField('locationId');
}
public function stubRequest()
{
$forte_api_access_id = $this->company_gateway->getConfigField('apiAccessId');
$forte_secure_key = $this->company_gateway->getConfigField('secureKey');
$forte_auth_organization_id = $this->company_gateway->getConfigField('authOrganizationId');
return Http::withBasicAuth($forte_api_access_id, $forte_secure_key)
->withHeaders(['X-Forte-Auth-Organization-Id' => $this->getOrganisationId()]);
}
private function getClient(?string $email)
{
return ClientContact::query()
->where('company_id', $this->company_gateway->company_id)
->where('email', $email)
->first();
}
public function getLocation()
{
$response = $this->stubRequest()
->withQueryParameters(['page_size' => 10000])
->get("{$this->baseUri()}/organizations/{$this->getOrganisationId()}/locations/{$this->getLocationId()}");
if($response->successful())
return $response->json();
return false;
}
public function updateFees()
{
$response = $this->getLocation();
if($response)
{
$body = $response['services'];
$fees_and_limits = $this->company_gateway->fees_and_limits;
if($body['card']['service_fee_percentage'] > 0 || $body['card']['service_fee_additional_amount'] > 0){
$fees_and_limits->{1}->fee_amount = $body['card']['service_fee_additional_amount'];
$fees_and_limits->{1}->fee_percent = $body['card']['service_fee_percentage'];
}
if($body['debit']['service_fee_percentage'] > 0 || $body['debit']['service_fee_additional_amount'] > 0) {
$fees_and_limits->{2}->fee_amount = $body['debit']['service_fee_additional_amount'];
$fees_and_limits->{2}->fee_percent = $body['debit']['service_fee_percentage'];
}
$this->company_gateway->fees_and_limits = $fees_and_limits;
$this->company_gateway->save();
}
return false;
}
public function importCustomers()
{
$response = $this->stubRequest()
->withQueryParameters(['page_size' => 10000])
->get("{$this->baseUri()}/organizations/{$this->getOrganisationId()}/locations/{$this->getLocationId()}/customers");
if($response->successful()){
foreach($response->json()['results'] as $customer)
{
$client_repo = new ClientRepository(new ClientContactRepository());
$factory = new ForteCustomerFactory();
$data = $factory->convertToNinja($customer, $this->company_gateway->company);
if(strlen($data['email']) == 0 || $this->getClient($data['email']))
continue;
$client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id));
//persist any payment methods here!
}
}
}
}

View File

@ -84,11 +84,11 @@ class GoCardlessPaymentDriver extends BaseDriver
$types[] = GatewayType::DIRECT_DEBIT;
}
if (in_array($this->client->currency()->code, ['EUR', 'GBP'])) {
if ($this->client && in_array($this->client->currency()->code, ['EUR', 'GBP'])) {
$types[] = GatewayType::SEPA;
}
if ($this->client->currency()->code === 'GBP') {
if ($this->client && $this->client->currency()->code === 'GBP') {
$types[] = GatewayType::INSTANT_BANK_PAY;
}

View File

@ -574,4 +574,14 @@ class PayPalPPCPPaymentDriver extends BaseDriver
return false;
}
public function importCustomers()
{
// $response = $this->gatewayRequest('/v1/reporting/transactions', 'get', ['fields' => 'all','page_size' => 500,'start_date' => '2024-02-01T00:00:00-0000', 'end_date' => '2024-03-01T00:00:00-0000']);
// nlog($response->json());
return true;
}
}

View File

@ -424,7 +424,7 @@ class PayPalRestPaymentDriver extends BaseDriver
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_PAYPAL,
$this->client,
$this->client->company,
$this->client->company ?? $this->company_gateway->company,
);
throw new PaymentFailed("Gateway failure - {$r->body()}", 401);
@ -474,4 +474,10 @@ class PayPalRestPaymentDriver extends BaseDriver
return false;
}
public function importCustomers()
{
return true;
}
}

View File

@ -59,6 +59,9 @@ class CreditCard
'enc_key' => $data['enc_key'],
'integrator_id' => $this->paytrace->company_gateway->getConfigField('integratorId'),
'billing_address' => $this->buildBillingAddress(),
'email' => $this->paytrace->client->present()->email(),
'phone' => $this->paytrace->client->present()->phone(),
];
$response = $this->paytrace->gatewayRequest('/v1/customer/pt_protect_create', $post_data);

View File

@ -11,19 +11,24 @@
namespace App\PaymentDrivers;
use App\Exceptions\SystemError;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Invoice;
use App\Models\Payment;
use App\Utils\CurlUtils;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\PayTrace\CreditCard;
use App\Utils\CurlUtils;
use App\Factory\ClientFactory;
use App\Exceptions\SystemError;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use App\Models\ClientGatewayToken;
use App\Repositories\ClientRepository;
use App\PaymentDrivers\PayTrace\CreditCard;
use App\Repositories\ClientContactRepository;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Models\ClientContact;
use App\PaymentDrivers\Factory\PaytraceCustomerFactory;
class PaytracePaymentDriver extends BaseDriver
{
@ -260,4 +265,62 @@ class PaytracePaymentDriver extends BaseDriver
return false;
}
public function importCustomers()
{
$data = [
'integrator_id' => $this->company_gateway->getConfigField('integratorId'),
];
$response = $this->gatewayRequest('/v1/customer/export', $data);
nlog($response);
if ($response && $response->success) {
$client_repo = new ClientRepository(new ClientContactRepository());
$factory = new PaytraceCustomerFactory();
foreach($response->customers as $customer)
{
$data = $factory->convertToNinja($customer, $this->company_gateway->company);
$client = false;
if(str_contains($data['contacts'][0]['email'], "@"))
{
$client = ClientContact::query()
->where('company_id', $this->company_gateway->company_id)
->where('email', $data['contacts'][0]['email'])
->first()->client ?? false;
}
if(!$client)
$client = $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id));
$this->client = $client;
if(ClientGatewayToken::query()->where('client_id', $client->id)->where('token',$data['card']['token'])->exists())
continue;
$cgt = [];
$cgt['token'] = $data['card']['token'];
$cgt['payment_method_id'] = GatewayType::CREDIT_CARD;
$payment_meta = new \stdClass();
$payment_meta->exp_month = $data['card']['expiry_month'];
$payment_meta->exp_year = $data['card']['expiry_year'];
$payment_meta->brand = 'CC';
$payment_meta->last4 = $data['card']['last4'];
$payment_meta->type = GatewayType::CREDIT_CARD;
$cgt['payment_meta'] = $payment_meta;
$token = $this->storeGatewayToken($cgt, []);
}
}
}
}

View File

@ -197,7 +197,7 @@ class CreditCard implements MethodInterface
{
$square_card = new \Square\Models\Card();
$square_card->setCustomerId($this->findOrCreateClient());
$square_card->setCustomerId($this->square_driver->findOrCreateClient());
$body = new \Square\Models\CreateCardRequest(uniqid("st", true), $source_id, $square_card);
@ -238,82 +238,5 @@ class CreditCard implements MethodInterface
return false;
}
private function findOrCreateClient()
{
$email_address = new \Square\Models\CustomerTextFilter();
$email_address->setExact($this->square_driver->client->present()->email());
$filter = new \Square\Models\CustomerFilter();
$filter->setEmailAddress($email_address);
$query = new \Square\Models\CustomerQuery();
$query->setFilter($filter);
$body = new \Square\Models\SearchCustomersRequest();
$body->setQuery($query);
$api_response = $this->square_driver
->init()
->square
->getCustomersApi()
->searchCustomers($body);
$customers = false;
if ($api_response->isSuccess()) {
$customers = $api_response->getBody();
$customers = json_decode($customers);
if (count([$api_response->getBody(), 1]) == 0) {
$customers = false;
}
} else {
$errors = $api_response->getErrors();
}
if ($customers && property_exists($customers, 'customers')) {
return $customers->customers[0]->id;
}
return $this->createClient();
}
private function createClient()
{
$country = $this->square_driver->client->country ? $this->square_driver->client->country->iso_3166_2 : $this->square_driver->client->company->country()->iso_3166_2;
/* Step two - create the customer */
$billing_address = new \Square\Models\Address();
$billing_address->setAddressLine1($this->square_driver->client->address1);
$billing_address->setAddressLine2($this->square_driver->client->address2);
$billing_address->setLocality($this->square_driver->client->city);
$billing_address->setAdministrativeDistrictLevel1($this->square_driver->client->state);
$billing_address->setPostalCode($this->square_driver->client->postal_code);
$billing_address->setCountry($country);
$body = new \Square\Models\CreateCustomerRequest();
$body->setGivenName($this->square_driver->client->present()->name());
$body->setFamilyName('');
$body->setEmailAddress($this->square_driver->client->present()->email());
$body->setAddress($billing_address);
// $body->setPhoneNumber($this->square_driver->client->phone);
$body->setReferenceId($this->square_driver->client->number);
$body->setNote('Created by Invoice Ninja.');
$api_response = $this->square_driver
->init()
->square
->getCustomersApi()
->createCustomer($body);
if ($api_response->isSuccess()) {
$result = $api_response->getResult();
return $result->getCustomer()->getId();
} else {
$errors = $api_response->getErrors();
nlog($errors);
return $this->processUnsuccessfulPayment($api_response);
}
}
}

View File

@ -11,22 +11,27 @@
namespace App\PaymentDrivers;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
use App\Models\GatewayType;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\Models\ClientContact;
use App\Factory\ClientFactory;
use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash;
use Square\Utils\WebhooksHelper;
use App\Models\ClientGatewayToken;
use App\Repositories\ClientRepository;
use Square\Models\WebhookSubscription;
use App\PaymentDrivers\Square\CreditCard;
use App\PaymentDrivers\Square\SquareWebhook;
use App\Utils\Traits\MakesHash;
use Square\Models\Builders\RefundPaymentRequestBuilder;
use App\Repositories\ClientContactRepository;
use Square\Models\CreateWebhookSubscriptionRequest;
use Square\Models\WebhookSubscription;
use Square\Utils\WebhooksHelper;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\PaymentDrivers\Factory\SquareCustomerFactory;
use Square\Models\Builders\RefundPaymentRequestBuilder;
class SquarePaymentDriver extends BaseDriver
{
@ -442,4 +447,192 @@ class SquarePaymentDriver extends BaseDriver
return (bool) count($api_response->getErrors()) == 0;
}
public function importCustomers()
{
$limit = 100;
$api_response = $this->init()
->square
->getCustomersApi()
->listCustomers(null,
$limit,
'DEFAULT',
'DESC'
);
if ($api_response->isSuccess()) {
while ($api_response->getResult()->getCustomers()) {
$customers = $api_response->getResult()->getCustomers();
$client_repo = new ClientRepository(new ClientContactRepository());
foreach($customers as $customer)
{
$data = (new SquareCustomerFactory())->convertToNinja($customer, $this->company_gateway->company);
$client = ClientContact::where('company_id', $this->company_gateway->company_id)->where('email', $customer->getEmailAddress())->first()->client ?? false;
if(!$client)
$client = $client_repo->save($data, ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id));
$this->client = $client;
foreach($data['cards'] as $card) {
if(ClientGatewayToken::where('company_id', $this->company_gateway->company_id)->where('token', $card['token'])->exists())
continue;
$this->storeGatewayToken($card);
}
}
$c = $api_response->getCursor();
if ($c) {
$api_response = $this->init()
->square
->getCustomersApi()
->listCustomers(
$c,
$limit,
'DEFAULT',
'DESC'
);
} else {
break;
}
}
}
}
private function findClient($email = null)
{
$email_address_string = $email ?? $this->client->present()->email();
$email_address = new \Square\Models\CustomerTextFilter();
$email_address->setExact($email_address_string);
$filter = new \Square\Models\CustomerFilter();
$filter->setEmailAddress($email_address);
$query = new \Square\Models\CustomerQuery();
$query->setFilter($filter);
$body = new \Square\Models\SearchCustomersRequest();
$body->setQuery($query);
$api_response = $this->init()
->square
->getCustomersApi()
->searchCustomers($body);
$customers = false;
if ($api_response->isSuccess()) {
$customers = $api_response->getBody();
$customers = json_decode($customers);
if (count([$api_response->getBody(), 1]) == 0) {
$customers = false;
}
} else {
$errors = $api_response->getErrors();
}
if ($customers && property_exists($customers, 'customers')) {
return $customers->customers[0]->id;
}
return false;
}
public function findOrCreateClient()
{
if($customer_id = $this->findClient())
return $customer_id;
return $this->createClient();
}
private function createClient()
{
$country = $this->client->country ? $this->client->country->iso_3166_2 : $this->client->company->country()->iso_3166_2;
/* Step two - create the customer */
$billing_address = new \Square\Models\Address();
$billing_address->setAddressLine1($this->client->address1);
$billing_address->setAddressLine2($this->client->address2);
$billing_address->setLocality($this->client->city);
$billing_address->setAdministrativeDistrictLevel1($this->client->state);
$billing_address->setPostalCode($this->client->postal_code);
$billing_address->setCountry($country);
$body = new \Square\Models\CreateCustomerRequest();
$body->setGivenName($this->client->present()->name());
$body->setFamilyName('');
$body->setEmailAddress($this->client->present()->email());
$body->setAddress($billing_address);
$body->setReferenceId($this->client->number);
$body->setNote('Created by Invoice Ninja.');
$api_response = $this->init()
->square
->getCustomersApi()
->createCustomer($body);
if ($api_response->isSuccess()) {
$result = $api_response->getResult();
return $result->getCustomer()->getId();
} else {
$errors = $api_response->getErrors();
nlog($errors);
$error = end($errors);
$data = [
'response' => $error->getDetail(),
'error' => $error->getDetail(),
'error_code' => $error->getCode(),
];
return $this->processUnsuccessfulTransaction($data);
}
}
}

View File

@ -62,12 +62,6 @@ class ImportCustomers
$this->addCustomer($customer);
}
//handle
// if(is_array($customers->data) && end($customers->data) && array_key_exists('id', end($customers->data)))
// $starting_after = end($customers->data)['id'];
// else
// break;
$starting_after = isset(end($customers->data)['id']) ? end($customers->data)['id'] : false;
if (!$starting_after) {

View File

@ -544,7 +544,7 @@ class InvoiceService
return $this;
}
public function fillDefaults()
public function fillDefaults(bool $is_recurring = false)
{
$this->invoice->load('client.company');
@ -571,7 +571,7 @@ class InvoiceService
$this->invoice->exchange_rate = $this->invoice->client->setExchangeRate();
}
if ($this->invoice->client->getSetting('auto_bill_standard_invoices')) {
if ($is_recurring && $this->invoice->client->getSetting('auto_bill_standard_invoices')) {
$this->invoice->auto_bill_enabled = true;
}

181
composer.lock generated
View File

@ -5941,34 +5941,34 @@
},
{
"name": "lcobucci/clock",
"version": "3.2.0",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/clock.git",
"reference": "6f28b826ea01306b07980cb8320ab30b966cd715"
"reference": "039ef98c6b57b101d10bd11d8fdfda12cbd996dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/6f28b826ea01306b07980cb8320ab30b966cd715",
"reference": "6f28b826ea01306b07980cb8320ab30b966cd715",
"url": "https://api.github.com/repos/lcobucci/clock/zipball/039ef98c6b57b101d10bd11d8fdfda12cbd996dc",
"reference": "039ef98c6b57b101d10bd11d8fdfda12cbd996dc",
"shasum": ""
},
"require": {
"php": "~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0",
"psr/clock": "^1.0"
},
"provide": {
"psr/clock-implementation": "1.0"
},
"require-dev": {
"infection/infection": "^0.27",
"lcobucci/coding-standard": "^11.0.0",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.10.25",
"phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^10.2.3"
"infection/infection": "^0.26",
"lcobucci/coding-standard": "^9.0",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.9.4",
"phpstan/phpstan-deprecation-rules": "^1.1.1",
"phpstan/phpstan-phpunit": "^1.3.2",
"phpstan/phpstan-strict-rules": "^1.4.4",
"phpunit/phpunit": "^9.5.27"
},
"type": "library",
"autoload": {
@ -5989,7 +5989,7 @@
"description": "Yet another clock abstraction",
"support": {
"issues": "https://github.com/lcobucci/clock/issues",
"source": "https://github.com/lcobucci/clock/tree/3.2.0"
"source": "https://github.com/lcobucci/clock/tree/3.0.0"
},
"funding": [
{
@ -6001,7 +6001,7 @@
"type": "patreon"
}
],
"time": "2023-11-17T17:00:27+00:00"
"time": "2022-12-19T15:00:24+00:00"
},
{
"name": "lcobucci/jwt",
@ -12263,20 +12263,20 @@
},
{
"name": "symfony/css-selector",
"version": "v7.0.3",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "ec60a4edf94e63b0556b6a0888548bb400a3a3be"
"reference": "ee0f7ed5cf298cc019431bb3b3977ebc52b86229"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/ec60a4edf94e63b0556b6a0888548bb400a3a3be",
"reference": "ec60a4edf94e63b0556b6a0888548bb400a3a3be",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/ee0f7ed5cf298cc019431bb3b3977ebc52b86229",
"reference": "ee0f7ed5cf298cc019431bb3b3977ebc52b86229",
"shasum": ""
},
"require": {
"php": ">=8.2"
"php": ">=8.1"
},
"type": "library",
"autoload": {
@ -12308,7 +12308,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/v7.0.3"
"source": "https://github.com/symfony/css-selector/tree/v6.4.3"
},
"funding": [
{
@ -12324,7 +12324,7 @@
"type": "tidelift"
}
],
"time": "2024-01-23T15:02:46+00:00"
"time": "2024-01-23T14:51:35+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -12470,24 +12470,24 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v7.0.3",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "834c28d533dd0636f910909d01b9ff45cc094b5e"
"reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/834c28d533dd0636f910909d01b9ff45cc094b5e",
"reference": "834c28d533dd0636f910909d01b9ff45cc094b5e",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae9d3a6f3003a6caf56acd7466d8d52378d44fef",
"reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/event-dispatcher-contracts": "^2.5|^3"
},
"conflict": {
"symfony/dependency-injection": "<6.4",
"symfony/dependency-injection": "<5.4",
"symfony/service-contracts": "<2.5"
},
"provide": {
@ -12496,13 +12496,13 @@
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/error-handler": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/error-handler": "^5.4|^6.0|^7.0",
"symfony/expression-language": "^5.4|^6.0|^7.0",
"symfony/http-foundation": "^5.4|^6.0|^7.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/stopwatch": "^6.4|^7.0"
"symfony/stopwatch": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
@ -12530,7 +12530,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v7.0.3"
"source": "https://github.com/symfony/event-dispatcher/tree/v6.4.3"
},
"funding": [
{
@ -12546,7 +12546,7 @@
"type": "tidelift"
}
],
"time": "2024-01-23T15:02:46+00:00"
"time": "2024-01-23T14:51:35+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@ -13114,25 +13114,25 @@
},
{
"name": "symfony/intl",
"version": "v7.0.3",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/intl.git",
"reference": "295995df4acf6790a35b9ce6ec32b313efb11ff8"
"reference": "2628ded562ca132ed7cdea72f5ec6aaf65d94414"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/intl/zipball/295995df4acf6790a35b9ce6ec32b313efb11ff8",
"reference": "295995df4acf6790a35b9ce6ec32b313efb11ff8",
"url": "https://api.github.com/repos/symfony/intl/zipball/2628ded562ca132ed7cdea72f5ec6aaf65d94414",
"reference": "2628ded562ca132ed7cdea72f5ec6aaf65d94414",
"shasum": ""
},
"require": {
"php": ">=8.2"
"php": ">=8.1"
},
"require-dev": {
"symfony/filesystem": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"symfony/var-exporter": "^6.4|^7.0"
"symfony/filesystem": "^5.4|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0|^7.0",
"symfony/var-exporter": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
@ -13176,7 +13176,7 @@
"localization"
],
"support": {
"source": "https://github.com/symfony/intl/tree/v7.0.3"
"source": "https://github.com/symfony/intl/tree/v6.4.3"
},
"funding": [
{
@ -13192,7 +13192,7 @@
"type": "tidelift"
}
],
"time": "2024-01-23T15:02:46+00:00"
"time": "2024-01-23T14:51:35+00:00"
},
{
"name": "symfony/mailer",
@ -13429,20 +13429,20 @@
},
{
"name": "symfony/options-resolver",
"version": "v7.0.0",
"version": "v6.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "700ff4096e346f54cb628ea650767c8130f1001f"
"reference": "22301f0e7fdeaacc14318928612dee79be99860e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/700ff4096e346f54cb628ea650767c8130f1001f",
"reference": "700ff4096e346f54cb628ea650767c8130f1001f",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e",
"reference": "22301f0e7fdeaacc14318928612dee79be99860e",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3"
},
"type": "library",
@ -13476,7 +13476,7 @@
"options"
],
"support": {
"source": "https://github.com/symfony/options-resolver/tree/v7.0.0"
"source": "https://github.com/symfony/options-resolver/tree/v6.4.0"
},
"funding": [
{
@ -13492,7 +13492,7 @@
"type": "tidelift"
}
],
"time": "2023-08-08T10:20:21+00:00"
"time": "2023-08-08T10:16:24+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -14676,20 +14676,20 @@
},
{
"name": "symfony/string",
"version": "v7.0.4",
"version": "v6.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "f5832521b998b0bec40bee688ad5de98d4cf111b"
"reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/f5832521b998b0bec40bee688ad5de98d4cf111b",
"reference": "f5832521b998b0bec40bee688ad5de98d4cf111b",
"url": "https://api.github.com/repos/symfony/string/zipball/4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9",
"reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
@ -14699,11 +14699,11 @@
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
"symfony/error-handler": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/error-handler": "^5.4|^6.0|^7.0",
"symfony/http-client": "^5.4|^6.0|^7.0",
"symfony/intl": "^6.2|^7.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.4|^7.0"
"symfony/var-exporter": "^5.4|^6.0|^7.0"
},
"type": "library",
"autoload": {
@ -14742,7 +14742,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v7.0.4"
"source": "https://github.com/symfony/string/tree/v6.4.4"
},
"funding": [
{
@ -14758,7 +14758,7 @@
"type": "tidelift"
}
],
"time": "2024-02-01T13:17:36+00:00"
"time": "2024-02-01T13:16:41+00:00"
},
{
"name": "symfony/translation",
@ -16230,16 +16230,16 @@
},
{
"name": "brianium/paratest",
"version": "v7.4.3",
"version": "v7.3.1",
"source": {
"type": "git",
"url": "https://github.com/paratestphp/paratest.git",
"reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec"
"reference": "551f46f52a93177d873f3be08a1649ae886b4a30"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paratestphp/paratest/zipball/64fcfd0e28a6b8078a19dbf9127be2ee645b92ec",
"reference": "64fcfd0e28a6b8078a19dbf9127be2ee645b92ec",
"url": "https://api.github.com/repos/paratestphp/paratest/zipball/551f46f52a93177d873f3be08a1649ae886b4a30",
"reference": "551f46f52a93177d873f3be08a1649ae886b4a30",
"shasum": ""
},
"require": {
@ -16247,27 +16247,28 @@
"ext-pcre": "*",
"ext-reflection": "*",
"ext-simplexml": "*",
"fidry/cpu-core-counter": "^1.1.0",
"fidry/cpu-core-counter": "^0.5.1 || ^1.0.0",
"jean85/pretty-package-versions": "^2.0.5",
"php": "~8.2.0 || ~8.3.0",
"phpunit/php-code-coverage": "^10.1.11 || ^11.0.0",
"phpunit/php-file-iterator": "^4.1.0 || ^5.0.0",
"phpunit/php-timer": "^6.0.0 || ^7.0.0",
"phpunit/phpunit": "^10.5.9 || ^11.0.3",
"sebastian/environment": "^6.0.1 || ^7.0.0",
"symfony/console": "^6.4.3 || ^7.0.3",
"symfony/process": "^6.4.3 || ^7.0.3"
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"phpunit/php-code-coverage": "^10.1.7",
"phpunit/php-file-iterator": "^4.1.0",
"phpunit/php-timer": "^6.0",
"phpunit/phpunit": "^10.4.2",
"sebastian/environment": "^6.0.1",
"symfony/console": "^6.3.4 || ^7.0.0",
"symfony/process": "^6.3.4 || ^7.0.0"
},
"require-dev": {
"doctrine/coding-standard": "^12.0.0",
"ext-pcov": "*",
"ext-posix": "*",
"phpstan/phpstan": "^1.10.58",
"infection/infection": "^0.27.6",
"phpstan/phpstan": "^1.10.40",
"phpstan/phpstan-deprecation-rules": "^1.1.4",
"phpstan/phpstan-phpunit": "^1.3.15",
"phpstan/phpstan-strict-rules": "^1.5.2",
"squizlabs/php_codesniffer": "^3.9.0",
"symfony/filesystem": "^6.4.3 || ^7.0.3"
"squizlabs/php_codesniffer": "^3.7.2",
"symfony/filesystem": "^6.3.1 || ^7.0.0"
},
"bin": [
"bin/paratest",
@ -16308,7 +16309,7 @@
],
"support": {
"issues": "https://github.com/paratestphp/paratest/issues",
"source": "https://github.com/paratestphp/paratest/tree/v7.4.3"
"source": "https://github.com/paratestphp/paratest/tree/v7.3.1"
},
"funding": [
{
@ -16320,7 +16321,7 @@
"type": "paypal"
}
],
"time": "2024-02-20T07:24:02+00:00"
"time": "2023-10-31T09:24:17+00:00"
},
{
"name": "composer/class-map-generator",
@ -19405,20 +19406,20 @@
},
{
"name": "symfony/stopwatch",
"version": "v7.0.3",
"version": "v6.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "983900d6fddf2b0cbaacacbbad07610854bd8112"
"reference": "416596166641f1f728b0a64f5b9dd07cceb410c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/983900d6fddf2b0cbaacacbbad07610854bd8112",
"reference": "983900d6fddf2b0cbaacacbbad07610854bd8112",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/416596166641f1f728b0a64f5b9dd07cceb410c1",
"reference": "416596166641f1f728b0a64f5b9dd07cceb410c1",
"shasum": ""
},
"require": {
"php": ">=8.2",
"php": ">=8.1",
"symfony/service-contracts": "^2.5|^3"
},
"type": "library",
@ -19447,7 +19448,7 @@
"description": "Provides a way to profile code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/stopwatch/tree/v7.0.3"
"source": "https://github.com/symfony/stopwatch/tree/v6.4.3"
},
"funding": [
{
@ -19463,7 +19464,7 @@
"type": "tidelift"
}
],
"time": "2024-01-23T15:02:46+00:00"
"time": "2024-01-23T14:35:58+00:00"
},
{
"name": "theseer/tokenizer",
@ -19533,5 +19534,5 @@
"platform-dev": {
"php": "^8.1|^8.2"
},
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.3.0"
}

View File

@ -84,9 +84,15 @@ return [
'username' => 'user@example.com',
'clientname' => 'client@example.com',
'password' => 'password',
'gocardless' => env('GOCARDLESS_KEYS',''),
'square' => env('SQUARE_KEYS',''),
'eway' => env('EWAY_KEYS',''),
'mollie', env('MOLLIE_KEYS',''),
'paytrace' => env('PAYTRACE_KEYS',''),
'stripe' => env('STRIPE_KEYS', ''),
'paypal' => env('PAYPAL_KEYS', ''),
'ppcp' => env('PPCP_KEYS', ''),
'forte' => env('FORTE_KEYS', ''),
'paypal_rest' => env('PAYPAL_REST_KEYS', ''),
'authorize' => env('AUTHORIZE_KEYS', ''),
'checkout' => env('CHECKOUT_KEYS', ''),
@ -94,11 +100,6 @@ return [
'test_email' => env('TEST_EMAIL', 'test@example.com'),
'wepay' => env('WEPAY_KEYS', ''),
'braintree' => env('BRAINTREE_KEYS', ''),
'paytrace' => [
'username' => env('PAYTRACE_U', ''),
'password' => env('PAYTRACE_P', ''),
'decrypted' => env('PAYTRACE_KEYS', ''),
],
'mollie' => env('MOLLIE_KEYS', ''),
'square' => env('SQUARE_KEYS', ''),
],
@ -243,4 +244,6 @@ return [
'public_key' => env('NINJA_PUBLIC_KEY', false),
'private_key' => env('NINJA_PRIVATE_KEY', false),
],
'upload_extensions' => env('ADDITIONAL_UPLOAD_EXTENSIONS', false),
];

View File

@ -198,6 +198,7 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
Route::post('company_gateways/bulk', [CompanyGatewayController::class, 'bulk'])->name('company_gateways.bulk');
Route::post('company_gateways/{company_gateway}/test', [CompanyGatewayController::class, 'test'])->name('company_gateways.test');
Route::post('company_gateways/{company_gateway}/import_customers', [CompanyGatewayController::class, 'importCustomers'])->name('company_gateways.import_customers');
Route::put('company_users/{user}', [CompanyUserController::class, 'update']);
Route::put('company_users/{user}/preferences', [CompanyUserController::class, 'updatePreferences']);