mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 22:14:35 -04:00
Working on Gateways
This commit is contained in:
parent
31afd09a0f
commit
0b0f0759f1
@ -82,7 +82,6 @@ class ClientSettings extends BaseSettings
|
|||||||
public $recurring_invoice_number_prefix;
|
public $recurring_invoice_number_prefix;
|
||||||
|
|
||||||
public $counter_padding;
|
public $counter_padding;
|
||||||
public $default_gateway;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings which which are unique to client settings
|
* Settings which which are unique to client settings
|
||||||
|
@ -111,8 +111,6 @@ class CompanySettings extends BaseSettings
|
|||||||
public $reset_counter_date;
|
public $reset_counter_date;
|
||||||
public $counter_padding;
|
public $counter_padding;
|
||||||
|
|
||||||
public $default_gateway;
|
|
||||||
|
|
||||||
public $design;
|
public $design;
|
||||||
/**
|
/**
|
||||||
* Cast object values and return entire class
|
* Cast object values and return entire class
|
||||||
|
@ -92,6 +92,11 @@ class Client extends BaseModel
|
|||||||
'settings' => 'object'
|
'settings' => 'object'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function gateway_tokens()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ClientGatewayToken::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function contacts()
|
public function contacts()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
return $this->hasMany(ClientContact::class)->orderBy('is_primary', 'desc');
|
||||||
@ -147,7 +152,10 @@ class Client extends BaseModel
|
|||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPaymentMethods()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
42
app/Models/ClientGatewayToken.php
Normal file
42
app/Models/ClientGatewayToken.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class ClientGatewayToken extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public function client()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Client::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function gateway()
|
||||||
|
{
|
||||||
|
return $this->hasOne(CompanyGateway::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function company()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Company::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->hasOne(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,10 +16,9 @@ use App\Models\Gateway;
|
|||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class CompanyGateway extends Model
|
class CompanyGateway extends BaseModel
|
||||||
{
|
{
|
||||||
public static $creditCards =
|
public static $credit_cards = [
|
||||||
[
|
|
||||||
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
||||||
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
|
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
|
||||||
4 => ['card' => 'images/credit_cards/Test-AmericanExpress-Icon.png', 'text' => 'American Express'],
|
4 => ['card' => 'images/credit_cards/Test-AmericanExpress-Icon.png', 'text' => 'American Express'],
|
||||||
@ -63,12 +62,22 @@ class CompanyGateway extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfigAttribute()
|
||||||
|
{
|
||||||
|
return decrypt($this->config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setConfigAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['config'] = encrypt(json_encode($value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getAchEnabled()
|
public function getAchEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableAch'));
|
return ! empty($this->config('enableAch'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +85,7 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getApplePayEnabled()
|
public function getApplePayEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableApplePay'));
|
return ! empty($this->config('enableApplePay'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +93,7 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getAlipayEnabled()
|
public function getAlipayEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableAlipay'));
|
return ! empty($this->config('enableAlipay'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +101,7 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getSofortEnabled()
|
public function getSofortEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableSofort'));
|
return ! empty($this->config('enableSofort'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +109,7 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getSepaEnabled()
|
public function getSepaEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableSepa'));
|
return ! empty($this->config('enableSepa'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +117,7 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getBitcoinEnabled()
|
public function getBitcoinEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enableBitcoin'));
|
return ! empty($this->config('enableBitcoin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,6 +125,6 @@ class CompanyGateway extends Model
|
|||||||
*/
|
*/
|
||||||
public function getPayPalEnabled()
|
public function getPayPalEnabled()
|
||||||
{
|
{
|
||||||
return ! empty($this->getConfigField('enablePayPal'));
|
return ! empty($this->config('enablePayPal'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
app/Models/CompanyGatewaySetting.php
Normal file
39
app/Models/CompanyGatewaySetting.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\CompanyGateway;
|
||||||
|
use App\Models\Gateway;
|
||||||
|
use App\Models\GatewayType;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CompanyGatewaySetting extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public function company()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Company::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function company_gateway()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(CompanyGateway::class);
|
||||||
|
}
|
||||||
|
}
|
@ -351,9 +351,13 @@ class CreateUsersTable extends Migration
|
|||||||
$table->unsignedInteger('company_id')->unique();
|
$table->unsignedInteger('company_id')->unique();
|
||||||
$table->unsignedInteger('user_id');
|
$table->unsignedInteger('user_id');
|
||||||
$table->unsignedInteger('gateway_id');
|
$table->unsignedInteger('gateway_id');
|
||||||
|
$table->unsignedInteger('accepted_credit_cards');
|
||||||
|
$table->boolean('require_cvv')->default(true);
|
||||||
$table->boolean('show_address')->default(true)->nullable();
|
$table->boolean('show_address')->default(true)->nullable();
|
||||||
$table->boolean('update_address')->default(true)->nullable();
|
$table->boolean('show_shipping_address')->default(true)->nullable();
|
||||||
|
$table->boolean('update_details')->default(false)->nullable();
|
||||||
$table->text('config');
|
$table->text('config');
|
||||||
|
$table->unsignedInteger('sort_id')->default(0);
|
||||||
|
|
||||||
$table->timestamps(6);
|
$table->timestamps(6);
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
@ -683,7 +687,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->unsignedInteger('client_contact_id')->nullable();
|
$t->unsignedInteger('client_contact_id')->nullable();
|
||||||
$t->unsignedInteger('invitation_id')->nullable();
|
$t->unsignedInteger('invitation_id')->nullable();
|
||||||
$t->unsignedInteger('user_id')->nullable();
|
$t->unsignedInteger('user_id')->nullable();
|
||||||
$t->unsignedInteger('account_gateway_id')->nullable();
|
$t->unsignedInteger('company_gateway_id')->nullable();
|
||||||
$t->unsignedInteger('payment_type_id')->nullable();
|
$t->unsignedInteger('payment_type_id')->nullable();
|
||||||
$t->unsignedInteger('status_id')->index();
|
$t->unsignedInteger('status_id')->index();
|
||||||
|
|
||||||
@ -700,7 +704,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
$t->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||||
$t->foreign('client_contact_id')->references('id')->on('client_contacts')->onDelete('cascade');
|
$t->foreign('client_contact_id')->references('id')->on('client_contacts')->onDelete('cascade');
|
||||||
$t->foreign('account_gateway_id')->references('id')->on('account_gateways')->onDelete('cascade');
|
$t->foreign('company_gateway_id')->references('id')->on('company_gateways')->onDelete('cascade');
|
||||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
;
|
;
|
||||||
$t->foreign('payment_type_id')->references('id')->on('payment_types');
|
$t->foreign('payment_type_id')->references('id')->on('payment_types');
|
||||||
@ -885,6 +889,42 @@ class CreateUsersTable extends Migration
|
|||||||
$table->string('alias');
|
$table->string('alias');
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Schema::create('client_gateway_tokens', function ($table){
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('company_id');
|
||||||
|
$table->unsignedInteger('client_id')->nullable();
|
||||||
|
$table->text('token');
|
||||||
|
$table->unsignedInteger('company_gateway_id');
|
||||||
|
$table->boolean('is_default');
|
||||||
|
$table->timestamps(6);
|
||||||
|
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||||
|
$table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Schema::create('company_gateway_settings', function ($table){
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('company_id');
|
||||||
|
$table->unsignedInteger('company_gateway_id')->nullable();
|
||||||
|
$table->unsignedInteger('gateway_type_id')->nullable();
|
||||||
|
$table->unsignedInteger('user_id')->nullable();
|
||||||
|
$table->decimal('min_limit', 13, 2)->nullable();
|
||||||
|
$table->decimal('max_limit', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_amount', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_percent', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_tax_name1', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_tax_name2', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_tax_rate1', 13, 2)->nullable();
|
||||||
|
$table->decimal('fee_tax_rate2', 13, 2)->nullable();
|
||||||
|
$table->unsignedInteger('fee_cap')->default(0);
|
||||||
|
$table->boolean('adjust_fee_percent');
|
||||||
|
|
||||||
|
$table->timestamps(6);
|
||||||
|
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
|
||||||
|
$table->foreign('company_gateway_id')->references('id')->on('company_gateways')->onDelete('cascade');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user