Add SOFORT support on Stripe

This commit is contained in:
Hillel Coren 2017-09-05 21:53:52 +03:00
parent b5bd3cb632
commit 5e6c65b6a9
4 changed files with 13 additions and 7 deletions

View File

@ -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');

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -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) {