mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix for adding a payment method twice
This commit is contained in:
parent
8cb650dd60
commit
0414b6e622
@ -15,6 +15,7 @@ namespace App\PaymentDrivers\Stripe;
|
|||||||
use App\Exceptions\PaymentFailed;
|
use App\Exceptions\PaymentFailed;
|
||||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
|
use App\Models\ClientGatewayToken;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
@ -177,8 +178,12 @@ class BACS
|
|||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
'payment_method_id' => GatewayType::BACS,
|
'payment_method_id' => GatewayType::BACS,
|
||||||
];
|
];
|
||||||
|
$clientgateway = ClientGatewayToken::query()
|
||||||
|
->where('token', $method->id)
|
||||||
|
->first();
|
||||||
|
if (!$clientgateway){
|
||||||
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
$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);
|
||||||
}
|
}
|
||||||
|
@ -738,10 +738,6 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
$customer = $this->findOrCreateCustomer();
|
$customer = $this->findOrCreateCustomer();
|
||||||
$this->attach($setup_intent->payment_method, $customer);
|
$this->attach($setup_intent->payment_method, $customer);
|
||||||
$payment_method = $this->getStripePaymentMethod($setup_intent->payment_method);
|
$payment_method = $this->getStripePaymentMethod($setup_intent->payment_method);
|
||||||
$clientgateway = ClientGatewayToken::query()
|
|
||||||
->where('token', $payment_method)
|
|
||||||
->first();
|
|
||||||
if (!$clientgateway){
|
|
||||||
$payment_meta = new \stdClass;
|
$payment_meta = new \stdClass;
|
||||||
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code;
|
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code;
|
||||||
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4;
|
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4;
|
||||||
@ -753,6 +749,10 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
'token' => $payment_method->id,
|
'token' => $payment_method->id,
|
||||||
'payment_method_id' => GatewayType::BACS,
|
'payment_method_id' => GatewayType::BACS,
|
||||||
];
|
];
|
||||||
|
$clientgateway = ClientGatewayToken::query()
|
||||||
|
->where('token', $payment_method)
|
||||||
|
->first();
|
||||||
|
if (!$clientgateway){
|
||||||
$this->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
$this->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||||
}
|
}
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
@ -772,12 +772,10 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
elseif ($request->data['object']['status'] === "inactive" && $request->data['object']['payment_method']){
|
elseif ($request->data['object']['status'] === "inactive" && $request->data['object']['payment_method']){
|
||||||
// Delete payment method
|
// Delete payment method
|
||||||
// $clientgateway = ClientGatewayToken::query()
|
$clientgateway = ClientGatewayToken::query()
|
||||||
// ->where('token', $request->data['object']['payment_method'])
|
->where('token', $request->data['object']['payment_method'])
|
||||||
// ->first();
|
->first();
|
||||||
// $clientgateway->delete();
|
$clientgateway->delete();
|
||||||
|
|
||||||
(new ClientGatewayTokenRepository)->archive($request->data['object']['payment_method']);
|
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
}
|
}
|
||||||
elseif ($request->data['object']['status'] === "pending"){
|
elseif ($request->data['object']['status'] === "pending"){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user