1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-05 15:08:53 +02:00
parent 73b43626e7
commit a9c685ddf4

View file

@ -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)