Minor fixes

This commit is contained in:
Lars Kusch 2023-01-30 08:56:59 +01:00
parent 9c672e9bb1
commit e0271b7b6a
2 changed files with 23 additions and 19 deletions

View File

@ -735,26 +735,29 @@ class StripePaymentDriver extends BaseDriver
// Store payment token for Stripe BACS // Store payment token for Stripe BACS
$this->init(); $this->init();
$setup_intent = $this->stripe->setupIntents->retrieve($request->data['object']['setup_intent'], []); $setup_intent = $this->stripe->setupIntents->retrieve($request->data['object']['setup_intent'], []);
$this->client = Client::where('id', ClientGatewayToken::where('gateway_customer_reference', $request->data['object']['customer'])->first()->client_id)->first(); $clientpayment_token = ClientGatewayToken::where('gateway_customer_reference', $request->data['object']['customer'])->first();
$customer = $this->findOrCreateCustomer(); if ($clientpayment_token){
$this->attach($setup_intent->payment_method, $customer); $this->client = Client::where('id', $clientpayment_token->client_id)->first();
$payment_method = $this->getStripePaymentMethod($setup_intent->payment_method); $customer = $this->findOrCreateCustomer();
$payment_meta = new \stdClass; $this->attach($setup_intent->payment_method, $customer);
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code; $payment_method = $this->getStripePaymentMethod($setup_intent->payment_method);
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4; $payment_meta = new \stdClass;
$payment_meta->state = 'unauthorized'; $payment_meta->brand = (string) $payment_method->bacs_debit->sort_code;
$payment_meta->type = GatewayType::BACS; $payment_meta->last4 = (string) $payment_method->bacs_debit->last4;
$payment_meta->state = 'unauthorized';
$payment_meta->type = GatewayType::BACS;
$data = [ $data = [
'payment_meta' => $payment_meta, 'payment_meta' => $payment_meta,
'token' => $payment_method->id, 'token' => $payment_method->id,
'payment_method_id' => GatewayType::BACS, 'payment_method_id' => GatewayType::BACS,
]; ];
$clientgateway = ClientGatewayToken::query() $clientgateway = ClientGatewayToken::query()
->where('token', $payment_method) ->where('token', $payment_method)
->first(); ->first();
if (!$clientgateway){ 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);
} elseif ($request->type === "mandate.updated"){ } elseif ($request->type === "mandate.updated"){

View File

@ -26,6 +26,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')]) @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')])
{{ ctrans('texts.bacs') }} {{ ctrans('texts.bacs') }}
@endcomponent @endcomponent
@component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-bacs']) @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'authorize-bacs'])
{{ ctrans('texts.add_payment_method') }} {{ ctrans('texts.add_payment_method') }}
@endcomponent @endcomponent