Enabled setting accepted credit cards

This commit is contained in:
Hillel Coren 2014-07-17 23:44:34 +03:00
parent 80d0eaf478
commit 4620a06a9b
12 changed files with 66 additions and 68 deletions

View File

@ -102,7 +102,7 @@ class AccountController extends \BaseController {
$accountGateway = null;
$config = null;
$configFields = null;
$selectedCards = 0;
$selectedCards = 0;
if (count($account->account_gateways) > 0)
{
@ -135,14 +135,14 @@ class AccountController extends \BaseController {
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach($creditCardsArray as $card => $name)
{
if($selectedCards > 0 && ($selectedCards & $card) == $card)
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
else
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
if($selectedCards > 0 && ($selectedCards & $card) == $card)
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card']), 'checked' => 'checked'];
else
$creditCards[$name['text']] = ['value' => $card, 'data-imageUrl' => asset($name['card'])];
}
$otherItem = array(
@ -165,7 +165,7 @@ class AccountController extends \BaseController {
->orderBy('name')
->get(),
'recommendedGateways' => $recommendedGatewayArray,
'creditCardTypes' => $creditCards,
'creditCardTypes' => $creditCards,
];
foreach ($data['gateways'] as $gateway)
@ -575,11 +575,6 @@ class AccountController extends \BaseController {
private function savePayments()
{
Validator::extend('notmasked', function($attribute, $value, $parameters)
{
return $value != str_repeat('*', strlen($value));
});
$rules = array();
$recommendedId = Input::get('recommendedGateway_id');
@ -587,7 +582,7 @@ class AccountController extends \BaseController {
{
$gateway = Gateway::findOrFail($gatewayId);
$paymentLibrary = $gateway->paymentlibrary;
$paymentLibrary = $gateway->paymentlibrary;
$fields = $gateway->getFields();
@ -599,23 +594,18 @@ class AccountController extends \BaseController {
{
if(in_array($field, ['merchant_id', 'passCode']))
{
$rules[$gateway->id.'_'.$field] = 'required|notmasked';
$rules[$gateway->id.'_'.$field] = 'required';
}
}
else
{
$rules[$gateway->id.'_'.$field] = 'required|notmasked';
$rules[$gateway->id.'_'.$field] = 'required';
}
}
}
}
$creditcards = Input::get('creditCardTypes');
if (count($creditcards) < 1)
{
$rules['creditCardTypes'] = 'required';
}
$creditcards = Input::get('creditCardTypes');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
@ -627,7 +617,6 @@ class AccountController extends \BaseController {
else
{
$account = Account::findOrFail(Auth::user()->account_id);
$account->account_gateways()->delete();
if ($gatewayId)
{
@ -637,21 +626,36 @@ class AccountController extends \BaseController {
$config = new stdClass;
foreach ($fields as $field => $details)
{
$config->$field = trim(Input::get($gateway->id.'_'.$field));
$value = trim(Input::get($gateway->id.'_'.$field));
if ($value && $value === str_repeat('*', strlen($value)))
{
Session::flash('error', trans('validation.notmasked'));
return Redirect::to('company/payments');
}
$config->$field = $value;
}
$cardCount = 0;
foreach($creditcards as $card => $value)
{
$cardCount += intval($value);
}
$cardCount = 0;
foreach($creditcards as $card => $value)
{
$cardCount += intval($value);
}
$accountGateway->config = json_encode($config);
$accountGateway->accepted_credit_cards = $cardCount;
$accountGateway->accepted_credit_cards = $cardCount;
$account->account_gateways()->delete();
$account->account_gateways()->save($accountGateway);
Session::flash('message', trans('texts.updated_settings'));
}
else
{
Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));
}
Session::flash('message', trans('texts.updated_settings'));
return Redirect::to('company/payments');
}
}

View File

@ -115,7 +115,7 @@ class ClientController extends \BaseController {
{
if (Client::scope()->count() > Auth::user()->getMaxNumClients())
{
return View::make('error', ['error' => "Sorry, you've exceeded the limit of " . Auth::user()->getMaxNumClients() . " clients"]);
return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of " . Auth::user()->getMaxNumClients() . " clients"]);
}
$data = [

View File

@ -85,7 +85,8 @@ class Utils
static::logError($message . ' ' . $exception);
$data = [
'showBreadcrumbs' => false
'showBreadcrumbs' => false,
'hideHeader' => true
];
return View::make('error', $data)->with('error', $message);

View File

@ -19,7 +19,7 @@ class Gateway extends Eloquent
{
$paymentLibrary = $this->paymentlibrary;
if($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY)
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY)
{
$fields = Omnipay::create($this->provider)->getDefaultParameters();
}
@ -28,11 +28,12 @@ class Gateway extends Eloquent
$fields = Payment_Utility::load('config', 'drivers/'.strtolower($this->provider));
}
if($fields == null)
if ($fields == null)
{
$fields = array();
}
return $fields;
}
}

View File

@ -60,7 +60,7 @@ App::error(function(Exception $exception, $code)
{
Utils::logError($exception . ' ' . $code);
return Response::view('error', ['error' => "A {$code} error occurred."], $code);
return Response::view('error', ['hideHeader' => true, 'error' => "A {$code} error occurred."], $code);
});
/*

View File

@ -3,7 +3,7 @@
@section('content')
@parent
{{ Former::open()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
{{ Former::open()->rule()->addClass('col-md-8 col-md-offset-2 warn-on-exit') }}
{{ Former::populate($account) }}
{{ Former::legend('Payment Gateway') }}
@ -20,17 +20,11 @@
@endforeach
@endif
<!-- TODO: creditcard-types IS SET IN JS FURTHER DOWN IN THE SCRIPT PART,
AND THEN IN INLINE STYLE. REMOVE THIS WHEN RAZI HAS FIXED THE IMAGES AND STYLE -->
<!--
<div class="two-column">
{{ Former::checkboxes('creditCardTypes[]')
->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)
->class('creditcard-types')
}}
{{ Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
}}
</div>
-->
<div class="two-column">
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateways')
@ -117,8 +111,8 @@
$(this).parent().children().last().after('<a href="#" onclick="gatewayLink(\'' + $(this).attr('data-siteUrl') + '\')">Create an account</a>');
});
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
// TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){
var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');

View File

@ -42,19 +42,6 @@
</div>
</section>
<!-- Only set with inline style CHANGE THIS -->
<!--
<section class="accepted-card-types" style="padding: 10px 0 10px 0; margin-top: 40px;">
<div class="container">
@if(isset($acceptedCreditCardTypes))
@foreach ($acceptedCreditCardTypes as $card)
<img src="{{ $card['source'] }}" alt="{{ $card['alt'] }}" style="width: 100px; display: inline; margin-right: 20px;"/>
@endforeach
@endif
</div>
</section>
-->
<section class="secure">
<div class="container">
@if (isset($paymentTitle))
@ -176,6 +163,17 @@
<!-- <p><span class="glyphicon glyphicon-credit-card" style="margin-right: 10px;"></span><a href="#">Where Do I find CVV?</a></p> -->
</div>
</div>
@if(isset($acceptedCreditCardTypes))
<div class="row">
<div class="form-group col-md-12">
@foreach ($acceptedCreditCardTypes as $card)
<img src="{{ $card['source'] }}" alt="{{ $card['alt'] }}" style="width: 70px; display: inline; margin-right: 6px;"/>
@endforeach
</div>
</div>
@endif
</div>

View File

@ -6,7 +6,7 @@
<div class="cell">Unlimited client invoices</div>
<div class="cell">Add your company logo</div>
<div class="cell">Live .PDF invoice creation </div>
<div class="cell">4 beatiful invoice templates</div>
<div class="cell">4 beautiful invoice templates</div>
<div class="cell">Accept credit card payments</div>
<div class="cell">Quotes/pro-forma invoices</div>
<div class="cell">Custom invoice fields and colors</div>
@ -23,7 +23,7 @@
<div class="cell"><div class="hide-desktop">Unlimited client invoices</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Add your company logo</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Live .PDF invoice creation</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">4 beatiful invoice templates</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">4 beautiful invoice templates</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Accept credit card payments</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Quotes/pro-forma invoices</div><span class="glyphicon glyphicon-remove"></div>
<div class="cell"><div class="hide-desktop">Custom fields and invoice colors</div><span class="glyphicon glyphicon-remove"></div>
@ -40,7 +40,7 @@
<div class="cell"><div class="hide-desktop">Unlimited client invoices</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Add your company logo</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Live .PDF invoice creation</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">4 beatiful invoice templates</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">4 beautiful invoice templates</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Accept credit card payments</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Quotes/pro-forma invoices</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">Custom invoice fields and colors</div><span class="glyphicon glyphicon-ok"></div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 242 KiB