mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Add SOFORT support on Stripe #1338
This commit is contained in:
parent
d251df7531
commit
5a3d5b8eea
@ -296,6 +296,7 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
if ($gatewayId == GATEWAY_STRIPE) {
|
||||
$config->enableAlipay = boolval(Input::get('enable_alipay'));
|
||||
$config->enableSofort = boolval(Input::get('enable_sofort'));
|
||||
}
|
||||
|
||||
if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) {
|
||||
|
@ -152,6 +152,14 @@ class AccountGateway extends EntityModel
|
||||
return ! empty($this->getConfigField('enableAlipay'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getSofortEnabled()
|
||||
{
|
||||
return ! empty($this->getConfigField('enableSofort'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -24,6 +24,7 @@ class Country extends Eloquent
|
||||
'swap_currency_symbol',
|
||||
'thousand_separator',
|
||||
'decimal_separator',
|
||||
'iso_3166_3',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -142,7 +142,7 @@ class BasePaymentDriver
|
||||
}
|
||||
|
||||
// For these gateway types we use the API directrly rather than Omnipay
|
||||
if (in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY])) {
|
||||
if ($this->shouldUseSource()) {
|
||||
return $this->createSource();
|
||||
}
|
||||
|
||||
@ -520,6 +520,12 @@ class BasePaymentDriver
|
||||
];
|
||||
}
|
||||
|
||||
public function shouldUseSource()
|
||||
{
|
||||
// Use Omnipay by default
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function shouldCreateToken()
|
||||
{
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
|
||||
|
@ -22,12 +22,13 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
GATEWAY_TYPE_TOKEN,
|
||||
];
|
||||
|
||||
if ($this->accountGateway && $this->accountGateway->getAchEnabled()) {
|
||||
$types[] = GATEWAY_TYPE_BANK_TRANSFER;
|
||||
}
|
||||
|
||||
if ($this->accountGateway && $this->accountGateway->getAlipayEnabled()) {
|
||||
$types[] = GATEWAY_TYPE_ALIPAY;
|
||||
if ($gateway = $this->accountGateway) {
|
||||
if ($gateway->getAchEnabled() || $gateway->getSofortEnabled()) {
|
||||
$types[] = GATEWAY_TYPE_BANK_TRANSFER;
|
||||
}
|
||||
if ($gateway->getAlipayEnabled()) {
|
||||
$types[] = GATEWAY_TYPE_ALIPAY;
|
||||
}
|
||||
}
|
||||
|
||||
return $types;
|
||||
@ -64,6 +65,34 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
public function shouldUseSource()
|
||||
{
|
||||
if (in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->gatewayType == GATEWAY_TYPE_BANK_TRANSFER) {
|
||||
$achEnabled = $this->accountGateway->getAchEnabled();
|
||||
$sofortEnabled = $this->accountGateway->getSofortEnabled();
|
||||
if ($sofortEnabled) {
|
||||
if (! $achEnabled) {
|
||||
return true;
|
||||
}
|
||||
if ($country = $this->client()->country) {
|
||||
$country = $country->iso_3166_3;
|
||||
} elseif ($country = $this->account()->country) {
|
||||
$country = $country->iso_3166_3;
|
||||
}
|
||||
// https://stripe.com/docs/sources/sofort
|
||||
if ($country && in_array($country, ['AUT', 'BEL', 'DEU', 'ITA', 'NLD', 'ESP'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
$response = $this->gateway()
|
||||
|
@ -1213,7 +1213,7 @@ $LANG = array(
|
||||
|
||||
'payment_type_stripe' => 'Stripe',
|
||||
'ach' => 'ACH',
|
||||
'enable_ach' => 'Enable ACH',
|
||||
'enable_ach' => 'Accept US bank transfers',
|
||||
'stripe_ach_help' => 'ACH support must also be enabled in :link.',
|
||||
'ach_disabled' => 'Another gateway is already configured for direct debit.',
|
||||
|
||||
@ -2439,9 +2439,12 @@ $LANG = array(
|
||||
'deleted_account_details' => 'Your account (:account) has been successfully deleted.',
|
||||
|
||||
'alipay' => 'Alipay',
|
||||
'enable_alipay' => 'Enable Alipay',
|
||||
'sofort' => 'Sofort',
|
||||
'enable_alipay' => 'Accept Alipay',
|
||||
'enable_sofort' => 'Accept EU bank transfers',
|
||||
'stripe_alipay_help' => 'These gateways also need to be activated in :link.',
|
||||
|
||||
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -19,6 +19,7 @@
|
||||
{!! Former::populateField('update_address', intval($accountGateway->update_address)) !!}
|
||||
{!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!}
|
||||
{!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? 1 : 0) !!}
|
||||
{!! 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('plaid_client_id', $accountGateway->getPlaidClientId() ? str_repeat('*', strlen($accountGateway->getPlaidClientId())) : '') !!}
|
||||
@ -154,6 +155,11 @@
|
||||
->text(trans('texts.enable_ach'))
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('enable_sofort')
|
||||
->label(trans('texts.sofort'))
|
||||
->text(trans('texts.enable_sofort'))
|
||||
->value(1) !!}
|
||||
|
||||
{!! Former::checkbox('enable_alipay')
|
||||
->label(trans('texts.alipay'))
|
||||
->text(trans('texts.enable_alipay'))
|
||||
@ -252,21 +258,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onEnableAchChanged() {
|
||||
var visible = $('#enable_ach').is(':checked');
|
||||
$('.stripe-webhook-options').toggle(visible);
|
||||
$('.stripe-ach-options').toggle(visible);
|
||||
}
|
||||
|
||||
function onEnableAlipayChanged() {
|
||||
var visible = $('#enable_alipay').is(':checked');
|
||||
$('.stripe-webhook-options').toggle(visible);
|
||||
}
|
||||
|
||||
function updateWebhookShown() {
|
||||
var enableAch = $('#enable_ach').is(':checked');
|
||||
var enableAlipay = $('#enable_alipay').is(':checked');
|
||||
$('.stripe-webhook-options').toggle(enableAch || enableAlipay);
|
||||
var enableSofort = $('#enable_sofort').is(':checked');
|
||||
$('.stripe-webhook-options').toggle(enableAch || enableAlipay || enableSofort);
|
||||
$('.stripe-ach-options').toggle(enableAch);
|
||||
}
|
||||
|
||||
@ -282,6 +278,7 @@
|
||||
|
||||
$('#enable_ach').change(updateWebhookShown);
|
||||
$('#enable_alipay').change(updateWebhookShown);
|
||||
$('#enable_sofort').change(updateWebhookShown);
|
||||
|
||||
@if (!$accountGateway && count($secondaryGateways))
|
||||
$('#primary_gateway_id').append($('<option>', {
|
||||
|
Loading…
Reference in New Issue
Block a user