Add payment settings block

This commit is contained in:
Joshua Dwire 2016-05-25 10:36:40 -04:00
parent 9d4b42a514
commit c701c5563c
6 changed files with 52 additions and 24 deletions

View File

@ -430,10 +430,17 @@ class AccountController extends BaseController
$switchToWepay = !$account->getGatewayConfig(GATEWAY_BRAINTREE) && !$account->getGatewayConfig(GATEWAY_STRIPE);
}
$tokenBillingOptions = [];
for ($i=1; $i<=4; $i++) {
$tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
}
return View::make('accounts.payments', [
'showSwitchToWepay' => $switchToWepay,
'showAdd' => $count < count(Gateway::$paymentTypes),
'title' => trans('texts.online_payments')
'title' => trans('texts.online_payments'),
'tokenBillingOptions' => $tokenBillingOptions,
'account' => $account,
]);
}
}
@ -661,6 +668,8 @@ class AccountController extends BaseController
return AccountController::saveDetails();
} elseif ($section === ACCOUNT_LOCALIZATION) {
return AccountController::saveLocalization();
} elseif ($section == ACCOUNT_PAYMENTS) {
return self::saveOnlinePayments();
} elseif ($section === ACCOUNT_NOTIFICATIONS) {
return AccountController::saveNotifications();
} elseif ($section === ACCOUNT_EXPORT) {
@ -1137,6 +1146,20 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_LOCALIZATION);
}
private function saveOnlinePayments()
{
$account = Auth::user()->account;
$account->token_billing_type_id = Input::get('token_billing_type_id');
$account->auto_bill_on_due_date = boolval(Input::get('auto_bill_on_due_date'));
$account->save();
event(new UserSettingsChanged());
Session::flash('message', trans('texts.updated_settings'));
return Redirect::to('settings/'.ACCOUNT_PAYMENTS);
}
public function removeLogo()
{
$account = Auth::user()->account;

View File

@ -141,11 +141,6 @@ class AccountGatewayController extends BaseController
}
}
$tokenBillingOptions = [];
for ($i=1; $i<=4; $i++) {
$tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
}
return [
'paymentTypes' => $paymentTypes,
'account' => $account,
@ -154,7 +149,6 @@ class AccountGatewayController extends BaseController
'config' => false,
'gateways' => $gateways,
'creditCardTypes' => $creditCards,
'tokenBillingOptions' => $tokenBillingOptions,
'countGateways' => count($currentGateways)
];
}
@ -327,11 +321,6 @@ class AccountGatewayController extends BaseController
$account->account_gateways()->save($accountGateway);
}
if (Input::get('token_billing_type_id')) {
$account->token_billing_type_id = Input::get('token_billing_type_id');
$account->save();
}
if(isset($wepayResponse)) {
return $wepayResponse;
} else {

View File

@ -1320,7 +1320,11 @@ $LANG = array(
'auto_bill_payment_method_bank' => 'your :bank account ending in :last4',
'auto_bill_payment_method_credit_card' => 'your :type card ending in :last4',
'auto_bill_payment_method_paypal' => 'your PayPal account (:email)',
'auto_bill_notification_placeholder' => 'This invoice will automatically be billed to your Visa card ending in 4242 on the due date.'
'auto_bill_notification_placeholder' => 'This invoice will automatically be billed to your Visa card ending in 4242 on the due date.',
'payment_settings' => 'Payment Settings',
'auto_bill_on_due_date' => 'Auto bill on due date instead of send date',
'auto_bill_ach_date_help' => 'ACH auto bill will always happen on the due date',
);
return $LANG;

View File

@ -16,7 +16,6 @@
</div>
<div class="panel-body form-padding-right">
{!! Former::open($url)->method($method)->rule()->addClass('warn-on-exit') !!}
{!! Former::populateField('token_billing_type_id', $account->token_billing_type_id) !!}
@if ($accountGateway)
{!! Former::populateField('gateway_id', $accountGateway->gateway_id) !!}
@ -99,12 +98,6 @@
{!! Former::text('publishable_key') !!}
@endif
@if ($gateway->id == GATEWAY_STRIPE || $gateway->id == GATEWAY_BRAINTREE || $gateway->id == GATEWAY_WEPAY)
{!! Former::select('token_billing_type_id')
->options($tokenBillingOptions)
->help(trans('texts.token_billing_help')) !!}
@endif
@if ($gateway->id == GATEWAY_STRIPE)
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4">{{ trans('texts.webhook_url') }}</label>

View File

@ -16,7 +16,6 @@
{!! Former::populateField('email', $user->email) !!}
{!! Former::populateField('show_address', 1) !!}
{!! Former::populateField('update_address', 1) !!}
{!! Former::populateField('token_billing_type_id', $account->token_billing_type_id) !!}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.online_payments') !!}</h3>
@ -40,9 +39,6 @@
->text(trans('texts.accept_debit_cards')) !!}
</div>
@endif
{!! Former::select('token_billing_type_id')
->options($tokenBillingOptions)
->help(trans('texts.token_billing_help')) !!}
{!! Former::checkbox('show_address')
->label(trans('texts.billing_address'))
->text(trans('texts.show_address_help')) !!}

View File

@ -4,6 +4,29 @@
@parent
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
{!! Former::open()->addClass('warn-on-exit') !!}
{!! Former::populateField('token_billing_type_id', $account->token_billing_type_id) !!}
{!! Former::populateField('auto_bill_on_due_date', $account->auto_bill_on_due_date) !!}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.payment_settings') !!}</h3>
</div>
<div class="panel-body">
{!! Former::select('token_billing_type_id')
->options($tokenBillingOptions)
->help(trans('texts.token_billing_help')) !!}
{!! Former::checkbox('auto_bill_on_due_date')
->label(trans('texts.auto_bill'))
->text(trans('texts.auto_bill_on_due_date'))
->help(trans('texts.auto_bill_ach_date_help')) !!}
{!! Former::actions( Button::success(trans('texts.save'))->submit()->appendIcon(Icon::create('floppy-disk')) ) !!}
</div>
</div>
{!! Former::close() !!}
@if ($showSwitchToWepay)
{!! Button::success(trans('texts.switch_to_wepay'))
->asLinkTo(URL::to('/gateways/switch/wepay'))