> For the complete documentation index, see [llms.txt](https://fiveforge-studios.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fiveforge-studios.gitbook.io/docs/mythic-resources/payment/usage.md).

# Usage

## Import The Component

```lua
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

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