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() 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(); $gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
if ( ! $gateway_settings) { 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_VERIFICATION_FAILED', 'verification_failed');
define('PAYMENT_METHOD_STATUS_VERIFIED', 'verified'); define('PAYMENT_METHOD_STATUS_VERIFIED', 'verified');
define('GATEWAY_TYPE_CREDIT_CARD', 'credit_card'); define('GATEWAY_TYPE_CREDIT_CARD', 1);
define('GATEWAY_TYPE_BANK_TRANSFER', 'bank_transfer'); define('GATEWAY_TYPE_BANK_TRANSFER', 2);
define('GATEWAY_TYPE_PAYPAL', 'paypal'); define('GATEWAY_TYPE_PAYPAL', 3);
define('GATEWAY_TYPE_BITCOIN', 'bitcoin'); define('GATEWAY_TYPE_BITCOIN', 4);
define('GATEWAY_TYPE_DWOLLA', 'dwolla'); define('GATEWAY_TYPE_DWOLLA', 5);
define('GATEWAY_TYPE_TOKEN', 'token'); define('GATEWAY_TYPE_TOKEN', 'token');
define('REMINDER1', 'reminder1'); define('REMINDER1', 'reminder1');

View File

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

View File

@ -156,14 +156,15 @@ class AccountGatewayDatatable extends EntityDatatable
$min = $accountGatewaySettings ? $accountGatewaySettings->min_limit : 0; $min = $accountGatewaySettings ? $accountGatewaySettings->min_limit : 0;
$max = $accountGatewaySettings ? $accountGatewaySettings->max_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) { function ($model) use ($gatewayType) {
// Only show this action if the given gateway supports this gateway type // Only show this action if the given gateway supports this gateway type
$accountGateway = AccountGateway::find($model->id); $accountGateway = AccountGateway::find($model->id);
$paymentDriver = $accountGateway->paymentDriver(); $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() public function up()
{ {
Schema::dropIfExists('account_gateway_settings');
Schema::dropIfExists('gateway_types'); Schema::dropIfExists('gateway_types');
Schema::create('gateway_types', function($t) Schema::create('gateway_types', function($t)
{ {
$t->string('id'); $t->increments('id');
$t->string('name'); $t->string('name');
$t->primary('id');
}); });
Schema::dropIfExists('account_gateway_settings');
Schema::create('account_gateway_settings', function($t) Schema::create('account_gateway_settings', function($t)
{ {
$t->increments('id'); $t->increments('id');
$t->unsignedInteger('account_id'); $t->unsignedInteger('account_id');
$t->unsignedInteger('user_id'); $t->unsignedInteger('user_id');
$t->string('gateway_type_id')->nullable(); $t->unsignedInteger('gateway_type_id')->nullable();
$t->timestamp('updated_at')->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'); $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. * Reverse the migrations.

View File

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