mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Better WePay switching
This commit is contained in:
parent
88c9fc1ac1
commit
ba000546c4
@ -430,7 +430,14 @@ class AccountController extends BaseController
|
||||
if ($count == 0) {
|
||||
return Redirect::to('gateways/create');
|
||||
} else {
|
||||
$switchToWepay = WEPAY_CLIENT_ID && !$account->getGatewayConfig(GATEWAY_WEPAY);
|
||||
|
||||
if ($switchToWepay && $account->token_billing_type_id != TOKEN_BILLING_DISABLED) {
|
||||
$switchToWepay = !$account->getGatewayConfig(GATEWAY_BRAINTREE) && !$account->getGatewayConfig(GATEWAY_STRIPE);
|
||||
}
|
||||
|
||||
return View::make('accounts.payments', [
|
||||
'showSwitchToWepay' => $switchToWepay,
|
||||
'showAdd' => $count < count(Gateway::$paymentTypes),
|
||||
'title' => trans('texts.online_payments')
|
||||
]);
|
||||
|
@ -410,7 +410,7 @@ class AccountGatewayController extends BaseController
|
||||
'original_ip' => \Request::getClientIp(true),
|
||||
'original_device' => \Request::server('HTTP_USER_AGENT'),
|
||||
'tos_acceptance_time' => time(),
|
||||
'redirect_uri' => URL::to('/gateways'),
|
||||
'redirect_uri' => URL::to('gateways'),
|
||||
'callback_uri' => URL::to('https://sometechie.ngrok.io/paymenthook/'.$account->account_key.'/'.GATEWAY_WEPAY),
|
||||
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
|
||||
));
|
||||
@ -437,6 +437,10 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (($gateway = $account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD)) || ($gateway = $account->getGatewayByType(PAYMENT_TYPE_STRIPE))) {
|
||||
$gateway->delete();
|
||||
}
|
||||
|
||||
$accountGateway = AccountGateway::createNew();
|
||||
$accountGateway->gateway_id = GATEWAY_WEPAY;
|
||||
$accountGateway->setConfig(array(
|
||||
@ -486,4 +490,18 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||
}
|
||||
|
||||
public function switchToWepay()
|
||||
{
|
||||
$data = self::getViewModel();
|
||||
$data['url'] = 'gateways';
|
||||
$data['method'] = 'POST';
|
||||
unset($data['gateways']);
|
||||
|
||||
if ( ! \Request::secure() && ! Utils::isNinjaDev()) {
|
||||
Session::flash('warning', trans('texts.enable_https'));
|
||||
}
|
||||
|
||||
return View::make('accounts.account_gateway_switch_wepay', $data);
|
||||
}
|
||||
}
|
||||
|
@ -243,6 +243,7 @@ Route::group([
|
||||
|
||||
Route::resource('gateways', 'AccountGatewayController');
|
||||
Route::get('gateways/{public_id}/resend_confirmation', 'AccountGatewayController@resendConfirmation');
|
||||
Route::get('gateways/switch/wepay', 'AccountGatewayController@switchToWepay');
|
||||
Route::get('api/gateways', array('as'=>'api.gateways', 'uses'=>'AccountGatewayController@getDatatable'));
|
||||
Route::post('account_gateways/bulk', 'AccountGatewayController@bulk');
|
||||
|
||||
|
@ -77,7 +77,7 @@ class AccountGateway extends EntityModel
|
||||
return !empty($this->getConfigField('enableAch'));
|
||||
}
|
||||
|
||||
public function getPayPAlEnabled()
|
||||
public function getPayPalEnabled()
|
||||
{
|
||||
return !empty($this->getConfigField('enablePayPal'));
|
||||
}
|
||||
|
@ -1308,7 +1308,9 @@ $LANG = array(
|
||||
'manage_wepay_account' => 'Manage WePay Account',
|
||||
'action_required' => 'Action Required',
|
||||
'finish_setup' => 'Finish Setup',
|
||||
'created_wepay_confirmation_required' => 'Please check your email and confirm your email address with WePay.'
|
||||
'created_wepay_confirmation_required' => 'Please check your email and confirm your email address with WePay.',
|
||||
'switch_to_wepay' => 'Switch to WePay',
|
||||
'switch' => 'Switch',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -5,43 +5,8 @@
|
||||
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
|
||||
|
||||
@if(!$accountGateway && WEPAY_CLIENT_ID)
|
||||
{!! Former::open($url)->method($method)->rules(array(
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required',
|
||||
'description' => 'required',
|
||||
'company_name' => 'required',
|
||||
'tos_agree' => 'required',
|
||||
))->addClass('warn-on-exit') !!}
|
||||
{!! Former::populateField('company_name', $account->getDisplayName()) !!}
|
||||
{!! Former::populateField('first_name', $user->first_name) !!}
|
||||
{!! Former::populateField('last_name', $user->last_name) !!}
|
||||
{!! Former::populateField('email', $user->email) !!}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.online_payments') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body form-padding-right">
|
||||
{!! Former::text('first_name') !!}
|
||||
{!! Former::text('last_name') !!}
|
||||
{!! Former::text('email') !!}
|
||||
{!! Former::text('company_name')->help('wepay_company_name_help')->maxlength(255) !!}
|
||||
{!! Former::text('description')->help('wepay_description_help') !!}
|
||||
{!! Former::checkbox('tos_agree')->label(' ')->text(trans('texts.wepay_tos_agree',
|
||||
['link'=>'<a href="https://go.wepay.com/terms-of-service-us" target="_blank">'.trans('texts.wepay_tos_link_text').'</a>']
|
||||
))->value('true') !!}
|
||||
<center>
|
||||
{!! Button::primary(trans('texts.sign_up_with_wepay'))
|
||||
->submit()
|
||||
->large() !!}<br><br>
|
||||
<a href="#" id="show-other-providers">{{ trans('texts.use_another_provider') }}</a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<style>#other-providers{display:none}</style>
|
||||
<input type="hidden" name="gateway_id" value="{{ GATEWAY_WEPAY }}">
|
||||
{!! Former::close() !!}
|
||||
@if(!$accountGateway && WEPAY_CLIENT_ID && !$account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD) && !$account->getGatewayByType(PAYMENT_TYPE_STRIPE))
|
||||
@include('accounts.partials.account_gateway_wepay')
|
||||
@endif
|
||||
|
||||
<div id="other-providers">
|
||||
|
@ -0,0 +1,7 @@
|
||||
@extends('header')
|
||||
|
||||
@section('content')
|
||||
@parent
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
|
||||
@include('accounts.partials.account_gateway_wepay')
|
||||
@stop
|
@ -0,0 +1,39 @@
|
||||
{!! Former::open($url)->method($method)->rules(array(
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required',
|
||||
'description' => 'required',
|
||||
'company_name' => 'required',
|
||||
'tos_agree' => 'required',
|
||||
))->addClass('warn-on-exit') !!}
|
||||
{!! Former::populateField('company_name', $account->getDisplayName()) !!}
|
||||
{!! Former::populateField('first_name', $user->first_name) !!}
|
||||
{!! Former::populateField('last_name', $user->last_name) !!}
|
||||
{!! Former::populateField('email', $user->email) !!}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{!! trans('texts.online_payments') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body form-padding-right">
|
||||
{!! Former::text('first_name') !!}
|
||||
{!! Former::text('last_name') !!}
|
||||
{!! Former::text('email') !!}
|
||||
{!! Former::text('company_name')->help('wepay_company_name_help')->maxlength(255) !!}
|
||||
{!! Former::text('description')->help('wepay_description_help') !!}
|
||||
{!! Former::checkbox('tos_agree')->label(' ')->text(trans('texts.wepay_tos_agree',
|
||||
['link'=>'<a href="https://go.wepay.com/terms-of-service-us" target="_blank">'.trans('texts.wepay_tos_link_text').'</a>']
|
||||
))->value('true') !!}
|
||||
<center>
|
||||
{!! Button::primary(trans('texts.sign_up_with_wepay'))
|
||||
->submit()
|
||||
->large() !!}
|
||||
@if(isset($gateways))
|
||||
<br><br>
|
||||
<a href="#" id="show-other-providers">{{ trans('texts.use_another_provider') }}</a>
|
||||
@endif
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<style>#other-providers{display:none}</style>
|
||||
<input type="hidden" name="gateway_id" value="{{ GATEWAY_WEPAY }}">
|
||||
{!! Former::close() !!}
|
@ -4,6 +4,12 @@
|
||||
@parent
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
|
||||
|
||||
@if ($showSwitchToWepay)
|
||||
{!! Button::success(trans('texts.switch_to_wepay'))
|
||||
->asLinkTo(URL::to('/gateways/switch/wepay'))
|
||||
->appendIcon(Icon::create('circle-arrow-up')) !!}
|
||||
@endif
|
||||
|
||||
@if ($showAdd)
|
||||
{!! Button::primary(trans('texts.add_gateway'))
|
||||
->asLinkTo(URL::to('/gateways/create'))
|
||||
|
Loading…
Reference in New Issue
Block a user