diff --git a/resources/[tools]/nordi_billing/billing_server.lua b/resources/[tools]/nordi_billing/billing_server.lua index 3dfcc5e9a..e5851351a 100644 --- a/resources/[tools]/nordi_billing/billing_server.lua +++ b/resources/[tools]/nordi_billing/billing_server.lua @@ -96,7 +96,7 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data if data.action == 'pay' then -- Process payment based on selected account if data.accountId == 'personal' then - -- Pay from personal bank account using ps-banking's payBill function + -- Pay from personal bank account local billResult = MySQL.query.await('SELECT * FROM ps_banking_bills WHERE id = ?', {data.billId}) if not billResult or #billResult == 0 then return false end @@ -110,6 +110,8 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data -- Process payment manually instead of using callback to avoid issues player.Functions.RemoveMoney("bank", amount, "bill-payment") + + -- IMPORTANT: Delete the bill from ps_banking_bills table MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {data.billId}) -- Process the payment to the recipient's account @@ -128,6 +130,9 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data -- Mark as declined in our system MySQL.update.await('UPDATE billing_accounts SET declined = 1 WHERE bill_id = ?', {data.billId}) + -- IMPORTANT: Delete the bill from ps_banking_bills table when declined + MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {data.billId}) + -- Find the sender to notify them local billInfo = MySQL.query.await('SELECT * FROM billing_accounts WHERE bill_id = ?', {data.billId}) if billInfo and #billInfo > 0 then @@ -137,7 +142,7 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data if sender then TriggerClientEvent('QBCore:Notify', sender.PlayerData.source, 'Deine Rechnung wurde abgelehnt', 'error') end - } + end -- Notify the player TriggerClientEvent('QBCore:Notify', src, 'Du hast die Rechnung abgelehnt', 'info') @@ -205,6 +210,8 @@ function PayBillFromSharedAccount(source, billId, accountId) -- Process payment MySQL.update.await('UPDATE ps_banking_accounts SET balance = balance - ? WHERE id = ?', {amount, accountId}) + + -- IMPORTANT: Delete the bill from ps_banking_bills table MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {billId}) -- Process the payment to the recipient's account @@ -239,6 +246,8 @@ lib.callback.register('billing:server:payBillFromAccount', function(source, data -- Process payment manually player.Functions.RemoveMoney("bank", amount, "bill-payment") + + -- IMPORTANT: Delete the bill from ps_banking_bills table MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {data.billId}) -- Process the payment to the recipient's account @@ -410,4 +419,3 @@ RegisterServerEvent('billing:server:notifyBillDeclined', function(senderId, amou TriggerClientEvent('QBCore:Notify', sender.PlayerData.source, receiverName .. ' hat deine Rechnung über $' .. amount .. ' abgelehnt', 'error') end end) -