Usage

How to implement this system correctly into your server.

Import The Component

AddEventHandler("ResourceName:Shared:DependencyUpdate", RetrieveComponents)
function RetrieveComponents()
	Payment = exports["mythic-base"]:FetchComponent("Payment")
end

AddEventHandler("Core:Shared:Ready", function()
	exports["mythic-base"]:RequestDependencies("RESOURCE_NAME_HERE", {
		"Payment"
	}, function(error)
		if #error > 0 then
			Logger:Critical("RESOURCE_NAME_HERE", "Failed To Load All Dependencies")
			return
		end
		RetrieveComponents()
	end)
end)

Resource Implementation

---@param hasPaid boolean Is true or false based on if the player has paid.
---@param paymentType string Outputs what method the player paid with 'bank' or 'wallet'
Payment:Get(source, PUT_COST_HERE, function(hasPaid, paymentType)
    if hasPaid then
        if paymentType == "wallet" then
            if Wallet:Has(source, PUT_COST_HERE) and Wallet:Modify(source, -PUT_COST_HERE) then
                -- do paid logic here
                cb(true)
            else
                cb(false)
            end
        elseif paymentType == "bank" then
            -- Either use billing or bank removal, whichever you prefer, this example uses billing
            Billing:Create(source, "BILL TITLE", PUT_COST_HERE, "BILL DESCRIPTION", function(wasPayed, withAccount)
                if wasPayed then
                    -- do paid logic here
                    cb(true)
                else
                    cb(false)
                end
            end)
        end
    else
        cb(false)
    end
end)

Last updated