forked from Simnation/Main
ed
This commit is contained in:
parent
73b43626e7
commit
a9c685ddf4
1 changed files with 11 additions and 3 deletions
|
@ -96,7 +96,7 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data
|
||||||
if data.action == 'pay' then
|
if data.action == 'pay' then
|
||||||
-- Process payment based on selected account
|
-- Process payment based on selected account
|
||||||
if data.accountId == 'personal' then
|
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})
|
local billResult = MySQL.query.await('SELECT * FROM ps_banking_bills WHERE id = ?', {data.billId})
|
||||||
if not billResult or #billResult == 0 then return false end
|
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
|
-- Process payment manually instead of using callback to avoid issues
|
||||||
player.Functions.RemoveMoney("bank", amount, "bill-payment")
|
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})
|
MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {data.billId})
|
||||||
|
|
||||||
-- Process the payment to the recipient's account
|
-- 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
|
-- Mark as declined in our system
|
||||||
MySQL.update.await('UPDATE billing_accounts SET declined = 1 WHERE bill_id = ?', {data.billId})
|
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
|
-- Find the sender to notify them
|
||||||
local billInfo = MySQL.query.await('SELECT * FROM billing_accounts WHERE bill_id = ?', {data.billId})
|
local billInfo = MySQL.query.await('SELECT * FROM billing_accounts WHERE bill_id = ?', {data.billId})
|
||||||
if billInfo and #billInfo > 0 then
|
if billInfo and #billInfo > 0 then
|
||||||
|
@ -137,7 +142,7 @@ lib.callback.register('billing:server:handleBillResponse', function(source, data
|
||||||
if sender then
|
if sender then
|
||||||
TriggerClientEvent('QBCore:Notify', sender.PlayerData.source, 'Deine Rechnung wurde abgelehnt', 'error')
|
TriggerClientEvent('QBCore:Notify', sender.PlayerData.source, 'Deine Rechnung wurde abgelehnt', 'error')
|
||||||
end
|
end
|
||||||
}
|
end
|
||||||
|
|
||||||
-- Notify the player
|
-- Notify the player
|
||||||
TriggerClientEvent('QBCore:Notify', src, 'Du hast die Rechnung abgelehnt', 'info')
|
TriggerClientEvent('QBCore:Notify', src, 'Du hast die Rechnung abgelehnt', 'info')
|
||||||
|
@ -205,6 +210,8 @@ function PayBillFromSharedAccount(source, billId, accountId)
|
||||||
|
|
||||||
-- Process payment
|
-- Process payment
|
||||||
MySQL.update.await('UPDATE ps_banking_accounts SET balance = balance - ? WHERE id = ?', {amount, accountId})
|
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})
|
MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {billId})
|
||||||
|
|
||||||
-- Process the payment to the recipient's account
|
-- Process the payment to the recipient's account
|
||||||
|
@ -239,6 +246,8 @@ lib.callback.register('billing:server:payBillFromAccount', function(source, data
|
||||||
|
|
||||||
-- Process payment manually
|
-- Process payment manually
|
||||||
player.Functions.RemoveMoney("bank", amount, "bill-payment")
|
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})
|
MySQL.query.await('DELETE FROM ps_banking_bills WHERE id = ?', {data.billId})
|
||||||
|
|
||||||
-- Process the payment to the recipient's account
|
-- 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')
|
TriggerClientEvent('QBCore:Notify', sender.PlayerData.source, receiverName .. ' hat deine Rechnung über $' .. amount .. ' abgelehnt', 'error')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue