Fixes for webhook

This commit is contained in:
Lars Kusch 2023-01-16 21:46:23 +01:00
parent 1580a93a6e
commit 133c49595f

View File

@ -737,18 +737,23 @@ 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);
$payment_meta = new \stdClass; $clientgateway = ClientGatewayToken::query()
$payment_meta->brand = (string) $payment_method->bacs_debit->sort_code; ->where('token', $payment_method)
$payment_meta->last4 = (string) $payment_method->bacs_debit->last4; ->first();
$payment_meta->state = 'unauthorized'; if (!$clientgateway){
$payment_meta->type = GatewayType::BACS; $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 = [ $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,
]; ];
$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"){
// Check if payment method BACS is still valid // Check if payment method BACS is still valid