1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Updated account controller, data objects, and logos for recommended gateways.

This commit is contained in:
blkmutt 2014-03-25 20:59:33 -04:00
parent af7ba0b7b1
commit 33ff8e1d60
12 changed files with 163 additions and 47 deletions

View File

@ -102,19 +102,56 @@ class AccountController extends \BaseController {
{
$accountGateway = $account->account_gateways[0];
$config = $accountGateway->config;
}
}
$recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE)
->where('recommended', '=', '1')
->orderBy('sort_order')
->get();
$recommendedGatewayArray = array();
foreach($recommendedGateways as $recommendedGateway)
{
$newRow = count($recommendedGatewayArray) + 1 == round(count($recommendedGateways) / 2);
$arrayItem = array(
$recommendedGateway->name => $recommendedGateway->provider,
'data-name' => $recommendedGateway->name,
'data-id' => $recommendedGateway->id,
'data-label' => $recommendedGateway->provider,
'data-value' => $recommendedGateway->name,
'value' => $recommendedGateway->id,
'data-imageUrl' => $recommendedGateway->getLogoUrl(),
'data-siteUrl' => $recommendedGateway->site_url,
'data-newRow' => $newRow
);
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$data = [
'account' => $account,
'accountGateway' => $accountGateway,
'config' => json_decode($config),
'gateways' => Gateway::remember(DEFAULT_QUERY_CACHE)->get(),
'gateways' => Gateway::remember(DEFAULT_QUERY_CACHE)
->orderBy('name')
->get(),
'recommendedGateways' => $recommendedGatewayArray,
];
foreach ($data['gateways'] as $gateway)
{
$gateway->fields = Omnipay::create($gateway->provider)->getDefaultParameters();
$paymentLibrary = $gateway->paymentlibrary;
if($paymentLibrary->name == 'Omnipay')
{
$gateway->fields = Omnipay::create($gateway->provider)->getDefaultParameters();
}
else {
$gateway->fields = array();
}
if ($accountGateway && $accountGateway->gateway_id == $gateway->id)
{
$accountGateway->fields = $gateway->fields;

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSortAndRecommendedToGateways extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('gateways', function($table)
{
$table->unsignedInteger('sort_order')->default(10000);
$table->boolean('recommended');
$table->string('site_url', 200);
});
}
public function down()
{
if (Schema::hasColumn('gateways', 'sort_order'))
{
Schema::table('gateways', function($table)
{
$table->dropColumn('sort_order');
});
}
if (Schema::hasColumn('gateways', 'recommended'))
{
Schema::table('gateways', function($table)
{
$table->dropColumn('recommended');
});
}
if (Schema::hasColumn('gateways', 'site_url'))
{
Schema::table('gateways', function($table)
{
$table->dropColumn('site_url');
});
}
}
}

View File

@ -6,39 +6,31 @@ class PaymentLibrariesSeeder extends Seeder
public function run()
{
$gateways = [
array('name'=>'Authorize.Net AIM', 'provider'=>'AuthorizeNet_AIM', 'payment_library_id' => 2),
array('name'=>'Authorize.Net SIM', 'provider'=>'AuthorizeNet_SIM', 'payment_library_id' => 2),
array('name'=>'CardSave', 'provider'=>'CardSave', 'payment_library_id' => 2),
array('name'=>'Eway Rapid', 'provider'=>'Eway_Rapid', 'payment_library_id' => 2),
array('name'=>'FirstData Connect', 'provider'=>'FirstData_Connect', 'payment_library_id' => 2),
array('name'=>'GoCardless', 'provider'=>'GoCardless', 'payment_library_id' => 2),
array('name'=>'Migs ThreeParty', 'provider'=>'Migs_ThreeParty', 'payment_library_id' => 2),
array('name'=>'Migs TwoParty', 'provider'=>'Migs_TwoParty', 'payment_library_id' => 2),
array('name'=>'Mollie', 'provider'=>'Mollie', 'payment_library_id' => 2),
array('name'=>'MultiSafepay', 'provider'=>'MultiSafepay', 'payment_library_id' => 2),
array('name'=>'Netaxept', 'provider'=>'Netaxept', 'payment_library_id' => 2),
array('name'=>'NetBanx', 'provider'=>'NetBanx', 'payment_library_id' => 2),
array('name'=>'PayFast', 'provider'=>'PayFast', 'payment_library_id' => 2),
array('name'=>'Payflow Pro', 'provider'=>'Payflow_Pro', 'payment_library_id' => 2),
array('name'=>'PaymentExpress PxPay', 'provider'=>'PaymentExpress_PxPay', 'payment_library_id' => 2),
array('name'=>'PaymentExpress PxPost', 'provider'=>'PaymentExpress_PxPost', 'payment_library_id' => 2),
array('name'=>'PayPal Express', 'provider'=>'PayPal_Express', 'payment_library_id' => 2),
array('name'=>'PayPal Pro', 'provider'=>'PayPal_Pro', 'payment_library_id' => 2),
array('name'=>'Pin', 'provider'=>'Pin', 'payment_library_id' => 2),
array('name'=>'SagePay Direct', 'provider'=>'SagePay_Direct', 'payment_library_id' => 2),
array('name'=>'SagePay Server', 'provider'=>'SagePay_Server', 'payment_library_id' => 2),
array('name'=>'SecurePay DirectPost', 'provider'=>'SecurePay_DirectPost', 'payment_library_id' => 2),
array('name'=>'Stripe', 'provider'=>'Stripe', 'payment_library_id' => 2),
array('name'=>'TargetPay Direct eBanking', 'provider'=>'TargetPay_Directebanking', 'payment_library_id' => 2),
array('name'=>'TargetPay Ideal', 'provider'=>'TargetPay_Ideal', 'payment_library_id' => 2),
array('name'=>'TargetPay Mr Cash', 'provider'=>'TargetPay_Mrcash', 'payment_library_id' => 2),
array('name'=>'TwoCheckout', 'provider'=>'TwoCheckout', 'payment_library_id' => 2),
array('name'=>'WorldPay', 'provider'=>'WorldPay', 'payment_library_id' => 2)
array('name'=>'BeanStream', 'provider'=>'BeanStream', 'payment_library_id' => 2),
array('name'=>'iTransact', 'provider'=>'iTransact', 'payment_library_id' => 2)
];
$updateProviders = array(
0 => 'AuthorizeNet_AIM',
1 => 'BeanStream',
2 => 'iTransact',
3 => 'FirstData_Connect',
4 => 'PayPal_Pro',
5 => 'TwoCheckout'
);
foreach ($gateways as $gateway)
{
Gateway::create($gateway);
}
Gateway::whereIn('provider', $updateProviders)->update(array('recommended' => 1));
Gateway::where('provider', '=', 'AuthorizeNet_AIM')->update(array('sort_order' => 5, 'site_url' => 'http://www.authorize.net/'));
Gateway::where('provider', '=', 'BeanStream')->update(array('sort_order' => 10, 'site_url' => 'http://www.beanstream.com/'));
Gateway::where('provider', '=', 'iTransact')->update(array('sort_order' => 15, 'site_url' => 'http://itransact.com/'));
Gateway::where('provider', '=', 'FirstData_Connect')->update(array('sort_order' => 20, 'site_url' => 'https://www.firstdata.com/'));
Gateway::where('provider', '=', 'PayPal_Pro')->update(array('sort_order' => 25, 'site_url' => 'https://www.paypal.com/'));
Gateway::where('provider', '=', 'TwoCheckout')->update(array('sort_order' => 30, 'site_url' => 'https://www.2checkout.com/'));
}
}

