SDK reference
Functions
The SDK is one ModuleScript, R3FTO, in ServerScriptService. Call it only from server code.
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
| Function | What 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
| Option | Default | Notes |
|---|---|---|
| environment | None, 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. |
| quiet | false | Hides 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:
print(game:GetService("HttpService"):JSONEncode(R3FTO.getDiagnostics()))
print(R3FTO.getReceiptStatus("<PurchaseId from the Output>"))
| durability | Meaning |
|---|---|
| delivered | R3FTO has saved it. |
| stored_awaiting_delivery | It is in your DataStore. R3FTO has not confirmed it yet. |
| memory_only | Not saved anywhere yet. Attempts remain. |
| not_durable | All 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 | Meaning |
|---|---|
| storage_failed | The DataStore write failed. In Studio, turn on Enable Studio Access to API Services. |
| transport_failed | R3FTO answered with a temporary error. The SDK tries again. |
| ambiguous | The request did not complete, so R3FTO may or may not have it. The same PurchaseId is sent again and never counted twice. |
| throttled | Roblox or R3FTO asked the SDK to slow down. It tries again later. |
| rejected | Refused and not tried again. The Output line shows why. |
| not_configured | The SDK token secret is not available on this server, so nothing was sent. The DataStore copy is kept. |