mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 17:40:54 -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\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
@ -177,8 +178,12 @@ class BACS
|
||||
'token' => $method->id,
|
||||
'payment_method_id' => GatewayType::BACS,
|
||||
];
|
||||
|
||||
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||
$clientgateway = ClientGatewayToken::query()
|
||||
->where('token', $method->id)
|
||||
->first();
|
||||
if (!$clientgateway){
|
||||
$this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->stripe->processInternallyFailedPayment($this->stripe, $e);
|
||||
}
|
||||
|
@ -738,21 +738,21 @@ class StripePaymentDriver extends BaseDriver
|
||||
$customer = $this->findOrCreateCustomer();
|
||||
$this->attach($setup_intent->payment_method, $customer);
|
||||
$payment_method = $this->getStripePaymentMethod($setup_intent->payment_method);
|
||||
$payment_meta = new \stdClass;
|
||||
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code;
|
||||
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4;
|
||||
$payment_meta->state = 'unauthorized';
|
||||
$payment_meta->type = GatewayType::BACS;
|
||||
|
||||
$data = [
|
||||
'payment_meta' => $payment_meta,
|
||||
'token' => $payment_method->id,
|
||||
'payment_method_id' => GatewayType::BACS,
|
||||
];
|
||||
$clientgateway = ClientGatewayToken::query()
|
||||
->where('token', $payment_method)
|
||||
->first();
|
||||
if (!$clientgateway){
|
||||
$payment_meta = new \stdClass;
|
||||
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code;
|
||||
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4;
|
||||
$payment_meta->state = 'unauthorized';
|
||||
$payment_meta->type = GatewayType::BACS;
|
||||
|
||||
$data = [
|
||||
'payment_meta' => $payment_meta,
|
||||
'token' => $payment_method->id,
|
||||
'payment_method_id' => GatewayType::BACS,
|
||||
];
|
||||
$this->storeGatewayToken($data, ['gateway_customer_reference' => $customer->id]);
|
||||
}
|
||||
return response()->json([], 200);
|
||||
@ -772,12 +772,10 @@ class StripePaymentDriver extends BaseDriver
|
||||
}
|
||||
elseif ($request->data['object']['status'] === "inactive" && $request->data['object']['payment_method']){
|
||||
// Delete payment method
|
||||
// $clientgateway = ClientGatewayToken::query()
|
||||
// ->where('token', $request->data['object']['payment_method'])
|
||||
// ->first();
|
||||
// $clientgateway->delete();
|
||||
|
||||
(new ClientGatewayTokenRepository)->archive($request->data['object']['payment_method']);
|
||||
$clientgateway = ClientGatewayToken::query()
|
||||
->where('token', $request->data['object']['payment_method'])
|
||||
->first();
|
||||
$clientgateway->delete();
|
||||
return response()->json([], 200);
|
||||
}
|
||||
elseif ($request->data['object']['status'] === "pending"){
|
||||
|
Loading…
x
Reference in New Issue
Block a user