mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 03:34:35 -04:00
Fixes for stripe sepa payment method duplicating each time token billing is used.
This commit is contained in:
parent
80e20c0f1e
commit
9fd016e6e1
@ -543,7 +543,8 @@ class ACH
|
|||||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||||
SystemLog::TYPE_STRIPE,
|
SystemLog::TYPE_STRIPE,
|
||||||
$this->stripe->client
|
$this->stripe->client,
|
||||||
|
$this->stripe->client->company,
|
||||||
);
|
);
|
||||||
|
|
||||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||||
@ -570,6 +571,20 @@ class ACH
|
|||||||
'payment_method_id' => $payment_method_id,
|
'payment_method_id' => $payment_method_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the method does not already exist!!
|
||||||
|
*/
|
||||||
|
|
||||||
|
$token = ClientGatewayToken::where([
|
||||||
|
'gateway_customer_reference' => $customer->id,
|
||||||
|
'token' => $method->id,
|
||||||
|
'client_id' => $this->stripe->client->id,
|
||||||
|
'company_id' => $this->stripe->client->company_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($token)
|
||||||
|
return $token;
|
||||||
|
|
||||||
return $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
return $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
@ -194,17 +194,14 @@ class Charge
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'visa':
|
case 'visa':
|
||||||
return PaymentType::VISA;
|
return PaymentType::VISA;
|
||||||
break;
|
|
||||||
case 'mastercard':
|
case 'mastercard':
|
||||||
return PaymentType::MASTERCARD;
|
return PaymentType::MASTERCARD;
|
||||||
break;
|
|
||||||
case PaymentType::SEPA:
|
case PaymentType::SEPA:
|
||||||
return PaymentType::SEPA;
|
return PaymentType::SEPA;
|
||||||
case PaymentType::BACS:
|
case PaymentType::BACS:
|
||||||
return PaymentType::BACS;
|
return PaymentType::BACS;
|
||||||
default:
|
default:
|
||||||
return PaymentType::CREDIT_CARD_OTHER;
|
return PaymentType::CREDIT_CARD_OTHER;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,15 @@
|
|||||||
|
|
||||||
namespace App\PaymentDrivers\Stripe;
|
namespace App\PaymentDrivers\Stripe;
|
||||||
|
|
||||||
use App\Exceptions\PaymentFailed;
|
|
||||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
|
||||||
use App\Jobs\Util\SystemLogger;
|
|
||||||
use App\Models\GatewayType;
|
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
|
||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
|
use App\Models\GatewayType;
|
||||||
|
use App\Models\PaymentType;
|
||||||
|
use App\Jobs\Util\SystemLogger;
|
||||||
|
use App\Exceptions\PaymentFailed;
|
||||||
|
use App\Models\ClientGatewayToken;
|
||||||
use App\PaymentDrivers\StripePaymentDriver;
|
use App\PaymentDrivers\StripePaymentDriver;
|
||||||
|
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||||
|
|
||||||
class SEPA
|
class SEPA
|
||||||
{
|
{
|
||||||
@ -159,6 +160,17 @@ class SEPA
|
|||||||
'payment_method_id' => GatewayType::SEPA,
|
'payment_method_id' => GatewayType::SEPA,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$token = ClientGatewayToken::where([
|
||||||
|
'gateway_customer_reference' => $method->customer,
|
||||||
|
'token' => $method->id,
|
||||||
|
'client_id' => $this->stripe->client->id,
|
||||||
|
'company_id' => $this->stripe->client->company_id,
|
||||||
|
])->first();
|
||||||
|
|
||||||
|
if($token) {
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
|
||||||
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $method->customer]);
|
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $method->customer]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||||
|
@ -106,7 +106,7 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the Stripe API.
|
* Initializes the Stripe API.
|
||||||
* @return void
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user