diff --git a/app/Constants.php b/app/Constants.php index 2159a0981615..5f91434ff485 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -417,6 +417,7 @@ if (! defined('APP_NAME')) { define('GATEWAY_TYPE_DWOLLA', 5); define('GATEWAY_TYPE_CUSTOM', 6); define('GATEWAY_TYPE_ALIPAY', 7); + define('GATEWAY_TYPE_SOFORT', 8); define('GATEWAY_TYPE_TOKEN', 'token'); define('TEMPLATE_INVOICE', 'invoice'); diff --git a/app/Ninja/PaymentDrivers/StripePaymentDriver.php b/app/Ninja/PaymentDrivers/StripePaymentDriver.php index 104b7103bb67..5582e2cafe6c 100644 --- a/app/Ninja/PaymentDrivers/StripePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/StripePaymentDriver.php @@ -23,9 +23,12 @@ class StripePaymentDriver extends BasePaymentDriver ]; if ($gateway = $this->accountGateway) { - if ($gateway->getAchEnabled() || $gateway->getSofortEnabled()) { + if ($gateway->getAchEnabled()) { $types[] = GATEWAY_TYPE_BANK_TRANSFER; } + if ($gateway->getSofortEnabled()) { + $types[] = GATEWAY_TYPE_SOFORT; + } if ($gateway->getAlipayEnabled()) { $types[] = GATEWAY_TYPE_ALIPAY; } @@ -67,10 +70,9 @@ class StripePaymentDriver extends BasePaymentDriver public function shouldUseSource() { - if (in_array($this->gatewayType, [GATEWAY_TYPE_ALIPAY])) { - return true; - } + 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(); @@ -91,6 +93,7 @@ class StripePaymentDriver extends BasePaymentDriver } return false; + */ } protected function checkCustomerExists($customer) @@ -245,12 +248,13 @@ class StripePaymentDriver extends BasePaymentDriver { $isBank = $this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER, $paymentMethod); $isAlipay = $this->isGatewayType(GATEWAY_TYPE_ALIPAY, $paymentMethod); + $isSofort = $this->isGatewayType(GATEWAY_TYPE_SOFORT, $paymentMethod); - if ($isBank || $isAlipay) { + if ($isBank || $isAlipay || $isSofort) { $payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded' ? PAYMENT_STATUS_COMPLETED : PAYMENT_STATUS_PENDING; if ($isAlipay) { $payment->payment_type_id = PAYMENT_TYPE_ALIPAY; - } elseif ($this->shouldUseSource()) { + } elseif ($isSofort) { $payment->payment_type_id = PAYMENT_TYPE_SOFORT; } } diff --git a/database/seeds/GatewayTypesSeeder.php b/database/seeds/GatewayTypesSeeder.php index c3502267d202..6ec180a9001f 100644 --- a/database/seeds/GatewayTypesSeeder.php +++ b/database/seeds/GatewayTypesSeeder.php @@ -16,6 +16,7 @@ class GatewayTypesSeeder extends Seeder ['alias' => 'dwolla', 'name' => 'Dwolla'], ['alias' => 'custom', 'name' => 'Custom'], ['alias' => 'alipay', 'name' => 'Alipay'], + ['alias' => 'sofort', 'name' => 'Sofort'], ]; foreach ($gateway_types as $gateway_type) { diff --git a/database/seeds/PaymentTypesSeeder.php b/database/seeds/PaymentTypesSeeder.php index dac2a007e086..afd679f3f493 100644 --- a/database/seeds/PaymentTypesSeeder.php +++ b/database/seeds/PaymentTypesSeeder.php @@ -37,7 +37,7 @@ class PaymentTypesSeeder extends Seeder ['name' => 'Venmo'], ['name' => 'Money Order'], ['name' => 'Alipay', 'gateway_type_id' => GATEWAY_TYPE_ALIPAY], - ['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_BANK_TRANSFER], + ['name' => 'Sofort', 'gateway_type_id' => GATEWAY_TYPE_SOFORT], ]; foreach ($paymentTypes as $paymentType) {