1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/resources/views/accounts/account_gateway.blade.php

382 lines
16 KiB
PHP
Raw Normal View History

2015-10-14 16:15:39 +02:00
@extends('header')
2015-03-16 22:45:25 +01:00
2017-11-19 21:34:34 +01:00
@section('head')
@parent
<style type="text/css">
label.checkbox-inline {
padding-left: 0px;
}
label.checkbox-inline div {
padding-left: 20px;
}
</style>
@stop
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])
2018-04-13 13:23:17 +02:00
@include('partials.email_templates')
2015-10-14 16:15:39 +02:00
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">
2017-11-27 15:50:06 +01:00
{!! Former::open_for_files($url)
->method($method)
->addClass('warn-on-exit') !!}
2016-01-18 10:13:39 +01:00
2015-03-16 22:45:25 +01:00
@if ($accountGateway)
2016-06-20 16:14:43 +02:00
{!! Former::populateField('primary_gateway_id', $accountGateway->gateway_id) !!}
2015-07-12 21:43:45 +02:00
{!! Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) !!}
2015-11-29 21:13:50 +01:00
{!! Former::populateField('show_address', intval($accountGateway->show_address)) !!}
2017-11-19 21:34:34 +01:00
{!! Former::populateField('show_shipping_address', intval($accountGateway->show_shipping_address)) !!}
2015-07-12 21:43:45 +02:00
{!! Former::populateField('update_address', intval($accountGateway->update_address)) !!}
2018-03-07 16:23:25 +01:00
{!! Former::populateField('publishable_key', $accountGateway->getPublishableKey() ? str_repeat('*', strlen($accountGateway->getPublishableKey())) : '') !!}
{!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? 1 : 0) !!}
2017-11-27 15:50:06 +01:00
{!! Former::populateField('enable_apple_pay', $accountGateway->getApplePayEnabled() ? 1 : 0) !!}
2017-09-05 15:37:19 +02:00
{!! Former::populateField('enable_sofort', $accountGateway->getSofortEnabled() ? 1 : 0) !!}
2017-09-04 22:22:57 +02:00
{!! Former::populateField('enable_alipay', $accountGateway->getAlipayEnabled() ? 1 : 0) !!}
{!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? 1 : 0) !!}
2017-10-19 15:49:15 +02:00
{!! Former::populateField('enable_sepa', $accountGateway->getSepaEnabled() ? 1 : 0) !!}
{!! Former::populateField('enable_bitcoin', $accountGateway->getBitcoinEnabled() ? 1 : 0) !!}
{!! 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
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) !!}
2018-04-18 16:27:25 +02:00
{!! Former::populateField(GATEWAY_SAGE_PAY_DIRECT . '_referrerId', '2C02C252-0F8A-1B84-E10D-CF933EFCAA99') !!}
2016-05-18 10:05:00 +02:00
@if (Utils::isNinjaDev())
2016-06-20 16:14:43 +02:00
@include('accounts.partials.payment_credentials')
2016-05-18 10:05:00 +02:00
@endif
2015-03-16 22:45:25 +01:00
@endif
2016-01-18 10:13:39 +01:00
2016-06-09 09:56:22 +02:00
@if ($accountGateway)
<div style="display: none">
2016-06-20 16:14:43 +02:00
{!! Former::text('primary_gateway_id') !!}
2016-06-09 09:56:22 +02:00
</div>
@else
{!! Former::select('primary_gateway_id')
->fromQuery($primaryGateways, 'name', 'id')
->label(trans('texts.gateway_id'))
->onchange('setFieldsShown()')
->help(count($secondaryGateways) ? false : 'limited_gateways') !!}
2016-06-09 09:56:22 +02:00
@if (count($secondaryGateways))
{!! Former::select('secondary_gateway_id')
->fromQuery($secondaryGateways, 'name', 'id')
->addGroupClass('secondary-gateway')
->label(' ')
->onchange('setFieldsShown()') !!}
@endif
@endif
2015-03-16 22:45:25 +01:00
2018-03-07 16:23:25 +01:00
<span id="publishableKey" style="display: none">
{!! Former::text('publishable_key') !!}
</span>
2015-03-16 22:45:25 +01:00
2018-03-07 16:23:25 +01:00
@foreach ($gateways as $gateway)
2015-03-16 22:45:25 +01:00
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
@foreach ($gateway->fields as $field => $details)
@if ($details && (!$accountGateway || !$accountGateway->getConfigField($field)) && !is_array($details) && !is_bool($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')
2017-07-17 09:52:16 +02:00
{!! Former::checkbox($gateway->id.'_'.$field)->label(ucwords(Utils::toSpaceCase($field)))->text('enable')->value(1) !!}
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))) !!}
2018-04-13 13:23:17 +02:00
@elseif ($gateway->isCustom())
@if ($field == 'text')
{!! Former::textarea($gateway->id.'_'.$field)->label(trans('texts.text'))->rows(6) !!}
@else
{!! Former::text($gateway->id.'_'.$field)->label('name')->appendIcon('question-sign')->addGroupClass('custom-text') !!}
@endif
@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
2017-09-05 12:51:08 +02:00
@if ($gateway->id == GATEWAY_BRAINTREE)
2016-06-09 09:56:22 +02:00
@if ($account->hasGatewayId(GATEWAY_PAYPAL_EXPRESS))
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'))
->value(1) !!}
2016-05-07 04:33:03 +02:00
@endif
2018-01-08 15:18:34 +01:00
@elseif ($gateway->id == GATEWAY_GOCARDLESS)
2018-04-27 15:10:24 +02:00
<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">
<input type="text" class="form-control" onfocus="$(this).select()" readonly value="{{ URL::to(env('WEBHOOK_PREFIX','').'payment_hook/'.$account->account_key.'/'.GATEWAY_GOCARDLESS) }}">
<div class="help-block"><strong>{!! trans('texts.stripe_webhook_help', [
'link'=>'<a href="https://manage.gocardless.com/developers" target="_blank">'.trans('texts.gocardless_webhook_help_link_text').'</a>'
]) !!}</strong></div>
</div>
</div>
2016-05-07 04:33:03 +02:00
@endif
2016-06-09 09:56:22 +02: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
</div>
2016-01-18 10:13:39 +01:00
2015-03-16 22:45:25 +01:00
@endforeach
2016-06-09 09:56:22 +02:00
<div class="onsite-fields" style="display:none">
{!! Former::checkbox('show_address')
->label(trans('texts.billing_address'))
->text(trans('texts.show_address_help'))
->addGroupClass('gateway-option')
->value(1) !!}
2017-11-20 15:44:28 +01:00
{!! Former::checkbox('update_address')
->label(' ')
->text(trans('texts.update_address_help'))
2017-11-19 21:34:34 +01:00
->addGroupClass('gateway-option')
->value(1) !!}
2017-11-20 15:44:28 +01:00
{!! Former::checkbox('show_shipping_address')
->label(trans('texts.shipping_address'))
->text(trans('texts.show_shipping_address_help'))
->addGroupClass('gateway-option')
->value(1) !!}
2016-06-09 09:56:22 +02:00
{!! Former::checkboxes('creditCardTypes[]')
2017-06-01 21:40:55 +02:00
->label('accepted_card_logos')
2016-06-09 09:56:22 +02:00
->checkboxes($creditCardTypes)
->class('creditcard-types')
->addGroupClass('gateway-option')
2017-11-19 21:34:34 +01:00
->inline()
->value(1)
2016-06-09 09:56:22 +02:00
!!}
2017-11-19 21:34:34 +01:00
<br/>
2016-06-09 09:56:22 +02:00
</div>
2016-05-17 20:09:39 +02:00
2016-06-09 09:56:22 +02:00
@if (!$accountGateway || $accountGateway->gateway_id == GATEWAY_STRIPE)
2016-05-17 20:09:39 +02:00
<div class="stripe-ach">
2017-11-27 18:57:16 +01:00
{!! Former::plaintext(' ')->value('<b>' . trans('texts.optional_payment_methods') . '</b>') !!}
2016-05-17 20:09:39 +02:00
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach'))
2017-09-04 22:22:57 +02:00
->value(1) !!}
2017-11-27 18:57:16 +01:00
{!! Former::checkbox('enable_sofort')
->label(trans('texts.sofort'))
->text(trans('texts.enable_sofort'))
->value(1) !!}
<!--
{!! Former::checkbox('enable_sepa')
->label('SEPA')
->text(trans('texts.enable_sepa'))
->value(1) !!}
-->
2017-11-27 15:50:06 +01:00
{!! Former::checkbox('enable_apple_pay')
->label(trans('texts.apple_pay'))
->text(trans('texts.enable_apple_pay'))
2018-01-14 11:00:59 +01:00
->disabled(Utils::isNinjaProd() && ! $account->subdomain)
->help((Utils::isNinjaProd() && ! $account->subdomain) ? trans('texts.requires_subdomain', [
2017-11-27 15:50:06 +01:00
'link' => link_to('/settings/client_portal', trans('texts.subdomain_is_set'), ['target' => '_blank'])
2017-11-27 19:14:25 +01:00
]) : ($accountGateway && $accountGateway->getApplePayEnabled() && Utils::isRootFolder() && ! $accountGateway->getAppleMerchantId() ? 'verification_file_missing' :
2018-01-14 11:00:59 +01:00
Utils::isNinjaProd() ? trans('texts.apple_pay_domain', [
2017-11-27 15:50:06 +01:00
'domain' => $account->subdomain . '.' . APP_DOMAIN, 'link' => link_to('https://dashboard.stripe.com/account/apple_pay', 'Stripe', ['target' => '_blank']),
]) : ''))
->value(1) !!}
@if (Utils::isRootFolder())
{!! Former::file('apple_merchant_id')
2017-11-27 19:14:25 +01:00
->label('verification_file')
->addGroupClass('verification-file') !!}
2017-11-27 15:50:06 +01:00
@endif
2018-01-24 16:25:01 +01:00
@if ($accountGateway && $accountGateway->getBitcoinEnabled())
{!! Former::checkbox('enable_bitcoin')
->label(trans('texts.bitcoin'))
->text(trans('texts.enable_bitcoin'))
->value(1) !!}
@endif
2017-10-23 20:47:24 +02:00
2017-09-04 22:22:57 +02:00
{!! Former::checkbox('enable_alipay')
->label(trans('texts.alipay'))
->text(trans('texts.enable_alipay'))
->help(trans('texts.stripe_alipay_help', ['link' => link_to('https://dashboard.stripe.com/account/payments/settings', 'Stripe', ['target' => '_blank'])]))
->value(1) !!}
2017-09-04 22:40:23 +02:00
<div class="stripe-webhook-options">
<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">
<input type="text" class="form-control" onfocus="$(this).select()" readonly value="{{ URL::to(env('WEBHOOK_PREFIX','').'payment_hook/'.$account->account_key.'/'.GATEWAY_STRIPE) }}">
2018-01-08 15:18:34 +01:00
<div class="help-block">{!! trans('texts.stripe_webhook_help', [
'link'=>'<a href="https://dashboard.stripe.com/account/webhooks" target="_blank">'.trans('texts.stripe_webhook_help_link_text').'</a>'
2018-01-08 15:18:34 +01:00
]) !!}</div>
</div>
</div>
2017-09-04 22:40:23 +02:00
</div>
2018-01-16 19:58:29 +01:00
<div class="stripe-ach-options" style="display:none">
2016-05-17 20:09:39 +02:00
<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>
</div>
2016-09-15 12:41:09 +02:00
@elseif ($accountGateway && $accountGateway->gateway_id == GATEWAY_WEPAY)
{!! Former::checkbox('enable_ach')
->label(trans('texts.ach'))
->text(trans('texts.enable_ach'))
->value(1) !!}
2016-05-17 20:09:39 +02:00
@endif
2016-06-20 16:14:43 +02:00
2015-04-20 16:34:23 +02:00
</div>
</div>
2016-01-18 10:13:39 +01:00
2016-06-09 09:56:22 +02:00
<br/>
2015-03-16 22:45:25 +01:00
2016-06-09 09:56:22 +02:00
<center>
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/online_payments'))->appendIcon(Icon::create('remove-circle')) !!}
2017-12-03 09:49:00 +01:00
{!! Button::success(trans('texts.save'))->addClass(['save-button'])->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
2016-06-09 09:56:22 +02:00
</center>
2015-03-16 22:45:25 +01:00
2016-06-09 09:56:22 +02:00
{!! Former::close() !!}
2015-03-16 22:45:25 +01:00
<script type="text/javascript">
2016-06-09 09:56:22 +02:00
function setFieldsShown() {
var primaryId = $('#primary_gateway_id').val();
var secondaryId = $('#secondary_gateway_id').val();
2015-04-15 18:35:41 +02:00
2016-06-09 09:56:22 +02:00
if (primaryId) {
$('.secondary-gateway').hide();
} else {
$('.secondary-gateway').show();
2015-04-15 18:35:41 +02:00
}
@if (! $accountGateway)
if (primaryId == {{ GATEWAY_WEPAY }}) {
$('.save-button').prop('disabled', true);
} else {
$('.save-button').prop('disabled', false);
}
@endif
2017-12-03 09:49:00 +01:00
2016-06-09 09:56:22 +02:00
var val = primaryId || secondaryId;
2015-03-16 22:45:25 +01:00
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
2016-06-09 09:56:22 +02:00
var gateway = _.findWhere(gateways, {'id': parseInt(val)});
if (parseInt(gateway.is_offsite)) {
$('.onsite-fields').hide();
} else {
$('.onsite-fields').show();
}
2016-06-20 16:14:43 +02:00
if (gateway.id == {{ GATEWAY_STRIPE }}) {
$('.stripe-ach').show();
} else {
$('.stripe-ach').hide();
}
2018-03-07 16:23:25 +01:00
$('#publishableKey').toggle([{{ GATEWAY_STRIPE }}, {{ GATEWAY_PAYMILL }}].indexOf(gateway.id) >= 0);
2015-03-16 22:45:25 +01:00
}
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) {
2017-11-20 15:44:28 +01:00
var disabled = ! $('#show_address').is(':checked');
2015-07-12 21:43:45 +02:00
$('#update_address').prop('disabled', disabled);
$('label[for=update_address]').css('color', disabled ? '#888' : '#000');
}
2017-09-04 22:40:23 +02:00
function updateWebhookShown() {
var enableAch = $('#enable_ach').is(':checked');
var enableAlipay = $('#enable_alipay').is(':checked');
2017-09-05 15:37:19 +02:00
var enableSofort = $('#enable_sofort').is(':checked');
2017-10-19 15:49:15 +02:00
var enableSepa = $('#enable_sepa').is(':checked');
var enableBicoin = $('#enable_bitcoin').is(':checked');
2017-11-27 19:14:25 +01:00
var enableApplePay = $('#enable_apple_pay').is(':checked');
2017-10-19 15:49:15 +02:00
$('.stripe-webhook-options').toggle(enableAch || enableAlipay || enableSofort || enableSepa || enableBicoin);
2017-12-31 15:43:02 +01:00
$('.stripe-ach-options').toggle(enableAch && {{ $accountGateway && $accountGateway->getPlaidClientId() ? 'true' : 'false' }});
2017-11-27 19:14:25 +01:00
$('.verification-file').toggle(enableApplePay);
2017-09-04 22:40:23 +02:00
}
2018-04-13 13:23:17 +02:00
$('.custom-text .input-group-addon').click(function() {
$('#templateHelpModal').modal('show');
});
2016-06-09 09:56:22 +02:00
var gateways = {!! Cache::get('gateways') !!};
2015-04-15 18:35:41 +02:00
$(function() {
2016-06-09 09:56:22 +02:00
setFieldsShown();
2017-09-04 22:40:23 +02:00
updateWebhookShown();
2015-07-12 21:43:45 +02:00
2017-11-19 21:34:34 +01:00
$('#show_address, #show_shipping_address').change(enableUpdateAddress);
2015-07-12 21:43:45 +02:00
enableUpdateAddress();
2017-11-27 19:14:25 +01:00
$('#enable_ach, #enable_alipay, #enable_sofort, #enable_sepa, #enable_bitcoin, #enable_apple_pay').change(updateWebhookShown);
2016-05-12 04:55:37 +02:00
2016-06-09 09:56:22 +02:00
@if (!$accountGateway && count($secondaryGateways))
$('#primary_gateway_id').append($('<option>', {
value: '',
text: "{{ trans('texts.more_options') }}"
}));
@endif
2015-04-15 18:35:41 +02:00
})
2015-03-16 22:45:25 +01:00
</script>
2016-05-18 10:05:00 +02:00
@stop