Working on SEPA

This commit is contained in:
Hillel Coren 2017-10-19 16:49:15 +03:00
parent eef4ab65fb
commit 6a25d8af89
8 changed files with 122 additions and 1 deletions

View File

@ -408,6 +408,7 @@ if (! defined('APP_NAME')) {
define('PAYMENT_TYPE_ALIPAY', 28); define('PAYMENT_TYPE_ALIPAY', 28);
define('PAYMENT_TYPE_SOFORT', 29); define('PAYMENT_TYPE_SOFORT', 29);
define('PAYMENT_TYPE_SEPA', 30); define('PAYMENT_TYPE_SEPA', 30);
define('PAYMENT_TYPE_BITCOIN', 31);
define('PAYMENT_METHOD_STATUS_NEW', 'new'); define('PAYMENT_METHOD_STATUS_NEW', 'new');
define('PAYMENT_METHOD_STATUS_VERIFICATION_FAILED', 'verification_failed'); define('PAYMENT_METHOD_STATUS_VERIFICATION_FAILED', 'verification_failed');

View File

@ -295,6 +295,8 @@ class AccountGatewayController extends BaseController
if ($gatewayId == GATEWAY_STRIPE) { if ($gatewayId == GATEWAY_STRIPE) {
$config->enableAlipay = boolval(Input::get('enable_alipay')); $config->enableAlipay = boolval(Input::get('enable_alipay'));
$config->enableSofort = boolval(Input::get('enable_sofort')); $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) { if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) {

View File

@ -160,6 +160,22 @@ class AccountGateway extends EntityModel
return ! empty($this->getConfigField('enableSofort')); 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 * @return bool
*/ */

View File

@ -43,6 +43,13 @@ class StripePaymentDriver extends BasePaymentDriver
} elseif ($sofortEnabled) { } elseif ($sofortEnabled) {
$types[] = GATEWAY_TYPE_SOFORT; $types[] = GATEWAY_TYPE_SOFORT;
} }
if ($gateway->getSepaEnabled()) {
$types[] = GATEWAY_TYPE_SEPA;
}
if ($gateway->getBitcoinEnabled()) {
$types[] = GATEWAY_TYPE_BITCOIN;
}
if ($gateway->getAlipayEnabled()) { if ($gateway->getAlipayEnabled()) {
$types[] = GATEWAY_TYPE_ALIPAY; $types[] = GATEWAY_TYPE_ALIPAY;
} }

View File

@ -40,6 +40,7 @@ class PaymentTypesSeeder extends Seeder
['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_SOFORT], ['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_SOFORT],
['name' => 'SEPA', 'gateway_type_id' => GATEWAY_TYPE_SEPA], ['name' => 'SEPA', 'gateway_type_id' => GATEWAY_TYPE_SEPA],
['name' => 'GoCardless', 'gateway_type_id' => GATEWAY_TYPE_GOCARDLESS], ['name' => 'GoCardless', 'gateway_type_id' => GATEWAY_TYPE_GOCARDLESS],
['name' => 'Bitcoin', 'gateway_type_id' => GATEWAY_TYPE_BITCOIN],
]; ];
foreach ($paymentTypes as $paymentType) { foreach ($paymentTypes as $paymentType) {

View File

@ -2492,6 +2492,10 @@ $LANG = array(
'document' => 'Document', 'document' => 'Document',
'invoice_or_expense' => 'Invoice/Expense', 'invoice_or_expense' => 'Invoice/Expense',
'invoice_pdfs' => 'Invoice PDFs', '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.',
); );

View File

@ -29,6 +29,8 @@
{!! Former::populateField('enable_sofort', $accountGateway->getSofortEnabled() ? 1 : 0) !!} {!! Former::populateField('enable_sofort', $accountGateway->getSofortEnabled() ? 1 : 0) !!}
{!! Former::populateField('enable_alipay', $accountGateway->getAlipayEnabled() ? 1 : 0) !!} {!! Former::populateField('enable_alipay', $accountGateway->getAlipayEnabled() ? 1 : 0) !!}
{!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? 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_client_id', $accountGateway->getPlaidClientId() ? str_repeat('*', strlen($accountGateway->getPlaidClientId())) : '') !!}
{!! Former::populateField('plaid_secret', $accountGateway->getPlaidSecret() ? str_repeat('*', strlen($accountGateway->getPlaidSecret())) : '') !!} {!! Former::populateField('plaid_secret', $accountGateway->getPlaidSecret() ? str_repeat('*', strlen($accountGateway->getPlaidSecret())) : '') !!}
{!! Former::populateField('plaid_public_key', $accountGateway->getPlaidPublicKey() ? str_repeat('*', strlen($accountGateway->getPlaidPublicKey())) : '') !!} {!! Former::populateField('plaid_public_key', $accountGateway->getPlaidPublicKey() ? str_repeat('*', strlen($accountGateway->getPlaidPublicKey())) : '') !!}
@ -167,6 +169,18 @@
->text(trans('texts.enable_sofort')) ->text(trans('texts.enable_sofort'))
->value(1) !!} ->value(1) !!}
<!--
{!! Former::checkbox('enable_sepa')
->label('SEPA')
->text(trans('texts.enable_sepa'))
->value(1) !!}
{!! Former::checkbox('enable_bitcoin')
->label(trans('texts.bitcoin'))
->text(trans('texts.enable_bitcoin'))
->value(1) !!}
-->
{!! Former::checkbox('enable_alipay') {!! Former::checkbox('enable_alipay')
->label(trans('texts.alipay')) ->label(trans('texts.alipay'))
->text(trans('texts.enable_alipay')) ->text(trans('texts.enable_alipay'))
@ -279,7 +293,9 @@
var enableAch = $('#enable_ach').is(':checked'); var enableAch = $('#enable_ach').is(':checked');
var enableAlipay = $('#enable_alipay').is(':checked'); var enableAlipay = $('#enable_alipay').is(':checked');
var enableSofort = $('#enable_sofort').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); $('.stripe-ach-options').toggle(enableAch);
} }

View File

@ -0,0 +1,74 @@
@extends('payments.payment_method')
@section('head')
@parent
<script src="https://js.stripe.com/v3/"></script>
<script type="text/javascript">
$(function() {
$('.payment-form').submit(function(event) {
// https://stripe.com/docs/sources/sepa-debit
var stripe = Stripe('{{ $accountGateway->getPublishableStripeKey() }}');
stripe.createSource({
type: 'sepa_debit',
sepa_debit: {
iban: $('#iban').val(),
},
currency: 'eur',
owner: {
name: '{{ $account->getPrimaryUser()->getFullName() }}',
},
}).then(function(result) {
console.log('create source: result');
console.log(result);
}).failure(function(result) {
console.log('create source: error');
console.log(result);
});
return false;
});
});
</script>
@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) !!}
<br/>
<div class="col-md-8 col-md-offset-4">
{!! Button::normal(strtoupper(trans('texts.cancel')))->large()->asLinkTo($invitation->getLink()) !!}
&nbsp;&nbsp;
{!! Button::success(strtoupper(trans('texts.add_account')))
->submit()
->withAttributes(['id'=>'add_account_button'])
->large() !!}
</div>
{!! Former::close() !!}
@stop