Update payments handling

This commit is contained in:
DariusIII
2024-11-16 11:57:08 +01:00
parent 2857a93880
commit 26ff0f2ca4
2 changed files with 32 additions and 2 deletions
@@ -30,7 +30,7 @@ class BtcPaymentController extends BasePageController
if ($checkOrder !== null) {
Log::error('Duplicate BTCPay webhook: '.$payload['webhookId']);
return response('Not Found', 404);
return response('OK', 200);
}
Payment::create([
@@ -57,7 +57,9 @@ class BtcPaymentController extends BasePageController
if ($payload['type'] === 'InvoiceSettled') {
// Check if we have the invoice_id in payments table and if we do, update the user account
$checkOrder = Payment::query()->where('invoice_id', '=', $payload['invoiceId'])->where('payment_status', '=', 'Settled')->first();
$checkOrder = Payment::query()->where('invoice_id', '=', $payload['invoiceId'])->where('payment_status', '=', 'Settled')->where(function ($query) {
return $query->where('invoice_status', 'Pending')->orWhereNull('invoice_status');
})->first();
if ($checkOrder !== null) {
$user = User::query()->where('email', '=', $checkOrder->email)->first();
if ($user) {