1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Revert change to string ID for gateway types

This commit is contained in:
Joshua Dwire 2016-09-09 16:47:08 -04:00
parent 286f9e8902
commit 2fc0265d06
6 changed files with 18 additions and 28 deletions

View File

@ -1235,7 +1235,7 @@ class AccountController extends BaseController
*/
public function savePaymentGatewayLimits()
{
$gateway_type_id = Input::get('gateway_type_id');
$gateway_type_id = intval(Input::get('gateway_type_id'));
$gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
if ( ! $gateway_settings) {

View File

@ -704,11 +704,11 @@ if (!defined('CONTACT_EMAIL')) {
define('PAYMENT_METHOD_STATUS_VERIFICATION_FAILED', 'verification_failed');
define('PAYMENT_METHOD_STATUS_VERIFIED', 'verified');
define('GATEWAY_TYPE_CREDIT_CARD', 'credit_card');
define('GATEWAY_TYPE_BANK_TRANSFER', 'bank_transfer');
define('GATEWAY_TYPE_PAYPAL', 'paypal');
define('GATEWAY_TYPE_BITCOIN', 'bitcoin');
define('GATEWAY_TYPE_DWOLLA', 'dwolla');
define('GATEWAY_TYPE_CREDIT_CARD', 1);
define('GATEWAY_TYPE_BANK_TRANSFER', 2);
define('GATEWAY_TYPE_PAYPAL', 3);
define('GATEWAY_TYPE_BITCOIN', 4);
define('GATEWAY_TYPE_DWOLLA', 5);
define('GATEWAY_TYPE_TOKEN', 'token');
define('REMINDER1', 'reminder1');

View File

@ -12,8 +12,6 @@ class GatewayType extends Eloquent
*/
public $timestamps = false;
public $incrementing = false;
/**
* @return mixed
*/

View File

@ -156,14 +156,15 @@ class AccountGatewayDatatable extends EntityDatatable
$min = $accountGatewaySettings ? $accountGatewaySettings->min_limit : 0;
$max = $accountGatewaySettings ? $accountGatewaySettings->max_limit : 0;
return "javascript:showLimitsModal('{$gatewayType->name}','{$gatewayType->id}',$min,$max)";
return "javascript:showLimitsModal('{$gatewayType->name}',{$gatewayType->id},$min,$max)";
},
function ($model) use ($gatewayType) {
// Only show this action if the given gateway supports this gateway type
$accountGateway = AccountGateway::find($model->id);
$paymentDriver = $accountGateway->paymentDriver();
$gatewayTypes = $paymentDriver->gatewayTypes();
return $paymentDriver->handles($gatewayType->id);
return in_array($gatewayType->id, $gatewayTypes);
}
];
}

View File

@ -12,24 +12,21 @@ class CreateGatewayTypes extends Migration
*/
public function up()
{
Schema::dropIfExists('account_gateway_settings');
Schema::dropIfExists('gateway_types');
Schema::create('gateway_types', function($t)
{
$t->string('id');
$t->increments('id');
$t->string('name');
$t->primary('id');
});
Schema::dropIfExists('account_gateway_settings');
Schema::create('account_gateway_settings', function($t)
{
$t->increments('id');
$t->unsignedInteger('account_id');
$t->unsignedInteger('user_id');
$t->string('gateway_type_id')->nullable();
$t->unsignedInteger('gateway_type_id')->nullable();
$t->timestamp('updated_at')->nullable();
@ -42,12 +39,6 @@ class CreateGatewayTypes extends Migration
$t->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade');
});
Schema::table('payment_types', function($t)
{
$t->string('gateway_type_id')->nullable();
$t->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade');
});
}
/**
* Reverse the migrations.

View File

@ -10,15 +10,15 @@ class GatewayTypesSeeder extends Seeder
$gateway_types = [
['id' => 'credit_card', 'name' => 'Credit Card'],
['id' => 'bank_transfer', 'name' => 'Bank Transfer'],
['id' => 'paypal', 'name' => 'PayPal'],
['id' => 'bitcoin', 'name' => 'Bitcoin'],
['id' => 'dwolla', 'name' => 'Dwolla'],
['name' => 'Credit Card'],
['name' => 'Bank Transfer'],
['name' => 'PayPal'],
['name' => 'Bitcoin'],
['name' => 'Dwolla'],
];
foreach ($gateway_types as $gateway_type) {
$record = GatewayType::where('id', '=', $gateway_type['id'])->first();
$record = GatewayType::where('name', '=', $gateway_type['name'])->first();
if (!$record) {
GatewayType::create($gateway_type);
}