diff --git a/app/Ninja/PaymentDrivers/StripePaymentDriver.php b/app/Ninja/PaymentDrivers/StripePaymentDriver.php index 5582e2cafe6c..b67ab6b7af28 100644 --- a/app/Ninja/PaymentDrivers/StripePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/StripePaymentDriver.php @@ -23,10 +23,24 @@ class StripePaymentDriver extends BasePaymentDriver ]; if ($gateway = $this->accountGateway) { - if ($gateway->getAchEnabled()) { + $achEnabled = $gateway->getAchEnabled(); + $sofortEnabled = $gateway->getSofortEnabled(); + if ($achEnabled && $sofortEnabled) { + if ($this->invitation) { + $country = ($this->client() && $this->client()->country) ? $this->client()->country->iso_3166_3 : ($this->account()->country ? $this->account()->country->iso_3166_3 : false); + // https://stripe.com/docs/sources/sofort + if ($country && in_array($country, ['AUT', 'BEL', 'DEU', 'ITA', 'NLD', 'ESP'])) { + $types[] = GATEWAY_TYPE_SOFORT; + } else { + $types[] = GATEWAY_TYPE_BANK_TRANSFER; + } + } else { + $types[] = GATEWAY_TYPE_BANK_TRANSFER; + $types[] = GATEWAY_TYPE_SOFORT; + } + } elseif ($achEnabled) { $types[] = GATEWAY_TYPE_BANK_TRANSFER; - } - if ($gateway->getSofortEnabled()) { + } elseif ($sofortEnabled) { $types[] = GATEWAY_TYPE_SOFORT; } if ($gateway->getAlipayEnabled()) { @@ -71,29 +85,6 @@ class StripePaymentDriver extends BasePaymentDriver public function shouldUseSource() { return in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY, GATEWAY_TYPE_SOFORT]); - - /* - 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)