API/Autodoc/Files/RuStoreGodotBilling.gd.en.md
Source code
# @brief The class implements an API for integrating payments into a mobile application.
class_name RuStoreGodotBillingClient extends Object
const SINGLETON_NAME = "RuStoreGodotBilling"
var _isInitialized: bool = false
var _clientWrapper: Object = null
var _core_client: RuStoreGodotCoreUtils = null
# @deprecated
signal on_check_purchases_availability_success
# @deprecated
signal on_check_purchases_availability_failure
# @deprecated
signal on_get_authorization_status_success
# @deprecated
signal on_get_authorization_status_failure
# @brief Action performed on successful completion of the get_products operation.
signal on_get_products_success
# @brief Action performed in case of get_products error.
signal on_get_products_failure
# @brief Action performed on successful completion of the purchase_product operation.
signal on_purchase_product_success
# @brief Action performed in case of purchase_product error.
signal on_purchase_product_failure
# @brief Action performed on successful completion of the get_purchases operation.
signal on_get_purchases_success
# @brief Action performed in case of get_purchases error.
signal on_get_purchases_failure
# @brief Action performed on successful completion of the confirm_purchase operation.
signal on_confirm_purchase_success
# @brief Action performed in case of confirm_purchase error.
signal on_confirm_purchase_failure
# @brief Action performed on successful completion of the delete_purchase operation.
signal on_delete_purchase_success
# @brief Action performed in case of delete_purchase error.
signal on_delete_purchase_failure
# @brief Action performed on successful completion of the operation.
signal on_get_purchase_info_success
# @brief Action performed in case of an error.
signal on_get_purchase_info_failure
# Used for writing logs that help in the debugging process of the application.
signal on_payment_logger_debug
# requiring intervention or correction.
signal on_payment_logger_error
# Used for writing standard logs that help track the normal execution of the program.
signal on_payment_logger_info
# Used for writing detailed logs that are useful for debugging.
signal on_payment_logger_verbose
# that do not hinder program execution but may require attention.
signal on_payment_logger_warning
static var _instance: RuStoreGodotBillingClient = null
# If the instance has not been created yet, creates it.
static func get_instance() -> RuStoreGodotBillingClient:
if _instance == null:
_instance = RuStoreGodotBillingClient.new()
return _instance
# Otherwise, specify false.
func init(
consoleApplicationId: String,
deeplinkScheme: String,
debugLogs: bool = false
):
_core_client = RuStoreGodotCoreUtils.get_instance()
if _isInitialized == false && Engine.has_singleton(SINGLETON_NAME):
_clientWrapper = Engine.get_singleton(SINGLETON_NAME)
_clientWrapper.rustore_check_purchases_available_success.connect(_on_check_purchases_availability_success)
_clientWrapper.rustore_check_purchases_available_failure.connect(_on_check_purchases_availability_failure)
_clientWrapper.rustore_on_get_authorization_status_success.connect(_on_get_authorization_status_success)
_clientWrapper.rustore_on_get_authorization_status_failure.connect(_on_get_authorization_status_failure)
_clientWrapper.rustore_on_get_products_success.connect(_on_get_products_success)
_clientWrapper.rustore_on_get_products_failure.connect(_on_get_products_failure)
_clientWrapper.rustore_on_purchase_product_success.connect(_on_purchase_product_success)
_clientWrapper.rustore_on_purchase_product_failure.connect(_on_purchase_product_failure)
_clientWrapper.rustore_on_get_purchases_success.connect(_on_get_purchases_success)
_clientWrapper.rustore_on_get_purchases_failure.connect(_on_get_purchases_failure)
_clientWrapper.rustore_on_confirm_purchase_success.connect(_on_confirm_purchase_success)
_clientWrapper.rustore_on_confirm_purchase_failure.connect(_on_confirm_purchase_failure)
_clientWrapper.rustore_on_delete_purchase_success.connect(_on_delete_purchase_success)
_clientWrapper.rustore_on_delete_purchase_failure.connect(_on_delete_purchase_failure)
_clientWrapper.rustore_on_get_purchase_info_success.connect(_on_get_purchase_info_success)
_clientWrapper.rustore_on_get_purchase_info_failure.connect(_on_get_purchase_info_failure)
_clientWrapper.rustore_on_payment_logger_debug.connect(_on_payment_logger_debug)
_clientWrapper.rustore_on_payment_logger_error.connect(_on_payment_logger_error)
_clientWrapper.rustore_on_payment_logger_info.connect(_on_payment_logger_info)
_clientWrapper.rustore_on_payment_logger_verbose.connect(_on_payment_logger_verbose)
_clientWrapper.rustore_on_payment_logger_warning.connect(_on_payment_logger_warning)
_clientWrapper.init(consoleApplicationId, deeplinkScheme, debugLogs)
_isInitialized = true
# Theme switcher
func setTheme(themeCode: int):
_clientWrapper.setTheme(themeCode)
# @param themeCode New theme, specified by a value from the EURuStoreTheme enumeration.
func set_theme(themeCode: int):
_clientWrapper.setTheme(themeCode)
# @deprecated
func check_purchases_availability():
_clientWrapper.checkPurchasesAvailability()
func _on_check_purchases_availability_success(data: String):
var obj = RuStoreBillingJsonParser.ToPurchaseAvailabilityResult(data)
on_check_purchases_availability_success.emit(obj)
func _on_check_purchases_availability_failure(data: String):
var obj = RuStoreError.new(data)
on_check_purchases_availability_failure.emit(obj)
# @brief Check the authorization status of the user.
func get_authorization_status():
_clientWrapper.getAuthorizationStatus()
func _on_get_authorization_status_success(data: String):
var obj = RuStoreBillingJsonParser.ToUserAuthorizationStatus(data)
on_get_authorization_status_success.emit(obj)
func _on_get_authorization_status_failure(data: String):
var obj = RuStoreError.new(data)
on_get_authorization_status_failure.emit(obj)
# @return Returns true if RuStore is installed, otherwise — false.
func is_rustore_installed() -> bool:
return _clientWrapper.isRuStoreInstalled()
# The product list is limited to 1000 items.
func get_products(productIds: Array):
_clientWrapper.getProducts(productIds)
func _on_get_products_success(data: String):
var obj_arr = []
var str_arr = JSON.parse_string(data)
for str_item in str_arr:
var obj_item = RuStoreProduct.new(str(str_item))
obj_arr.append(obj_item)
on_get_products_success.emit(obj_arr)
func _on_get_products_failure(data: String):
var obj = RuStoreError.new(data)
on_get_products_failure.emit(obj)
# - developerPayload — a string with additional order information that you can set when initializing the purchase process.
func purchase_product(productId: String, params: Dictionary = {}):
_clientWrapper.purchaseProduct(productId, params)
func _on_purchase_product_success(data: String):
var obj = RuStorePaymentResult.parse(data)
on_purchase_product_success.emit(obj)
func _on_purchase_product_failure(data: String):
var obj = RuStoreError.new(data)
on_purchase_product_failure.emit(obj)
# @brief Get the list of user purchases.
func get_purchases():
_clientWrapper.getPurchases()
func _on_get_purchases_success(data: String):
var obj_arr = []
var str_arr = JSON.parse_string(data)
for str_item in str_arr:
var obj_item = RuStorePurchase.new(str(str_item))
obj_arr.append(obj_item)
on_get_purchases_success.emit(obj_arr)
func _on_get_purchases_failure(data: String):
var obj = RuStoreError.new(data)
on_get_purchases_failure.emit(obj)
# which you can set when initializing the purchase process.
func confirm_purchase(purchase_id: String, developer_payload: String = ""):
_clientWrapper.confirmPurchase(purchase_id, developer_payload)
func _on_confirm_purchase_success(purchase_id: String):
on_confirm_purchase_success.emit(purchase_id)
func _on_confirm_purchase_failure(purchase_id: String, data: String):
var obj = RuStoreError.new(data)
on_confirm_purchase_failure.emit(purchase_id, obj)
# @param purchase_id Purchase identifier.
func delete_purchase(purchase_id: String):
_clientWrapper.deletePurchase(purchase_id)
func _on_delete_purchase_success(purchase_id: String):
on_delete_purchase_success.emit(purchase_id)
func _on_delete_purchase_failure(purchase_id: String, data: String):
var obj = RuStoreError.new(data)
on_delete_purchase_failure.emit(purchase_id, obj)
# @param purchaseId Purchase identifier.
func get_purchase_info(purchase_id: String):
_clientWrapper.getPurchaseInfo(purchase_id)
func _on_get_purchase_info_success(data: String):
var obj = RuStorePurchase.new(data)
on_get_purchase_info_success.emit(obj)
func _on_get_purchase_info_failure(purchase_id: String, data: String):
var obj = RuStoreError.new(data)
on_get_purchase_info_failure.emit(purchase_id, obj)
# Debug logs
func _on_payment_logger_debug(data: String, message: String, tag: String):
var obj = RuStoreError.new(data)
on_payment_logger_debug.emit(obj, message, tag)
func _on_payment_logger_error(data: String, message: String, tag: String):
var obj = RuStoreError.new(data)
on_payment_logger_error.emit(obj, message, tag)
func _on_payment_logger_info(data: String, message: String, tag: String):
var obj = RuStoreError.new(data)
on_payment_logger_info.emit(obj, message, tag)
func _on_payment_logger_verbose(data: String, message: String, tag: String):
var obj = RuStoreError.new(data)
on_payment_logger_verbose.emit(obj, message, tag)
func _on_payment_logger_warning(data: String, message: String, tag: String):
var obj = RuStoreError.new(data)
on_payment_logger_warning.emit(obj, message, tag)