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,108 @@
--[[
CLILUACORE-310: Retrieve these values via native platform code,
like we do with Xbox, or from some reasonable endpoint
]]
local NativeProducts = {
IOS = {
BC = {
{
robuxValue = 90,
productId = "com.roblox.robloxmobile.90RobuxBC"
}, {
robuxValue = 180,
productId = "com.roblox.robloxmobile.180RobuxBC",
}, {
robuxValue = 270,
productId = "com.roblox.robloxmobile.270RobuxBC",
}, {
robuxValue = 360,
productId = "com.roblox.robloxmobile.360RobuxBC",
}, {
robuxValue = 450,
productId = "com.roblox.robloxmobile.450RobuxBC",
}, {
robuxValue = 1000,
productId = "com.roblox.robloxmobile.1000RobuxBC",
}, {
robuxValue = 2750,
productId = "com.roblox.robloxmobile.2750RobuxBC",
},
},
NonBC = {
{
robuxValue = 80,
productId = "com.roblox.robloxmobile.80RobuxNonBC",
}, {
robuxValue = 160,
productId = "com.roblox.robloxmobile.160RobuxNonBC",
}, {
robuxValue = 240,
productId = "com.roblox.robloxmobile.240RobuxNonBC",
}, {
robuxValue = 320,
productId = "com.roblox.robloxmobile.320RobuxNonBC",
}, {
robuxValue = 400,
productId = "com.roblox.robloxmobile.400RobuxNonBC",
}, {
robuxValue = 800,
productId = "com.roblox.robloxmobile.800RobuxNonBC",
}, {
robuxValue = 2000,
productId = "com.roblox.robloxmobile.2000RobuxNonBC",
},
}
},
Standard = {
BC = {
{
robuxValue = 90,
productId = "com.roblox.client.robux90bc",
}, {
robuxValue = 180,
productId = "com.roblox.client.robux180bc",
}, {
robuxValue = 270,
productId = "com.roblox.client.robux270bc",
}, {
robuxValue = 360,
productId = "com.roblox.client.robux360bc",
}, {
robuxValue = 450,
productId = "com.roblox.client.robux450bc",
}, {
robuxValue = 1000,
productId = "com.roblox.client.robux1000bc",
}, {
robuxValue = 2750,
productId = "com.roblox.client.robux2750bc",
},
},
NonBC = {
{
robuxValue = 80,
productId = "com.roblox.client.robux80",
}, {
robuxValue = 160,
productId = "com.roblox.client.robux160",
}, {
robuxValue = 240,
productId = "com.roblox.client.robux240",
}, {
robuxValue = 320,
productId = "com.roblox.client.robux320",
}, {
robuxValue = 400,
productId = "com.roblox.client.robux400",
}, {
robuxValue = 800,
productId = "com.roblox.client.robux800",
}, {
robuxValue = 2000,
productId = "com.roblox.client.robux2000",
},
}
}
}
return NativeProducts
@@ -0,0 +1,49 @@
--[[
CLILUACORE-311: We need to find a proper way to encapsulate this;
conditionally depending on PlatformService is bad!
]]
local PlatformService = nil
pcall(function()
PlatformService = game:GetService("PlatformService")
end)
local Promise = require(script.Parent.Parent.Promise)
local function parseRobuxValue(productInfo)
local rawText = productInfo and productInfo.Name
local noJunk = string.gsub(rawText, ",", "")
noJunk = noJunk and string.match(noJunk, "[0-9]+") or nil
return noJunk and tonumber(noJunk) or 1000
end
local XboxCatalogData = {}
function XboxCatalogData.GetCatalogInfoAsync()
if PlatformService == nil then
error("PlatformService unavailable; are you on XboxOne?")
end
local promisified = Promise.promisify(function()
return PlatformService:BeginGetCatalogInfo()
end)
return promisified()
:andThen(function(catalogInfo)
local availableProducts = {}
for _, productInfo in pairs(catalogInfo) do
local product = {
robuxValue = parseRobuxValue(productInfo),
productId = productInfo.ProductId
}
table.insert(availableProducts, product)
end
return Promise.resolve(availableProducts)
end)
:catch(function(errorReason)
return Promise.reject(errorReason)
end)
end
return XboxCatalogData
@@ -0,0 +1,15 @@
local UpsellFlow = require(script.Parent.Parent.UpsellFlow)
local function getUpsellFlow(platform)
if platform == Enum.Platform.Windows or platform == Enum.Platform.OSX then
return UpsellFlow.Web
elseif platform == Enum.Platform.IOS or platform == Enum.Platform.Android or platform == Enum.Platform.UWP then
return UpsellFlow.Mobile
elseif platform == Enum.Platform.XBoxOne then
return UpsellFlow.Xbox
end
return UpsellFlow.None
end
return getUpsellFlow
@@ -0,0 +1,38 @@
local XboxCatalogData = require(script.Parent.XboxCatalogData)
local NativeProducts = require(script.Parent.NativeProducts)
local Promise = require(script.Parent.Parent.Promise)
local function sortAscending(a, b)
return a.robuxValue < b.robuxValue
end
local function selectProduct(price, availableProducts)
table.sort(availableProducts, sortAscending)
for _, product in ipairs(availableProducts) do
if product.robuxValue >= price then
return Promise.resolve(product)
end
end
return Promise.reject()
end
local function selectRobuxProduct(platform, price, isBuildersClubMember)
if platform == Enum.Platform.XBoxOne then
return XboxCatalogData.GetCatalogInfoAsync()
:andThen(function(availableProducts)
return selectProduct(price, availableProducts)
end)
elseif platform == Enum.Platform.IOS then
local productOptions = isBuildersClubMember and NativeProducts.IOS.BC or NativeProducts.IOS.NonBC
return selectProduct(price, productOptions)
else
-- This product format is standard for other supported platforms (Android and UWP)
local productOptions = isBuildersClubMember and NativeProducts.Standard.BC or NativeProducts.Standard.NonBC
return selectProduct(price, productOptions)
end
end
return selectRobuxProduct