View File

@ -7,6 +7,11 @@ class Gateway extends Eloquent
public function paymentlibrary()
{
return $this->belongsTo('PaymentLibrary');
return $this->belongsTo('PaymentLibrary', 'payment_library_id');
}
public function getLogoUrl()
{
return '/images/gateways/logo_'.$this->provider.'.png';
}
}

View File

@ -6,6 +6,6 @@ class PaymentLibrary extends Eloquent
public function gateways()
{
return $this->hasMany('Gateway');
return $this->hasMany('Gateway', 'payment_library_id');
}
}

View File

@ -10,6 +10,14 @@
{{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }}
{{ Former::legend('Payment Gateway') }}
{{Former::label('Lorem Ipsum goes here.')}}
{{ Former::radios('recommendedGateway_id')
->label('Recommended Gateways')
->radios($recommendedGateways)
->class('recommended-gateway')}}
@if ($accountGateway)
{{ Former::populateField('gateway_id', $accountGateway->gateway_id) }}
@ -22,12 +30,14 @@
@endforeach
@endif
{{ Former::select('gateway_id')->label('Provider')->addOption('', '')
->fromQuery($gateways, 'name', 'id')->onchange('setFieldsShown()'); }}
{{ Former::select('gateway_id')->label('PayPal & Other Gateways')->addOption('', '')
->dataClass('gateway-dropdown')
->fromQuery($gateways, 'name', 'id')
->onchange('setFieldsShown()'); }}
@foreach ($gateways as $gateway)
<div id="gateway_{{ $gateway->id }}_div" style="display: none">
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@foreach ($gateway->fields as $field => $details)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
@ -51,20 +61,43 @@
<script type="text/javascript">
var gateways = {{ $gateways }};
function setFieldsShown() {
var val = $('#gateway_id').val();
for (var i=0; i<gateways.length; i++) {
var gateway = gateways[i];
if (val == gateway.id) {
$('#gateway_' + gateway.id + '_div').show();
} else {
$('#gateway_' + gateway.id + '_div').hide();
}
}
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
}
$(function() {
$(document).ready(function() {
$('.recommended-gateway').change(
function(){
var recVal = $(this).val();
$('#gateway_id').val(recVal);
setFieldsShown();
}
);
$('select[data-class=gateway-dropdown]').change(function(){
$('.recommended-gateway').attr('checked', false);
var activeElement = $('.recommended-gateway[value=' + $(this).val() + ']');
if(activeElement)
{
activeElement.attr('checked', true);
}
});
$('.recommended-gateway').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img src="' +$(this).attr('data-imageUrl') + '" /><br />');
$(this).parent().children().last().after('<a href="' + $(this).attr('data-siteUrl') + '">Create an account</a>');
if($(this).attr('data-newRow') && true)
{
}
});
setFieldsShown();
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB