This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,24 @@
local PurchaseError = require(script.Parent.Parent.PurchaseError)
local Promise = require(script.Parent.Parent.Promise)
local MAX_ROBUX = 2147483647
local function getAccountInfo(network, externalSettings)
return network.getAccountInfo()
:andThen(function(result)
--[[
In studio, we falsely report that users have the maximum amount
of robux, so that they can always test the normal purchase flow
]]
if externalSettings.isStudio() then
result.RobuxBalance = MAX_ROBUX
end
return Promise.resolve(result)
end)
:catch(function(failure)
return Promise.reject(PurchaseError.UnknownFailure)
end)
end
return getAccountInfo
@@ -0,0 +1,14 @@
local Players = game:GetService("Players")
local PurchaseError = require(script.Parent.Parent.PurchaseError)
local Promise = require(script.Parent.Parent.Promise)
local function getIsAlreadyOwned(network, id, infoType)
return network.getPlayerOwns(Players.LocalPlayer, id, infoType)
:catch(function(failure)
return Promise.reject(PurchaseError.UnknownFailure)
end)
end
return getIsAlreadyOwned
@@ -0,0 +1,11 @@
local PurchaseError = require(script.Parent.Parent.PurchaseError)
local Promise = require(script.Parent.Parent.Promise)
local function getProductInfo(network, id, infoType)
return network.getProductInfo(id, infoType)
:catch(function(failure)
return Promise.reject(PurchaseError.UnknownFailureNoItemName)
end)
end
return getProductInfo
@@ -0,0 +1,22 @@
local function getToolAsset(network, assetId)
return network.loadAssetForEquip(assetId)
:andThen(function(tool)
if tool:IsA("Tool") then
return tool
else
local children = tool:GetChildren()
for _, child in ipairs(children) do
if child:IsA("Tool") then
return child
end
end
end
end)
:catch(function(failure)
-- There isn't really much we can do here with error reporting,
-- since the failure is unrelated to purchasing itself
return nil
end)
end
return getToolAsset
@@ -0,0 +1,28 @@
local PurchaseError = require(script.Parent.Parent.PurchaseError)
local Promise = require(script.Parent.Parent.Promise)
local function performPurchase(network, infoType, productId, expectedPrice, requestId)
return network.performPurchase(infoType, productId, expectedPrice, requestId)
:andThen(function(result)
--[[
User might purchase the product through the web after having
opened the purchase prompt, so an AlreadyOwned status is
acceptable.
]]
if result.success or result.status == "AlreadyOwned" then
return Promise.resolve(result)
elseif infoType == Enum.InfoType.Product and not result.receipt then
return Promise.reject(PurchaseError.UnknownFailure)
else
if result.status == "EconomyDisabled" then
return Promise.reject(PurchaseError.PurchaseDisabled)
else
return Promise.reject(PurchaseError.UnknownFailure)
end
end
end, function(failure)
return Promise.reject(PurchaseError.UnknownFailure)
end)
end
return performPurchase