API/Autodoc/Files/RuStorePaymentResult.gd.en.md
Source code
# @brief Parent class for purchase results.
class_name RuStorePaymentResult extends RefCounted
# @brief Result of successful digital purchase completion.
class Success extends RuStorePaymentResult:
# Maximum length is 150 characters.
var orderId = null
# @brief Purchase identifier.
var purchaseId: String = ""
# @brief Product identifier assigned to the product in the RuStore console.
var productId: String = ""
# @brief Invoice identifier.
var invoiceId: String = ""
# @brief Token for purchase validation on the server.
var subscriptionToken = null
# Values can be true or false, where true indicates a test payment and false a real one.
var sandbox: bool = false
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("orderId"):
orderId = obj["orderId"]
purchaseId = obj["purchaseId"]
productId = obj["productId"]
invoiceId = obj["invoiceId"]
sandbox = obj["sandbox"]
if obj.has("subscriptionToken"):
subscriptionToken = obj["subscriptionToken"]
# and the payment result is unknown.
class Cancelled extends RuStorePaymentResult:
# @brief Purchase identifier.
var purchaseId: String
# where true indicates a test payment and false a real one.
var sandbox: bool = false
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
purchaseId = obj["purchaseId"]
sandbox = obj["sandbox"]
# it is impossible to determine the purchase status.
class Failure extends RuStorePaymentResult:
# @brief Purchase identifier.
var purchaseId = null
# @brief Invoice identifier.
var invoiceId = null
# Maximum length is 150 characters.
var orderId = null
# @brief Product quantity (optional parameter).
var quantity = null
# @brief Product identifier assigned to the product in the RuStore console.
var productId = null
# @brief Error code.
var errorCode = null
# where true indicates a test payment and false a real one.
var sandbox: bool = false
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("purchaseId"): purchaseId = obj["purchaseId"]
if obj.has("invoiceId"): invoiceId = obj["invoiceId"]
if obj.has("orderId"): orderId = obj["orderId"]
if obj.has("quantity"): quantity = int(obj["quantity"])
if obj.has("productId"): productId = obj["productId"]
if obj.has("errorCode"): errorCode = int(obj["errorCode"])
sandbox = obj["sandbox"]
# May occur in case of an invalid return deeplink.
class InvalidPaymentState extends RuStorePaymentResult:
pass
static func parse(json: String):
var obj = JSON.parse_string(json)
var type = obj["type"]
var data = str(obj["data"])
if type == "Success":
return Success.new(data)
elif type == "Cancelled":
return Cancelled.new(data)
elif type == "Failure":
return Failure.new(data)
elif type == "InvalidPaymentState":
return InvalidPaymentState.new()
else:
return RuStorePaymentResult.new()