1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/resources/views/accounts/account_gateway.blade.php

287 lines
12 KiB
PHP
Raw Normal View History

2015-10-14 16:15:39 +02:00
@extends('header')
2015-03-16 22:45:25 +01:00
2016-01-18 10:13:39 +01:00
@section('content')
@parent
2015-03-16 22:45:25 +01:00
2015-10-14 16:15:39 +02:00
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENTS])
2016-05-12 17:09:07 +02:00
@if(!$accountGateway && WEPAY_CLIENT_ID && !$account->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD) && !$account->getGatewayByType(PAYMENT_TYPE_STRIPE))
@include('accounts.partials.account_gateway_wepay')
2016-05-12 04:55:37 +02:00
@endif
2015-04-20 16:34:23 +02:00
2016-05-12 04:55:37 +02:00
<div id="other-providers">
2015-04-20 16:34:23 +02:00
<div class="panel panel-default">
2015-04-22 21:21:04 +02:00
<div class="panel-heading">
<h3 class="panel-title">{!! trans($title) !!}</h3>
</div>
2015-10-14 19:18:19 +02:00
<div class="panel-body form-padding-right">
2016-05-12 04:55:37 +02:00
{!! Former::open($url)->method($method)->rule()->addClass('warn-on-exit') !!}
{!! Former::populateField('token_billing_type_id', $account->token_billing_type_id) !!}
2016-01-18 10:13:39 +01:00
2015-03-16 22:45:25 +01:00
@if ($accountGateway)
2015-04-01 21:57:02 +02:00
{!! Former::populateField('gateway_id', $accountGateway->gateway_id) !!}
2015-07-12 21:43:45 +02:00
{!! Former::populateField('payment_type_id', $paymentTypeId) !!}
{!! Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) !!}
2015-11-29 21:13:50 +01:00
{!! Former::populateField('show_address', intval($accountGateway->show_address)) !!}
2015-07-12 21:43:45 +02:00
{!! Former::populateField('update_address', intval($accountGateway->update_address)) !!}
2015-11-29 21:13:50 +01:00
{!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!}
{!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? '1' : null) !!}
2016-05-07 04:33:03 +02:00
{!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? '1' : null) !!}
{!! Former::populateField('plaid_client_id', $accountGateway->getPlaidClientId() ? str_repeat('*', strlen($accountGateway->getPlaidClientId())) : '') !!}
{!! Former::populateField('plaid_secret', $accountGateway->getPlaidSecret() ? str_repeat('*', strlen($accountGateway->getPlaidSecret())) : '') !!}
{!! Former::populateField('plaid_public_key', $accountGateway->getPlaidPublicKey() ? str_repeat('*', strlen($accountGateway->getPlaidPublicKey())) : '') !!}
2015-07-12 21:43:45 +02:00
2015-03-16 22:45:25 +01:00
@if ($config)
@foreach ($accountGateway->fields as $field => $junk)
2015-05-31 14:37:29 +02:00
@if (in_array($field, $hiddenFields))
2015-03-16 22:45:25 +01:00
{{-- do nothing --}}
@elseif (isset($config->$field))
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, $config->$field) }}
@endif
@endforeach
@endif
2015-04-16 19:12:56 +02:00
@else
2015-04-17 13:57:17 +02:00
{!! Former::populateField('gateway_id', GATEWAY_STRIPE) !!}
2016-01-18 10:13:39 +01:00
{!! Former::populateField('show_address', 1) !!}
2015-07-12 21:43:45 +02:00
{!! Former::populateField('update_address', 1) !!}
2015-03-16 22:45:25 +01:00
@endif
2016-01-18 10:13:39 +01:00
2015-04-15 18:35:41 +02:00
{!! Former::select('payment_type_id')
->options($paymentTypes)
->addGroupClass('payment-type-option')
->onchange('setPaymentType()') !!}
2015-04-16 19:12:56 +02:00
{!! Former::select('gateway_id')
2015-03-16 22:45:25 +01:00
->dataClass('gateway-dropdown')
->addGroupClass('gateway-option gateway-choice')
2015-04-15 18:35:41 +02:00
->fromQuery($selectGateways, 'name', 'id')
->onchange('setFieldsShown()') !!}
2015-03-16 22:45:25 +01:00
@foreach ($gateways as $gateway)
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
2016-03-17 14:28:28 +01:00
@if ($gateway->getHelp())
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4"></label>
<div class="col-lg-8 col-sm-8 help-block">
{!! $gateway->getHelp() !!}
</div>
</div>
@endif
2015-03-16 22:45:25 +01:00
@foreach ($gateway->fields as $field => $details)
@if ($details && !$accountGateway && !is_array($details))
2015-12-24 12:17:11 +01:00
{!! Former::populateField($gateway->id.'_'.$field, $details) !!}
@endif
2015-05-31 14:37:29 +02:00
@if (in_array($field, $hiddenFields))
2015-03-16 22:45:25 +01:00
{{-- do nothing --}}
2016-01-18 10:13:39 +01:00
@elseif ($gateway->id == GATEWAY_DWOLLA && ($field == 'key' || $field == 'secret')
2015-06-01 15:06:18 +02:00
&& isset($_ENV['DWOLLA_KEY']) && isset($_ENV['DWOLLA_SECRET']))
2015-05-31 14:37:29 +02:00
{{-- do nothing --}}
2016-01-18 10:13:39 +01:00
@elseif ($field == 'testMode' || $field == 'developerMode' || $field == 'sandbox')
2016-03-15 12:57:50 +01:00
{!! Former::checkbox($gateway->id.'_'.$field)->label(ucwords(Utils::toSpaceCase($field)))->text('Enable')->value('true') !!}
2016-01-18 10:13:39 +01:00
@elseif ($field == 'username' || $field == 'password')
2015-04-01 21:57:02 +02:00
{!! Former::text($gateway->id.'_'.$field)->label('API '. ucfirst(Utils::toSpaceCase($field))) !!}
2015-03-16 22:45:25 +01:00
@else
2016-03-15 12:57:50 +01:00
{!! Former::text($gateway->id.'_'.$field)->label($gateway->id == GATEWAY_STRIPE ? trans('texts.secret_key') : ucwords(Utils::toSpaceCase($field))) !!}
2015-03-16 22:45:25 +01:00
@endif
@endforeach
@if ($gateway->id == GATEWAY_STRIPE)
2015-11-29 21:13:50 +01:00
{!! Former::text('publishable_key') !!}
2016-04-27 01:59:52 +02:00
@endif
2015-11-29 21:13:50 +01:00
2016-05-14 23:23:20 +02:00
@if ($gateway->id == GATEWAY_STRIPE || $gateway->id == GATEWAY_BRAINTREE || $gateway->id == GATEWAY_WEPAY)
2015-09-25 11:57:40 +02:00
{!! Former::select('token_billing_type_id')
->options($tokenBillingOptions)
->help(trans('texts.token_billing_help')) !!}
2015-03-16 22:45:25 +01:00
@endif
2016-05-07 04:33:03 +02:00
2016-05-11 00:46:32 +02:00
@if ($gateway->id == GATEWAY_STRIPE)
<div class="form-group">
<label class="control-label col-lg-4 col-sm-4">{{ trans('texts.webhook_url') }}</label>
<div class="col-lg-8 col-sm-8 help-block">
2016-05-15 04:22:06 +02:00
<input type="text" class="form-control" onfocus="$(this).select()" readonly value="{{ URL::to(env('WEBHOOK_PREFIX','').'paymenthook/'.$account->account_key.'/'.GATEWAY_STRIPE) }}">
2016-05-11 00:46:32 +02:00
<div class="help-block"><strong>{!! trans('texts.stripe_webhook_help', [
'link'=>'<a href="https://dashboard.stripe.com/account/webhooks" target="_blank">'.trans('texts.stripe_webhook_help_link_text').'</a>'
]) !!}</strong></div>
</div>
</div>
@endif
2016-05-07 04:33:03 +02:00
@if ($gateway->id == GATEWAY_BRAINTREE)
2016-05-17 20:09:39 +02:00
@if ($account->getGatewayByType(PAYMENT_TYPE_PAYPAL, isset($accountGateway)?$accountGateway:null))
2016-05-07 04:33:03 +02:00
{!! Former::checkbox('enable_paypal')
->label(trans('texts.paypal'))
->text(trans('texts.braintree_enable_paypal'))
->value(null)
->disabled(true)
->help(trans('texts.braintree_paypal_disabled_help')) !!}
@else
{!! Former::checkbox('enable_paypal')
->label(trans('texts.paypal'))
->help(trans('texts.braintree_paypal_help', [
'link'=>'<a href="https://articles.braintreepayments.com/guides/paypal/setup-guide" target="_blank">'.
trans('texts.braintree_paypal_help_link_text').'</a>'
]))
->text(trans('texts.braintree_enable_paypal')) !!}
@endif
@endif
2015-03-16 22:45:25 +01:00
</div>
2016-01-18 10:13:39 +01:00
2015-03-16 22:45:25 +01:00
@endforeach
2015-07-12 21:43:45 +02:00
{!! Former::checkbox('show_address')
->label(trans('texts.billing_address'))
->text(trans('texts.show_address_help'))
->addGroupClass('gateway-option') !!}
{!! Former::checkbox('update_address')
->label(' ')
->text(trans('texts.update_address_help'))
->addGroupClass('gateway-option') !!}
2015-04-15 18:35:41 +02:00
{!! Former::checkboxes('creditCardTypes[]')
->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)
->class('creditcard-types')
->addGroupClass('gateway-option')
2015-04-06 13:46:02 +02:00
!!}
2016-05-17 20:09:39 +02:00
@if(isset($accountGateway) && $accountGateway->gateway_id == GATEWAY_WEPAY)
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT, $accountGateway))
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach'))
->value(null)
->disabled(true)
2016-05-17 20:09:39 +02:00
->help(trans('texts.ach_disabled')) !!}
@else
2016-05-17 20:09:39 +02:00
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach')) !!}
@endif
@elseif(!isset($accountGateway) || $accountGateway->gateway_id == GATEWAY_STRIPE)
<div class="stripe-ach">
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT, isset($accountGateway)?$accountGateway:null))
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach'))
->value(null)
->disabled(true)
->help(trans('texts.ach_disabled')) !!}
@else
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach'))
->help(trans('texts.stripe_ach_help')) !!}
<div class="stripe-ach-options">
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<h4>{{trans('texts.plaid')}}</h4>
<div class="help-block">{{trans('texts.plaid_optional')}}</div>
</div>
</div>
2016-05-17 20:09:39 +02:00
{!! Former::text('plaid_client_id')->label(trans('texts.client_id')) !!}
{!! Former::text('plaid_secret')->label(trans('texts.secret')) !!}
{!! Former::text('plaid_public_key')->label(trans('texts.public_key'))
->help(trans('texts.plaid_environment_help')) !!}
</div>
2016-05-17 20:09:39 +02:00
@endif
</div>
2016-05-17 20:09:39 +02:00
@endif
2015-04-20 16:34:23 +02:00
</div>
</div>
2016-01-18 10:13:39 +01:00
2015-03-16 22:45:25 +01:00
<p/>&nbsp;<p/>
2016-01-18 10:13:39 +01:00
{!! Former::actions(
2015-10-14 16:15:39 +02:00
$countGateways > 0 ? Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/online_payments'))->appendIcon(Icon::create('remove-circle')) : false,
2015-06-04 22:53:58 +02:00
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk'))) !!}
2015-04-01 21:57:02 +02:00
{!! Former::close() !!}
2016-05-12 04:55:37 +02:00
</div>
2015-03-16 22:45:25 +01:00
<script type="text/javascript">
2015-04-15 18:35:41 +02:00
function setPaymentType() {
var val = $('#payment_type_id').val();
if (val == 'PAYMENT_TYPE_CREDIT_CARD') {
$('.gateway-option').show();
$('.stripe-ach').hide();
2015-04-15 18:35:41 +02:00
setFieldsShown();
} else {
$('.gateway-option').hide();
$('.stripe-ach').hide();
2015-04-15 18:35:41 +02:00
if (val == 'PAYMENT_TYPE_PAYPAL') {
setFieldsShown({{ GATEWAY_PAYPAL_EXPRESS }});
2015-05-31 14:37:29 +02:00
} else if (val == 'PAYMENT_TYPE_DWOLLA') {
setFieldsShown({{ GATEWAY_DWOLLA }});
2016-01-18 10:13:39 +01:00
} else if (val == 'PAYMENT_TYPE_DIRECT_DEBIT') {
setFieldsShown({{ GATEWAY_GOCARDLESS }});
} else if (val == 'PAYMENT_TYPE_STRIPE') {
$('.gateway-option:not(.gateway-choice)').show();
$('.stripe-ach').show();
setFieldsShown({{ GATEWAY_STRIPE }});
2015-04-15 18:35:41 +02:00
} else {
setFieldsShown({{ GATEWAY_BITPAY }});
}
2016-01-18 10:13:39 +01:00
}
2015-04-15 18:35:41 +02:00
}
function setFieldsShown(val) {
if (!val) {
val = $('#gateway_id').val();
}
2015-03-16 22:45:25 +01:00
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
}
function gatewayLink(url) {
var host = new URL(url).hostname;
if (host) {
openUrl(url, '/affiliate/' + host);
}
}
2015-07-12 21:43:45 +02:00
function enableUpdateAddress(event) {
var disabled = !$('#show_address').is(':checked');
$('#update_address').prop('disabled', disabled);
$('label[for=update_address]').css('color', disabled ? '#888' : '#000');
if (disabled) {
$('#update_address').prop('checked', false);
2016-01-18 10:13:39 +01:00
} else if (event) {
2015-07-12 21:43:45 +02:00
$('#update_address').prop('checked', true);
}
}
function enablePlaidSettings() {
var visible = $('#enable_ach').is(':checked');
2016-04-30 23:54:56 +02:00
$('.stripe-ach-options').toggle(visible);
}
2015-04-15 18:35:41 +02:00
$(function() {
setPaymentType();
enablePlaidSettings();
2015-04-15 18:35:41 +02:00
@if ($accountGateway)
$('.payment-type-option').hide();
@endif
2015-07-12 21:43:45 +02:00
$('#show_address').change(enableUpdateAddress);
enableUpdateAddress();
$('#enable_ach').change(enablePlaidSettings)
2016-05-12 04:55:37 +02:00
$('#show-other-providers').click(function(){
$(this).hide();
$('#other-providers').show();
})
2015-04-15 18:35:41 +02:00
})
2015-03-16 22:45:25 +01:00
</script>
@stop