Skip to main content

Payment

Charge LIX from other players.


🗿Static Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
💂Authority
This static class can be accessed only on 🟦 Server side.

Examples

Server/Index.lua
function ChargeTax(player)
-- Charges a Player, this will show a PopUp on the Player's screen
Payment.ChargePlayer(
player, -- Player to charge
3500, -- LIX Amount
"a269ab5f-b68c-48dc-a17c-930696f1766f", -- Player ID to send amount
"BUY ITEM", -- Title
"YOU SHALL NOT PASS, UNLESS YOU PAY A TAX.", -- Description
function(success, intent_id) -- Callback if charge succeeded or not
if success then
Console.Log("Intent ID " .. intent_id .. " was created")
else
Console.Error("Something wrong happened while charging player")
end
end
)
end

function SellItemToPlayer(player)
-- Sell a item to a player, this will show a Popup on Player's screen
Payment.SellItem(
player, -- Player to charge
"033968d6-b5d8-4f29-a86c-61a911cf364f", -- Selling item
1, -- Quantity
"BUY MY ITEM", -- Charge Title
"MY AWESOME DESCRIPTION.", -- Charge Description
function(success, intent_id)
if success then
Console.Log("Intent ID " .. intent_id .. " was created")
else
Console.Error("Something wrong happened while selling item to player")
end
end)
end

-- This will be called when the Player accepts or refuses the Charge
Payment.Subscribe("ChargePlayerComplete", function(success, id, amount, status)
Console.Log("ChargePlayerCompleted %s %d %s", id, amount, status)
end)

-- This will be called when the Player accepts or refuses the item sale
Payment.Subscribe("SellItemToPlayerComplete", function(success, id, item_id, status)
Console.Log("ChargePlayerCompleted %s %s %s", id, item_id, status)
end)

-- Charges someone random
ChargeTax(Player.GetByIndex(1))

-- Sell item
SellItemToPlayer(Player.GetByIndex(1))

Static Functions

ReturnsNameDescription
ChargePlayerCharges an amount of LIX from a player
SellItemToPlayerSells an item to a player

ChargePlayer

Charges an amount of LIX from a player

Payment.ChargePlayer(player, amount, to_id, charge_title, charge_description, callback)
TypeParameterDefaultDescription
PlayerplayerPlayer charged
integeramountAmount of LIX being charged
stringto_idID of the player who will receive the LIX
stringcharge_titleTitle of charge
stringcharge_descriptionDescription of charge
functioncallbackCharge creation callback in the format (success, charge_id)

SellItemToPlayer

Sells an item to a player

Payment.SellItemToPlayer(player, item_id, amount, charge_title, charge_description, callback)
TypeParameterDefaultDescription
PlayerplayerPlayer being charged
stringitem_idID of the item being sold
integeramountHow many items
stringcharge_titleTitle of charge
stringcharge_descriptionDescription of charge
functioncallbackCharge creation callback in the format (success, charge_id)

Events

NameDescription
ChargePlayerCompleteCharge completed when the Player has accepted or refused it
SellItemToPlayerCompleteItem charge completed when the Player has accepted or refused it

ChargePlayerComplete

Charge completed when the Player has accepted or refused it
Payment.Subscribe("ChargePlayerComplete", function(success, charge_id, amount, status)
-- ChargePlayerComplete was called
end)
TypeArgumentDescription
booleansuccessIf the charge intent was created successfully
stringcharge_idCharge ID
integeramountCharge amount
stringstatusCharge status

SellItemToPlayerComplete

Item charge completed when the Player has accepted or refused it
Payment.Subscribe("SellItemToPlayerComplete", function(success, charge_id, item_id, amount, status)
-- SellItemToPlayerComplete was called
end)
TypeArgumentDescription
booleansuccessIf the charge intent was created successfully
stringcharge_idCharge ID
stringitem_idItem ID
integeramountHow many items was sold
stringstatusCharge status