Register Login

SDK reference

The SDK's functions, start settings and receipt states.

Functions

The SDK is one ModuleScript, R3FTO, in ServerScriptService. Call it only from server code.

The SDK's public functions
local R3FTO = require(game:GetService("ServerScriptService"):WaitForChild("R3FTO"))

R3FTO.start({ environment = "test" })            -- once, from one server Script; "production" with the Production token

-- inside YOUR receipt handler, before your own grant code:
pcall(R3FTO.observeReceipt, receiptInfo)

R3FTO.simulateTestReceipt({ userId = 1, productId = 2, currencySpent = 25, simulationId = "demo-1" })  -- Test only
R3FTO.getReceiptStatus(purchaseId)               -- this server's view of one receipt
R3FTO.getDiagnostics()                           -- safe to print: no token, no PlayerId
R3FTO.openKeyPanel(player)                       -- optional: the R3FTO Key panel for one player
The SDK's public functions
FunctionWhat it does
R3FTO.start(options)Starts the SDK. Call it once, from one server Script. See Start settings.
R3FTO.observeReceipt(receiptInfo)Reports one receipt. Call it with pcall inside your receipt handler, before your own grant code.
R3FTO.simulateTestReceipt(options)Sends a simulated receipt. Test only.
R3FTO.getReceiptStatus(purchaseId)This server's view of one receipt.
R3FTO.getDiagnostics()What the SDK did on this server. Safe to print: no token, no PlayerId.
R3FTO.openKeyPanel(player)Optional. Opens the R3FTO Key panel for one player, where the player can type a creator's R3FTO Key.

Start settings

The options of R3FTO.start
OptionDefaultNotes
environmentNone, required"test" or "production". Must match the token's environment; R3FTO refuses a mismatch.
tokenSecretName"R3FTO_SDK_TOKEN"The name of the Roblox secret that holds your token. No script can read its value.
apiBaseUrl"https://r3f.to"An https origin.
quietfalseHides the [R3FTO] info lines; warnings still print.

What observeReceipt returns

observeReceipt returns at once with accepted, purchaseId, firstObservedAtUtc and duplicate, and, when they apply, queuedUntilStart and reason. Its work starts after your handler returns. Calls made before start are kept with their own time and sent when start runs.

What getReceiptStatus shows

R3FTO.getReceiptStatus(purchaseId) shows what this server knows about one receipt. For a quick look:

Server code, for a check · Luau
print(game:GetService("HttpService"):JSONEncode(R3FTO.getDiagnostics()))
print(R3FTO.getReceiptStatus("<PurchaseId from the Output>"))
Receipt states
durabilityMeaning
deliveredR3FTO has saved it.
stored_awaiting_deliveryIt is in your DataStore. R3FTO has not confirmed it yet.
memory_onlyNot saved anywhere yet. Attempts remain.
not_durableAll attempts failed. If this server stops now, the receipt is lost.

Each of the two channels, storage (the DataStore copy) and delivery (sending to R3FTO), has a state: pending, in_progress, retry_scheduled, succeeded, failed (no attempts left) or rejected (not tried again).

lastError values
lastErrorMeaning
storage_failedThe DataStore write failed. In Studio, turn on Enable Studio Access to API Services.
transport_failedR3FTO answered with a temporary error. The SDK tries again.
ambiguousThe request did not complete, so R3FTO may or may not have it. The same PurchaseId is sent again and never counted twice.
throttledRoblox or R3FTO asked the SDK to slow down. It tries again later.
rejectedRefused and not tried again. The Output line shows why.
not_configuredThe SDK token secret is not available on this server, so nothing was sent. The DataStore copy is kept.

Documentation

Back to site