mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Select gateway using client's country
This commit is contained in:
parent
5e6c65b6a9
commit
be8b966e0e
@ -23,10 +23,24 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($gateway = $this->accountGateway) {
|
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;
|
$types[] = GATEWAY_TYPE_BANK_TRANSFER;
|
||||||
}
|
} elseif ($sofortEnabled) {
|
||||||
if ($gateway->getSofortEnabled()) {
|
|
||||||
$types[] = GATEWAY_TYPE_SOFORT;
|
$types[] = GATEWAY_TYPE_SOFORT;
|
||||||
}
|
}
|
||||||
if ($gateway->getAlipayEnabled()) {
|
if ($gateway->getAlipayEnabled()) {
|
||||||
@ -71,29 +85,6 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
public function shouldUseSource()
|
public function shouldUseSource()
|
||||||
{
|
{
|
||||||
return in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY, GATEWAY_TYPE_SOFORT]);
|
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)
|
protected function checkCustomerExists($customer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user