diff --git a/app/Constants.php b/app/Constants.php index b5008b43bfe7..e667770e9b43 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -408,6 +408,7 @@ if (! defined('APP_NAME')) { define('PAYMENT_TYPE_ALIPAY', 28); define('PAYMENT_TYPE_SOFORT', 29); define('PAYMENT_TYPE_SEPA', 30); + define('PAYMENT_TYPE_BITCOIN', 31); define('PAYMENT_METHOD_STATUS_NEW', 'new'); define('PAYMENT_METHOD_STATUS_VERIFICATION_FAILED', 'verification_failed'); diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index 6aad0c21b69a..09a17ede065e 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -295,6 +295,8 @@ class AccountGatewayController extends BaseController if ($gatewayId == GATEWAY_STRIPE) { $config->enableAlipay = boolval(Input::get('enable_alipay')); $config->enableSofort = boolval(Input::get('enable_sofort')); + $config->enableSepa = boolval(Input::get('enable_sepa')); + $config->enableBitcoin = boolval(Input::get('enable_bitcoin')); } if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) { diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php index 846c1605d361..5e78f4aca62c 100644 --- a/app/Models/AccountGateway.php +++ b/app/Models/AccountGateway.php @@ -160,6 +160,22 @@ class AccountGateway extends EntityModel return ! empty($this->getConfigField('enableSofort')); } + /** + * @return bool + */ + public function getSepaEnabled() + { + return ! empty($this->getConfigField('enableSepa')); + } + + /** + * @return bool + */ + public function getBitcoinEnabled() + { + return ! empty($this->getConfigField('enableBitcoin')); + } + /** * @return bool */ diff --git a/app/Ninja/PaymentDrivers/StripePaymentDriver.php b/app/Ninja/PaymentDrivers/StripePaymentDriver.php index 31baed37edd7..37746e66bca7 100644 --- a/app/Ninja/PaymentDrivers/StripePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/StripePaymentDriver.php @@ -43,6 +43,13 @@ class StripePaymentDriver extends BasePaymentDriver } elseif ($sofortEnabled) { $types[] = GATEWAY_TYPE_SOFORT; } + + if ($gateway->getSepaEnabled()) { + $types[] = GATEWAY_TYPE_SEPA; + } + if ($gateway->getBitcoinEnabled()) { + $types[] = GATEWAY_TYPE_BITCOIN; + } if ($gateway->getAlipayEnabled()) { $types[] = GATEWAY_TYPE_ALIPAY; } diff --git a/database/seeds/PaymentTypesSeeder.php b/database/seeds/PaymentTypesSeeder.php index f140514805d0..d96c46d24af6 100644 --- a/database/seeds/PaymentTypesSeeder.php +++ b/database/seeds/PaymentTypesSeeder.php @@ -40,6 +40,7 @@ class PaymentTypesSeeder extends Seeder ['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_SOFORT], ['name' => 'SEPA', 'gateway_type_id' => GATEWAY_TYPE_SEPA], ['name' => 'GoCardless', 'gateway_type_id' => GATEWAY_TYPE_GOCARDLESS], + ['name' => 'Bitcoin', 'gateway_type_id' => GATEWAY_TYPE_BITCOIN], ]; foreach ($paymentTypes as $paymentType) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index ce08e7d12b6e..e16cea901f57 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2492,6 +2492,10 @@ $LANG = array( 'document' => 'Document', 'invoice_or_expense' => 'Invoice/Expense', 'invoice_pdfs' => 'Invoice PDFs', + 'enable_sepa' => 'Accept SEPA', + 'enable_bitcoin' => 'Accept Bitcoin', + 'iban' => 'IBAN', + 'sepa_authorization' => 'By providing your IBAN and confirming this payment, you are authorizing :company and Stripe, our payment service provider, to send instructions to your bank to debit your account and your bank to debit your account in accordance with those instructions. You are entitled to a refund from your bank under the terms and conditions of your agreement with your bank. A refund must be claimed within 8 weeks starting from the date on which your account was debited.', ); diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php index 207398b73744..7be5540e4d26 100644 --- a/resources/views/accounts/account_gateway.blade.php +++ b/resources/views/accounts/account_gateway.blade.php @@ -29,6 +29,8 @@ {!! Former::populateField('enable_sofort', $accountGateway->getSofortEnabled() ? 1 : 0) !!} {!! Former::populateField('enable_alipay', $accountGateway->getAlipayEnabled() ? 1 : 0) !!} {!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? 1 : 0) !!} + {!! 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())) : '') !!} @@ -167,6 +169,18 @@ ->text(trans('texts.enable_sofort')) ->value(1) !!} + + {!! Former::checkbox('enable_alipay') ->label(trans('texts.alipay')) ->text(trans('texts.enable_alipay')) @@ -279,7 +293,9 @@ var enableAch = $('#enable_ach').is(':checked'); var enableAlipay = $('#enable_alipay').is(':checked'); var enableSofort = $('#enable_sofort').is(':checked'); - $('.stripe-webhook-options').toggle(enableAch || enableAlipay || enableSofort); + var enableSepa = $('#enable_sepa').is(':checked'); + var enableBicoin = $('#enable_bitcoin').is(':checked'); + $('.stripe-webhook-options').toggle(enableAch || enableAlipay || enableSofort || enableSepa || enableBicoin); $('.stripe-ach-options').toggle(enableAch); } diff --git a/resources/views/payments/stripe/sepa.blade.php b/resources/views/payments/stripe/sepa.blade.php new file mode 100644 index 000000000000..fffb9ce2c4c7 --- /dev/null +++ b/resources/views/payments/stripe/sepa.blade.php @@ -0,0 +1,74 @@ +@extends('payments.payment_method') + +@section('head') + @parent + + + +@stop + +@section('payment_details') + + {!! Former::open($url) + ->autocomplete('on') + ->addClass('payment-form') + ->id('payment-form') + ->rules(array( + 'iban' => 'required', + 'authorize_sepa' => 'required', + )) !!} + + @if (Utils::isNinjaDev()) + {{ Former::populateField('iban', 'DE89370400440532013000') }} + @endif + + {!! Former::text('iban') !!} + + {!! Former::checkbox('authorize_sepa') + ->text(trans('texts.sepa_authorization', ['company'=>$account->getDisplayName(), 'email' => $account->work_email])) + ->label(' ') + ->value(1) !!} + + +
+ +
+ + {!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo($invitation->getLink()) !!} +    + {!! Button::success(strtoupper(trans('texts.add_account'))) + ->submit() + ->withAttributes(['id'=>'add_account_button']) + ->large() !!} +
+ + {!! Former::close() !!} + + + +@stop