API/Autodoc/Files/RuStorePurchase.gd.en.md


Source code

# @brief Purchase information.
class_name RuStorePurchase extends RefCounted

# @brief Purchase ID.
var purchaseId = null

# @brief Product ID that was assigned to the product in the RuStore console.
var productId: String = ""

# @brief Product type.
var productType = null

# @brief Invoice ID.
var invoiceId = null

# @brief Language specified using BCP 47 encoding.
var language = null

# @brief Purchase time.
var purchaseTime = null

#   Maximum length of 150 characters.
var orderId = null

# @brief Formatted purchase price, including currency sign.
var amountLabel = null

# @brief Price in the smallest currency units (e.g., in kopecks).
var amount = null

# @brief ISO 4217 currency code.
var currency = null

# @brief Product quantity.
var quantity = null

# @brief Purchase state.
var purchaseState = null

#   which you can set when initializing the purchase process.
var developerPayload = null

# @brief Token for purchase validation on the server.
var subscriptionToken = null

func _init(json: String = ""):
    if json != "":
        var obj = JSON.parse_string(json)
        if obj.has("purchaseId"): purchaseId = obj["purchaseId"]
        productId = obj["productId"]
        if obj.has("productType"): productType = ERuStoreProductType.Item.get(obj["productType"])
        if obj.has("invoiceId"): invoiceId = obj["invoiceId"]
        if obj.has("language"): language = obj["language"]
        if obj.has("purchaseTime"): purchaseTime = obj["purchaseTime"]#RuStoreDateTime
        if obj.has("orderId"): orderId = obj["orderId"]
        if obj.has("amountLabel"): amountLabel = obj["amountLabel"]
        if obj.has("amount"): amount = int(obj["amount"])
        if obj.has("currency"): currency = obj["currency"]
        if obj.has("quantity"): quantity = int(obj["quantity"])
        if obj.has("purchaseState"): purchaseState = ERuStorePurchaseState.Item.get(obj["purchaseState"])
        if obj.has("developerPayload"): developerPayload = obj["developerPayload"]
        if obj.has("subscriptionToken"): subscriptionToken = obj["subscriptionToken"]