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

View File

@ -115,7 +115,7 @@ class ClientController extends \BaseController {
{ {
if (Client::scope()->count() > Auth::user()->getMaxNumClients()) 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 = [ $data = [

View File

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

View File

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

View File

@ -60,7 +60,7 @@ App::error(function(Exception $exception, $code)
{ {
Utils::logError($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') @section('content')
@parent @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::populate($account) }}
{{ Former::legend('Payment Gateway') }} {{ Former::legend('Payment Gateway') }}
@ -20,17 +20,11 @@
@endforeach @endforeach
@endif @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"> <div class="two-column">
{{ Former::checkboxes('creditCardTypes[]') {{ Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->label('Accepted Credit Cards') ->checkboxes($creditCardTypes)->class('creditcard-types')
->checkboxes($creditCardTypes) }}
->class('creditcard-types')
}}
</div> </div>
-->
<div class="two-column"> <div class="two-column">
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateways') {{ 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>'); $(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 // TODO: THIS IS JUST TO SHOW THE IMAGES, STYLE IS SET INLINE STYLE
$('.creditcard-types').each(function(){ $('.creditcard-types').each(function(){
var contents = $(this).parent().contents(); var contents = $(this).parent().contents();
contents[contents.length - 1].nodeValue = ''; contents[contents.length - 1].nodeValue = '';
$(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />'); $(this).after('<img style="width: 60px; display: inline;" src="' +$(this).attr('data-imageUrl') + '" /><br />');

View File

@ -42,19 +42,6 @@
</div> </div>
</section> </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"> <section class="secure">
<div class="container"> <div class="container">
@if (isset($paymentTitle)) @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> --> <!-- <p><span class="glyphicon glyphicon-credit-card" style="margin-right: 10px;"></span><a href="#">Where Do I find CVV?</a></p> -->
</div> </div>
</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> </div>

View File

@ -6,7 +6,7 @@
<div class="cell">Unlimited client invoices</div> <div class="cell">Unlimited client invoices</div>
<div class="cell">Add your company logo</div> <div class="cell">Add your company logo</div>
<div class="cell">Live .PDF invoice creation </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">Accept credit card payments</div>
<div class="cell">Quotes/pro-forma invoices</div> <div class="cell">Quotes/pro-forma invoices</div>
<div class="cell">Custom invoice fields and colors</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">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">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">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">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">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> <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">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">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">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">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">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> <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